From c478523a0251b93b57cb156d57a9aa7cde2458f9 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Nov 2024 06:06:46 +0000 Subject: [PATCH] feat: handle peronal view similar to locked view and restrict filter/sort/field changes --- packages/nc-gui/composables/useSmartsheetStore.ts | 6 ++++-- packages/nocodb/src/services/tables.service.ts | 4 +--- packages/nocodb/src/services/views.service.ts | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui/composables/useSmartsheetStore.ts b/packages/nc-gui/composables/useSmartsheetStore.ts index 2cafb585a9..c2d0409245 100644 --- a/packages/nc-gui/composables/useSmartsheetStore.ts +++ b/packages/nc-gui/composables/useSmartsheetStore.ts @@ -1,4 +1,4 @@ -import { ViewTypes } from 'nocodb-sdk' +import {ViewLockType, ViewTypes} from 'nocodb-sdk' import type { FilterType, KanbanType, SortType, TableType, ViewType } from 'nocodb-sdk' import type { Ref } from 'vue' import type { SmartsheetStoreEvents } from '#imports' @@ -14,6 +14,8 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState( ) => { const { $api } = useNuxtApp() + const {user} = useGlobal() + const { activeView: view, activeNestedFilters, activeSorts } = storeToRefs(useViewsStore()) const baseStore = useBase() @@ -28,7 +30,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState( const eventBus = useEventBus(Symbol('SmartsheetStore')) - const isLocked = computed(() => view.value?.lock_type === 'locked') + const isLocked = computed(() => (view.value?.lock_type === ViewLockType.Personal && user.value?.id !== view.value?.owned_by) || view.value?.lock_type === ViewLockType.Locked) const isPkAvail = computed(() => (meta.value as TableType)?.columns?.some((c) => c.pk)) const isGrid = computed(() => view.value?.type === ViewTypes.GRID) const isForm = computed(() => view.value?.type === ViewTypes.FORM) diff --git a/packages/nocodb/src/services/tables.service.ts b/packages/nocodb/src/services/tables.service.ts index 93800fcb88..fee3972572 100644 --- a/packages/nocodb/src/services/tables.service.ts +++ b/packages/nocodb/src/services/tables.service.ts @@ -359,9 +359,7 @@ export class TablesService { return ( Object.keys(param.user?.roles).some( (role) => param.user?.roles[role] && !view.disabled[role], - ) && - (view.lock_type !== ViewLockType.Locked || - view.fk_owned_by === param.user.id) + ) ); }); diff --git a/packages/nocodb/src/services/views.service.ts b/packages/nocodb/src/services/views.service.ts index bdcf59df45..ca9379ac23 100644 --- a/packages/nocodb/src/services/views.service.ts +++ b/packages/nocodb/src/services/views.service.ts @@ -95,13 +95,13 @@ export class ViewsService { // todo: user roles //await View.list(param.tableId) const filteredViewList = viewList.filter((view: any) => { - if ( - view.lock_type === ViewLockType.Personal && - view.owned_by !== param.user.id && - !(!view.owned_by && !param.user.base_roles?.[ProjectRoles.OWNER]) - ) { - return false; - } + // if ( + // view.lock_type === ViewLockType.Personal && + // view.owned_by !== param.user.id && + // !(!view.owned_by && !param.user.base_roles?.[ProjectRoles.OWNER]) + // ) { + // return false; + // } return Object.values(ProjectRoles).some( (role) => param?.user?.['base_roles']?.[role] && !view.disabled[role],