1
0
Fork 0
mirror of synced 2024-07-01 12:30:41 +12:00

remove the link from navigation bar when removing the screen

This commit is contained in:
Maurits Lourens 2021-09-21 15:16:10 +02:00
parent f5edc45570
commit ff4476b333

View file

@ -215,6 +215,13 @@ export const getFrontendStore = () => {
if (screenToDelete._id === state.selectedScreenId) {
state.selectedScreenId = null
}
//remove the link for this screen
screenDeletePromises.push(
store.actions.components.links.delete(
screenToDelete.routing.route,
screenToDelete.props._instanceName
)
)
}
return state
})
@ -646,6 +653,36 @@ export const getFrontendStore = () => {
// Save layout
await store.actions.layouts.save(layout)
},
delete: async (url, title) => {
const layout = get(mainLayout)
if (!layout) {
return
}
// Add link setting to main layout
if (layout.props._component.endsWith("layout")) {
// If using a new SDK, add to the layout component settings
layout.props.links = layout.props.links.filter(
link => !(link.text === title && link.url === url)
)
} else {
// If using an old SDK, add to the navigation component
// TODO: remove this when we can assume everyone has updated
const nav = findComponentType(
layout.props,
"@budibase/standard-components/navigation"
)
if (!nav) {
return
}
nav._children = nav._children.filter(
child => !(child.url === url && child.text === title)
)
}
// Save layout
await store.actions.layouts.save(layout)
},
},
},
}