Skip to content

Commit

Permalink
Support dashboard and lens (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
milewski authored Oct 7, 2023
1 parent 2767dba commit 9a698c0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

38 changes: 31 additions & 7 deletions resources/js/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@
import SectionHeader from './SectionHeader.vue'
import UserMenu from '../native/UserMenu.vue'
import SvgIcon from './SvgIcon.vue'
import MenuSection from './MenuSection.vue'
export default {
props: [ 'screen', 'NotificationCenter', 'ThemeDropdown' ],
emits: [ 'actionExecuted' ],
components: { SvgIcon, UserMenu, MenuItem, MenuGroup, SectionHeader },
components: { SvgIcon, UserMenu, MenuItem, MenuGroup, SectionHeader, MenuSection },
data() {
return {
currentActiveMenu: null,
Expand All @@ -90,6 +91,13 @@
this.currentActiveMenu = this.currentActiveMenu ?? this.storeActiveMenu
/**
* if there is a path and no items we don't open the panel on page load
*/
if (this.currentActiveMenu?.path !== '' && this.currentActiveMenu?.items?.length === 0) {
this.currentActiveMenu = null
}
},
computed: {
storeActiveMenu() {
Expand Down Expand Up @@ -130,6 +138,10 @@
methods: {
recursiveFind(menus) {
if (menus.active === true) {
return menus
}
if (Array.isArray(menus)) {
for (const item of menus) {
Expand All @@ -142,26 +154,38 @@
}
} else if (menus.items) {
return this.recursiveFind(menus.items)
}
if (menus.active === true) {
return menus
if (menus.items) {
return this.recursiveFind(menus.items)
}
},
hasActiveMenu(menu) {
return this.recursiveFind(menu)
},
setActiveMenu(menu) {
if (menu.items.length === 0 && menu.path) {
Nova.visit(menu.path)
this.currentActiveMenu = null
return
}
if (this.currentActiveMenu === menu) {
this.currentActiveMenu = null
} else {
this.currentActiveMenu = menu
}
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/MenuGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="mt-2">

<div v-for="item of item.items">
<component :is="item.component" :item="item"/>
<MenuItem :item="item"/>
</div>

</div>
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/MenuItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
v-bind="omit(linkAttributes, 'data.icon')"
@click="handleClick">

<SvgIcon :type="item.data?.icon" class="mr-2 min-w-[24px]"/>
<SvgIcon :type="item.data?.icon ?? item.icon" class="mr-2 min-w-[24px]"/>
{{ item.name }}
<SvgIcon v-if="item.external" type="external-link" width="16" class="hidden group-hover:block ml-auto"/>
<SvgIcon v-if="item.external" type="external-link" :width="16" class="hidden group-hover:block ml-auto"/>
<div v-if="item.badge" class="ml-auto">
Expand Down
16 changes: 16 additions & 0 deletions resources/js/components/MenuSection.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>

<MenuItem :item="item"/>

</template>

<script>
import MenuItem from './MenuItem.vue'
export default {
components: { MenuItem },
props: [ 'item' ],
}
</script>

0 comments on commit 9a698c0

Please sign in to comment.