Prune dashtimev1 values for dashboards that do not exist in dasboards page
Co-authored-by: Deniz Kusefoglu <denizk@gmail.com> Co-authored-by: Jared Scheib <jared.scheib@gmail.com>pull/3556/head
parent
b90f815596
commit
26b480f959
|
@ -38,13 +38,6 @@ export const loadDashboards = (dashboards, dashboardID) => ({
|
|||
},
|
||||
})
|
||||
|
||||
export const loadDeafaultDashTimeV1 = dashboardID => ({
|
||||
type: 'ADD_DASHBOARD_TIME_V1',
|
||||
payload: {
|
||||
dashboardID,
|
||||
},
|
||||
})
|
||||
|
||||
export const setDashTimeV1 = (dashboardID, timeRange) => ({
|
||||
type: 'SET_DASHBOARD_TIME_V1',
|
||||
payload: {
|
||||
|
@ -53,6 +46,11 @@ export const setDashTimeV1 = (dashboardID, timeRange) => ({
|
|||
},
|
||||
})
|
||||
|
||||
export const pruneDashTimeV1 = dashboardIDs => ({
|
||||
type: 'PRUNE_DASHBOARD_TIME_V1',
|
||||
payload: {dashboardIDs},
|
||||
})
|
||||
|
||||
export const setTimeRange = timeRange => ({
|
||||
type: 'SET_DASHBOARD_TIME_RANGE',
|
||||
payload: {
|
||||
|
|
|
@ -8,15 +8,21 @@ import DashboardsHeader from 'src/dashboards/components/DashboardsHeader'
|
|||
import DashboardsContents from 'src/dashboards/components/DashboardsPageContents'
|
||||
|
||||
import {createDashboard} from 'src/dashboards/apis'
|
||||
import {getDashboardsAsync, deleteDashboardAsync} from 'src/dashboards/actions'
|
||||
import {
|
||||
getDashboardsAsync,
|
||||
deleteDashboardAsync,
|
||||
pruneDashTimeV1 as pruneDashTimeV1Action,
|
||||
} from 'src/dashboards/actions'
|
||||
|
||||
import {NEW_DASHBOARD} from 'src/dashboards/constants'
|
||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||
|
||||
@ErrorHandling
|
||||
class DashboardsPage extends Component {
|
||||
componentDidMount() {
|
||||
this.props.handleGetDashboards()
|
||||
async componentDidMount() {
|
||||
const dashboards = await this.props.handleGetDashboards()
|
||||
const dashboardIDs = dashboards.map(d => d.id)
|
||||
this.props.pruneDashTimeV1(dashboardIDs)
|
||||
}
|
||||
|
||||
handleCreateDashboard = async () => {
|
||||
|
@ -80,6 +86,7 @@ DashboardsPage.propTypes = {
|
|||
}).isRequired,
|
||||
handleGetDashboards: func.isRequired,
|
||||
handleDeleteDashboard: func.isRequired,
|
||||
pruneDashTimeV1: func.isRequired,
|
||||
dashboards: arrayOf(shape()),
|
||||
}
|
||||
|
||||
|
@ -91,6 +98,7 @@ const mapStateToProps = ({dashboardUI: {dashboards, dashboard}}) => ({
|
|||
const mapDispatchToProps = dispatch => ({
|
||||
handleGetDashboards: bindActionCreators(getDashboardsAsync, dispatch),
|
||||
handleDeleteDashboard: bindActionCreators(deleteDashboardAsync, dispatch),
|
||||
pruneDashTimeV1: bindActionCreators(pruneDashTimeV1Action, dispatch),
|
||||
})
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(
|
||||
|
|
|
@ -11,6 +11,13 @@ const dashTimeV1 = (state = initialState, action) => {
|
|||
|
||||
return {...state, ranges}
|
||||
}
|
||||
case 'PRUNE_DASHBOARD_TIME_V1': {
|
||||
const {dashboardIDs} = action.payload
|
||||
const ranges = state.ranges.filter(r =>
|
||||
dashboardIDs.includes(r.dashboardID)
|
||||
)
|
||||
return {...state, ranges}
|
||||
}
|
||||
|
||||
case 'SET_DASHBOARD_TIME_V1': {
|
||||
const {dashboardID, timeRange} = action.payload
|
||||
|
|
|
@ -31,10 +31,6 @@ export const queryStringConfig = store => {
|
|||
r => r.dashboardID === idNormalizer(TYPE_ID, dashboardID)
|
||||
)
|
||||
|
||||
if (!dashboardTimeRange) {
|
||||
return
|
||||
}
|
||||
|
||||
let timeRange = dashboardTimeRange
|
||||
|
||||
if (urlQueries.upper) {
|
||||
|
|
Loading…
Reference in New Issue