From 5d8b1fc55ab639a8effd84907b360afdfbf33473 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 18 Jun 2024 19:06:17 +0000 Subject: [PATCH] feat: restrict data/meta operations in gui --- .../nc-gui/components/cell/MultiSelect.vue | 3 +- .../nc-gui/components/cell/SingleSelect.vue | 3 +- .../components/cell/attachment/Modal.vue | 3 +- .../components/cell/attachment/index.vue | 3 +- .../dashboard/Sidebar/TopSection.vue | 4 +- .../dashboard/TreeView/AddNewTableNode.vue | 3 +- .../dashboard/TreeView/BaseOptions.vue | 6 +-- .../dashboard/TreeView/ProjectNode.vue | 2 +- .../dashboard/TreeView/TableNode.vue | 19 ++++++--- .../settings/data-sources/CreateBase.vue | 9 +++-- .../settings/data-sources/EditBase.vue | 8 ++-- .../nc-gui/components/project/AllTables.vue | 4 +- .../nc-gui/components/smartsheet/Details.vue | 3 +- .../nc-gui/components/smartsheet/Form.vue | 3 +- .../nc-gui/components/smartsheet/Gallery.vue | 3 +- .../nc-gui/components/smartsheet/Kanban.vue | 3 +- .../smartsheet/calendar/DayView/DateField.vue | 3 +- .../calendar/DayView/DateTimeField.vue | 3 +- .../smartsheet/calendar/MonthView.vue | 3 +- .../smartsheet/calendar/SideMenu.vue | 3 +- .../calendar/WeekView/DateField.vue | 3 +- .../calendar/WeekView/DateTimeField.vue | 2 +- .../smartsheet/expanded-form/Comments.vue | 3 +- .../smartsheet/expanded-form/index.vue | 3 +- .../components/smartsheet/grid/Table.vue | 2 +- .../components/smartsheet/header/Cell.vue | 3 +- .../smartsheet/header/VirtualCell.vue | 3 +- .../smartsheet/sidebar/RenameableMenuItem.vue | 3 +- .../toolbar/KanbanStackEditOrAdd.vue | 4 +- .../smartsheet/toolbar/MoreActions.vue | 3 +- .../smartsheet/toolbar/ShareView.vue | 3 +- .../smartsheet/toolbar/ViewActionMenu.vue | 3 +- .../smartsheet/toolbar/ViewActions.vue | 3 +- .../smartsheet/topbar/SelectMode.vue | 4 +- .../nc-gui/components/tabs/Smartsheet.vue | 14 ++++++- .../components/virtual-cell/BelongsTo.vue | 3 +- .../components/virtual-cell/HasMany.vue | 3 +- .../nc-gui/components/virtual-cell/Links.vue | 3 +- .../components/virtual-cell/ManyToMany.vue | 3 +- .../components/virtual-cell/OneToOne.vue | 3 +- .../virtual-cell/components/ItemChip.vue | 3 +- .../composables/useCalendarViewStore.ts | 3 +- .../composables/useExpandedFormStore.ts | 3 +- .../nc-gui/composables/useKanbanViewStore.ts | 3 +- .../nc-gui/composables/useMapViewDataStore.ts | 3 +- packages/nc-gui/composables/useRoles/index.ts | 39 ++++++++++++++++++- packages/nc-gui/composables/useViewColumns.ts | 3 +- packages/nc-gui/composables/useViewData.ts | 3 +- packages/nc-gui/composables/useViewFilters.ts | 3 +- packages/nc-gui/composables/useViewGroupBy.ts | 3 +- packages/nc-gui/composables/useViewSorts.ts | 2 +- packages/nc-gui/context/index.ts | 9 ++++- packages/nocodb-sdk/src/lib/enums.ts | 8 ++++ .../src/services/public-datas.service.ts | 7 +++- packages/nocodb/src/utils/acl.ts | 16 ++++++++ 55 files changed, 202 insertions(+), 68 deletions(-) diff --git a/packages/nc-gui/components/cell/MultiSelect.vue b/packages/nc-gui/components/cell/MultiSelect.vue index 3a625e8c24..fee5afe43a 100644 --- a/packages/nc-gui/components/cell/MultiSelect.vue +++ b/packages/nc-gui/components/cell/MultiSelect.vue @@ -5,6 +5,7 @@ import type { Select as AntSelect } from 'ant-design-vue' import type { SelectOptionType, SelectOptionsType } from 'nocodb-sdk' import type { FormFieldsLimitOptionsType } from '~/lib/types' import MdiCloseCircle from '~icons/mdi/close-circle' +import {useRolesWrapper} from "~/composables/useRoles"; interface Props { modelValue?: string | string[] @@ -57,7 +58,7 @@ const { $api } = useNuxtApp() const { getMeta } = useMetas() -const { isUIAllowed } = useRoles() +const { isUIAllowed } = useRolesWrapper() const { isPg, isMysql } = useBase() diff --git a/packages/nc-gui/components/cell/SingleSelect.vue b/packages/nc-gui/components/cell/SingleSelect.vue index 5852a9dcbf..e61ac988dd 100644 --- a/packages/nc-gui/components/cell/SingleSelect.vue +++ b/packages/nc-gui/components/cell/SingleSelect.vue @@ -4,6 +4,7 @@ import { message } from 'ant-design-vue' import tinycolor from 'tinycolor2' import type { SelectOptionType } from 'nocodb-sdk' import type { FormFieldsLimitOptionsType } from '~/lib/types' +import {useRolesWrapper} from "~/composables/useRoles"; interface Props { modelValue?: string | undefined @@ -49,7 +50,7 @@ const searchVal = ref() const { getMeta } = useMetas() -const { isUIAllowed } = useRoles() +const { isUIAllowed } = useRolesWrapper() const { isPg, isMysql } = useBase() diff --git a/packages/nc-gui/components/cell/attachment/Modal.vue b/packages/nc-gui/components/cell/attachment/Modal.vue index 4af4ec4526..82944f27ae 100644 --- a/packages/nc-gui/components/cell/attachment/Modal.vue +++ b/packages/nc-gui/components/cell/attachment/Modal.vue @@ -2,8 +2,9 @@ import { onKeyDown, useEventListener } from '@vueuse/core' import { useAttachmentCell } from './utils' import { useSortable } from './sort' +import {useRolesWrapper} from "~/composables/useRoles"; -const { isUIAllowed } = useRoles() +const { isUIAllowed } = useRolesWrapper() const { open, diff --git a/packages/nc-gui/components/cell/attachment/index.vue b/packages/nc-gui/components/cell/attachment/index.vue index a95f1c4da8..8335952e9a 100644 --- a/packages/nc-gui/components/cell/attachment/index.vue +++ b/packages/nc-gui/components/cell/attachment/index.vue @@ -2,6 +2,7 @@ import { onKeyDown } from '@vueuse/core' import { useProvideAttachmentCell } from './utils' import { useSortable } from './sort' +import {useRolesWrapper} from "~/composables/useRoles"; interface Props { modelValue?: string | Record[] | null @@ -175,7 +176,7 @@ const keydownSpace = (e: KeyboardEvent) => { } } -const { isUIAllowed } = useRoles() +const { isUIAllowed } = useRolesWrapper() const isConfirmModalOpen = ref(false) const filetoDelete = reactive({ title: '', diff --git a/packages/nc-gui/components/dashboard/Sidebar/TopSection.vue b/packages/nc-gui/components/dashboard/Sidebar/TopSection.vue index 28f94f6a0c..57fe869023 100644 --- a/packages/nc-gui/components/dashboard/Sidebar/TopSection.vue +++ b/packages/nc-gui/components/dashboard/Sidebar/TopSection.vue @@ -1,8 +1,10 @@