Skip to content

Commit

Permalink
Only log invalid tabs if valid tabs are present
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
  • Loading branch information
raimund-schluessler committed Aug 20, 2020
1 parent ac3a544 commit eb14785
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/AppSidebar/AppSidebarTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,29 +218,28 @@ export default {
return
}
// Find all valid children (AppSidbarTab, other components, text nodes, etc.)
const children = this.$slots.default.filter(elem => elem.tag || elem.text.trim())
// Find all valid instances of AppSidebarTab
const tabs = this.$slots.default.reduce((tabs, tabNode) => {
const invalidTabs = []
const tabs = children.reduce((tabs, tabNode) => {
const tab = tabNode.componentInstance
// Make sure all required props are provided and valid
if (IsValidString(tab?.name)
&& IsValidString(tab?.id)
&& IsValidString(tab?.icon)) {
tabs.push(tab)
} else {
// Don't warn if the node only contains whitespace
if (tabNode.tag || tabNode.text.trim()) {
console.debug('Ignoring invalid tab', tabNode)
}
invalidTabs.push(tabNode)
}
return tabs
}, [])
// Find all valid children (AppSidbarTab, other components, text nodes, etc.)
const children = this.$slots.default.filter(elem => elem.tag || elem.text.trim())
// Tabs are optional, but you can use either tabs or non-tab-content only
if (tabs.length !== 0 && tabs.length !== children.length) {
Vue.util.warn('Mixing tabs and non-tab-content is not possible.')
invalidTabs.map(invalid => console.debug('Ignoring invalid tab', invalid))
}
// We sort the tabs by their order or by their name
Expand Down

0 comments on commit eb14785

Please sign in to comment.