Browse Source

fix/Fixed viewer permission issues

pull/3292/head
Muhammed Mustafa 2 years ago
parent
commit
5895ddb4ba
  1. 3
      packages/nc-gui-v2/components/smartsheet/Toolbar.vue
  2. 1
      packages/nc-gui-v2/composables/useUIPermission/rolePermissions.ts
  3. 10
      packages/nc-gui-v2/composables/useViewColumns.ts

3
packages/nc-gui-v2/components/smartsheet/Toolbar.vue

@ -5,6 +5,7 @@ import ToggleDrawer from '~/components/smartsheet/sidebar/toolbar/ToggleDrawer.v
const { isGrid, isForm, isGallery } = useSmartsheetStoreOrThrow()
const isPublic = inject(IsPublicInj, ref(false))
const { allowCSVDownload } = useSharedView()
const { isUIAllowed } = useUIPermission()
const { isOpen } = useSidebar()
</script>
@ -31,7 +32,7 @@ const { isOpen } = useSidebar()
<div class="flex-1" />
<SmartsheetToolbarReload class="mx-1" />
<SmartsheetToolbarAddRow class="mx-1" />
<SmartsheetToolbarAddRow v-if="isUIAllowed('dataInsert')" class="mx-1" />
<SmartsheetToolbarSearchData v-if="(isGrid || isGallery) && !isPublic" class="shrink mr-2 ml-2" />

1
packages/nc-gui-v2/composables/useUIPermission/rolePermissions.ts

@ -8,6 +8,7 @@ const rolePermissions = {
column: true,
tableAttachment: true,
tableRowUpdate: true,
dataInsert: true,
rowComments: true,
gridViewOptions: true,
sortSync: true,

10
packages/nc-gui-v2/composables/useViewColumns.ts

@ -19,6 +19,10 @@ export function useViewColumns(view: Ref<ViewType> | undefined, meta: ComputedRe
const { isSharedBase } = useProject()
const isLocalMode = computed(
() => isPublic.value || !isUIAllowed('hideAllColumns') || !isUIAllowed('showAllColumns') || isSharedBase.value,
)
const loadViewColumns = async () => {
if (!meta || !view) return
@ -52,7 +56,7 @@ export function useViewColumns(view: Ref<ViewType> | undefined, meta: ComputedRe
}
const showAll = async (ignoreIds?: any) => {
if (isPublic.value || isSharedBase.value) {
if (isLocalMode.value) {
fields.value = fields.value?.map((field: Field) => ({
...field,
show: true,
@ -75,7 +79,7 @@ export function useViewColumns(view: Ref<ViewType> | undefined, meta: ComputedRe
reloadData?.()
}
const hideAll = async (ignoreIds?: any) => {
if (isPublic.value || isSharedBase.value) {
if (isLocalMode.value) {
fields.value = fields.value?.map((field: Field) => ({
...field,
show: false,
@ -144,7 +148,7 @@ export function useViewColumns(view: Ref<ViewType> | undefined, meta: ComputedRe
},
set(v: boolean) {
if (view?.value?.id) {
if (!isPublic.value && !isSharedBase.value) {
if (!isLocalMode.value) {
$api.dbView
.update(view.value.id, {
show_system_fields: v,

Loading…
Cancel
Save