Skip to content

Commit

Permalink
fix: null check cards on layout init (#1484)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
  • Loading branch information
pedrolamas committed Aug 16, 2024
1 parent 7ec4626 commit 3f1d22e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/store/layout/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ export const mutations: MutationTree<LayoutState> = {
// migrate existing layouts
const migratableLayoutKeys = ['dashboard']

for (const layoutKey of Object.keys(payload.layouts)) {
for (const [layoutKey, currentLayout] of Object.entries(payload.layouts)) {
for (const [containerKey, components] of Object.entries(currentLayout)) {
currentLayout[containerKey] = components
.filter(card => card != null)
}

const migratableLayoutKey = migratableLayoutKeys.find(key => layoutKey.startsWith(key))

if (migratableLayoutKey) {
const defaultLayout = defaultState.layouts[migratableLayoutKey]
const defaultComponentIds = Object.values(defaultLayout).flat().map(card => card.id)
const currentLayout = payload.layouts[layoutKey]
const currentComponentIds = Object.values(currentLayout).flat().map(card => card.id)

for (const [containerKey, defaultContainerComponents] of Object.entries(defaultLayout)) {
Expand All @@ -53,7 +57,7 @@ export const mutations: MutationTree<LayoutState> = {

// diagnostics specific layout updates
if (layoutKey.startsWith('diagnostics')) {
const diagnostics = payload.layouts[layoutKey] as DiagnosticsCardContainer
const diagnostics = currentLayout as DiagnosticsCardContainer

for (const diagnosticsCardConfigs of Object.values(diagnostics)) {
for (const diagnosticsCardConfig of diagnosticsCardConfigs) {
Expand Down

0 comments on commit 3f1d22e

Please sign in to comment.