Skip to content

Commit 1c28ac3

Browse files
committed
Fixed infinite loop issue
- The UI was stuck when route between components. - Updated the NavigationData.js
1 parent c76f642 commit 1c28ac3

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

src/components/AppNavigation/AppNavigation.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ import IconChevronUp from '@carbon/icons-vue/es/chevron--up/16';
6969
import stores from '@/store';
7070
import eventBus from '@/eventBus';
7171
72-
const navigationItems = AppNavigationData().navigationItems;
73-
const globalStore = stores.GlobalStore();
72+
const navigationItems = computed(() => {
73+
return AppNavigationData().navigationItems;
74+
});
75+
const globalStore = stores.GlobalStore();
7476
const userManagementStore = stores.UserManagementStore();
7577
const isNavigationOpen = ref(false);
7678
const loadingCompleted = ref(false);

src/components/AppNavigation/AppNavigationData.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import IconDocument from '@carbon/icons-vue/es/document/16';
99
import i18n from '@/i18n';
1010
import stores from '@/store'
1111

12-
import { ref, computed, onMounted } from 'vue';
12+
import { computed, onMounted } from 'vue';
1313

1414
const AppNavigationData = () => {
15-
const navigationData = ref([
15+
const navigationData = [
1616
{
1717
id: 'overview',
1818
label: i18n.global.t('appNavigation.overview'),
@@ -259,7 +259,7 @@ const AppNavigationData = () => {
259259
route: '/notices',
260260
icon: IconDocument,
261261
},
262-
]);
262+
];
263263

264264
const globalStore = stores.GlobalStore();
265265
const roleId = computed(
@@ -275,34 +275,37 @@ const AppNavigationData = () => {
275275
hmcInfo.value === 'Enabled' ? 'HMCManaged' : 'NonHMCManaged',
276276
);
277277

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-
});
278+
const navigationItems = navigationData;
279+
// const navigationItems = computed(() => {
280+
// console.log('navigationData', navigationData);
281+
// return navigationData.map((section) => {
282+
// const restrictedPages = [];
283+
// section.children?.forEach((page) => {
284+
// if (page.restrictTo.length > 0) {
285+
// const isPageNeeded = page.restrictTo.some(
286+
// (requiredRole) =>
287+
// requiredRole === roleId.value ||
288+
// requiredRole === model.value ||
289+
// requiredRole === isHmcManged.value,
290+
// );
291+
// if (!isPageNeeded) restrictedPages.push(page);
292+
// }
293+
// });
294+
// if (section?.children && section?.children.length > 0) {
295+
// const finalSection = section.children.filter(
296+
// (item) => !restrictedPages.includes(item),
297+
// );
298+
// section.children = finalSection;
299+
// }
300+
// console.log('section', section);
301+
// return section;
302+
// });
303+
// });
301304

302305
onMounted(() => {
303306
globalStore.getHmcManaged();
304307
});
305-
308+
306309
return {
307310
navigationItems,
308311
roleId,

0 commit comments

Comments
 (0)