Browse Source

feat(gui-v2): includeM2M

pull/3157/head
Wing-Kam Wong 2 years ago
parent
commit
199579b509
  1. 13
      packages/nc-gui-v2/components/dashboard/settings/Misc.vue
  2. 5
      packages/nc-gui-v2/components/dashboard/settings/Modal.vue
  3. 6
      packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue
  4. 1
      packages/nc-gui-v2/composables/useGlobal/state.ts
  5. 1
      packages/nc-gui-v2/composables/useGlobal/types.ts
  6. 5
      packages/nc-gui-v2/composables/useProject.ts

13
packages/nc-gui-v2/components/dashboard/settings/Misc.vue

@ -0,0 +1,13 @@
<script setup lang="ts">
const { includeM2M } = useGlobal()
</script>
<template>
<div class="flex flex-row w-full">
<div class="flex flex-column w-full">
<div class="flex flex-row items-center w-full mb-4 gap-2">
<a-checkbox v-model:checked="includeM2M">Show M2M Tables</a-checkbox>
</div>
</div>
</div>
</template>

5
packages/nc-gui-v2/components/dashboard/settings/Modal.vue

@ -5,6 +5,7 @@ import AuditTab from './AuditTab.vue'
import AppStore from './AppStore.vue' import AppStore from './AppStore.vue'
import Metadata from './Metadata.vue' import Metadata from './Metadata.vue'
import UIAcl from './UIAcl.vue' import UIAcl from './UIAcl.vue'
import Misc from './Misc.vue'
import ApiTokenManagement from '~/components/tabs/auth/ApiTokenManagement.vue' import ApiTokenManagement from '~/components/tabs/auth/ApiTokenManagement.vue'
import UserManagement from '~/components/tabs/auth/UserManagement.vue' import UserManagement from '~/components/tabs/auth/UserManagement.vue'
import StoreFrontOutline from '~icons/mdi/storefront-outline' import StoreFrontOutline from '~icons/mdi/storefront-outline'
@ -86,6 +87,10 @@ const tabsInfo: TabGroup = {
title: 'UI Access Control', title: 'UI Access Control',
body: UIAcl, body: UIAcl,
}, },
misc: {
title: 'Misc',
body: Misc,
},
}, },
}, },
audit: { audit: {

6
packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue

@ -7,6 +7,8 @@ const { $api, $e } = useNuxtApp()
const { project } = useProject() const { project } = useProject()
const { includeM2M } = useGlobal()
const roles = $ref<string[]>(['editor', 'commenter', 'viewer']) const roles = $ref<string[]>(['editor', 'commenter', 'viewer'])
let isLoading = $ref(false) let isLoading = $ref(false)
@ -28,9 +30,9 @@ async function loadTableList() {
if (!project.value?.id) return if (!project.value?.id) return
isLoading = true isLoading = true
// TODO includeM2M
tables = await $api.project.modelVisibilityList(project.value?.id, { tables = await $api.project.modelVisibilityList(project.value?.id, {
includeM2M: false, includeM2M: includeM2M.value,
}) })
} catch (e) { } catch (e) {
console.error(e) console.error(e)

1
packages/nc-gui-v2/composables/useGlobal/state.ts

@ -58,6 +58,7 @@ export function useGlobalState(storageKey = 'nocodb-gui-v2'): State {
}, },
filterAutoSave: true, filterAutoSave: true,
previewAs: null, previewAs: null,
includeM2M: false,
} }
/** saves a reactive state, any change to these values will write/delete to localStorage */ /** saves a reactive state, any change to these values will write/delete to localStorage */

1
packages/nc-gui-v2/composables/useGlobal/types.ts

@ -35,6 +35,7 @@ export interface StoredState {
feedbackForm: FeedbackForm feedbackForm: FeedbackForm
filterAutoSave: boolean filterAutoSave: boolean
previewAs: string | null previewAs: string | null
includeM2M: boolean
} }
export type State = ToRefs<Omit<StoredState, 'token'>> & { export type State = ToRefs<Omit<StoredState, 'token'>> & {

5
packages/nc-gui-v2/composables/useProject.ts

@ -12,6 +12,7 @@ export function useProject(projectId?: MaybeRef<string>) {
const project = useState<ProjectType>('project') const project = useState<ProjectType>('project')
const tables = useState<TableType[]>('tables', () => [] as TableType[]) const tables = useState<TableType[]>('tables', () => [] as TableType[])
const route = useRoute() const route = useRoute()
const { includeM2M } = useGlobal()
// todo: refactor path param name and variable name // todo: refactor path param name and variable name
const projectType = $computed(() => route.params.projectType as string) const projectType = $computed(() => route.params.projectType as string)
@ -27,7 +28,9 @@ export function useProject(projectId?: MaybeRef<string>) {
async function loadTables() { async function loadTables() {
if (project.value.id) { if (project.value.id) {
const tablesResponse = await $api.dbTable.list(project.value.id) const tablesResponse = await $api.dbTable.list(project.value.id, {
includeM2M: includeM2M.value,
})
if (tablesResponse.list) tables.value = tablesResponse.list if (tablesResponse.list) tables.value = tablesResponse.list
} }
} }

Loading…
Cancel
Save