Browse Source

Merge pull request #7230 from nocodb/nc-fix/sentry-errors

fix: Miscellaneous ui errors
pull/7234/head
Pranav C 12 months ago committed by GitHub
parent
commit
3c9b500a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      packages/nc-gui/components/monaco/Editor.vue
  2. 2
      packages/nc-gui/components/smartsheet/ApiSnippet.vue
  3. 8
      packages/nc-gui/components/smartsheet/details/Api.vue
  4. 3
      packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts
  5. 12
      packages/nc-gui/composables/useViewData.ts
  6. 8
      packages/nc-gui/nuxt.config.ts

26
packages/nc-gui/components/monaco/Editor.vue

@ -1,9 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker&inline'
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker&inline'
import TypescriptWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
import type { editor as MonacoEditor } from 'monaco-editor' import type { editor as MonacoEditor } from 'monaco-editor'
import { deepCompare, isDrawerOrModalExist, onMounted, ref, watch } from '#imports' import { deepCompare, initWorker, isDrawerOrModalExist, onMounted, ref, watch } from '#imports'
interface Props { interface Props {
modelValue: string | Record<string, any> modelValue: string | Record<string, any>
@ -45,15 +45,17 @@ const isValid = ref(true)
* Adding monaco editor to Vite * Adding monaco editor to Vite
* *
* @ts-expect-error */ * @ts-expect-error */
self.MonacoEnvironment = { self.MonacoEnvironment = window.MonacoEnvironment = {
getWorker(_: any, label: string) { async getWorker(_: any, label: string) {
switch (label) { switch (label) {
case 'json': case 'json': {
return new JsonWorker() const workerBlob = new Blob([JsonWorker], { type: 'text/javascript' })
case 'typescript': return await initWorker(URL.createObjectURL(workerBlob))
return new TypescriptWorker() }
default: default: {
return new EditorWorker() const workerBlob = new Blob([EditorWorker], { type: 'text/javascript' })
return await initWorker(URL.createObjectURL(workerBlob))
}
} }
}, },
} }

2
packages/nc-gui/components/smartsheet/ApiSnippet.vue

@ -84,7 +84,7 @@ const selectedLangName = ref(langs[0].name)
const apiUrl = computed( const apiUrl = computed(
() => () =>
new URL( new URL(
`/api/v1/db/data/noco/${base.value.id}/${meta.value?.title}/views/${view.value?.title}`, `/api/v1/db/data/noco/${base.value.id}/${meta.value?.id}/views/${view.value?.id}`,
(appInfo.value && appInfo.value.ncSiteUrl) || '/', (appInfo.value && appInfo.value.ncSiteUrl) || '/',
).href, ).href,
) )

8
packages/nc-gui/components/smartsheet/details/Api.vue

@ -84,7 +84,7 @@ const selectedLangName = ref(langs[0].name)
const apiUrl = computed( const apiUrl = computed(
() => () =>
new URL( new URL(
`/api/v1/db/data/noco/${base.value?.id}/${meta.value?.title}/views/${view.value?.title}`, `/api/v1/db/data/noco/${base.value?.id}/${meta.value?.id}/views/${view.value?.id}`,
(appInfo.value && appInfo.value.ncSiteUrl) || '/', (appInfo.value && appInfo.value.ncSiteUrl) || '/',
).href, ).href,
) )
@ -118,9 +118,9 @@ const api = new Api({
api.dbViewRow.list( api.dbViewRow.list(
"noco", "noco",
${JSON.stringify(base.value?.title)}, ${JSON.stringify(base.value?.id)},
${JSON.stringify(meta.value?.title)}, ${JSON.stringify(meta.value?.id)},
${JSON.stringify(view.value?.title)}, ${JSON.stringify(queryParams.value, null, 4)}).then(function (data) { ${JSON.stringify(view.value?.id)}, ${JSON.stringify(queryParams.value, null, 4)}).then(function (data) {
console.log(data); console.log(data);
}).catch(function (error) { }).catch(function (error) {
console.error(error); console.error(error);

3
packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts

@ -34,6 +34,9 @@ export const useColumnDrag = ({
const lastCol = fields.value[fields.value.length - 1] const lastCol = fields.value[fields.value.length - 1]
const lastViewCol = gridViewCols.value[lastCol.id!] const lastViewCol = gridViewCols.value[lastCol.id!]
// if nextToViewCol/toViewCol is null, return
if (nextToViewCol === null || lastViewCol === null) return
const newOrder = nextToViewCol ? toViewCol.order! + (nextToViewCol.order! - toViewCol.order!) / 2 : lastViewCol.order! + 1 const newOrder = nextToViewCol ? toViewCol.order! + (nextToViewCol.order! - toViewCol.order!) / 2 : lastViewCol.order! + 1
const oldOrder = toBeReorderedViewCol.order const oldOrder = toBeReorderedViewCol.order

12
packages/nc-gui/composables/useViewData.ts

@ -187,8 +187,10 @@ export function useViewData(
controller.value = CancelToken.source() controller.value = CancelToken.source()
isPaginationLoading.value = true isPaginationLoading.value = true
let response
const response = !isPublic.value try {
response = !isPublic.value
? await api.dbViewRow.list( ? await api.dbViewRow.list(
'noco', 'noco',
base.value.id!, base.value.id!,
@ -204,7 +206,13 @@ export function useViewData(
{ cancelToken: controller.value.token }, { cancelToken: controller.value.token },
) )
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value }) : await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value })
} catch (error) {
// if the request is canceled, then do nothing
if (error.code === 'ERR_CANCELED') {
return
}
throw error
}
formattedData.value = formatData(response.list) formattedData.value = formatData(response.list)
paginationData.value = response.pageInfo paginationData.value = response.pageInfo
isPaginationLoading.value = false isPaginationLoading.value = false

8
packages/nc-gui/nuxt.config.ts

@ -4,7 +4,6 @@ import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver' import IconsResolver from 'unplugin-icons/resolver'
import Components from 'unplugin-vue-components/vite' import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers' import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import monacoEditorPlugin from 'vite-plugin-monaco-editor'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill' import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import { FileSystemIconLoader } from 'unplugin-icons/loaders' import { FileSystemIconLoader } from 'unplugin-icons/loaders'
@ -180,13 +179,6 @@ export default defineNuxtConfig({
}), }),
], ],
}), }),
monacoEditorPlugin({
languageWorkers: ['json'],
// customWorkers: [{ label: 'sql', entry: 'monaco-sql-languages/out/esm/sql/sql.worker.js' }],
customDistPath: (root: string, buildOutDir: string) => {
return `${buildOutDir}/` + `monacoeditorwork`
},
}),
PurgeIcons({ PurgeIcons({
/* PurgeIcons Options */ /* PurgeIcons Options */
includedCollections: ['emojione'], includedCollections: ['emojione'],

Loading…
Cancel
Save