Browse Source

fix(gui-v2): lint & use notification

pull/3051/head
Wing-Kam Wong 2 years ago
parent
commit
7c03cc79c5
  1. 1
      packages/nc-gui-v2/components.d.ts
  2. 20
      packages/nc-gui-v2/components/dashboard/settings/AppStore.vue
  3. 16
      packages/nc-gui-v2/components/dashboard/settings/Metadata.vue
  4. 14
      packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue
  5. 30
      packages/nc-gui-v2/components/dashboard/settings/app-store/AppInstall.vue
  6. 17
      packages/nc-gui-v2/components/dlg/AirtableImport.vue
  7. 15
      packages/nc-gui-v2/components/dlg/QuickImport.vue
  8. 15
      packages/nc-gui-v2/components/dlg/TableRename.vue
  9. 13
      packages/nc-gui-v2/components/smartsheet-column/FormulaOptions.vue
  10. 23
      packages/nc-gui-v2/components/smartsheet-header/Menu.vue
  11. 16
      packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue
  12. 30
      packages/nc-gui-v2/components/smartsheet-toolbar/ShareView.vue
  13. 16
      packages/nc-gui-v2/components/smartsheet-toolbar/SharedViewList.vue
  14. 18
      packages/nc-gui-v2/components/smartsheet/sidebar/toolbar/LockMenu.vue
  15. 28
      packages/nc-gui-v2/components/tabs/auth/ApiTokenManagement.vue
  16. 39
      packages/nc-gui-v2/components/tabs/auth/UserManagement.vue
  17. 36
      packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue
  18. 20
      packages/nc-gui-v2/components/tabs/auth/user-management/UsersModal.vue
  19. 25
      packages/nc-gui-v2/components/template/Editor.vue
  20. 21
      packages/nc-gui-v2/components/webhook/Editor.vue
  21. 17
      packages/nc-gui-v2/components/webhook/List.vue
  22. 12
      packages/nc-gui-v2/components/webhook/Test.vue
  23. 24
      packages/nc-gui-v2/composables/useColumnCreateStore.ts
  24. 18
      packages/nc-gui-v2/composables/useTable.ts
  25. 9
      packages/nc-gui-v2/pages/index/index.vue
  26. 17
      packages/nc-gui-v2/pages/project/index/[id].vue
  27. 18
      packages/nc-gui-v2/pages/project/index/create-external.vue
  28. 8
      packages/nc-gui-v2/pages/project/index/create.vue
  29. 10
      packages/nc-gui-v2/pages/projects/index.vue

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

@ -92,6 +92,7 @@ declare module '@vue/runtime-core' {
MdiDotsVertical: typeof import('~icons/mdi/dots-vertical')['default'] MdiDotsVertical: typeof import('~icons/mdi/dots-vertical')['default']
MdiDownload: typeof import('~icons/mdi/download')['default'] MdiDownload: typeof import('~icons/mdi/download')['default']
MdiDrag: typeof import('~icons/mdi/drag')['default'] MdiDrag: typeof import('~icons/mdi/drag')['default']
MdiDragVertical: typeof import('~icons/mdi/drag-vertical')['default']
MdiEmail: typeof import('~icons/mdi/email')['default'] MdiEmail: typeof import('~icons/mdi/email')['default']
MdiEyeOffOutline: typeof import('~icons/mdi/eye-off-outline')['default'] MdiEyeOffOutline: typeof import('~icons/mdi/eye-off-outline')['default']
MdiFlag: typeof import('~icons/mdi/flag')['default'] MdiFlag: typeof import('~icons/mdi/flag')['default']

20
packages/nc-gui-v2/components/dashboard/settings/AppStore.vue

@ -1,12 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import AppInstall from './app-store/AppInstall.vue' import AppInstall from './app-store/AppInstall.vue'
import MdiEditIcon from '~icons/ic/round-edit' import MdiEditIcon from '~icons/ic/round-edit'
import MdiCloseCircleIcon from '~icons/mdi/close-circle-outline' import MdiCloseCircleIcon from '~icons/mdi/close-circle-outline'
import MdiPlusIcon from '~icons/mdi/plus' import MdiPlusIcon from '~icons/mdi/plus'
import { extractSdkResponseErrorMsg } from '~/utils'
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const toast = useToast()
let apps = $ref<null | Array<any>>(null) let apps = $ref<null | Array<any>>(null)
let showPluginUninstallModal = $ref(false) let showPluginUninstallModal = $ref(false)
@ -22,9 +22,10 @@ const fetchPluginApps = async () => {
tags: p.tags ? p.tags.split(',') : [], tags: p.tags ? p.tags.split(',') : [],
parsedInput: p.input && JSON.parse(p.input), parsedInput: p.input && JSON.parse(p.input),
})) }))
} catch (e) { } catch (e: any) {
console.error(e) notification.error({
toast.error('Something went wrong') message: await extractSdkResponseErrorMsg(e),
})
} }
} }
@ -34,12 +35,15 @@ const resetPlugin = async () => {
input: undefined, input: undefined,
active: false, active: false,
}) })
toast.success('Plugin uninstalled successfully') notification.success({
message: 'Plugin uninstalled successfully',
})
showPluginUninstallModal = false showPluginUninstallModal = false
await fetchPluginApps() await fetchPluginApps()
} catch (e: any) { } catch (e: any) {
console.log(e) notification.error({
toast.error(e.message) message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:appstore:reset', { app: pluginApp.title }) $e('a:appstore:reset', { app: pluginApp.title })

16
packages/nc-gui-v2/components/dashboard/settings/Metadata.vue

@ -1,12 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { h, useNuxtApp, useProject } from '#imports' import { h, useNuxtApp, useProject } from '#imports'
import MdiReload from '~icons/mdi/reload' import MdiReload from '~icons/mdi/reload'
import MdiDatabaseSync from '~icons/mdi/database-sync' import MdiDatabaseSync from '~icons/mdi/database-sync'
import { extractSdkResponseErrorMsg } from '~/utils'
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const { project } = useProject() const { project } = useProject()
const toast = useToast()
let isLoading = $ref(false) let isLoading = $ref(false)
let isDifferent = $ref(false) let isDifferent = $ref(false)
@ -38,14 +38,14 @@ async function syncMetaDiff() {
isLoading = true isLoading = true
await $api.project.metaDiffSync(project.value.id) await $api.project.metaDiffSync(project.value.id)
toast.info(`Table metadata recreated successfully`) notification.info({
message: 'Table metadata recreated successfully',
})
await loadMetaDiff() await loadMetaDiff()
} catch (e: any) { } catch (e: any) {
if (e.response?.status === 402) { notification.error({
toast.info(e.message) message: await extractSdkResponseErrorMsg(e),
} else { })
toast.error(e.message)
}
} finally { } finally {
isLoading = false isLoading = false
} }

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

@ -1,14 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { viewIcons } from '~/utils' import { extractSdkResponseErrorMsg, viewIcons } from '~/utils'
import { computed, h, useNuxtApp, useProject } from '#imports' import { computed, h, useNuxtApp, useProject } from '#imports'
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const { project } = useProject() const { project } = useProject()
const toast = useToast()
const roles = $ref<string[]>(['editor', 'commenter', 'viewer']) const roles = $ref<string[]>(['editor', 'commenter', 'viewer'])
let isLoading = $ref(false) let isLoading = $ref(false)
@ -49,9 +47,13 @@ async function saveUIAcl() {
project.value.id, project.value.id,
tables.filter((t) => t.edited), tables.filter((t) => t.edited),
) )
toast.success('Updated UI ACL for tables successfully') notification.success({
message: 'Updated UI ACL for tables successfully',
})
} catch (e: any) { } catch (e: any) {
toast.error(e?.message) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:proj-meta:ui-acl') $e('a:proj-meta:ui-acl')
} }

30
packages/nc-gui-v2/components/dashboard/settings/app-store/AppInstall.vue

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref } from 'vue'
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import type { PluginType } from 'nocodb-sdk' import type { PluginType } from 'nocodb-sdk'
import MdiDeleteOutlineIcon from '~icons/mdi/delete-outline' import MdiDeleteOutlineIcon from '~icons/mdi/delete-outline'
import CloseIcon from '~icons/material-symbols/close-rounded' import CloseIcon from '~icons/material-symbols/close-rounded'
@ -25,8 +25,6 @@ enum Action {
Test = 'test', Test = 'test',
} }
const toast = useToast()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const formRef = ref() const formRef = ref()
@ -55,10 +53,13 @@ const saveSettings = async () => {
}) })
emits('saved') emits('saved')
toast.success(plugin?.formDetails.msgOnInstall || 'Plugin settings saved successfully') notification.success({
} catch (_e: any) { message: plugin?.formDetails.msgOnInstall || 'Plugin settings saved successfully',
const e = await extractSdkResponseErrorMsg(_e) })
toast.error(e.message) } catch (e: any) {
notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} finally { } finally {
loadingAction = null loadingAction = null
} }
@ -76,13 +77,18 @@ const testSettings = async () => {
}) })
if (res) { if (res) {
toast.success('Successfully tested plugin settings') notification.success({
message: 'Successfully tested plugin settings',
})
} else { } else {
toast.info('Invalid credentials') notification.info({
message: 'Invalid credentials',
})
} }
} catch (_e: any) { } catch (e: any) {
const e = await extractSdkResponseErrorMsg(_e) notification.error({
toast.error(e.message) message: await extractSdkResponseErrorMsg(e),
})
} finally { } finally {
loadingAction = null loadingAction = null
} }

17
packages/nc-gui-v2/components/dlg/AirtableImport.vue

@ -1,11 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import io from 'socket.io-client' import io from 'socket.io-client'
import type { Socket } from 'socket.io-client' import type { Socket } from 'socket.io-client'
import { Form } from 'ant-design-vue' import { Form, notification } from 'ant-design-vue'
import type { Card as AntCard } from 'ant-design-vue' import type { Card as AntCard } from 'ant-design-vue'
import { useToast } from 'vue-toastification' import { extractSdkResponseErrorMsg, fieldRequiredValidator } from '~/utils'
import { fieldRequiredValidator } from '~/utils/validation'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import MdiCloseCircleOutlineIcon from '~icons/mdi/close-circle-outline' import MdiCloseCircleOutlineIcon from '~icons/mdi/close-circle-outline'
import MdiCurrencyUsdIcon from '~icons/mdi/currency-usd' import MdiCurrencyUsdIcon from '~icons/mdi/currency-usd'
import MdiLoadingIcon from '~icons/mdi/loading' import MdiLoadingIcon from '~icons/mdi/loading'
@ -23,8 +21,6 @@ const baseURL = 'http://localhost:8080' // this.$axios.defaults.baseURL
const { $state } = useNuxtApp() const { $state } = useNuxtApp()
const toast = useToast()
const { project, loadTables } = useProject() const { project, loadTables } = useProject()
const showGoToDashboardButton = ref(false) const showGoToDashboardButton = ref(false)
@ -107,7 +103,9 @@ async function createOrUpdate() {
syncSource.value = data syncSource.value = data
} }
} catch (e: any) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }
@ -158,8 +156,9 @@ async function sync() {
}, },
}) })
} catch (e: any) { } catch (e: any) {
console.log(e) notification.error({
toast.error(e) message: await extractSdkResponseErrorMsg(e),
})
} }
} }

15
packages/nc-gui-v2/components/dlg/QuickImport.vue

@ -1,6 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification' import { Form, notification } from 'ant-design-vue'
import { Form } from 'ant-design-vue'
import type { TableType } from 'nocodb-sdk' import type { TableType } from 'nocodb-sdk'
import type { UploadChangeParam } from 'ant-design-vue' import type { UploadChangeParam } from 'ant-design-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
@ -135,7 +134,9 @@ async function handlePreImport() {
await validate() await validate()
await parseAndExtractData(importState.url, '') await parseAndExtractData(importState.url, '')
} catch (e: any) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} else if (activeKey.value === 'jsonEditorTab') { } else if (activeKey.value === 'jsonEditorTab') {
await parseAndExtractData(JSON.stringify(importState.jsonEditor), '') await parseAndExtractData(JSON.stringify(importState.jsonEditor), '')
@ -148,7 +149,9 @@ async function handleImport() {
loading.value = true loading.value = true
await templateEditorRef.value.importTemplate() await templateEditorRef.value.importTemplate()
} catch (e: any) { } catch (e: any) {
return toast.error(await extractSdkResponseErrorMsg(e)) return notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} finally { } finally {
loading.value = false loading.value = false
} }
@ -174,7 +177,9 @@ async function parseAndExtractData(val: any, name: string) {
templateEditorModal.value = true templateEditorModal.value = true
} catch (e: any) { } catch (e: any) {
console.log(e) console.log(e)
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }

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

@ -1,11 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { watchEffect } from '@vue/runtime-core' import { watchEffect } from '@vue/runtime-core'
import { Form } from 'ant-design-vue' import { Form, notification } from 'ant-design-vue'
import type { TableType } from 'nocodb-sdk' import type { TableType } from 'nocodb-sdk'
import { useToast } from 'vue-toastification'
import { useProject, useTabs } from '#imports' import { useProject, useTabs } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { extractSdkResponseErrorMsg, validateTableName } from '~/utils/errorUtils'
import { validateTableName } from '~/utils/validation'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
interface Props { interface Props {
@ -16,7 +14,6 @@ interface Props {
const { modelValue = false, tableMeta } = defineProps<Props>() const { modelValue = false, tableMeta } = defineProps<Props>()
const emit = defineEmits(['update:modelValue', 'updated']) const emit = defineEmits(['update:modelValue', 'updated'])
const { $e, $api } = useNuxtApp() const { $e, $api } = useNuxtApp()
const toast = useToast()
const dialogShow = computed({ const dialogShow = computed({
get() { get() {
return modelValue return modelValue
@ -79,11 +76,15 @@ const renameTable = async () => {
dialogShow.value = false dialogShow.value = false
loadTables() loadTables()
updateTab({ id: tableMeta?.id }, { title: formState.title }) updateTab({ id: tableMeta?.id }, { title: formState.title })
toast.success('Table renamed successfully') notification.success({
message: 'Table renamed successfully',
})
$e('a:table:rename') $e('a:table:rename')
dialogShow.value = false dialogShow.value = false
} catch (e) { } catch (e) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
loading = false loading = false
} }

13
packages/nc-gui-v2/components/smartsheet-column/FormulaOptions.vue

@ -581,19 +581,6 @@ function scrollToSelectedOption() {
}) })
} }
function getFormulaTypeName(type: string) {
switch (type) {
case 'function':
return 'Function'
case 'op':
return 'Operator'
case 'column':
return 'Column'
default:
return ''
}
}
// set default value // set default value
formState.value.formula_raw = (column?.value?.colOptions as Record<string, any>)?.formula_raw || '' formState.value.formula_raw = (column?.value?.colOptions as Record<string, any>)?.formula_raw || ''

23
packages/nc-gui-v2/components/smartsheet-header/Menu.vue

@ -1,26 +1,28 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Modal } from 'ant-design-vue' import { Modal, notification } from 'ant-design-vue'
import { inject } from 'vue' import { inject } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useToast } from 'vue-toastification'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import { useMetas } from '#imports' import { useMetas } from '#imports'
import { ColumnInj, MetaInj } from '~/context' import { ColumnInj, MetaInj } from '~/context'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { extractSdkResponseErrorMsg } from '~/utils'
import MdiEditIcon from '~icons/mdi/pencil' import MdiEditIcon from '~icons/mdi/pencil'
import MdiStarIcon from '~icons/mdi/star' import MdiStarIcon from '~icons/mdi/star'
import MdiDeleteIcon from '~icons/mdi/delete-outline' import MdiDeleteIcon from '~icons/mdi/delete-outline'
import MdiMenuDownIcon from '~icons/mdi/menu-down' import MdiMenuDownIcon from '~icons/mdi/menu-down'
const { virtual = false } = defineProps<{ virtual?: boolean }>() const { virtual = false } = defineProps<{ virtual?: boolean }>()
const editColumnDropdown = ref(false) const editColumnDropdown = ref(false)
const column = inject(ColumnInj) const column = inject(ColumnInj)
const meta = inject(MetaInj) const meta = inject(MetaInj)
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const { t } = useI18n() const { t } = useI18n()
const toast = useToast()
const { getMeta } = useMetas() const { getMeta } = useMetas()
const deleteColumn = () => const deleteColumn = () =>
@ -34,7 +36,9 @@ const deleteColumn = () =>
await $api.dbTableColumn.delete(column?.value?.id as string) await $api.dbTableColumn.delete(column?.value?.id as string)
getMeta(meta?.value?.id as string, true) getMeta(meta?.value?.id as string, true)
} catch (e) { } catch (e) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
}, },
}) })
@ -43,10 +47,13 @@ const setAsPrimaryValue = async () => {
try { try {
await $api.dbTableColumn.primaryColumnSet(column?.value?.id as string) await $api.dbTableColumn.primaryColumnSet(column?.value?.id as string)
getMeta(meta?.value?.id as string, true) getMeta(meta?.value?.id as string, true)
toast.success('Successfully updated as primary column') notification.success({
message: 'Successfully updated as primary column',
})
} catch (e) { } catch (e) {
console.log(e) notification.error({
toast.error('Failed to update primary column') message: 'Failed to update primary column',
})
} }
} }

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

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ExportTypes } from 'nocodb-sdk' import { ExportTypes } from 'nocodb-sdk'
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import FileSaver from 'file-saver' import FileSaver from 'file-saver'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import { useProject } from '#imports' import { useProject } from '#imports'
@ -22,8 +22,6 @@ const { project } = useProject()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const toast = useToast()
const meta = inject(MetaInj) const meta = inject(MetaInj)
const selectedView = inject(ActiveViewInj) const selectedView = inject(ActiveViewInj)
@ -84,13 +82,19 @@ const exportCsv = async () => {
const blob = new Blob([data], { type: 'text/plain;charset=utf-8' }) const blob = new Blob([data], { type: 'text/plain;charset=utf-8' })
FileSaver.saveAs(blob, `${meta?.value.title}_exported_${c++}.csv`) FileSaver.saveAs(blob, `${meta?.value.title}_exported_${c++}.csv`)
if (offset > -1) { if (offset > -1) {
toast.info('Downloading more files') notification.info({
message: 'Downloading more files',
})
} else { } else {
toast.success('Successfully exported all table data') notification.success({
message: 'Successfully exported all table data',
})
} }
} }
} catch (e: any) { } catch (e: any) {
toast.error(extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }
</script> </script>

30
packages/nc-gui-v2/components/smartsheet-toolbar/ShareView.vue

@ -2,23 +2,25 @@
import { useClipboard } from '@vueuse/core' import { useClipboard } from '@vueuse/core'
import { ViewTypes } from 'nocodb-sdk' import { ViewTypes } from 'nocodb-sdk'
import { computed } from 'vue' import { computed } from 'vue'
import { message } from 'ant-design-vue' import { message, notification } from 'ant-design-vue'
import { useToast } from 'vue-toastification'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import { useSmartsheetStoreOrThrow } from '#imports' import { useSmartsheetStoreOrThrow } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { extractSdkResponseErrorMsg } from '~/utils'
import MdiOpenInNewIcon from '~icons/mdi/open-in-new' import MdiOpenInNewIcon from '~icons/mdi/open-in-new'
import MdiCopyIcon from '~icons/mdi/content-copy' import MdiCopyIcon from '~icons/mdi/content-copy'
const { view, $api } = useSmartsheetStoreOrThrow() const { view, $api } = useSmartsheetStoreOrThrow()
const { copy } = useClipboard() const { copy } = useClipboard()
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
const toast = useToast()
const { dashboardUrl } = useDashboard() const { dashboardUrl } = useDashboard()
let showShareModel = $ref(false) let showShareModel = $ref(false)
const passwordProtected = $ref(false) const passwordProtected = $ref(false)
const shared = ref() const shared = ref()
const allowCSVDownload = computed({ const allowCSVDownload = computed({
@ -69,9 +71,13 @@ async function saveAllowCSVDownload() {
await $api.dbViewShare.update(shared.value.id, { await $api.dbViewShare.update(shared.value.id, {
meta, meta,
} as any) } as any)
toast.success('Successfully updated') notification.success({
} catch (e) { message: 'Successfully updated',
toast.error(await extractSdkResponseErrorMsg(e)) })
} catch (e: any) {
notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
if (allowCSVDownload?.value) { if (allowCSVDownload?.value) {
$e('a:view:share:enable-csv-download') $e('a:view:share:enable-csv-download')
@ -85,9 +91,13 @@ const saveShareLinkPassword = async () => {
await $api.dbViewShare.update(shared.value.id, { await $api.dbViewShare.update(shared.value.id, {
password: shared.value.password, password: shared.value.password,
}) })
toast.success('Successfully updated') notification.success({
} catch (e) { message: 'Successfully updated',
toast.error(await extractSdkResponseErrorMsg(e)) })
} catch (e: any) {
notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:view:share:enable-pwd') $e('a:view:share:enable-pwd')

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

@ -1,8 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useClipboard } from '@vueuse/core' import { useClipboard } from '@vueuse/core'
import { ViewTypes } from 'nocodb-sdk' import { ViewTypes } from 'nocodb-sdk'
import { useToast } from 'vue-toastification' import { message, notification } from 'ant-design-vue'
import { message } from 'ant-design-vue'
import { onMounted, useSmartsheetStoreOrThrow } from '#imports' import { onMounted, useSmartsheetStoreOrThrow } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import MdiVisibilityOnIcon from '~icons/mdi/visibility' import MdiVisibilityOnIcon from '~icons/mdi/visibility'
@ -20,8 +19,9 @@ interface SharedViewType {
} }
const { $api, meta } = useSmartsheetStoreOrThrow() const { $api, meta } = useSmartsheetStoreOrThrow()
const { copy } = useClipboard() const { copy } = useClipboard()
const toast = useToast()
const { dashboardUrl } = useDashboard() const { dashboardUrl } = useDashboard()
const sharedViewList = ref<SharedViewType[]>() const sharedViewList = ref<SharedViewType[]>()
@ -80,10 +80,14 @@ const copyLink = (view: SharedViewType) => {
const deleteLink = async (id: string) => { const deleteLink = async (id: string) => {
try { try {
await $api.dbViewShare.delete(id) await $api.dbViewShare.delete(id)
toast.success('Deleted shared view successfully') notification.success({
message: 'Deleted shared view successfully',
})
await loadSharedViewsList() await loadSharedViewsList()
} catch (e) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }
</script> </script>

18
packages/nc-gui-v2/components/smartsheet/sidebar/toolbar/LockMenu.vue

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { computed, useSmartsheetStoreOrThrow } from '#imports' import { computed, useSmartsheetStoreOrThrow } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils' import { extractSdkResponseErrorMsg } from '~/utils'
import MdiLockOutlineIcon from '~icons/mdi/lock-outline' import MdiLockOutlineIcon from '~icons/mdi/lock-outline'
@ -13,14 +13,16 @@ enum LockType {
} }
const { view, $api } = useSmartsheetStoreOrThrow() const { view, $api } = useSmartsheetStoreOrThrow()
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
const toast = useToast()
function changeLockType(type: LockType) { async function changeLockType(type: LockType) {
$e('a:grid:lockmenu', { lockType: type }) $e('a:grid:lockmenu', { lockType: type })
if (type === 'personal') { if (type === 'personal') {
return toast.info('Coming soon', { timeout: 3000 }) return notification.info({
message: 'Coming soon',
})
} }
try { try {
;(view.value as any).lock_type = type ;(view.value as any).lock_type = type
@ -28,9 +30,13 @@ function changeLockType(type: LockType) {
lock_type: type, lock_type: type,
}) })
toast.success(`Successfully Switched to ${type} view`, { timeout: 3000 }) notification.success({
message: `Successfully Switched to ${type} view`,
})
} catch (e: any) { } catch (e: any) {
toast.error(extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }

28
packages/nc-gui-v2/components/tabs/auth/ApiTokenManagement.vue

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ApiTokenType } from 'nocodb-sdk' import type { ApiTokenType } from 'nocodb-sdk'
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { useClipboard } from '@vueuse/core' import { useClipboard } from '@vueuse/core'
import KebabIcon from '~icons/ic/baseline-more-vert' import KebabIcon from '~icons/ic/baseline-more-vert'
import MdiPlusIcon from '~icons/mdi/plus' import MdiPlusIcon from '~icons/mdi/plus'
@ -10,9 +10,7 @@ import VisibilityOpenIcon from '~icons/material-symbols/visibility'
import VisibilityCloseIcon from '~icons/material-symbols/visibility-off' import VisibilityCloseIcon from '~icons/material-symbols/visibility-off'
import MdiDeleteOutlineIcon from '~icons/mdi/delete-outline' import MdiDeleteOutlineIcon from '~icons/mdi/delete-outline'
import MdiContentCopyIcon from '~icons/mdi/content-copy' import MdiContentCopyIcon from '~icons/mdi/content-copy'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { extractSdkResponseErrorMsg } from '~/utils'
const toast = useToast()
interface ApiToken extends ApiTokenType { interface ApiToken extends ApiTokenType {
show?: boolean show?: boolean
@ -42,7 +40,9 @@ const copyToken = (token: string | undefined) => {
if (!token) return if (!token) return
copy(token) copy(token)
toast.info('Copied to clipboard') notification.info({
message: 'Copied to clipboard',
})
$e('c:api-token:copy') $e('c:api-token:copy')
} }
@ -53,12 +53,15 @@ const generateToken = async () => {
await $api.apiToken.create(project.id, selectedTokenData) await $api.apiToken.create(project.id, selectedTokenData)
showNewTokenModal = false showNewTokenModal = false
toast.success('Token generated successfully') notification.success({
message: 'Token generated successfullyd',
})
selectedTokenData = {} selectedTokenData = {}
await loadApiTokens() await loadApiTokens()
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:api-token:generate') $e('a:api-token:generate')
@ -70,12 +73,15 @@ const deleteToken = async () => {
await $api.apiToken.delete(project.id, selectedTokenData.token) await $api.apiToken.delete(project.id, selectedTokenData.token)
toast.success('Token deleted successfully') notification.success({
message: 'Token deleted successfully',
})
await loadApiTokens() await loadApiTokens()
showDeleteTokenModal = false showDeleteTokenModal = false
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:api-token:delete') $e('a:api-token:delete')

39
packages/nc-gui-v2/components/tabs/auth/UserManagement.vue

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { useClipboard, watchDebounced } from '@vueuse/core' import { useClipboard, watchDebounced } from '@vueuse/core'
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import UsersModal from './user-management/UsersModal.vue' import UsersModal from './user-management/UsersModal.vue'
import FeedbackForm from './user-management/FeedbackForm.vue' import FeedbackForm from './user-management/FeedbackForm.vue'
import KebabIcon from '~icons/ic/baseline-more-vert' import KebabIcon from '~icons/ic/baseline-more-vert'
@ -17,7 +17,6 @@ import MdiContentCopyIcon from '~icons/mdi/content-copy'
import MdiEmailSendIcon from '~icons/mdi/email-arrow-right-outline' import MdiEmailSendIcon from '~icons/mdi/email-arrow-right-outline'
import RolesIcon from '~icons/mdi/drama-masks' import RolesIcon from '~icons/mdi/drama-masks'
import type { User } from '~/lib/types' import type { User } from '~/lib/types'
const toast = useToast()
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const { project } = useProject() const { project } = useProject()
@ -51,8 +50,9 @@ const loadUsers = async (page = currentPage, limit = currentLimit) => {
totalRows = response.users.pageInfo.totalRows ?? 0 totalRows = response.users.pageInfo.totalRows ?? 0
users = response.users.list as User[] users = response.users.list as User[]
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
} }
@ -61,11 +61,14 @@ const inviteUser = async (user: User) => {
if (!project.value?.id) return if (!project.value?.id) return
await $api.auth.projectUserAdd(project.value.id, user) await $api.auth.projectUserAdd(project.value.id, user)
toast.success('Successfully added user to project') notification.success({
message: 'Successfully added user to project',
})
await loadUsers() await loadUsers()
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:user:add') $e('a:user:add')
@ -76,12 +79,15 @@ const deleteUser = async () => {
if (!project.value?.id || !selectedUser?.id) return if (!project.value?.id || !selectedUser?.id) return
await $api.auth.projectUserRemove(project.value.id, selectedUser.id) await $api.auth.projectUserRemove(project.value.id, selectedUser.id)
toast.success('Successfully deleted user from project') notification.success({
message: 'Successfully deleted user from project',
})
await loadUsers() await loadUsers()
showUserDeleteModal = false showUserDeleteModal = false
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:user:delete') $e('a:user:delete')
@ -107,11 +113,14 @@ const resendInvite = async (user: User) => {
try { try {
await $api.auth.projectUserResendInvite(project.value.id, user.id) await $api.auth.projectUserResendInvite(project.value.id, user.id)
toast.success('Invite email sent successfully') notification.success({
message: 'Invite email sent successfully',
})
await loadUsers() await loadUsers()
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:user:resend-invite') $e('a:user:resend-invite')
@ -123,7 +132,9 @@ const copyInviteUrl = (user: User) => {
const getInviteUrl = (token: string) => `${location.origin}${location.pathname}#/user/authentication/signup/${token}` const getInviteUrl = (token: string) => `${location.origin}${location.pathname}#/user/authentication/signup/${token}`
copy(getInviteUrl(user.invite_token)) copy(getInviteUrl(user.invite_token))
toast.success('Invite url copied to clipboard') notification.success({
message: 'Invite url copied to clipboard',
})
} }
onMounted(async () => { onMounted(async () => {

36
packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue

@ -1,10 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { onMounted, useClipboard, useNuxtApp, useProject } from '#imports' import { onMounted, useClipboard, useNuxtApp, useProject } from '#imports'
import { dashboardUrl, extractSdkResponseErrorMsg } from '~/utils' import { dashboardUrl, extractSdkResponseErrorMsg } from '~/utils'
const toast = useToast()
interface ShareBase { interface ShareBase {
uuid?: string uuid?: string
url?: string url?: string
@ -40,9 +38,9 @@ const loadBase = async () => {
role: res.roles, role: res.roles,
} }
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
message: await extractSdkResponseErrorMsg(e),
toast.error(await extractSdkResponseErrorMsg(e)) })
} }
} }
@ -58,9 +56,9 @@ const createShareBase = async (role = ShareBaseRole.Viewer) => {
base = res ?? {} base = res ?? {}
base!.role = role base!.role = role
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
message: await extractSdkResponseErrorMsg(e),
toast.error(await extractSdkResponseErrorMsg(e)) })
} }
$e('a:shared-base:enable', { role }) $e('a:shared-base:enable', { role })
@ -73,8 +71,9 @@ const disableSharedBase = async () => {
await $api.project.sharedBaseDisable(project.value.id) await $api.project.sharedBaseDisable(project.value.id)
base = null base = null
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:shared-base:disable') $e('a:shared-base:disable')
@ -92,9 +91,9 @@ const recreate = async () => {
base = { ...newBase, role: base?.role } base = { ...newBase, role: base?.role }
} catch (e: any) { } catch (e: any) {
console.error(e) notification.error({
message: await extractSdkResponseErrorMsg(e),
toast.error(await extractSdkResponseErrorMsg(e)) })
} }
$e('a:shared-base:recreate') $e('a:shared-base:recreate')
@ -105,7 +104,9 @@ const copyUrl = async () => {
await copy(url) await copy(url)
toast.success('Copied shareable base url to clipboard!') notification.success({
message: 'Copied shareable base url to clipboard!',
})
$e('c:shared-base:copy-url') $e('c:shared-base:copy-url')
} }
@ -128,7 +129,10 @@ frameborder="0"
width="100%" width="100%"
height="700" height="700"
style="background: transparent; border: 1px solid #ddd"></iframe>`) style="background: transparent; border: 1px solid #ddd"></iframe>`)
toast.success('Copied embeddable html code!')
notification.success({
message: 'Copied embeddable html code!',
})
$e('c:shared-base:copy-embed-frame') $e('c:shared-base:copy-embed-frame')
} }

20
packages/nc-gui-v2/components/tabs/auth/user-management/UsersModal.vue

@ -1,6 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification' import { Form, notification } from 'ant-design-vue'
import { Form } from 'ant-design-vue'
import { useClipboard } from '@vueuse/core' import { useClipboard } from '@vueuse/core'
import ShareBase from './ShareBase.vue' import ShareBase from './ShareBase.vue'
import SendIcon from '~icons/material-symbols/send-outline' import SendIcon from '~icons/material-symbols/send-outline'
@ -9,9 +8,7 @@ import MidAccountIcon from '~icons/mdi/account-outline'
import ContentCopyIcon from '~icons/mdi/content-copy' import ContentCopyIcon from '~icons/mdi/content-copy'
import type { User } from '~/lib/types' import type { User } from '~/lib/types'
import { ProjectRole } from '~/lib/enums' import { ProjectRole } from '~/lib/enums'
import { projectRoleTagColors } from '~/utils/userUtils' import { extractSdkResponseErrorMsg, isEmail, projectRoleTagColors } from '~/utils'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import { isEmail } from '~/utils/validation'
interface Props { interface Props {
show: boolean show: boolean
@ -26,7 +23,6 @@ interface Users {
const { show, selectedUser } = defineProps<Props>() const { show, selectedUser } = defineProps<Props>()
const emit = defineEmits(['closed', 'reload']) const emit = defineEmits(['closed', 'reload'])
const toast = useToast()
const { project } = useProject() const { project } = useProject()
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
@ -92,10 +88,14 @@ const saveUser = async () => {
}) })
usersData.invitationToken = res.invite_token usersData.invitationToken = res.invite_token
} }
toast.success('Successfully updated the user details') notification.success({
message: 'Successfully updated the user details',
})
} catch (e: any) { } catch (e: any) {
console.error(e) console.error(e)
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }
@ -109,7 +109,9 @@ const copyUrl = async () => {
if (!inviteUrl) return if (!inviteUrl) return
copy(inviteUrl) copy(inviteUrl)
toast.success('Copied shareable base url to clipboard!') notification.success({
message: 'Copied shareable base url to clipboard!',
})
$e('c:shared-base:copy-url') $e('c:shared-base:copy-url')
} }

25
packages/nc-gui-v2/components/template/Editor.vue

@ -1,5 +1,4 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification'
import type { ColumnType, TableType } from 'nocodb-sdk' import type { ColumnType, TableType } from 'nocodb-sdk'
import { UITypes, isVirtualCol } from 'nocodb-sdk' import { UITypes, isVirtualCol } from 'nocodb-sdk'
import { Form, notification } from 'ant-design-vue' import { Form, notification } from 'ant-design-vue'
@ -69,8 +68,6 @@ const data = reactive<{ title: string | null; name: string; tables: TableType[]
tables: [], tables: [],
}) })
const toast = useToast()
const { addTab } = useTabs() const { addTab } = useTabs()
const { sqlUi, project, loadTables } = useProject() const { sqlUi, project, loadTables } = useProject()
@ -314,19 +311,19 @@ async function importTemplate() {
const v = columns.value.find((c: Record<string, any>) => c.title === col.destCn) as Record<string, any> const v = columns.value.find((c: Record<string, any>) => c.title === col.destCn) as Record<string, any>
let input = row[col.srcCn] let input = row[col.srcCn]
// parse potential boolean values // parse potential boolean values
if (v.uidt == UITypes.Checkbox) { if (v.uidt === UITypes.Checkbox) {
input = input.replace(/["']/g, '').toLowerCase().trim() input = input.replace(/["']/g, '').toLowerCase().trim()
if (input == 'false' || input == 'no' || input == 'n') { if (input === 'false' || input === 'no' || input === 'n') {
input = '0' input = '0'
} else if (input == 'true' || input == 'yes' || input == 'y') { } else if (input === 'true' || input === 'yes' || input === 'y') {
input = '1' input = '1'
} }
} else if (v.uidt === UITypes.Number) { } else if (v.uidt === UITypes.Number) {
if (input == '') { if (input === '') {
input = null input = null
} }
} else if (v.uidt === UITypes.SingleSelect || v.uidt === UITypes.MultiSelect) { } else if (v.uidt === UITypes.SingleSelect || v.uidt === UITypes.MultiSelect) {
if (input == '') { if (input === '') {
input = null input = null
} }
} }
@ -442,7 +439,9 @@ async function importTemplate() {
type: 'table', type: 'table',
}) })
} catch (e: any) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} finally { } finally {
isImporting.value = false isImporting.value = false
} }
@ -526,16 +525,16 @@ onMounted(() => {
{{ column.name }} {{ column.name }}
</span> </span>
</template> </template>
<template #bodyCell="{ column, record, index }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'source_column'"> <template v-if="column.key === 'source_column'">
<span>{{ record.srcCn }}</span> <span>{{ record.srcCn }}</span>
</template> </template>
<template v-else-if="column.key === 'destination_column'"> <template v-else-if="column.key === 'destination_column'">
<a-select v-model:value="record.destCn" class="w-52" show-search :filter-option="filterOption"> <a-select v-model:value="record.destCn" class="w-52" show-search :filter-option="filterOption">
<a-select-option v-for="(column, i) of columns" :key="i" :value="column.title"> <a-select-option v-for="(col, i) of columns" :key="i" :value="col.title">
<div class="flex items-center"> <div class="flex items-center">
<component :is="getUIDTIcon(column.uidt)" /> <component :is="getUIDTIcon(col.uidt)" />
<span class="ml-2">{{ column.title }}</span> <span class="ml-2">{{ col.title }}</span>
</div> </div>
</a-select-option> </a-select-option>
</a-select> </a-select>

21
packages/nc-gui-v2/components/webhook/Editor.vue

@ -1,6 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { Form } from 'ant-design-vue' import { Form, notification } from 'ant-design-vue'
import { useToast } from 'vue-toastification'
import { MetaInj } from '~/context' import { MetaInj } from '~/context'
import { extractSdkResponseErrorMsg, fieldRequiredValidator } from '~/utils' import { extractSdkResponseErrorMsg, fieldRequiredValidator } from '~/utils'
import { inject, reactive, useApi, useNuxtApp } from '#imports' import { inject, reactive, useApi, useNuxtApp } from '#imports'
@ -16,8 +15,6 @@ const { $e } = useNuxtApp()
const { api, isLoading: loading } = useApi() const { api, isLoading: loading } = useApi()
const toast = useToast()
const meta = inject(MetaInj) const meta = inject(MetaInj)
const useForm = Form.useForm const useForm = Form.useForm
@ -305,7 +302,9 @@ async function loadPluginList() {
hook.eventOperation = `${hook.event} ${hook.operation}` hook.eventOperation = `${hook.event} ${hook.operation}`
} }
} catch (e: any) { } catch (e: any) {
toast.error(extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }
@ -314,7 +313,9 @@ async function saveHooks() {
try { try {
await validate() await validate()
} catch (_: any) { } catch (_: any) {
toast.error('Invalid Form') notification.error({
message: 'Invalid Form',
})
loading.value = false loading.value = false
@ -352,9 +353,13 @@ async function saveHooks() {
// }); // });
// } // }
toast.success('Webhook details updated successfully') notification.success({
message: 'Webhook details updated successfully',
})
} catch (e: any) { } catch (e: any) {
toast.error(extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} finally { } finally {
loading.value = false loading.value = false
} }

17
packages/nc-gui-v2/components/webhook/List.vue

@ -1,14 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { MetaInj } from '~/context' import { MetaInj } from '~/context'
import { inject, onMounted, ref, useNuxtApp } from '#imports' import { inject, onMounted, ref, useNuxtApp } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils'
const emit = defineEmits(['edit']) const emit = defineEmits(['edit'])
const { $api, $e } = useNuxtApp() const { $api, $e } = useNuxtApp()
const toast = useToast()
const hooks = ref<Record<string, any>[]>([]) const hooks = ref<Record<string, any>[]>([])
const meta = inject(MetaInj) const meta = inject(MetaInj)
@ -21,7 +20,9 @@ async function loadHooksList() {
return hook return hook
}) })
} catch (e: any) { } catch (e: any) {
toast.error(e.message) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }
@ -33,12 +34,16 @@ async function deleteHook(item: Record<string, any>, index: number) {
} else { } else {
hooks.value.splice(index, 1) hooks.value.splice(index, 1)
} }
toast.success('Hook deleted successfully') notification.success({
message: 'Hook deleted successfully',
})
if (!hooks.value.length) { if (!hooks.value.length) {
hooks.value = [] hooks.value = []
} }
} catch (e: any) { } catch (e: any) {
toast.error(e.message) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
$e('a:webhook:delete') $e('a:webhook:delete')

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

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted } from '@vue/runtime-core' import { onMounted } from '@vue/runtime-core'
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { MetaInj } from '~/context' import { MetaInj } from '~/context'
import { extractSdkResponseErrorMsg } from '~/utils' import { extractSdkResponseErrorMsg } from '~/utils'
@ -12,8 +12,6 @@ const { hook } = defineProps<Props>()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const toast = useToast()
const meta = inject(MetaInj) const meta = inject(MetaInj)
const sampleData = ref({ const sampleData = ref({
@ -41,9 +39,13 @@ async function testWebhook() {
payload: sampleData.value, payload: sampleData.value,
}) })
toast.success('Webhook tested successfully') notification.success({
message: 'Webhook tested successfully',
})
} catch (e: any) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }

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

@ -1,9 +1,8 @@
import { createInjectionState } from '@vueuse/core' import { createInjectionState } from '@vueuse/core'
import { Form } from 'ant-design-vue' import { Form, notification } from 'ant-design-vue'
import type { ColumnType, TableType } from 'nocodb-sdk' import type { ColumnType, TableType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { useToast } from 'vue-toastification'
import { useColumn } from './useColumn' import { useColumn } from './useColumn'
import { computed } from '#imports' import { computed } from '#imports'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
@ -25,7 +24,6 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const { sqlUi } = useProject() const { sqlUi } = useProject()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const { getMeta } = useMetas() const { getMeta } = useMetas()
const toast = useToast()
const idType = null const idType = null
@ -178,12 +176,21 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
try { try {
console.log(formState, validators) console.log(formState, validators)
if (!(await validate())) return if (!(await validate())) return
} catch (e) {
notification.error({
message: 'Form validation failed',
})
return
}
try {
formState.value.table_name = meta.value.table_name formState.value.table_name = meta.value.table_name
formState.value.title = formState.value.column_name formState.value.title = formState.value.column_name
if (column?.value) { if (column?.value) {
await $api.dbTableColumn.update(column?.value?.id as string, formState.value) await $api.dbTableColumn.update(column?.value?.id as string, formState.value)
toast.success('Column updated') notification.success({
message: 'Column updated',
})
} else { } else {
// todo : set additional meta for auto generated string id // todo : set additional meta for auto generated string id
if (formState.value.uidt === UITypes.ID) { if (formState.value.uidt === UITypes.ID) {
@ -201,12 +208,15 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
getMeta(formState.value.childId, true).then(() => {}) getMeta(formState.value.childId, true).then(() => {})
} }
toast.success('Column created') notification.success({
message: 'Column created',
})
} }
onSuccess() onSuccess()
} catch (e: any) { } catch (e: any) {
const error = await extractSdkResponseErrorMsg(e) notification.error({
if (error) toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
} }

18
packages/nc-gui-v2/composables/useTable.ts

@ -1,7 +1,6 @@
import { Modal } from 'ant-design-vue' import { Modal, notification } from 'ant-design-vue'
import type { LinkToAnotherRecordType, TableType } from 'nocodb-sdk' import type { LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import { useToast } from 'vue-toastification'
import { useProject } from './useProject' import { useProject } from './useProject'
import { TabType } from '~/composables/useTabs' import { TabType } from '~/composables/useTabs'
import { extractSdkResponseErrorMsg } from '~/utils' import { extractSdkResponseErrorMsg } from '~/utils'
@ -15,7 +14,6 @@ export function useTable(onTableCreate?: (tableMeta: TableType) => void) {
}) })
const { $e, $api } = useNuxtApp() const { $e, $api } = useNuxtApp()
const toast = useToast()
const { getMeta, removeMeta } = useMetas() const { getMeta, removeMeta } = useMetas()
const { loadTables } = useProject() const { loadTables } = useProject()
const { closeTab } = useTabs() const { closeTab } = useTabs()
@ -78,13 +76,13 @@ export function useTable(onTableCreate?: (tableMeta: TableType) => void) {
return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}` return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}`
}), }),
) )
toast.info( notification.info({
h('div', { message: h('div', {
innerHTML: `<div style="padding:10px 4px">Unable to delete tables because of the following. innerHTML: `<div style="padding:10px 4px">Unable to delete tables because of the following.
<br><br>${refColMsgs.join('<br>')}<br><br> <br><br>${refColMsgs.join('<br>')}<br><br>
Delete them & try again</div>`, Delete them & try again</div>`,
}), }),
) })
return return
} }
@ -99,10 +97,14 @@ export function useTable(onTableCreate?: (tableMeta: TableType) => void) {
await loadTables() await loadTables()
removeMeta(table.id as string) removeMeta(table.id as string)
toast.info(`Deleted table ${table.title} successfully`) notification.info({
message: `Deleted table ${table.title} successfully`,
})
$e('a:table:delete') $e('a:table:delete')
} catch (e: any) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
}, },
}) })

9
packages/nc-gui-v2/pages/index/index.vue

@ -1,7 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Modal } from 'ant-design-vue' import { Modal, notification } from 'ant-design-vue'
import type { ProjectType } from 'nocodb-sdk' import type { ProjectType } from 'nocodb-sdk'
import { useToast } from 'vue-toastification'
import { navigateTo } from '#app' import { navigateTo } from '#app'
import { computed, onMounted, ref, useApi, useNuxtApp, useSidebar } from '#imports' import { computed, onMounted, ref, useApi, useNuxtApp, useSidebar } from '#imports'
import { extractSdkResponseErrorMsg } from '~/utils' import { extractSdkResponseErrorMsg } from '~/utils'
@ -18,8 +17,6 @@ const { api, isLoading } = useApi()
useSidebar({ hasSidebar: true, isOpen: true }) useSidebar({ hasSidebar: true, isOpen: true })
const toast = useToast()
const filterQuery = ref('') const filterQuery = ref('')
const projects = ref<ProjectType[]>() const projects = ref<ProjectType[]>()
@ -48,7 +45,9 @@ const deleteProject = (project: ProjectType) => {
await $api.project.delete(project.id as string) await $api.project.delete(project.id as string)
return projects.value?.splice(projects.value.indexOf(project), 1) return projects.value?.splice(projects.value.indexOf(project), 1)
} catch (e: any) { } catch (e: any) {
return toast.error(await extractSdkResponseErrorMsg(e)) return notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
}, },
}) })

17
packages/nc-gui-v2/pages/project/index/[id].vue

@ -3,10 +3,9 @@ import { onMounted } from '@vue/runtime-core'
import type { Form } from 'ant-design-vue' import type { Form } from 'ant-design-vue'
import type { ProjectType } from 'nocodb-sdk' import type { ProjectType } from 'nocodb-sdk'
import { ref } from 'vue' import { ref } from 'vue'
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { navigateTo, useRoute } from '#app' import { navigateTo, useRoute } from '#app'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { extractSdkResponseErrorMsg, projectTitleValidator } from '~/utils'
import { projectTitleValidator } from '~/utils/validation'
import MaterialSymbolsRocketLaunchOutline from '~icons/material-symbols/rocket-launch-outline' import MaterialSymbolsRocketLaunchOutline from '~icons/material-symbols/rocket-launch-outline'
import { nextTick, reactive, useSidebar } from '#imports' import { nextTick, reactive, useSidebar } from '#imports'
@ -14,8 +13,6 @@ const { api } = useApi()
useSidebar({ hasSidebar: false }) useSidebar({ hasSidebar: false })
const toast = useToast()
const route = useRoute() const route = useRoute()
const nameValidationRules = [ const nameValidationRules = [
@ -32,10 +29,12 @@ const formState = reactive({
const getProject = async () => { const getProject = async () => {
try { try {
const result: ProjectType = await $api.project.read(route.params.id as string) const result: ProjectType = await api.project.read(route.params.id as string)
formState.title = result.title as string formState.title = result.title as string
} catch (e: any) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }
@ -45,7 +44,9 @@ const renameProject = async () => {
navigateTo(`/nc/${route.params.id}`) navigateTo(`/nc/${route.params.id}`)
} catch (e: any) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }

18
packages/nc-gui-v2/pages/project/index/create-external.vue

@ -1,8 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted } from '@vue/runtime-core' import { onMounted } from '@vue/runtime-core'
import { Form, Modal } from 'ant-design-vue' import { Form, Modal, notification } from 'ant-design-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useToast } from 'vue-toastification'
import { computed, ref, useSidebar, watch } from '#imports' import { computed, ref, useSidebar, watch } from '#imports'
import { navigateTo, useNuxtApp } from '#app' import { navigateTo, useNuxtApp } from '#app'
import { ClientType } from '~/lib' import { ClientType } from '~/lib'
@ -27,8 +26,6 @@ const { $api, $e } = useNuxtApp()
useSidebar({ hasSidebar: false }) useSidebar({ hasSidebar: false })
const toast = useToast()
const { t } = useI18n() const { t } = useI18n()
const formState = $ref<ProjectCreateForm>({ const formState = $ref<ProjectCreateForm>({
@ -145,8 +142,9 @@ const createProject = async () => {
$e('a:project:create:extdb') $e('a:project:create:extdb')
await navigateTo(`/nc/${result.id}`) await navigateTo(`/nc/${result.id}`)
} catch (e: any) { } catch (e: any) {
// todo: toast notification.error({
toast.error(await extractSdkResponseErrorMsg(e)) message: await extractSdkResponseErrorMsg(e),
})
} }
loading.value = false loading.value = false
} }
@ -187,12 +185,16 @@ const testConnection = async () => {
}) })
} else { } else {
testSuccess.value = false testSuccess.value = false
toast.error(`${t('msg.error.dbConnectionFailed')} ${result.message}`) notification.error({
message: `${t('msg.error.dbConnectionFailed')} ${result.message}`,
})
} }
} }
} catch (e: any) { } catch (e: any) {
testSuccess.value = false testSuccess.value = false
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }

8
packages/nc-gui-v2/pages/project/index/create.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted } from '@vue/runtime-core' import { onMounted } from '@vue/runtime-core'
import type { Form } from 'ant-design-vue' import type { Form } from 'ant-design-vue'
import { useToast } from 'vue-toastification' import { notification } from 'ant-design-vue'
import { nextTick, reactive, ref, useApi, useSidebar } from '#imports' import { nextTick, reactive, ref, useApi, useSidebar } from '#imports'
import { navigateTo, useNuxtApp } from '#app' import { navigateTo, useNuxtApp } from '#app'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
@ -14,8 +14,6 @@ const { api, isLoading } = useApi()
useSidebar({ hasSidebar: false }) useSidebar({ hasSidebar: false })
const toast = useToast()
const nameValidationRules = [ const nameValidationRules = [
{ {
required: true, required: true,
@ -37,7 +35,9 @@ const createProject = async () => {
await navigateTo(`/nc/${result.id}`) await navigateTo(`/nc/${result.id}`)
} catch (e: any) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
} }

10
packages/nc-gui-v2/pages/projects/index.vue

@ -1,7 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Modal } from 'ant-design-vue' import { Modal, notification } from 'ant-design-vue'
import type { ProjectType } from 'nocodb-sdk' import type { ProjectType } from 'nocodb-sdk'
import { useToast } from 'vue-toastification'
import { navigateTo } from '#app' import { navigateTo } from '#app'
import { extractSdkResponseErrorMsg } from '~/utils' import { extractSdkResponseErrorMsg } from '~/utils'
import MaterialSymbolsFormatListBulletedRounded from '~icons/material-symbols/format-list-bulleted-rounded' import MaterialSymbolsFormatListBulletedRounded from '~icons/material-symbols/format-list-bulleted-rounded'
@ -33,7 +32,6 @@ const navDrawerOptions = [
const route = useRoute() const route = useRoute()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const toast = useToast()
const response = await $api.project.list({}) const response = await $api.project.list({})
const projects = $ref(response.list) const projects = $ref(response.list)
@ -50,8 +48,10 @@ const deleteProject = (project: ProjectType) => {
try { try {
await $api.project.delete(project.id as string) await $api.project.delete(project.id as string)
projects.splice(projects.indexOf(project), 1) projects.splice(projects.indexOf(project), 1)
} catch (e) { } catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: await extractSdkResponseErrorMsg(e),
})
} }
}, },
}) })

Loading…
Cancel
Save