Browse Source

refactor: overwrite the default shared useRoles with a wrapped composable which injects currentSource from the component context

pull/8708/head
Pranav C 6 months ago
parent
commit
e82ea344bd
  1. 4
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 4
      packages/nc-gui/components/cell/SingleSelect.vue
  3. 4
      packages/nc-gui/components/cell/attachment/Modal.vue
  4. 4
      packages/nc-gui/components/cell/attachment/index.vue
  5. 4
      packages/nc-gui/components/dashboard/Sidebar/TopSection.vue
  6. 4
      packages/nc-gui/components/dashboard/TreeView/AddNewTableNode.vue
  7. 4
      packages/nc-gui/components/smartsheet/Details.vue
  8. 4
      packages/nc-gui/components/smartsheet/Form.vue
  9. 4
      packages/nc-gui/components/smartsheet/Gallery.vue
  10. 4
      packages/nc-gui/components/smartsheet/Kanban.vue
  11. 4
      packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue
  12. 4
      packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue
  13. 4
      packages/nc-gui/components/smartsheet/calendar/MonthView.vue
  14. 4
      packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
  15. 4
      packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue
  16. 2
      packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue
  17. 4
      packages/nc-gui/components/smartsheet/expanded-form/Comments.vue
  18. 4
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  19. 2
      packages/nc-gui/components/smartsheet/grid/Table.vue
  20. 4
      packages/nc-gui/components/smartsheet/header/Cell.vue
  21. 4
      packages/nc-gui/components/smartsheet/header/VirtualCell.vue
  22. 4
      packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue
  23. 4
      packages/nc-gui/components/smartsheet/toolbar/KanbanStackEditOrAdd.vue
  24. 4
      packages/nc-gui/components/smartsheet/toolbar/MoreActions.vue
  25. 4
      packages/nc-gui/components/smartsheet/toolbar/ShareView.vue
  26. 4
      packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue
  27. 4
      packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue
  28. 4
      packages/nc-gui/components/smartsheet/topbar/SelectMode.vue
  29. 4
      packages/nc-gui/components/virtual-cell/BelongsTo.vue
  30. 4
      packages/nc-gui/components/virtual-cell/HasMany.vue
  31. 4
      packages/nc-gui/components/virtual-cell/Links.vue
  32. 4
      packages/nc-gui/components/virtual-cell/ManyToMany.vue
  33. 4
      packages/nc-gui/components/virtual-cell/OneToOne.vue
  34. 4
      packages/nc-gui/components/virtual-cell/components/ItemChip.vue
  35. 4
      packages/nc-gui/composables/useCalendarViewStore.ts
  36. 3
      packages/nc-gui/composables/useExpandedFormStore.ts
  37. 4
      packages/nc-gui/composables/useKanbanViewStore.ts
  38. 4
      packages/nc-gui/composables/useMapViewDataStore.ts
  39. 10
      packages/nc-gui/composables/useRoles/index.ts
  40. 4
      packages/nc-gui/composables/useViewColumns.ts
  41. 4
      packages/nc-gui/composables/useViewData.ts
  42. 4
      packages/nc-gui/composables/useViewFilters.ts
  43. 4
      packages/nc-gui/composables/useViewGroupBy.ts
  44. 2
      packages/nc-gui/composables/useViewSorts.ts

4
packages/nc-gui/components/cell/MultiSelect.vue

@ -5,7 +5,7 @@ import type { Select as AntSelect } from 'ant-design-vue'
import type { SelectOptionType, SelectOptionsType } from 'nocodb-sdk' import type { SelectOptionType, SelectOptionsType } from 'nocodb-sdk'
import type { FormFieldsLimitOptionsType } from '~/lib/types' import type { FormFieldsLimitOptionsType } from '~/lib/types'
import MdiCloseCircle from '~icons/mdi/close-circle' import MdiCloseCircle from '~icons/mdi/close-circle'
import {useRolesWrapper} from "~/composables/useRoles";
interface Props { interface Props {
modelValue?: string | string[] modelValue?: string | string[]
@ -58,7 +58,7 @@ const { $api } = useNuxtApp()
const { getMeta } = useMetas() const { getMeta } = useMetas()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { isPg, isMysql } = useBase() const { isPg, isMysql } = useBase()

4
packages/nc-gui/components/cell/SingleSelect.vue

@ -4,7 +4,7 @@ import { message } from 'ant-design-vue'
import tinycolor from 'tinycolor2' import tinycolor from 'tinycolor2'
import type { SelectOptionType } from 'nocodb-sdk' import type { SelectOptionType } from 'nocodb-sdk'
import type { FormFieldsLimitOptionsType } from '~/lib/types' import type { FormFieldsLimitOptionsType } from '~/lib/types'
import {useRolesWrapper} from "~/composables/useRoles";
interface Props { interface Props {
modelValue?: string | undefined modelValue?: string | undefined
@ -50,7 +50,7 @@ const searchVal = ref()
const { getMeta } = useMetas() const { getMeta } = useMetas()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { isPg, isMysql } = useBase() const { isPg, isMysql } = useBase()

4
packages/nc-gui/components/cell/attachment/Modal.vue

@ -2,9 +2,9 @@
import { onKeyDown, useEventListener } from '@vueuse/core' import { onKeyDown, useEventListener } from '@vueuse/core'
import { useAttachmentCell } from './utils' import { useAttachmentCell } from './utils'
import { useSortable } from './sort' import { useSortable } from './sort'
import {useRolesWrapper} from "~/composables/useRoles";
const { isUIAllowed } = useRolesWrapper()
const { isUIAllowed } = useRoles()
const { const {
open, open,

4
packages/nc-gui/components/cell/attachment/index.vue

@ -2,7 +2,7 @@
import { onKeyDown } from '@vueuse/core' import { onKeyDown } from '@vueuse/core'
import { useProvideAttachmentCell } from './utils' import { useProvideAttachmentCell } from './utils'
import { useSortable } from './sort' import { useSortable } from './sort'
import {useRolesWrapper} from "~/composables/useRoles";
interface Props { interface Props {
modelValue?: string | Record<string, any>[] | null modelValue?: string | Record<string, any>[] | null
@ -176,7 +176,7 @@ const keydownSpace = (e: KeyboardEvent) => {
} }
} }
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const isConfirmModalOpen = ref(false) const isConfirmModalOpen = ref(false)
const filetoDelete = reactive({ const filetoDelete = reactive({
title: '', title: '',

4
packages/nc-gui/components/dashboard/Sidebar/TopSection.vue

@ -1,10 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import {useRolesWrapper} from "~/composables/useRoles";
const workspaceStore = useWorkspace() const workspaceStore = useWorkspace()
const baseStore = useBase() const baseStore = useBase()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { appInfo } = useGlobal() const { appInfo } = useGlobal()

4
packages/nc-gui/components/dashboard/TreeView/AddNewTableNode.vue

@ -4,7 +4,7 @@ import { storeToRefs } from 'pinia'
import { toRef } from '@vue/reactivity' import { toRef } from '@vue/reactivity'
import { resolveComponent } from '@vue/runtime-core' import { resolveComponent } from '@vue/runtime-core'
import { ref } from 'vue' import { ref } from 'vue'
import {useRolesWrapper} from "~/composables/useRoles";
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -20,7 +20,7 @@ const emit = defineEmits<{
openTableCreateDialog: () => void openTableCreateDialog: () => void
}>() }>()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const base = toRef(props, 'base') const base = toRef(props, 'base')

4
packages/nc-gui/components/smartsheet/Details.vue

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { LoadingOutlined } from '@ant-design/icons-vue' import { LoadingOutlined } from '@ant-design/icons-vue'
import {useRolesWrapper} from "~/composables/useRoles";
const { openedViewsTab } = storeToRefs(useViewsStore()) const { openedViewsTab } = storeToRefs(useViewsStore())
const { onViewsTabChange } = useViewsStore() const { onViewsTabChange } = useViewsStore()
@ -9,7 +9,7 @@ const { isLeftSidebarOpen } = storeToRefs(useSidebarStore())
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { base } = storeToRefs(useBase()) const { base } = storeToRefs(useBase())
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())

4
packages/nc-gui/components/smartsheet/Form.vue

@ -15,7 +15,7 @@ import {
isVirtualCol, isVirtualCol,
} from 'nocodb-sdk' } from 'nocodb-sdk'
import type { ImageCropperConfig } from '~/lib/types' import type { ImageCropperConfig } from '~/lib/types'
import {useRolesWrapper} from "~/composables/useRoles";
provide(IsFormInj, ref(true)) provide(IsFormInj, ref(true))
provide(IsGalleryInj, ref(false)) provide(IsGalleryInj, ref(false))
@ -53,7 +53,7 @@ const { isMobileMode, user } = useGlobal()
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { base } = storeToRefs(useBase()) const { base } = storeToRefs(useBase())

4
packages/nc-gui/components/smartsheet/Gallery.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ViewTypes, isVirtualCol } from 'nocodb-sdk' import { ViewTypes, isVirtualCol } from 'nocodb-sdk'
import type { Row as RowType } from '#imports' import type { Row as RowType } from '#imports'
import {useRolesWrapper} from "~/composables/useRoles";
interface Attachment { interface Attachment {
url: string url: string
@ -65,7 +65,7 @@ const coverImageObjectFitClass = computed(() => {
if (fk_cover_image_object_fit === CoverImageObjectFit.COVER) return '!object-cover' if (fk_cover_image_object_fit === CoverImageObjectFit.COVER) return '!object-cover'
}) })
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const hasEditPermission = computed(() => isUIAllowed('dataEdit')) const hasEditPermission = computed(() => isUIAllowed('dataEdit'))
// TODO: extract this code (which is duplicated in grid and gallery) into a separate component // TODO: extract this code (which is duplicated in grid and gallery) into a separate component
const _contextMenu = ref(false) const _contextMenu = ref(false)

4
packages/nc-gui/components/smartsheet/Kanban.vue

@ -4,7 +4,7 @@ import Draggable from 'vuedraggable'
import tinycolor from 'tinycolor2' import tinycolor from 'tinycolor2'
import { ViewTypes, isVirtualCol } from 'nocodb-sdk' import { ViewTypes, isVirtualCol } from 'nocodb-sdk'
import type { Row as RowType } from '#imports' import type { Row as RowType } from '#imports'
import {useRolesWrapper} from "~/composables/useRoles";
interface Attachment { interface Attachment {
url: string url: string
@ -74,7 +74,7 @@ const {
const { isViewDataLoading } = storeToRefs(useViewsStore()) const { isViewDataLoading } = storeToRefs(useViewsStore())
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { appInfo, isMobileMode } = useGlobal() const { appInfo, isMobileMode } = useGlobal()

4
packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
const emit = defineEmits(['expandRecord', 'newRecord']) const emit = defineEmits(['expandRecord', 'newRecord'])
@ -9,7 +9,7 @@ const meta = inject(MetaInj, ref())
const container = ref() const container = ref()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { selectedDate, formattedData, formattedSideBarData, calendarRange, updateRowProperty } = useCalendarViewStoreOrThrow() const { selectedDate, formattedData, formattedSideBarData, calendarRange, updateRowProperty } = useCalendarViewStoreOrThrow()

4
packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
const emit = defineEmits(['expandRecord', 'newRecord']) const emit = defineEmits(['expandRecord', 'newRecord'])
@ -21,7 +21,7 @@ const { $e } = useNuxtApp()
const container = ref<null | HTMLElement>(null) const container = ref<null | HTMLElement>(null)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())

4
packages/nc-gui/components/smartsheet/calendar/MonthView.vue

@ -2,7 +2,7 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
const emit = defineEmits(['newRecord', 'expandRecord']) const emit = defineEmits(['newRecord', 'expandRecord'])
@ -24,7 +24,7 @@ const { $e } = useNuxtApp()
const isMondayFirst = ref(true) const isMondayFirst = ref(true)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())

4
packages/nc-gui/components/smartsheet/calendar/SideMenu.vue

@ -2,7 +2,7 @@
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import {useRolesWrapper} from "~/composables/useRoles";
const props = defineProps<{ const props = defineProps<{
visible: boolean visible: boolean
@ -16,7 +16,7 @@ interface Attachment {
const INFINITY_SCROLL_THRESHOLD = 100 const INFINITY_SCROLL_THRESHOLD = 100
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { $e } = useNuxtApp() const { $e } = useNuxtApp()

4
packages/nc-gui/components/smartsheet/calendar/WeekView/DateField.vue

@ -2,7 +2,7 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import type { Row } from '~/lib/types' import type { Row } from '~/lib/types'
import {useRolesWrapper} from "~/composables/useRoles";
const emits = defineEmits(['expandRecord', 'newRecord']) const emits = defineEmits(['expandRecord', 'newRecord'])
@ -25,7 +25,7 @@ const container = ref<null | HTMLElement>(null)
const { width: containerWidth } = useElementSize(container) const { width: containerWidth } = useElementSize(container)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())

2
packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue

@ -28,7 +28,7 @@ const { width: containerWidth } = useElementSize(container)
const isPublic = inject(IsPublicInj, ref(false)) const isPublic = inject(IsPublicInj, ref(false))
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())

4
packages/nc-gui/components/smartsheet/expanded-form/Comments.vue

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type CommentType, ProjectRoles } from 'nocodb-sdk' import { type CommentType, ProjectRoles } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
const props = defineProps<{ const props = defineProps<{
loading: boolean loading: boolean
@ -46,7 +46,7 @@ const isExpandedFormLoading = computed(() => props.loading)
const tab = ref<'comments' | 'audits'>('comments') const tab = ref<'comments' | 'audits'>('comments')
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const router = useRouter() const router = useRouter()

4
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -12,7 +12,7 @@ import type { Ref } from 'vue'
import { Drawer } from 'ant-design-vue' import { Drawer } from 'ant-design-vue'
import NcModal from '../../nc/Modal.vue' import NcModal from '../../nc/Modal.vue'
import MdiChevronDown from '~icons/mdi/chevron-down' import MdiChevronDown from '~icons/mdi/chevron-down'
import {useRolesWrapper} from "~/composables/useRoles";
interface Props { interface Props {
modelValue?: boolean modelValue?: boolean
@ -74,7 +74,7 @@ const isUnsavedDuplicatedRecordExist = ref(false)
const isRecordLinkCopied = ref(false) const isRecordLinkCopied = ref(false)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const readOnly = computed(() => !isUIAllowed('dataEdit') || isPublic.value) const readOnly = computed(() => !isUIAllowed('dataEdit') || isPublic.value)

2
packages/nc-gui/components/smartsheet/grid/Table.vue

@ -166,7 +166,7 @@ const isViewColumnsLoading = computed(() => _isViewColumnsLoading.value || !meta
const resizingColumn = ref(false) const resizingColumn = ref(false)
// #Permissions // #Permissions
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const hasEditPermission = computed(() => isUIAllowed('dataEdit')) const hasEditPermission = computed(() => isUIAllowed('dataEdit'))
const isAddingColumnAllowed = computed(() => !readOnly.value && !isLocked.value && isUIAllowed('fieldAdd') && !isSqlView.value) const isAddingColumnAllowed = computed(() => !readOnly.value && !isLocked.value && isUIAllowed('fieldAdd') && !isSqlView.value)

4
packages/nc-gui/components/smartsheet/header/Cell.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ColumnReqType, ColumnType } from 'nocodb-sdk' import type { ColumnReqType, ColumnType } from 'nocodb-sdk'
import { UITypes, UITypesName } from 'nocodb-sdk' import { UITypes, UITypesName } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
interface Props { interface Props {
column: ColumnType column: ColumnType
@ -33,7 +33,7 @@ const isDropDownOpen = ref(false)
const column = toRef(props, 'column') const column = toRef(props, 'column')
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
provide(ColumnInj, column) provide(ColumnInj, column)

4
packages/nc-gui/components/smartsheet/header/VirtualCell.vue

@ -9,7 +9,7 @@ import {
isLinksOrLTAR, isLinksOrLTAR,
} from 'nocodb-sdk' } from 'nocodb-sdk'
import { RelationTypes, UITypes, UITypesName, substituteColumnIdWithAliasInFormula } from 'nocodb-sdk' import { RelationTypes, UITypes, UITypesName, substituteColumnIdWithAliasInFormula } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
const props = defineProps<{ const props = defineProps<{
column: ColumnType column: ColumnType
@ -37,7 +37,7 @@ provide(ColumnInj, column)
const { metas } = useMetas() const { metas } = useMetas()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())

4
packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue

@ -2,7 +2,7 @@
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import type { KanbanType, ViewType, ViewTypes } from 'nocodb-sdk' import type { KanbanType, ViewType, ViewTypes } from 'nocodb-sdk'
import type { WritableComputedRef } from '@vue/reactivity' import type { WritableComputedRef } from '@vue/reactivity'
import {useRolesWrapper} from "~/composables/useRoles";
interface Props { interface Props {
view: ViewType view: ViewType
@ -31,7 +31,7 @@ const vModel = useVModel(props, 'view', emits) as WritableComputedRef<ViewType &
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const activeView = inject(ActiveViewInj, ref()) const activeView = inject(ActiveViewInj, ref())

4
packages/nc-gui/components/smartsheet/toolbar/KanbanStackEditOrAdd.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import {useRolesWrapper} from "~/composables/useRoles";
const { isUIAllowed } = useRolesWrapper()
const { isUIAllowed } = useRoles()
const { groupingFieldColumn } = useKanbanViewStoreOrThrow() const { groupingFieldColumn } = useKanbanViewStoreOrThrow()

4
packages/nc-gui/components/smartsheet/toolbar/MoreActions.vue

@ -3,7 +3,7 @@ import type { RequestParams } from 'nocodb-sdk'
import { ExportTypes } from 'nocodb-sdk' import { ExportTypes } from 'nocodb-sdk'
import { saveAs } from 'file-saver' import { saveAs } from 'file-saver'
import * as XLSX from 'xlsx' import * as XLSX from 'xlsx'
import {useRolesWrapper} from "~/composables/useRoles";
const { t } = useI18n() const { t } = useI18n()
@ -33,7 +33,7 @@ const showWebhookDrawer = ref(false)
const quickImportDialog = ref(false) const quickImportDialog = ref(false)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const exportFile = async (exportType: ExportTypes) => { const exportFile = async (exportType: ExportTypes) => {
let offset = 0 let offset = 0

4
packages/nc-gui/components/smartsheet/toolbar/ShareView.vue

@ -2,7 +2,7 @@
import { ViewTypes } from 'nocodb-sdk' import { ViewTypes } from 'nocodb-sdk'
import { isString } from '@vue/shared' import { isString } from '@vue/shared'
import tinycolor from 'tinycolor2' import tinycolor from 'tinycolor2'
import {useRolesWrapper} from "~/composables/useRoles";
const { t } = useI18n() const { t } = useI18n()
@ -14,7 +14,7 @@ const { $e } = useNuxtApp()
const { dashboardUrl } = useDashboard() const { dashboardUrl } = useDashboard()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { isSharedBase } = storeToRefs(useBase()) const { isSharedBase } = storeToRefs(useBase())

4
packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue

@ -2,7 +2,7 @@
import type { TableType, ViewType } from 'nocodb-sdk' import type { TableType, ViewType } from 'nocodb-sdk'
import { ViewTypes } from 'nocodb-sdk' import { ViewTypes } from 'nocodb-sdk'
import { LockType } from '#imports' import { LockType } from '#imports'
import {useRolesWrapper} from "~/composables/useRoles";
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -17,7 +17,7 @@ const props = withDefaults(
const emits = defineEmits(['rename', 'closeModal', 'delete']) const emits = defineEmits(['rename', 'closeModal', 'delete'])
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const isPublicView = inject(IsPublicInj, ref(false)) const isPublicView = inject(IsPublicInj, ref(false))

4
packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Ref } from '@vue/reactivity' import type { Ref } from '@vue/reactivity'
import { LockType } from '#imports' import { LockType } from '#imports'
import {useRolesWrapper} from "~/composables/useRoles";
const { t } = useI18n() const { t } = useI18n()
@ -38,7 +38,7 @@ const quickImportDialogs: Record<(typeof quickImportDialogTypes)[number], Ref<bo
{}, {},
) as Record<QuickImportDialogType, Ref<boolean>> ) as Record<QuickImportDialogType, Ref<boolean>>
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
useBase() useBase()

4
packages/nc-gui/components/smartsheet/topbar/SelectMode.vue

@ -1,9 +1,9 @@
<script lang="ts" setup> <script lang="ts" setup>
import {useRolesWrapper} from "~/composables/useRoles";
const { openedViewsTab, activeView } = storeToRefs(useViewsStore()) const { openedViewsTab, activeView } = storeToRefs(useViewsStore())
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { onViewsTabChange } = useViewsStore() const { onViewsTabChange } = useViewsStore()

4
packages/nc-gui/components/virtual-cell/BelongsTo.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import {useRolesWrapper} from "~/composables/useRoles";
const column = inject(ColumnInj)! const column = inject(ColumnInj)!
@ -19,7 +19,7 @@ const isForm = inject(IsFormInj, ref(false))
const isUnderLookup = inject(IsUnderLookupInj, ref(false)) const isUnderLookup = inject(IsUnderLookupInj, ref(false))
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const listItemsDlg = ref(false) const listItemsDlg = ref(false)

4
packages/nc-gui/components/virtual-cell/HasMany.vue

@ -2,7 +2,7 @@
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import { isSystemColumn } from 'nocodb-sdk' import { isSystemColumn } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import {useRolesWrapper} from "~/composables/useRoles";
const column = inject(ColumnInj)! const column = inject(ColumnInj)!
@ -26,7 +26,7 @@ const isOpen = ref(false)
const hideBackBtn = ref(false) const hideBackBtn = ref(false)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow() const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()

4
packages/nc-gui/components/virtual-cell/Links.vue

@ -3,7 +3,7 @@ import { computed } from '@vue/reactivity'
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { ref } from 'vue' import { ref } from 'vue'
import {useRolesWrapper} from "~/composables/useRoles";
const value = inject(CellValueInj, ref(0)) const value = inject(CellValueInj, ref(0))
@ -29,7 +29,7 @@ const isOpen = ref(false)
const hideBackBtn = ref(false) const hideBackBtn = ref(false)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { t } = useI18n() const { t } = useI18n()

4
packages/nc-gui/components/virtual-cell/ManyToMany.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import {useRolesWrapper} from "~/composables/useRoles";
const column = inject(ColumnInj)! const column = inject(ColumnInj)!
@ -25,7 +25,7 @@ const isOpen = ref(false)
const hideBackBtn = ref(false) const hideBackBtn = ref(false)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow() const { state, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()

4
packages/nc-gui/components/virtual-cell/OneToOne.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import {useRolesWrapper} from "~/composables/useRoles";
const column = inject(ColumnInj)! const column = inject(ColumnInj)!
@ -19,7 +19,7 @@ const isForm = inject(IsFormInj, ref(false))
const isUnderLookup = inject(IsUnderLookupInj, ref(false)) const isUnderLookup = inject(IsUnderLookupInj, ref(false))
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const listItemsDlg = ref(false) const listItemsDlg = ref(false)

4
packages/nc-gui/components/virtual-cell/components/ItemChip.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import { UITypes, isVirtualCol } from 'nocodb-sdk' import { UITypes, isVirtualCol } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
interface Props { interface Props {
value: string | number | boolean value: string | number | boolean
@ -18,7 +18,7 @@ const emit = defineEmits(['unlink'])
const { relatedTableMeta } = useLTARStoreOrThrow()! const { relatedTableMeta } = useLTARStoreOrThrow()!
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const readOnly = inject(ReadonlyInj, ref(false)) const readOnly = inject(ReadonlyInj, ref(false))

4
packages/nc-gui/composables/useCalendarViewStore.ts

@ -2,7 +2,7 @@ import type { ComputedRef, Ref } from 'vue'
import type { Api, CalendarRangeType, CalendarType, ColumnType, PaginatedType, TableType, ViewType } from 'nocodb-sdk' import type { Api, CalendarRangeType, CalendarType, ColumnType, PaginatedType, TableType, ViewType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import {useRolesWrapper} from "~/composables/useRoles";
const formatData = (list: Record<string, any>[]) => const formatData = (list: Record<string, any>[]) =>
list.map( list.map(
@ -34,7 +34,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
const pageDate = ref<dayjs.Dayjs>(dayjs()) const pageDate = ref<dayjs.Dayjs>(dayjs())
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { isMobileMode } = useGlobal() const { isMobileMode } = useGlobal()

3
packages/nc-gui/composables/useExpandedFormStore.ts

@ -2,7 +2,6 @@ import type { AuditType, ColumnType, CommentType, TableType } from 'nocodb-sdk'
import { UITypes, ViewTypes, isVirtualCol } from 'nocodb-sdk' import { UITypes, ViewTypes, isVirtualCol } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import {useRolesWrapper} from "~/composables/useRoles";
const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((meta: Ref<TableType>, _row: Ref<Row>) => { const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((meta: Ref<TableType>, _row: Ref<Row>) => {
const { $e, $state, $api } = useNuxtApp() const { $e, $state, $api } = useNuxtApp()
@ -62,7 +61,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook()) const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook())
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
// getters // getters
const displayValue = computed(() => { const displayValue = computed(() => {

4
packages/nc-gui/composables/useKanbanViewStore.ts

@ -1,6 +1,6 @@
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import type { Api, ColumnType, KanbanType, SelectOptionType, SelectOptionsType, TableType, ViewType } from 'nocodb-sdk' import type { Api, ColumnType, KanbanType, SelectOptionType, SelectOptionsType, TableType, ViewType } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
type GroupingFieldColOptionsType = SelectOptionType & { collapsed: boolean } type GroupingFieldColOptionsType = SelectOptionType & { collapsed: boolean }
@ -28,7 +28,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(
const { sharedView, fetchSharedViewData, fetchSharedViewGroupedData } = useSharedView() const { sharedView, fetchSharedViewData, fetchSharedViewGroupedData } = useSharedView()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const isPublic = ref(shared) || inject(IsPublicInj, ref(false)) const isPublic = ref(shared) || inject(IsPublicInj, ref(false))

4
packages/nc-gui/composables/useMapViewDataStore.ts

@ -1,6 +1,6 @@
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import type { ColumnType, MapType, PaginatedType, TableType, ViewType } from 'nocodb-sdk' import type { ColumnType, MapType, PaginatedType, TableType, ViewType } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
const formatData = (list: Record<string, any>[]) => const formatData = (list: Record<string, any>[]) =>
list.map( list.map(
@ -33,7 +33,7 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const isPublic = ref(shared) || inject(IsPublicInj, ref(false)) const isPublic = ref(shared) || inject(IsPublicInj, ref(false))

10
packages/nc-gui/composables/useRoles/index.ts

@ -24,7 +24,7 @@ const hasPermission = (role: Exclude<Roles, WorkspaceUserRoles>, hasRole: boolea
* * `allRoles` - all roles a user has (userRoles + baseRoles) * * `allRoles` - all roles a user has (userRoles + baseRoles)
* * `loadRoles` - a function to load reload user roles for scope * * `loadRoles` - a function to load reload user roles for scope
*/ */
export const useRoles = createSharedComposable(() => { export const useRolesShared = createSharedComposable(() => {
const { user } = useGlobal() const { user } = useGlobal()
const { api } = useApi() const { api } = useApi()
@ -172,9 +172,13 @@ export const useRoles = createSharedComposable(() => {
return { allRoles, orgRoles, workspaceRoles, baseRoles, loadRoles, isUIAllowed } return { allRoles, orgRoles, workspaceRoles, baseRoles, loadRoles, isUIAllowed }
}) })
export const useRolesWrapper = () => { /**
* Wrap the default shared composable to inject the current source if available
* which will be used to determine if a user has permission to perform an action based on the source's restrictions
*/
export const useRoles = () => {
const currentSource = inject(ActiveSourceInj, ref()) const currentSource = inject(ActiveSourceInj, ref())
const useRolesRes = useRoles() const useRolesRes = useRolesShared()
return { return {
...useRolesRes, ...useRolesRes,

4
packages/nc-gui/composables/useViewColumns.ts

@ -1,7 +1,7 @@
import type { ColumnType, GridColumnReqType, GridColumnType, MapType, TableType, ViewType } from 'nocodb-sdk' import type { ColumnType, GridColumnReqType, GridColumnType, MapType, TableType, ViewType } from 'nocodb-sdk'
import { ViewTypes, isHiddenCol, isSystemColumn } from 'nocodb-sdk' import { ViewTypes, isHiddenCol, isSystemColumn } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import {useRolesWrapper} from "~/composables/useRoles";
const [useProvideViewColumns, useViewColumns] = useInjectionState( const [useProvideViewColumns, useViewColumns] = useInjectionState(
( (
@ -18,7 +18,7 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { isSharedBase } = storeToRefs(useBase()) const { isSharedBase } = storeToRefs(useBase())

4
packages/nc-gui/composables/useViewData.ts

@ -3,7 +3,7 @@ import axios from 'axios'
import type { Api, ColumnType, FormColumnType, FormType, GalleryType, PaginatedType, TableType, ViewType } from 'nocodb-sdk' import type { Api, ColumnType, FormColumnType, FormType, GalleryType, PaginatedType, TableType, ViewType } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import { NavigateDir } from '#imports' import { NavigateDir } from '#imports'
import {useRolesWrapper} from "~/composables/useRoles";
const formatData = (list: Record<string, any>[]) => const formatData = (list: Record<string, any>[]) =>
list.map((row) => ({ list.map((row) => ({
@ -60,7 +60,7 @@ export function useViewData(
const { sorts, nestedFilters } = useSmartsheetStoreOrThrow() const { sorts, nestedFilters } = useSmartsheetStoreOrThrow()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const routeQuery = computed(() => route.value.query as Record<string, string>) const routeQuery = computed(() => route.value.query as Record<string, string>)

4
packages/nc-gui/composables/useViewFilters.ts

@ -9,7 +9,7 @@ import {
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import type { SelectProps } from 'ant-design-vue' import type { SelectProps } from 'ant-design-vue'
import { UITypes, isSystemColumn } from 'nocodb-sdk' import { UITypes, isSystemColumn } from 'nocodb-sdk'
import {useRolesWrapper} from "~/composables/useRoles";
type ColumnFilterType = FilterType & { status?: string; id?: string; children?: ColumnFilterType[]; is_group?: boolean } type ColumnFilterType = FilterType & { status?: string; id?: string; children?: ColumnFilterType[]; is_group?: boolean }
@ -42,7 +42,7 @@ export function useViewFilters(
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { metas, getMeta } = useMetas() const { metas, getMeta } = useMetas()

4
packages/nc-gui/composables/useViewGroupBy.ts

@ -2,7 +2,7 @@ import type { ColumnType, LinkToAnotherRecordType, LookupType, SelectOptionsType
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import {useRolesWrapper} from "~/composables/useRoles";
const excludedGroupingUidt = [UITypes.Attachment, UITypes.QrCode, UITypes.Barcode] const excludedGroupingUidt = [UITypes.Attachment, UITypes.QrCode, UITypes.Barcode]
@ -49,7 +49,7 @@ const [useProvideViewGroupBy, useViewGroupBy] = useInjectionState(
const isGroupBy = computed(() => !!groupBy.value.length) const isGroupBy = computed(() => !!groupBy.value.length)
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { sorts, nestedFilters } = useSmartsheetStoreOrThrow() const { sorts, nestedFilters } = useSmartsheetStoreOrThrow()

2
packages/nc-gui/composables/useViewSorts.ts

@ -8,7 +8,7 @@ export function useViewSorts(view: Ref<ViewType | undefined>, reloadData?: () =>
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const { isUIAllowed } = useRolesWrapper() const { isUIAllowed } = useRoles()
const { isSharedBase } = storeToRefs(useBase()) const { isSharedBase } = storeToRefs(useBase())

Loading…
Cancel
Save