fix: hide unused panels on dashboard (#1233)

This commit is contained in:
Stefan Dej
2023-01-29 15:23:52 +01:00
committed by GitHub
parent 2b7bf2a3f4
commit e7eb94faa1

View File

@@ -48,10 +48,10 @@ export const getters: GetterTree<GuiState, any> = {
allPanels = allPanels.filter((name) => name !== 'macros')
}
// remove toolhead panel, if kinematics === none
// remove toolhead & machine-settings panel, if kinematics === none
const printerKinematics = rootGetters['printer/getKinematics']
if (printerKinematics === 'none') {
allPanels = allPanels.filter((name) => name !== 'toolhead-control')
allPanels = allPanels.filter((name) => !['toolhead-control', 'machine-settings'].includes(name))
}
// remove extruder panel, if printerExtruderCount < 1
@@ -82,10 +82,10 @@ export const getters: GetterTree<GuiState, any> = {
const layoutName = column ? `${viewport}Layout${column}` : `${viewport}Layout`
// @ts-ignore
let panels = state.dashboard[layoutName]?.filter((element: any) => element !== null) ?? []
const allPossiblePanels = getters['getAllPossiblePanels']
if (column < 2) {
const allViewportPanels = getters['getAllPanelsFromViewport'](viewport)
const allPossiblePanels = getters['getAllPossiblePanels']
const missingPanels: any[] = []
allPossiblePanels.forEach((panelname: string) => {
@@ -121,11 +121,7 @@ export const getters: GetterTree<GuiState, any> = {
}
}
if (getters['webcams/getWebcams'].length === 0) {
panels = panels.filter((element: any) => element.name !== 'webcam')
}
return panels
return panels.filter((element: any) => allPossiblePanels.includes(element.name))
},
getAllPanelsFromViewport: (state) => (viewport: string) => {