Skip to content

Commit 713b5d7

Browse files
committed
dashboard: fix filters in edit mode
When editing a host & site overview, service overview, or alert & notifications widget, the filter selection set to single was observed. Now we set them to multiple (when applies) CMK-28069 Change-Id: I6c3e5a047e34aa29bd3cdd21e5d106da1da7b746
1 parent ab60f34 commit 713b5d7

4 files changed

Lines changed: 38 additions & 4 deletions

File tree

packages/cmk-frontend-vue/src/dashboard-wip/components/Wizard/wizards/alert-notification/AlertNotificationWizard.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ const widgetFilterManager = useWidgetFilterManager({}, filterDefinitions)
6767
6868
const addFilters = useAddFilter()
6969
70-
const hostFilterType = ref<ElementSelection>(ElementSelection.SPECIFIC)
71-
const serviceFilterType = ref<ElementSelection>(ElementSelection.SPECIFIC)
70+
const hostFilterType = ref<ElementSelection>(
71+
props.editWidgetSpec ? ElementSelection.MULTIPLE : ElementSelection.SPECIFIC
72+
)
73+
const serviceFilterType = ref<ElementSelection>(
74+
props.editWidgetSpec ? ElementSelection.MULTIPLE : ElementSelection.SPECIFIC
75+
)
7276
7377
const wizardHandler = useWizard(2)
7478
const wizardStages: QuickSetupStageSpec[] = [

packages/cmk-frontend-vue/src/dashboard-wip/components/Wizard/wizards/hosts-site/HostsSiteWizard.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import StepsHeader from '../../components/StepsHeader.vue'
3434
import WizardContainer from '../../components/WizardContainer.vue'
3535
import WizardStageContainer from '../../components/WizardStageContainer.vue'
3636
import WizardStepsContainer from '../../components/WizardStepsContainer.vue'
37-
import { ElementSelection } from '../../types'
37+
import type { ElementSelection } from '../../types'
38+
import { getDefaultsFromGraph } from './composables/useSelectGraphTypes'
3839
import Stage1 from './stage1/StageContents.vue'
3940
import Stage2 from './stage2/StageContents.vue'
4041
@@ -68,7 +69,9 @@ const widgetFilterManager = useWidgetFilterManager(
6869
6970
const addFilters = useAddFilter()
7071
71-
const hostFilterType = ref<ElementSelection>(ElementSelection.SPECIFIC)
72+
const hostFilterType = ref<ElementSelection>(
73+
getDefaultsFromGraph(props?.editWidgetSpec?.content?.type)
74+
)
7275
7376
const wizardHandler = useWizard(2)
7477
const wizardStages: QuickSetupStageSpec[] = [

packages/cmk-frontend-vue/src/dashboard-wip/components/Wizard/wizards/hosts-site/composables/useSelectGraphTypes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,11 @@ export const getAvailableGraphs = (
5353

5454
return [...graphSelector[hostSelection]]
5555
}
56+
57+
export const getDefaultsFromGraph = (graph?: Graph | string): ElementSelection => {
58+
if (!graph || graph === Graph.HOST_STATE) {
59+
return ElementSelection.SPECIFIC
60+
}
61+
62+
return ElementSelection.MULTIPLE
63+
}

packages/cmk-frontend-vue/src/dashboard-wip/components/Wizard/wizards/services/composables/useSelectGraphTypes.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,22 @@ export const getAvailableGraphs = (
6868
}
6969
return [...graphSelector[hostSelection][serviceSelection]]
7070
}
71+
72+
interface GetDefaultsFromGraph {
73+
hostSelection: ElementSelection
74+
serviceSelection: ElementSelection
75+
}
76+
77+
export const getDefaultsFromGraph = (graph?: Graph | string): GetDefaultsFromGraph => {
78+
if (!graph || graph === Graph.SERVICE_STATE) {
79+
return {
80+
hostSelection: ElementSelection.SPECIFIC,
81+
serviceSelection: ElementSelection.SPECIFIC
82+
}
83+
}
84+
85+
return {
86+
hostSelection: ElementSelection.MULTIPLE,
87+
serviceSelection: ElementSelection.MULTIPLE
88+
}
89+
}

0 commit comments

Comments
 (0)