Skip to content

Commit 90a0b6d

Browse files
committed
Testing Vite revert
- Reverted Vite config and env based config Signed-off-by: Nikhil Ashoka <[email protected]>
1 parent 4b98c58 commit 90a0b6d

File tree

5 files changed

+415
-215
lines changed

5 files changed

+415
-215
lines changed

index.html

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta http-equiv="Content-Security-Policy">
5-
<meta charset="utf-8">
6-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
8-
<link rel="icon" href="/bee-2-light.svg">
4+
<meta http-equiv="Content-Security-Policy" />
5+
<meta charset="UTF-8" />
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7+
<link rel="icon" href="/favicon.ico" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
99
<title>OpenBMC Web UI</title>
1010
</head>
1111
<body>
12-
<noscript>
13-
<strong>We're sorry but this application does not work properly without JavaScript enabled. Please enable it to continue.</strong>
14-
</noscript>
1512
<div id="app"></div>
1613
<script type="module" src="/src/main.js"></script>
1714
</body>

src/components/AppNavigation/AppNavigationData.js

Lines changed: 185 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,91 @@ import IconSettingsAdjust from '@carbon/icons-vue/es/settings--adjust/16';
55
import IconSettings from '@carbon/icons-vue/es/settings/16';
66
import IconSecurity from '@carbon/icons-vue/es/security/16';
77
import IconDataBase from '@carbon/icons-vue/es/data--base--alt/16';
8+
import IconDocument from '@carbon/icons-vue/es/document/16';
89
import i18n from '@/i18n';
10+
import stores from '@/store'
11+
12+
import { ref, computed, onMounted } from 'vue';
913

1014
const AppNavigationData = () => {
11-
const navigationItems = [
15+
const navigationData = ref([
1216
{
1317
id: 'overview',
1418
label: i18n.global.t('appNavigation.overview'),
1519
route: '/',
1620
icon: IconDashboard,
1721
},
1822
{
19-
id: 'logs',
20-
label: i18n.global.t('appNavigation.logs'),
21-
icon: IconTextLinkAnalysis,
23+
id: 'operations',
24+
label: i18n.global.t('appNavigation.operations'),
25+
icon: IconSettingsAdjust,
2226
children: [
2327
{
24-
id: 'event-logs',
25-
label: i18n.global.t('appNavigation.eventLogs'),
26-
route: '/logs/event-logs',
28+
id: 'server-power-operations',
29+
label: i18n.global.t('appNavigation.serverPowerOperations'),
30+
route: '/operations/server-power-operations',
31+
restrictTo: [],
2732
},
2833
{
29-
id: 'audit-logs',
30-
label: i18n.global.t('appNavigation.auditLogs'),
31-
route: '/logs/audit-logs',
34+
id: 'host-console',
35+
label: i18n.global.t('appNavigation.hostConsole'),
36+
route: '/operations/host-console',
37+
restrictTo: ['Administrator', 'OemIBMServiceAgent'],
3238
},
3339
{
34-
id: 'post-code-logs',
35-
label: i18n.global.t('appNavigation.postCodeLogs'),
36-
route: '/logs/post-code-logs',
40+
id: 'service-login',
41+
label: i18n.global.t('appPageTitle.serviceLogin'),
42+
route: '/operations/service-login',
43+
restrictTo: ['OemIBMServiceAgent'],
44+
},
45+
{
46+
id: 'firmware',
47+
label: i18n.global.t('appNavigation.firmware'),
48+
route: '/operations/firmware',
49+
restrictTo: [],
50+
},
51+
{
52+
id: 'reboot-bmc',
53+
label: i18n.global.t('appNavigation.rebootBmc'),
54+
route: '/operations/reboot-bmc',
55+
restrictTo: [],
56+
},
57+
],
58+
},
59+
{
60+
id: 'resource-management',
61+
label: i18n.global.t('appNavigation.resourceManagement'),
62+
icon: IconDataBase,
63+
children: [
64+
{
65+
id: 'memory',
66+
label: i18n.global.t('appNavigation.memory'),
67+
route: '/resource-management/memory',
68+
restrictTo: [],
69+
},
70+
{
71+
id: 'power',
72+
label: i18n.global.t('appNavigation.power'),
73+
route: '/resource-management/power',
74+
restrictTo: [],
75+
},
76+
{
77+
id: 'capacity-on-demand',
78+
label: i18n.global.t('appNavigation.capacityOnDemand'),
79+
route: '/resource-management/capacity-on-demand',
80+
restrictTo: [],
81+
},
82+
{
83+
id: 'field-core-override',
84+
label: i18n.global.t('appNavigation.fieldCoreOverride'),
85+
route: '/resource-management/field-core-override',
86+
restrictTo: [],
87+
},
88+
{
89+
id: 'system-parameters',
90+
label: i18n.global.t('appNavigation.systemParameters'),
91+
route: '/resource-management/system-parameters',
92+
restrictTo: [],
3793
},
3894
],
3995
},
@@ -46,73 +102,74 @@ const AppNavigationData = () => {
46102
id: 'inventory',
47103
label: i18n.global.t('appNavigation.inventory'),
48104
route: '/hardware-status/inventory',
105+
restrictTo: [],
49106
},
50107
{
51108
id: 'sensors',
52109
label: i18n.global.t('appNavigation.sensors'),
53110
route: '/hardware-status/sensors',
111+
restrictTo: [],
112+
},
113+
{
114+
id: 'hardware-deconfiguration',
115+
label: i18n.global.t('appNavigation.deconfigurationHardware'),
116+
route: '/settings/hardware-deconfiguration',
117+
restrictTo: [],
54118
},
55119
{
56120
id: 'pcie-topology',
57121
label: i18n.global.t('appNavigation.pcieTopology'),
58122
route: '/hardware-status/pcie-topology',
123+
restrictTo: [],
59124
},
60125
{
61126
id: 'concurrent-maintenance',
62127
label: i18n.global.t('appNavigation.concurrentMaintenance'),
63128
route: '/hardware-status/concurrent-maintenance',
129+
restrictTo: ['Everest'],
64130
},
65131
],
66132
},
67133
{
68-
id: 'operations',
69-
label: i18n.global.t('appNavigation.operations'),
70-
icon: IconSettingsAdjust,
134+
id: 'logs',
135+
label: i18n.global.t('appNavigation.logs'),
136+
icon: IconTextLinkAnalysis,
71137
children: [
72138
{
73-
id: 'factory-reset',
74-
label: i18n.global.t('appNavigation.factoryReset'),
75-
route: '/operations/factory-reset',
76-
},
77-
{
78-
id: 'kvm',
79-
label: i18n.global.t('appNavigation.kvm'),
80-
route: '/operations/kvm',
81-
},
82-
{
83-
id: 'key-clear',
84-
label: i18n.global.t('appNavigation.keyClear'),
85-
route: '/operations/key-clear',
86-
},
87-
{
88-
id: 'firmware',
89-
label: i18n.global.t('appNavigation.firmware'),
90-
route: '/operations/firmware',
139+
id: 'post-code-logs',
140+
label: i18n.global.t('appNavigation.postCodeLogs'),
141+
route: '/logs/post-code-logs',
142+
restrictTo: [],
91143
},
92144
{
93-
id: 'reboot-bmc',
94-
label: i18n.global.t('appNavigation.rebootBmc'),
95-
route: '/operations/reboot-bmc',
145+
id: 'event-logs',
146+
label: i18n.global.t('appNavigation.eventLogs'),
147+
route: '/logs/event-logs',
148+
restrictTo: [],
96149
},
97150
{
98-
id: 'service-login',
99-
label: i18n.global.t('appNavigation.serviceLogin'),
100-
route: '/operations/service-login',
151+
id: 'audit-logs',
152+
label: i18n.global.t('appNavigation.auditLogs'),
153+
route: '/logs/audit-logs',
154+
restrictTo: [],
101155
},
102156
{
103-
id: 'host-console',
104-
label: i18n.global.t('appNavigation.hostConsole'),
105-
route: '/operations/host-console',
157+
id: 'dumps',
158+
label: i18n.global.t('appNavigation.dumps'),
159+
route: '/logs/dumps',
160+
restrictTo: [],
106161
},
107162
{
108-
id: 'server-power-operations',
109-
label: i18n.global.t('appNavigation.serverPowerOperations'),
110-
route: '/operations/server-power-operations',
163+
id: 'ibmi-service-functions',
164+
label: i18n.global.t('appNavigation.ibmiServiceFunctions'),
165+
route: '/logs/ibmi-service-functions',
166+
restrictTo: ['NonHMCManaged'],
111167
},
112168
{
113-
id: 'virtual-media',
114-
label: i18n.global.t('appNavigation.virtualMedia'),
115-
route: '/operations/virtual-media',
169+
id: 'deconfiguration-records',
170+
label: i18n.global.t('appNavigation.deconfigurationRecords'),
171+
route: '/logs/deconfiguration-records',
172+
restrictTo: [],
116173
},
117174
],
118175
},
@@ -125,26 +182,31 @@ const AppNavigationData = () => {
125182
id: 'date-time',
126183
label: i18n.global.t('appNavigation.dateTime'),
127184
route: '/settings/date-time',
128-
},
129-
{
130-
id: 'hardware-deconfiguration',
131-
label: i18n.global.t('appNavigation.deconfigurationHardware'),
132-
route: '/settings/hardware-deconfiguration',
185+
restrictTo: [],
133186
},
134187
{
135188
id: 'network',
136189
label: i18n.global.t('appNavigation.network'),
137190
route: '/settings/network',
191+
restrictTo: [],
138192
},
139193
{
140194
id: 'power-restore-policy',
141195
label: i18n.global.t('appNavigation.powerRestorePolicy'),
142196
route: '/settings/power-restore-policy',
197+
restrictTo: [],
143198
},
144199
{
145200
id: 'snmp-alerts',
146201
label: i18n.global.t('appNavigation.snmpAlerts'),
147202
route: '/settings/snmp-alerts',
203+
restrictTo: [],
204+
},
205+
{
206+
id: 'factory-reset',
207+
label: i18n.global.t('appNavigation.factoryReset'),
208+
route: '/operations/factory-reset',
209+
restrictTo: [],
148210
},
149211
],
150212
},
@@ -157,54 +219,96 @@ const AppNavigationData = () => {
157219
id: 'sessions',
158220
label: i18n.global.t('appNavigation.sessions'),
159221
route: '/security-and-access/sessions',
160-
},
161-
{
162-
id: 'ldap',
163-
label: i18n.global.t('appNavigation.ldap'),
164-
route: '/security-and-access/ldap',
222+
restrictTo: [],
165223
},
166224
{
167225
id: 'user-management',
168226
label: i18n.global.t('appNavigation.userManagement'),
169227
route: '/security-and-access/user-management',
228+
restrictTo: [],
170229
},
171230
{
172-
id: 'policies',
173-
label: i18n.global.t('appNavigation.policies'),
174-
route: '/security-and-access/policies',
231+
id: 'ldap',
232+
label: i18n.global.t('appNavigation.ldap'),
233+
route: '/security-and-access/ldap',
234+
restrictTo: [],
175235
},
176236
{
177237
id: 'certificates',
178238
label: i18n.global.t('appNavigation.certificates'),
179239
route: '/security-and-access/certificates',
240+
restrictTo: [],
180241
},
181-
],
182-
},
183-
{
184-
id: 'resource-management',
185-
label: i18n.global.t('appNavigation.resourceManagement'),
186-
icon: IconDataBase,
187-
children: [
188242
{
189-
id: 'system-parameters',
190-
label: i18n.global.t('appNavigation.systemParameters'),
191-
route: '/resource-management/system-parameters',
192-
},
193-
{
194-
id: 'memory',
195-
label: i18n.global.t('appNavigation.memory'),
196-
route: '/resource-management/memory',
243+
id: 'policies',
244+
label: i18n.global.t('appNavigation.policies'),
245+
route: '/security-and-access/policies',
246+
restrictTo: [],
197247
},
198248
{
199-
id: 'power',
200-
label: i18n.global.t('appNavigation.power'),
201-
route: '/resource-management/power',
249+
id: 'key-clear',
250+
label: i18n.global.t('appNavigation.keyClear'),
251+
route: '/operations/key-clear',
252+
restrictTo: ['Administrator', 'OemIBMServiceAgent'],
202253
},
203254
],
204255
},
205-
]
256+
{
257+
id: 'notices',
258+
label: i18n.global.t('appNavigation.notices'),
259+
route: '/notices',
260+
icon: IconDocument,
261+
},
262+
]);
263+
264+
const globalStore = stores.GlobalStore();
265+
const roleId = computed(
266+
() => globalStore.currentUserGetter?.RoleId,
267+
);
268+
const systemInfo = computed(() => globalStore.modelTypeGetter);
269+
const hmcInfo = computed(() => globalStore.hmcManagedGetter);
270+
271+
const model = computed(() =>
272+
systemInfo.value?.startsWith('9043') ? 'Everest' : 'NotEverest',
273+
);
274+
const isHmcManged = computed(() =>
275+
hmcInfo.value === 'Enabled' ? 'HMCManaged' : 'NonHMCManaged',
276+
);
277+
278+
const navigationItems = computed(() => {
279+
return navigationData.value.map((section) => {
280+
const restrictedPages = [];
281+
section.children?.forEach((page) => {
282+
if (page.restrictTo.length > 0) {
283+
const isPageNeeded = page.restrictTo.some(
284+
(requiredRole) =>
285+
requiredRole === roleId.value ||
286+
requiredRole === model.value ||
287+
requiredRole === isHmcManged.value,
288+
);
289+
if (!isPageNeeded) restrictedPages.push(page);
290+
}
291+
});
292+
if (section?.children && section?.children.length > 0) {
293+
const finalSection = section.children.filter(
294+
(item) => !restrictedPages.includes(item),
295+
);
296+
section.children = finalSection;
297+
}
298+
return section;
299+
});
300+
});
301+
302+
onMounted(() => {
303+
globalStore.getHmcManaged();
304+
});
305+
206306
return {
207307
navigationItems,
308+
roleId,
309+
model,
310+
systemInfo,
311+
isHmcManged,
208312
};
209313
}
210314
export default AppNavigationData;

0 commit comments

Comments
 (0)