Remove deleted tempVars from URL query upon manager save
parent
b592cede56
commit
747443da49
|
@ -1,5 +1,6 @@
|
||||||
import {push} from 'react-router-redux'
|
import _ from 'lodash'
|
||||||
import queryString from 'query-string'
|
import queryString from 'query-string'
|
||||||
|
import {push} from 'react-router-redux'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getDashboards as getDashboardsAJAX,
|
getDashboards as getDashboardsAJAX,
|
||||||
|
@ -365,9 +366,14 @@ export const updateTempVarValues = (source, dashboard) => async dispatch => {
|
||||||
|
|
||||||
export const syncURLQueryFromQueryObject = (
|
export const syncURLQueryFromQueryObject = (
|
||||||
location,
|
location,
|
||||||
updatedQuery
|
updatedQuery,
|
||||||
|
deletedQueries = {}
|
||||||
) => dispatch => {
|
) => dispatch => {
|
||||||
const updatedLocationQuery = {...location.query, ...updatedQuery}
|
const updatedLocationQuery = {...location.query, ...updatedQuery}
|
||||||
|
_.each(deletedQueries, (v, k) => {
|
||||||
|
delete updatedLocationQuery[k]
|
||||||
|
})
|
||||||
|
|
||||||
const updatedSearchString = queryString.stringify(updatedLocationQuery)
|
const updatedSearchString = queryString.stringify(updatedLocationQuery)
|
||||||
const updatedSearch = {search: updatedSearchString}
|
const updatedSearch = {search: updatedSearchString}
|
||||||
const updatedLocation = {
|
const updatedLocation = {
|
||||||
|
@ -379,8 +385,15 @@ export const syncURLQueryFromQueryObject = (
|
||||||
dispatch(push(updatedLocation))
|
dispatch(push(updatedLocation))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const syncURLQueryFromTempVars = (location, tempVars) => dispatch => {
|
export const syncURLQueryFromTempVars = (
|
||||||
|
location,
|
||||||
|
tempVars,
|
||||||
|
deletedTempVars = []
|
||||||
|
) => dispatch => {
|
||||||
const updatedQueries = generateURLQueryFromTempVars(tempVars)
|
const updatedQueries = generateURLQueryFromTempVars(tempVars)
|
||||||
|
const deletedQueries = generateURLQueryFromTempVars(deletedTempVars)
|
||||||
|
|
||||||
dispatch(syncURLQueryFromQueryObject(location, updatedQueries))
|
dispatch(
|
||||||
|
syncURLQueryFromQueryObject(location, updatedQueries, deletedQueries)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,15 @@ class DashboardPage extends Component {
|
||||||
templates,
|
templates,
|
||||||
})
|
})
|
||||||
onSaveTemplatesSuccess()
|
onSaveTemplatesSuccess()
|
||||||
dashboardActions.syncURLQueryFromTempVars(location, templates)
|
const deletedTempVars = dashboard.templates.filter(
|
||||||
|
({tempVar: oldTempVar}) =>
|
||||||
|
!templates.find(({tempVar: newTempVar}) => oldTempVar === newTempVar)
|
||||||
|
)
|
||||||
|
dashboardActions.syncURLQueryFromTempVars(
|
||||||
|
location,
|
||||||
|
templates,
|
||||||
|
deletedTempVars
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue