Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): hide sort menu from calendar sidebar if user dont have permission

Ramesh Mane11307d11dd71
diff --git a/packages/nc-gui/components/smartsheet/Toolbar.vue b/packages/nc-gui/components/smartsheet/Toolbar.vue
index c02744e30a..f0aa266212 100644
--- a/packages/nc-gui/components/smartsheet/Toolbar.vue
+++ b/packages/nc-gui/components/smartsheet/Toolbar.vue
@@ -5,7 +5,7 @@ defineProps<{
const isPublic = inject(IsPublicInj, ref(false))
-const { isGrid, isGallery, isKanban, isMap, isCalendar } = useSmartsheetStoreOrThrow()
+const { isGrid, isGallery, isKanban, isMap, isCalendar, isToolbarOperationsAllowed } = useSmartsheetStoreOrThrow()
const { isUIAllowed } = useRoles()
@@ -43,14 +43,6 @@ const isToolbarIconMode = computed(() => {
return false
})
-const isToolbarOperationsAllowed = computed(() => {
- // Allow toolbar operations in shared base and view
- if (isPublic.value || isSharedBase.value) return true
-
- // Allow toolbar operations only for editor and above roles
- return isUIAllowed('toolbarOperations')
-})
-
provide(IsToolbarIconMode, isToolbarIconMode)
</script>
diff --git a/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue b/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
index d62f31f84d..2515d7a407 100644
--- a/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
+++ b/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
@@ -42,7 +42,7 @@ const {
timezoneDayjs,
} = useCalendarViewStoreOrThrow()
-const { isSyncedTable } = useSmartsheetStoreOrThrow()
+const { isSyncedTable, isToolbarOperationsAllowed } = useSmartsheetStoreOrThrow()
const sideBarListRef = ref<VNodeRef | null>(null)
@@ -469,8 +469,11 @@ const selectOption = (option) => {
</template>
</a-input>
</div>
- <div class="mx-4 gap-2 flex items-center">
- <LazySmartsheetToolbarSortListMenu />
+ <div
+ v-if="isToolbarOperationsAllowed || (isUIAllowed('dataEdit') && props.visible && !isSyncedTable)"
+ class="mx-4 gap-2 flex items-center"
+ >
+ <LazySmartsheetToolbarSortListMenu v-if="isToolbarOperationsAllowed" />
<div class="flex-1" />
diff --git a/packages/nc-gui/composables/useSmartsheetStore.ts b/packages/nc-gui/composables/useSmartsheetStore.ts
index 92d724b69e..e842d77076 100644
--- a/packages/nc-gui/composables/useSmartsheetStore.ts
+++ b/packages/nc-gui/composables/useSmartsheetStore.ts
@@ -20,11 +20,13 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(
const { user, isMobileMode } = useGlobal()
+ const { isUIAllowed } = useRoles()
+
const { activeView: view, activeNestedFilters, activeSorts } = storeToRefs(useViewsStore())
const baseStore = useBase()
- const { sqlUis, base } = storeToRefs(baseStore)
+ const { sqlUis, base, isSharedBase } = storeToRefs(baseStore)
const sqlUi = computed(() =>
(meta.value as TableType)?.source_id ? sqlUis.value[(meta.value as TableType).source_id!] : Object.values(sqlUis.value)[0],
@@ -54,6 +56,14 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(
() => !!base.value?.sources?.some((s) => s.id === (meta.value as TableType)?.source_id && !s.is_meta && !s.is_local),
)
+ const isToolbarOperationsAllowed = computed(() => {
+ // Allow toolbar operations in shared base and view
+ if (isPublic.value || isSharedBase.value) return true
+
+ // Allow toolbar operations only for editor and above roles
+ return isUIAllowed('toolbarOperations')
+ })
+
const isAlreadyShownUpgradeModal = ref(false)
const aliasColObjMap = computed(() => {
@@ -230,6 +240,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(
fetchTotalRowsWithSearchQuery,
gridEditEnabled,
getValidSearchQueryForColumn,
+ isToolbarOperationsAllowed,
}
},
'smartsheet-store',