Browse Source

feat: handle peronal view similar to locked view and restrict filter/sort/field changes

pull/9807/head
Pranav C 2 weeks ago
parent
commit
c478523a02
  1. 6
      packages/nc-gui/composables/useSmartsheetStore.ts
  2. 4
      packages/nocodb/src/services/tables.service.ts
  3. 14
      packages/nocodb/src/services/views.service.ts

6
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<SmartsheetStoreEvents>(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)

4
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)
)
);
});

14
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],

Loading…
Cancel
Save