Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: null check cards on layout init #1484

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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