-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: NaYeong,Kim <[email protected]>
- Loading branch information
Showing
43 changed files
with
269 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
import type { Ref } from 'vue'; | ||
import { computed, reactive, toRef } from 'vue'; | ||
import { useRoute } from 'vue-router/composables'; | ||
|
||
import { clone } from 'lodash'; | ||
|
||
import { MENU_ID } from '@/lib/menu/config'; | ||
|
||
|
||
import { COST_EXPLORER_ROUTE } from '@/services/cost-explorer/routes/route-constant'; | ||
interface UseCurrentMenuIdReturnType { | ||
currentMenuId: Ref<string>; | ||
} | ||
|
||
export const useCurrentMenuId = (): string => { | ||
export const useCurrentMenuId = (): UseCurrentMenuIdReturnType => { | ||
const route = useRoute(); | ||
const reversedMatched = clone(route.matched).reverse(); | ||
const closestRoute = reversedMatched.find((d) => d.meta?.menuId !== undefined); | ||
const targetMenuId = closestRoute?.meta?.menuId || MENU_ID.WORKSPACE_HOME; | ||
if (route.name === COST_EXPLORER_ROUTE.LANDING._NAME) { | ||
return ''; | ||
} | ||
return targetMenuId; | ||
|
||
const state = reactive({ | ||
currentMenuId: computed<string>(() => { | ||
const reversedMatched = clone(route.matched).reverse(); | ||
const closestRoute = reversedMatched.find((d) => d.meta?.menuId !== undefined); | ||
return closestRoute?.meta?.menuId || MENU_ID.WORKSPACE_HOME; | ||
}), | ||
}); | ||
|
||
return { | ||
currentMenuId: toRef(state, 'currentMenuId'), | ||
}; | ||
}; |
19 changes: 16 additions & 3 deletions
19
apps/web/src/common/composables/page-editable-status/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import { computed, reactive } from 'vue'; | ||
import type { Ref } from 'vue'; | ||
import { computed, reactive, toRef } from 'vue'; | ||
|
||
import { useUserStore } from '@/store/user/user-store'; | ||
|
||
import type { PageAccessMap } from '@/lib/access-control/config'; | ||
|
||
import { useCurrentMenuId } from '@/common/composables/current-menu-id'; | ||
|
||
export const usePageEditableStatus = (): boolean|undefined => { | ||
interface UsePageEditableStatusReturnType { | ||
hasReadWriteAccess: Ref<boolean|undefined>; | ||
} | ||
|
||
export const usePageEditableStatus = (): UsePageEditableStatusReturnType => { | ||
const userStore = useUserStore(); | ||
const userGetters = userStore.getters; | ||
|
||
const { currentMenuId } = useCurrentMenuId(); | ||
|
||
const storeState = reactive({ | ||
pageAccessPermissionMap: computed<PageAccessMap>(() => userGetters.pageAccessPermissionMap), | ||
}); | ||
|
||
return storeState.pageAccessPermissionMap[useCurrentMenuId()]?.write; | ||
const state = reactive({ | ||
hasReadWriteAccess: computed<boolean|undefined>(() => storeState.pageAccessPermissionMap[currentMenuId.value]?.write), | ||
}); | ||
|
||
return { | ||
hasReadWriteAccess: toRef(state, 'hasReadWriteAccess'), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
<script setup lang="ts"> | ||
import { computed, reactive } from 'vue'; | ||
import { MENU_ID } from '@/lib/menu/config.js'; | ||
import { useCurrentMenuId } from '@/common/composables/current-menu-id'; | ||
import BookmarkLSB from '@/services/advanced/components/BookmarkLSB.vue'; | ||
import DomainSettingsLSB from '@/services/advanced/components/PreferencesLSB.vue'; | ||
const state = reactive({ | ||
menuId: computed<string>(() => useCurrentMenuId()), | ||
}); | ||
const { currentMenuId } = useCurrentMenuId(); | ||
</script> | ||
|
||
<template> | ||
<fragment> | ||
<bookmark-l-s-b v-if="state.menuId === MENU_ID.BOOKMARK" /> | ||
<domain-settings-l-s-b v-if="state.menuId === MENU_ID.PREFERENCES" /> | ||
<bookmark-l-s-b v-if="currentMenuId === MENU_ID.BOOKMARK" /> | ||
<domain-settings-l-s-b v-if="currentMenuId === MENU_ID.PREFERENCES" /> | ||
</fragment> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.