From 5895ddb4bab455353fcd0dccb35909338873d8c1 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Mon, 22 Aug 2022 19:28:54 +0530 Subject: [PATCH 1/4] fix/Fixed viewer permission issues --- packages/nc-gui-v2/components/smartsheet/Toolbar.vue | 3 ++- .../composables/useUIPermission/rolePermissions.ts | 1 + packages/nc-gui-v2/composables/useViewColumns.ts | 10 +++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet/Toolbar.vue b/packages/nc-gui-v2/components/smartsheet/Toolbar.vue index 01260b88b3..a49d8e4a7b 100644 --- a/packages/nc-gui-v2/components/smartsheet/Toolbar.vue +++ b/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() @@ -31,7 +32,7 @@ const { isOpen } = useSidebar()
- + diff --git a/packages/nc-gui-v2/composables/useUIPermission/rolePermissions.ts b/packages/nc-gui-v2/composables/useUIPermission/rolePermissions.ts index b0884700bd..b89ef57c00 100644 --- a/packages/nc-gui-v2/composables/useUIPermission/rolePermissions.ts +++ b/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, diff --git a/packages/nc-gui-v2/composables/useViewColumns.ts b/packages/nc-gui-v2/composables/useViewColumns.ts index 830e9651eb..9923839ed0 100644 --- a/packages/nc-gui-v2/composables/useViewColumns.ts +++ b/packages/nc-gui-v2/composables/useViewColumns.ts @@ -19,6 +19,10 @@ export function useViewColumns(view: Ref | 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 | 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 | 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 | 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, From a43c3b9f2c077c13d94a54299a0b4b0c95728ad1 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Mon, 22 Aug 2022 19:46:52 +0530 Subject: [PATCH 2/4] fix/Fixed welcome page for the viewer --- .../pages/[projectType]/[projectId]/index/index/index.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue index 08e1eb1467..f84902cfbe 100644 --- a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue +++ b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue @@ -12,6 +12,7 @@ const { isOverDropZone } = useDropZone(dropZone, onDrop) const { files, open, reset } = useFileDialog() const { isSharedBase } = useProject() +const { isUIAllowed } = useUIPermission() const { $e } = useNuxtApp() @@ -140,8 +141,12 @@ function onDropZoneClick(e: MouseEvent) { diff --git a/packages/nc-gui-v2/layouts/shared-view.vue b/packages/nc-gui-v2/layouts/shared-view.vue index 60141394c8..0805a47a06 100644 --- a/packages/nc-gui-v2/layouts/shared-view.vue +++ b/packages/nc-gui-v2/layouts/shared-view.vue @@ -19,11 +19,11 @@ export default {
-
+
{{ sharedView?.title }}