diff --git a/app/javascript/dashboard/components/layout/Sidebar.vue b/app/javascript/dashboard/components/layout/Sidebar.vue index 509c34696..79bef628a 100644 --- a/app/javascript/dashboard/components/layout/Sidebar.vue +++ b/app/javascript/dashboard/components/layout/Sidebar.vue @@ -144,6 +144,7 @@ export default { cssClass: 'menu-title align-justify', toState: frontendURL(`accounts/${this.accountId}/settings/inboxes`), toStateName: 'settings_inbox_list', + newLinkRouteName: 'settings_inbox_new', children: this.inboxes.map(inbox => ({ id: inbox.id, label: inbox.name, @@ -158,10 +159,13 @@ export default { icon: 'ion-pound', label: 'LABELS', hasSubMenu: true, + newLink: true, key: 'label', cssClass: 'menu-title align-justify', toState: frontendURL(`accounts/${this.accountId}/settings/labels`), toStateName: 'labels_list', + showModalForNewItem: true, + modalName: 'AddLabel', children: this.accountLabels.map(label => ({ id: label.id, label: label.title, @@ -178,10 +182,12 @@ export default { icon: 'ion-ios-people', label: 'TEAMS', hasSubMenu: true, + newLink: true, key: 'team', cssClass: 'menu-title align-justify teams-sidebar-menu', toState: frontendURL(`accounts/${this.accountId}/settings/teams`), toStateName: 'teams_list', + newLinkRouteName: 'settings_teams_new', children: this.teams.map(team => ({ id: team.id, label: team.name, diff --git a/app/javascript/dashboard/components/layout/SidebarItem.vue b/app/javascript/dashboard/components/layout/SidebarItem.vue index f00753497..810155bef 100644 --- a/app/javascript/dashboard/components/layout/SidebarItem.vue +++ b/app/javascript/dashboard/components/layout/SidebarItem.vue @@ -19,7 +19,7 @@ + @@ -61,8 +66,17 @@ import { mapGetters } from 'vuex'; import router from '../../routes'; import adminMixin from '../../mixins/isAdmin'; import { getInboxClassByType } from 'dashboard/helper/inbox'; +import AddLabelModal from '../../routes/dashboard/settings/labels/AddLabel'; export default { + components: { + AddLabelModal, + }, mixins: [adminMixin], + data() { + return { + showAddLabel: false, + }; + }, props: { menuItem: { type: Object, @@ -108,12 +122,24 @@ export default { if (!child.truncateLabel) return false; return child.label; }, - newLinkClick() { - router.push({ name: 'settings_inbox_new', params: { page: 'new' } }); + newLinkClick(item) { + if (item.newLinkRouteName) { + router.push({ name: item.newLinkRouteName, params: { page: 'new' } }); + } else if (item.showModalForNewItem) { + if (item.modalName === 'AddLabel') { + this.showAddLabelPopup(); + } + } }, showItem(item) { return this.isAdmin && item.newLink !== undefined; }, + showAddLabelPopup() { + this.showAddLabel = true; + }, + hideAddLabelPopup() { + this.showAddLabel = false; + }, }, }; diff --git a/app/javascript/dashboard/routes/dashboard/settings/labels/AddLabel.vue b/app/javascript/dashboard/routes/dashboard/settings/labels/AddLabel.vue index a7ea01e6b..8056362b4 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/labels/AddLabel.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/labels/AddLabel.vue @@ -37,16 +37,14 @@