Browse Source

chore(gui-v2): cleanup

pull/2877/head
braks 2 years ago
parent
commit
8098f3fb57
  1. 2
      packages/nc-gui-v2/components/general/Sponsors.test.ts
  2. 6
      packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue
  3. 5
      packages/nc-gui-v2/components/smartsheet-toolbar/SortListMenu.vue
  4. 2
      packages/nc-gui-v2/composables/useGlobal/index.ts
  5. 4
      packages/nc-gui-v2/middleware/auth.global.ts
  6. 0
      packages/nc-gui-v2/plugins/a.i18n.ts
  7. 2
      packages/nc-gui-v2/plugins/state.ts

2
packages/nc-gui-v2/components/general/Sponsors.test.ts

@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
import { expect, test } from 'vitest' import { expect, test } from 'vitest'
import Sponsors from './Sponsors.vue' import Sponsors from './Sponsors.vue'
import { createVuetifyPlugin } from '~/plugins/vuetify' import { createVuetifyPlugin } from '~/plugins/vuetify'
import { createI18nPlugin } from '~/plugins/i18n' import { createI18nPlugin } from '~/plugins/a.i18n'
const mountComponent = async (nav: boolean) => { const mountComponent = async (nav: boolean) => {
const vuetify = createVuetifyPlugin() const vuetify = createVuetifyPlugin()

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

@ -3,9 +3,9 @@ import { ExportTypes } from 'nocodb-sdk'
import { useToast } from 'vue-toastification' import { useToast } from 'vue-toastification'
import FileSaver from 'file-saver' import FileSaver from 'file-saver'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import useProject from '~/composables/useProject' import { useProject } from '#imports'
import { ActiveViewInj, MetaInj } from '~/context' import { ActiveViewInj, MetaInj } from '~/context'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { extractSdkResponseErrorMsg } from '~/utils'
import MdiFlashIcon from '~icons/mdi/flash-outline' import MdiFlashIcon from '~icons/mdi/flash-outline'
import MdiMenuDownIcon from '~icons/mdi/menu-down' import MdiMenuDownIcon from '~icons/mdi/menu-down'
import MdiDownloadIcon from '~icons/mdi/download-outline' import MdiDownloadIcon from '~icons/mdi/download-outline'
@ -80,7 +80,7 @@ const exportCsv = async () => {
toast.success('Successfully exported all table data') toast.success('Successfully exported all table data')
} }
} }
} catch (e) { } catch (e: any) {
toast.error(extractSdkResponseErrorMsg(e)) toast.error(extractSdkResponseErrorMsg(e))
} }
} }

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

@ -1,8 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import FieldListAutoCompleteDropdown from './FieldListAutoCompleteDropdown.vue' import FieldListAutoCompleteDropdown from './FieldListAutoCompleteDropdown.vue'
import { computed, inject } from '#imports' import { computed, inject, useViewSorts } from '#imports'
import { ActiveViewInj, IsLockedInj, MetaInj, ReloadViewDataHookInj } from '~/context' import { ActiveViewInj, IsLockedInj, MetaInj, ReloadViewDataHookInj } from '~/context'
import useViewSorts from '~/composables/useViewSorts'
import MdiMenuDownIcon from '~icons/mdi/menu-down' import MdiMenuDownIcon from '~icons/mdi/menu-down'
import MdiSortIcon from '~icons/mdi/sort' import MdiSortIcon from '~icons/mdi/sort'
import MdiDeleteIcon from '~icons/mdi/close-box' import MdiDeleteIcon from '~icons/mdi/close-box'
@ -18,7 +17,7 @@ const { sorts, saveOrUpdate, loadSorts, addSort, deleteSort } = useViewSorts(vie
const columns = computed(() => meta?.value?.columns || []) const columns = computed(() => meta?.value?.columns || [])
watch( watch(
() => view?.value?.id, () => (view?.value as any)?.id,
() => { () => {
loadSorts() loadSorts()
}, },

2
packages/nc-gui-v2/composables/useGlobal/index.ts

@ -46,5 +46,7 @@ export const useGlobal = (): UseGlobalReturn => {
/** provide a fresh state instance into nuxt app */ /** provide a fresh state instance into nuxt app */
provide('state', state) provide('state', state)
console.log('provided state')
return { ...toRefs($$(state)), ...getters, ...actions } return { ...toRefs($$(state)), ...getters, ...actions }
} }

4
packages/nc-gui-v2/middleware/auth.global.ts

@ -22,6 +22,10 @@ import { defineNuxtRouteMiddleware, navigateTo, useNuxtApp } from '#app'
export default defineNuxtRouteMiddleware((to, from) => { export default defineNuxtRouteMiddleware((to, from) => {
const { $state } = useNuxtApp() const { $state } = useNuxtApp()
if (!$state) return navigateTo('/')
console.log($state)
/** if auth is required or unspecified (same as required) and user is not signed in, redirect to signin page */ /** if auth is required or unspecified (same as required) and user is not signed in, redirect to signin page */
if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !$state.signedIn.value) { if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !$state.signedIn.value) {
return navigateTo('/signin') return navigateTo('/signin')

0
packages/nc-gui-v2/plugins/i18n.ts → packages/nc-gui-v2/plugins/a.i18n.ts

2
packages/nc-gui-v2/plugins/state.ts

@ -17,6 +17,8 @@ import { useBreakpoints, useDark, useGlobal, watch } from '#imports'
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
const state = useGlobal() const state = useGlobal()
console.log('state', state)
const darkMode = useDark() const darkMode = useDark()
/** get current breakpoints (for enabling sidebar) */ /** get current breakpoints (for enabling sidebar) */

Loading…
Cancel
Save