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 { isGrid, isForm, isGallery } = useSmartsheetStoreOrThrow()
const isPublic = inject(IsPublicInj, ref(false)) const isPublic = inject(IsPublicInj, ref(false))
const { allowCSVDownload } = useSharedView() const { allowCSVDownload } = useSharedView()
const { isUIAllowed } = useUIPermission()
const { isOpen } = useSidebar() const { isOpen } = useSidebar()
</script> </script>
@ -31,7 +32,7 @@ const { isOpen } = useSidebar()
<div class="flex-1" /> <div class="flex-1" />
<SmartsheetToolbarReload class="mx-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" /> <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, column: true,
tableAttachment: true, tableAttachment: true,
tableRowUpdate: true, tableRowUpdate: true,
dataInsert: true,
rowComments: true, rowComments: true,
gridViewOptions: true, gridViewOptions: true,
sortSync: 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 { isSharedBase } = useProject()
const isLocalMode = computed(
() => isPublic.value || !isUIAllowed('hideAllColumns') || !isUIAllowed('showAllColumns') || isSharedBase.value,
)
const loadViewColumns = async () => { const loadViewColumns = async () => {
if (!meta || !view) return if (!meta || !view) return
@ -52,7 +56,7 @@ export function useViewColumns(view: Ref<ViewType> | undefined, meta: ComputedRe
} }
const showAll = async (ignoreIds?: any) => { const showAll = async (ignoreIds?: any) => {
if (isPublic.value || isSharedBase.value) { if (isLocalMode.value) {
fields.value = fields.value?.map((field: Field) => ({ fields.value = fields.value?.map((field: Field) => ({
...field, ...field,
show: true, show: true,
@ -75,7 +79,7 @@ export function useViewColumns(view: Ref<ViewType> | undefined, meta: ComputedRe
reloadData?.() reloadData?.()
} }
const hideAll = async (ignoreIds?: any) => { const hideAll = async (ignoreIds?: any) => {
if (isPublic.value || isSharedBase.value) { if (isLocalMode.value) {
fields.value = fields.value?.map((field: Field) => ({ fields.value = fields.value?.map((field: Field) => ({
...field, ...field,
show: false, show: false,
@ -144,7 +148,7 @@ export function useViewColumns(view: Ref<ViewType> | undefined, meta: ComputedRe
}, },
set(v: boolean) { set(v: boolean) {
if (view?.value?.id) { if (view?.value?.id) {
if (!isPublic.value && !isSharedBase.value) { if (!isLocalMode.value) {
$api.dbView $api.dbView
.update(view.value.id, { .update(view.value.id, {
show_system_fields: v, show_system_fields: v,

Loading…
Cancel
Save