Browse Source

refactor(gui-v2): code cleanup

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3050/head
Pranav C 2 years ago
parent
commit
7a8d89b3d7
  1. 2
      packages/nc-gui-v2/components.d.ts
  2. 4
      packages/nc-gui-v2/components/dashboard/TreeView.vue
  3. 9
      packages/nc-gui-v2/components/dlg/TableCreate.vue
  4. 2
      packages/nc-gui-v2/components/dlg/TableRename.vue
  5. 4
      packages/nc-gui-v2/components/general/MiniSidebar.vue
  6. 5
      packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue
  7. 5
      packages/nc-gui-v2/components/smartsheet-toolbar/SharedViewList.vue
  8. 4
      packages/nc-gui-v2/components/smartsheet/Cell.vue
  9. 3
      packages/nc-gui-v2/components/smartsheet/Gallery.vue
  10. 4
      packages/nc-gui-v2/components/smartsheet/Grid.vue
  11. 2
      packages/nc-gui-v2/components/webhook/Test.vue
  12. 2
      packages/nc-gui-v2/composables/useColumnCreateStore.ts
  13. 4
      packages/nc-gui-v2/layouts/base.vue

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

@ -91,6 +91,7 @@ declare module '@vue/runtime-core' {
MdiDatabase: typeof import('~icons/mdi/database')['default']
MdiDeleteOutline: typeof import('~icons/mdi/delete-outline')['default']
MdiDiscord: typeof import('~icons/mdi/discord')['default']
MdiDotsHorizontal: typeof import('~icons/mdi/dots-horizontal')['default']
MdiDotsVertical: typeof import('~icons/mdi/dots-vertical')['default']
MdiDownload: typeof import('~icons/mdi/download')['default']
MdiDrag: typeof import('~icons/mdi/drag')['default']
@ -115,6 +116,7 @@ declare module '@vue/runtime-core' {
MdiPlus: typeof import('~icons/mdi/plus')['default']
MdiPlusOutline: typeof import('~icons/mdi/plus-outline')['default']
MdiReload: typeof import('~icons/mdi/reload')['default']
MdiSearch: typeof import('~icons/mdi/search')['default']
MdiShieldLockOutline: typeof import('~icons/mdi/shield-lock-outline')['default']
MdiSlack: typeof import('~icons/mdi/slack')['default']
MdiStar: typeof import('~icons/mdi/star')['default']

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

@ -31,8 +31,10 @@ const tablesById = $computed<Record<string, TableType>>(() =>
const showTableList = ref(true)
const tableCreateDlg = ref(false)
const menuRef = $ref<HTMLLIElement>()
let key = $ref(0)
const menuRef = $ref<HTMLLIElement>()
let sortable: Sortable
// todo: replace with vuedraggable

9
packages/nc-gui-v2/components/dlg/TableCreate.vue

@ -31,18 +31,9 @@ const { table, createTable, generateUniqueTitle, tables, project } = useTable(as
dialogShow.value = false
})
// const prefix = computed(() => project?.value?.prefix || '')
const validateDuplicateAlias = (v: string) => {
return (tables?.value || []).every((t) => t.title !== (v || '')) || 'Duplicate table alias'
}
// const validateLeadingOrTrailingWhiteSpace = (v: string) => {
// return !/^\s+|\s+$/.test(v) || 'Leading or trailing whitespace not allowed in table name'
// }
// const validateDuplicate = (v: string) => {
// return (tables?.value || []).every((t) => t.table_name.toLowerCase() !== (v || '').toLowerCase()) || 'Duplicate table name'
// }
const inputEl = ref<HTMLInputElement>()
const useForm = Form.useForm

2
packages/nc-gui-v2/components/dlg/TableRename.vue

@ -30,8 +30,6 @@ const { updateTab } = useTabs()
const { loadTables } = useProject()
const { tables } = useProject()
// const prefix = computed(() => project?.value?.prefix || '')
const inputEl = $ref<any>()
let loading = $ref(false)
const useForm = Form.useForm

4
packages/nc-gui-v2/components/general/MiniSidebar.vue

@ -1,11 +1,7 @@
<script lang="ts" setup>
// import { breakpointsTailwind } from '@vueuse/core'
import { navigateTo } from '#app'
import { computed, useGlobal, useProject, useRoute, useSidebar } from '#imports'
/** get current breakpoints (for enabling sidebar) */
// const breakpoints = useBreakpoints(breakpointsTailwind)
const { signOut, signedIn, user } = useGlobal()
const { isOpen } = useSidebar({ isOpen: true })

5
packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue

@ -18,11 +18,6 @@ const sharedViewListDlg = ref(false)
// todo : replace with inject
const publicViewId = null
// // TODO:: identify based on meta
// const isView = ref(false)
//
// const { isUIAllowed } = useUIPermission()
const { project } = useProject()
const { $api } = useNuxtApp()

5
packages/nc-gui-v2/components/smartsheet-toolbar/SharedViewList.vue

@ -24,12 +24,9 @@ const { copy } = useClipboard()
const toast = useToast()
const { dashboardUrl } = useDashboard()
// let isLoading = $ref(false)
// let activeSharedView = $ref(null)
const sharedViewList = ref<SharedViewType[]>()
const loadSharedViewsList = async () => {
// isLoading = true
const list = await $api.dbViewShare.list(meta.value?.id as string)
console.log(unref(sharedViewList))
@ -47,8 +44,6 @@ const loadSharedViewsList = async () => {
// } else {
// activeSharedView = null
// }
// isLoading = false
}
onMounted(loadSharedViewsList)

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

@ -12,10 +12,6 @@ interface Props {
editEnabled: boolean
}
// interface Emits {
// (event: 'update:modelValue', value: any): void
// }
const props = defineProps<Props>()
const emit = defineEmits(['update:modelValue', 'save', 'navigate', 'update:editEnabled'])
const column = toRef(props, 'column')

3
packages/nc-gui-v2/components/smartsheet/Gallery.vue

@ -11,9 +11,6 @@ interface Attachment {
const meta = inject(MetaInj)
const view = inject(ActiveViewInj)
// todo: get from parent ( inject or use prop )
// const isPublicView = false
const { loadData, paginationData, formattedData: data, loadGalleryData, galleryData, changePage } = useViewData(meta, view as any)
provide(IsFormInj, false)

4
packages/nc-gui-v2/components/smartsheet/Grid.vue

@ -379,8 +379,8 @@ const onNavigate = (dir: NavigateDir) => {
>
<a-menu-item @click="deleteSelectedRows"><span class="text-xs">Delete all selected rows</span></a-menu-item>
<a-menu-item v-if="contextMenuTarget" @click="clearCell(contextMenuTarget)"
><span class="text-xs">Clear cell</span></a-menu-item
>
><span class="text-xs">Clear cell</span>
</a-menu-item>
<a-menu-item v-if="contextMenuTarget" @click="addEmptyRow(contextMenuTarget.row + 1)">
<span class="text-xs">Insert new row</span>
</a-menu-item>

2
packages/nc-gui-v2/components/webhook/Test.vue

@ -23,7 +23,7 @@ const activeKey = ref(0)
watch(
() => hook?.operation,
async (_v) => {
async () => {
await loadSampleData()
},
)

2
packages/nc-gui-v2/composables/useColumnCreateStore.ts

@ -198,7 +198,7 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
/** if LTAR column then force reload related table meta */
if (formState.value.uidt === UITypes.LinkToAnotherRecord && meta.value.id !== formState.value.childId) {
getMeta(formState.value.childId, true)
getMeta(formState.value.childId, true).then(() => {})
}
toast.success('Column created')

4
packages/nc-gui-v2/layouts/base.vue

@ -1,11 +1,7 @@
<script lang="ts" setup>
// import { breakpointsTailwind } from '@vueuse/core'
import { navigateTo } from '#app'
import { computed, useGlobal, useRoute } from '#imports'
/** get current breakpoints (for enabling sidebar) */
// const breakpoints = useBreakpoints(breakpointsTailwind)
const { signOut, signedIn, isLoading, user } = useGlobal()
const route = useRoute()

Loading…
Cancel
Save