-
Notifications
You must be signed in to change notification settings - Fork 389
Expand file tree
/
Copy pathNavList.vue
More file actions
210 lines (201 loc) · 5.47 KB
/
Copy pathNavList.vue
File metadata and controls
210 lines (201 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<script setup lang="ts">
import { computed, getCurrentInstance, onMounted, onUnmounted } from "vue";
import { useRoute } from "vue-router";
import { unreadNotificationsCount } from "@/data/notifications";
import { session } from "@/data/session";
import { getTeam } from "@/data/team";
import Activity from "~icons/lucide/activity";
import Boxes from "~icons/lucide/boxes";
import Code from "~icons/lucide/code";
import DatabaseZap from "~icons/lucide/database-zap";
import DoorOpen from "~icons/lucide/door-open";
import FileSearch from "~icons/lucide/file-search";
import Globe from "~icons/lucide/globe";
import App from "~icons/lucide/layout-grid";
import PanelTopInactive from "~icons/lucide/panel-top-inactive";
import Logs from "~icons/lucide/scroll-text";
import Server from "~icons/lucide/server";
import Settings from "~icons/lucide/settings";
import WalletCards from "~icons/lucide/wallet-cards";
import Item from "./Item.vue";
import ItemGroup from "./ItemGroup.vue";
import NotificationPanel from "./Notifications.vue";
import SearchItem from "./SearchItem.vue";
const $route = useRoute();
const $team = getTeam();
const $session = session;
const $socket = getCurrentInstance().proxy.$socket;
const navigation = computed(() => {
if (!$team?.doc) return [];
const routeName = String($route?.name || "");
const onboardingComplete = $team.doc.onboarding.complete;
const isSaasUser = $team.doc.is_saas_user;
const enforce2FA = Boolean(
!$team.doc.is_desk_user &&
$team.doc.enforce_2fa &&
!$team.doc.user_info?.is_2fa_enabled,
);
return [
{
name: "Welcome",
icon: DoorOpen,
route: "/welcome",
isActive: routeName === "Welcome",
condition: !onboardingComplete,
},
{
customComponent: SearchItem,
condition: onboardingComplete,
},
{
name: "Notifications",
condition: onboardingComplete && !isSaasUser,
customComponent: NotificationPanel,
disabled: enforce2FA,
},
{
name: "Sites",
icon: PanelTopInactive,
route: "/sites",
class: "mt-1.5",
isActive:
["Site List", "Site Detail", "New Site"].includes(routeName) ||
routeName.startsWith("Site Detail"),
disabled: enforce2FA,
},
/* {
name: 'Benches',
icon: (Package),
route: '/benches',
isActive: routeName.startsWith('Bench'),
condition: $team.doc?.is_desk_user,
disabled: !onboardingComplete || enforce2FA,
}, */
{
name: "Benches",
icon: Boxes,
route: onboardingComplete ? "/groups" : "/enable-bench-groups",
isActive:
[
"Release Group List",
"Release Group Detail",
"New Release Group",
"Release Group New Site",
"Deploy Candidate",
].includes(routeName) ||
routeName.startsWith("Release Group Detail") ||
routeName === "Enable Benches",
disabled: enforce2FA,
},
{
name: "Servers",
icon: Server,
route: onboardingComplete ? "/servers" : "/enable-servers",
isActive:
["New Server"].includes(routeName) ||
routeName.startsWith("Server") ||
routeName === "Enable Servers",
disabled: enforce2FA,
},
{
name: "Dev Tools",
icon: Code,
route: "/devtools",
condition: onboardingComplete && !isSaasUser,
disabled: enforce2FA,
children: [
{
name: "Log Browser",
icon: Logs,
route: "/log-browser",
isActive: routeName === "Log Browser",
},
{
name: "DB Analyzer",
icon: Activity,
route: "/database-analyzer",
isActive: routeName === "DB Analyzer",
},
{
name: "SQL Playground",
icon: DatabaseZap,
route: "/sql-playground",
isActive: routeName === "SQL Playground",
},
{
name: "Binlog Browser",
icon: FileSearch,
route: "/binlog-browser",
isActive: routeName === "Binlog Browser",
condition: $team.doc.is_binlog_indexer_enabled ?? false,
},
].filter((item) => item.condition ?? true),
isActive: [
"SQL Playground",
"DB Analyzer",
"Log Browser",
"Binlog Browser",
].includes(routeName),
},
{
name: "Marketplace",
icon: App,
route: "/apps",
isActive: routeName.startsWith("Marketplace"),
class: "-mt-1",
condition:
$team.doc?.is_desk_user ||
(!!$team.doc.is_developer && $session.hasAppsAccess),
disabled: enforce2FA,
},
{
name: "Billing",
icon: WalletCards,
route: "/billing",
isActive: routeName.startsWith("Billing"),
condition: $team.doc?.is_desk_user || $session.hasBillingAccess,
disabled: enforce2FA,
},
{
name: "Partnership",
icon: Globe,
route: "/partners",
isActive: routeName === "Partnership",
condition: Boolean($team.doc.erpnext_partner),
disabled: enforce2FA,
},
{
name: "Settings",
icon: Settings,
route: "/settings",
isActive: routeName.startsWith("Settings"),
disabled: enforce2FA,
},
{
name: "Status",
icon: LucideActivity,
route: "/status",
isActive: routeName === "Status",
disabled: enforce2FA,
},
].filter((item) => item.condition ?? true);
});
onMounted(() => {
$socket.emit("doctype_subscribe", "Press Notification");
$socket.on("press_notification", (data) => {
if (data.team === $team.doc.name) {
unreadNotificationsCount.setData((data) => data + 1);
}
});
});
onUnmounted(() => {
$socket.off("press_notification");
});
</script>
<template>
<template v-for="(item, _) in navigation" :key="item.name">
<ItemGroup v-if="item.children" v-bind="item" />
<component v-else-if="item.customComponent" :is="item.customComponent" :disabled="item.disabled" />
<Item v-else v-bind="item" />
</template>
</template>