Browse Source

refactor/gui-v2-settings-modal-added

pull/2813/head
Muhammed Mustafa 2 years ago
parent
commit
00b2996a92
  1. 2
      packages/nc-gui-v2/components.d.ts
  2. 44
      packages/nc-gui-v2/components/dashboard/settings/AuditTab.vue
  3. 147
      packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue
  4. 1
      packages/nc-gui-v2/package.json

2
packages/nc-gui-v2/components.d.ts vendored

@ -50,4 +50,4 @@ declare module '@vue/runtime-core' {
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
}
}

44
packages/nc-gui-v2/components/dashboard/settings/AuditTab.vue

@ -45,35 +45,36 @@ async function loadAudits(page = currentPage, limit = currentLimit) {
onMounted(async () => {
if (audits === null) {
await loadProject(projectId)
await loadAudits(currentPage, currentLimit)
}
})
const tableHeaderRenderer = (label: string) => (value: { text: string }) => h('div', { class: 'text-gray-500' }, label)
const columns = [
{
title: 'Operation Type',
title: tableHeaderRenderer('Operation Type'),
dataIndex: 'op_type',
key: 'op_type',
},
{
title: 'Operation sub-type',
title: tableHeaderRenderer('Operation sub-type'),
dataIndex: 'op_sub_type',
key: 'op_sub_type',
},
{
title: 'Description',
title: tableHeaderRenderer('Description'),
dataIndex: 'description',
key: 'description',
},
{
title: 'User',
title: tableHeaderRenderer('User'),
dataIndex: 'user',
key: 'user',
customRender: (value: { text: string }) => h('div', () => value.text || 'Shared base'),
customRender: (value: { text: string }) => h('div', {}, value.text || 'Shared base'),
},
{
title: 'Created',
title: tableHeaderRenderer('Created'),
dataIndex: 'created_at',
key: 'created_at',
sort: 'desc',
@ -85,21 +86,22 @@ const columns = [
<template>
<div class="flex flex-col gap-4 w-full">
<a-button class="self-start" @click="loadAudits">
<div class="flex items-center gap-2">
<MdiReload :class="{ 'animate-infinite animate-spin !text-success': isLoading }" />
Reload
</div>
</a-button>
<div class="flex flex-row justify-between items-center">
<a-button class="self-start" @click="loadAudits">
<div class="flex items-center gap-2 text-gray-600 font-light">
<MdiReload :class="{ 'animate-infinite animate-spin !text-success': isLoading }" />
Reload
</div>
</a-button>
<a-pagination
v-model:current="currentPage"
:page-size="currentLimit"
:total="totalRows"
show-less-items
@change="loadAudits"
/>
</div>
<a-table class="w-full" :data-source="audits ?? []" :columns="columns" :pagination="false" :loading="isLoading" />
<a-pagination
v-model:current="currentPage"
:page-size="currentLimit"
:total="totalRows"
show-less-items
@change="loadAudits"
/>
</div>
</template>

147
packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue

@ -0,0 +1,147 @@
<script setup lang="ts">
import type { FunctionalComponent, SVGAttributes, VNode } from 'vue'
import AuditTab from './AuditTab.vue'
import StoreFrontOutline from '~icons/mdi/storefront-outline'
import TeamFillIcon from '~icons/ri/team-fill'
import MultipleTableIcon from '~icons/mdi/table-multiple'
import NootbookOutline from '~icons/mdi/notebook-outline'
interface Props {
show: boolean
}
interface SubTabGroup {
[key: string]: {
title: string
body: any
}
}
interface TabGroup {
[key: string]: {
title: string
icon: FunctionalComponent<SVGAttributes, {}>
subTabs: SubTabGroup
}
}
const { show } = defineProps<Props>()
const emits = defineEmits(['closed'])
const tabsInfo: TabGroup = {
teamAndAuth: {
title: 'Team and Auth',
icon: TeamFillIcon,
subTabs: {
usersManagement: {
title: 'Users Management',
body: () => AuditTab,
},
apiTokenManagement: {
title: 'API Token Management',
body: () => AuditTab,
},
},
},
appStore: {
title: 'App Store',
icon: StoreFrontOutline,
subTabs: {
new: {
title: 'Apps',
body: () => AuditTab,
},
},
},
metaData: {
title: 'Project Metadata',
icon: MultipleTableIcon,
subTabs: {
metaData: {
title: 'Metadata',
body: () => AuditTab,
},
acl: {
title: 'UI Access Control',
body: () => AuditTab,
},
},
},
audit: {
title: 'Audit',
icon: NootbookOutline,
subTabs: {
audit: {
title: 'Audit',
body: () => AuditTab,
},
},
},
}
const firstKeyOfObject = (obj: object) => Object.keys(obj)[0]
// Array of keys of tabs which are selected. In our case will be only one.
const selectedTabKeys = $ref<string[]>([firstKeyOfObject(tabsInfo)])
const selectedTab = $computed(() => tabsInfo[selectedTabKeys[0]])
let selectedSubTabKeys = $ref<string[]>([firstKeyOfObject(selectedTab.subTabs)])
const selectedSubTab = $computed(() => {
const isSubTabInSelectedTab = (subTab: any) => subTab in selectedTab.subTabs
// Select the first subtab
const currentlySelectedSubTabKey = selectedSubTabKeys[0]
const subTabKey = isSubTabInSelectedTab(currentlySelectedSubTabKey)
? currentlySelectedSubTabKey
: firstKeyOfObject(selectedTab.subTabs)
if (subTabKey !== selectedSubTabKeys[0]) {
selectedSubTabKeys = [subTabKey]
}
return selectedTab.subTabs[subTabKey]
})
</script>
<template>
<a-modal :footer="null" :visible="show" width="max(90vw, 600px)" @cancel="emits('closed')">
<a-typography-title class="ml-4 mb-2 select-none" type="secondary" :level="5">SETTINGS</a-typography-title>
<a-layout class="mt-3 modal-body">
<!-- Side tabs -->
<a-layout-sider theme="light">
<a-menu v-model:selectedKeys="selectedTabKeys" class="h-full" mode="inline" :open-keys="[]">
<a-menu-item v-for="(tab, key) of tabsInfo" :key="key">
<div class="flex flex-row items-center space-x-2">
<component :is="tab.icon" class="flex" />
<div class="flex select-none">
{{ tab.title }}
</div>
</div>
</a-menu-item>
</a-menu>
</a-layout-sider>
<!-- Sub Tabs -->
<a-layout-content class="h-full px-4">
<a-menu v-model:selectedKeys="selectedSubTabKeys" :open-keys="[]" mode="horizontal">
<a-menu-item v-for="(tab, key) of selectedTab.subTabs" :key="key" class="select-none">
{{ tab.title }}
</a-menu-item>
</a-menu>
<component :is="selectedSubTab.body()" class="px-2 py-6" />
</a-layout-content>
</a-layout>
</a-modal>
</template>
<style scoped>
.modal-body {
height: 70vh;
}
::-webkit-scrollbar-thumb {
width: 8px;
background-color: darkgrey;
}
</style>

1
packages/nc-gui-v2/package.json

@ -30,6 +30,7 @@
"@iconify-json/clarity": "^1.1.4",
"@iconify-json/material-symbols": "^1.1.8",
"@iconify-json/mdi": "^1.1.25",
"@iconify-json/ri": "^1.1.3",
"@intlify/vite-plugin-vue-i18n": "^4.0.0",
"@types/sortablejs": "^1.13.0",
"@vitejs/plugin-vue": "^2.3.3",

Loading…
Cancel
Save