Skip to content

fix: prevent commentor/viewer from enabling hidden columns #8268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
10 changes: 8 additions & 2 deletions packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { CalendarType, ColumnType, GalleryType, KanbanType } from 'nocodb-sdk'
import { UITypes, ViewTypes, isVirtualCol } from 'nocodb-sdk'
import { ProjectRoles, UITypes, ViewTypes, isVirtualCol } from 'nocodb-sdk'
import Draggable from 'vuedraggable'

import type { SelectProps } from 'ant-design-vue'
Expand All @@ -17,12 +17,15 @@ import {
resolveComponent,
useMenuCloseOnEsc,
useNuxtApp,
useRoles,
useSmartsheetStoreOrThrow,
useUndoRedo,
useViewColumnsOrThrow,
watch,
} from '#imports'

const { baseRoles } = useRoles()

const activeView = inject(ActiveViewInj, ref())

const reloadViewMetaHook = inject(ReloadViewMetaHookInj, undefined)!
Expand Down Expand Up @@ -54,6 +57,9 @@ const {
toggleFieldVisibility,
} = useViewColumnsOrThrow()

const shouldShowField = (show: boolean) =>
!((baseRoles?.value[ProjectRoles.COMMENTER] || baseRoles?.value[ProjectRoles.VIEWER]) && !show)

const { eventBus } = useSmartsheetStoreOrThrow()

const { addUndo, defineViewScope } = useUndoRedo()
Expand Down Expand Up @@ -409,7 +415,7 @@ useMenuCloseOnEsc(open)
v-if="
filteredFieldList
.filter((el) => (activeView.type !== ViewTypes.CALENDAR ? el !== gridDisplayValueField : true))
.includes(field)
.includes(field) && shouldShowField(field.show)
"
:key="field.id"
:data-testid="`nc-fields-menu-${field.title}`"
Expand Down