bugfix: Switch to first dashboard if actions page is empty

This commit is contained in:
jamesread 2024-03-04 22:47:45 +00:00
parent 29fe38eff4
commit e344530fc0
1 changed files with 5 additions and 10 deletions

View File

@ -170,25 +170,20 @@ function marshalDashboardStructureToHtml (json) {
document.getElementById('navigation-links').appendChild(navigationLi) document.getElementById('navigation-links').appendChild(navigationLi)
} }
if (document.getElementById('root-group').querySelectorAll('action-button').length === 0 && json.dashboards.length > 0) {
showSection(json.dashboards[0].title)
} else {
showSection('Actions')
}
const rootGroup = document.querySelector('#root-group') const rootGroup = document.querySelector('#root-group')
let hasRootActions = false
for (const btn of Object.values(window.actionButtons)) { for (const btn of Object.values(window.actionButtons)) {
if (btn.parentElement === null) { if (btn.parentElement === null) {
rootGroup.appendChild(btn) rootGroup.appendChild(btn)
hasRootActions = true
} }
} }
if (!hasRootActions) { if (rootGroup.querySelectorAll('action-button').length > 0 && json.dashboards.length > 0) {
nav.querySelector('li[title="Actions"]').style.display = 'none' nav.querySelector('li[title="Actions"]').style.display = 'none'
showSection(json.dashboards[0].title)
} else {
showSection('Actions')
} }
} }