diff --git a/packages/builder/vite.config.mjs.timestamp-1728399274731-fb0dcfaf9cacc.mjs b/packages/builder/vite.config.mjs.timestamp-1728399274731-fb0dcfaf9cacc.mjs new file mode 100644 index 0000000000..8a28a7ca60 --- /dev/null +++ b/packages/builder/vite.config.mjs.timestamp-1728399274731-fb0dcfaf9cacc.mjs @@ -0,0 +1,146 @@ +// vite.config.mjs +import { svelte } from "file:///Users/aptk/dev/budibase/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js"; +import replace from "file:///Users/aptk/dev/budibase/node_modules/@rollup/plugin-replace/dist/es/index.js"; +import { defineConfig, loadEnv } from "file:///Users/aptk/dev/budibase/node_modules/vite/dist/node/index.js"; +import { viteStaticCopy } from "file:///Users/aptk/dev/budibase/node_modules/vite-plugin-static-copy/dist/index.js"; +import path from "path"; +var ignoredWarnings = [ + "unused-export-let", + "css-unused-selector", + "module-script-reactive-declaration", + "a11y-no-onchange", + "a11y-click-events-have-key-events" +]; +var copyFonts = (dest) => viteStaticCopy({ + targets: [ + { + src: "../../node_modules/@fontsource/source-sans-pro", + dest + }, + { + src: "../../node_modules/remixicon/fonts/*", + dest + } + ] +}); +var vite_config_default = defineConfig(({ mode }) => { + const isProduction = mode === "production"; + const env = loadEnv(mode, process.cwd()); + const devOnlyPlugins = [ + // Copy fonts to an additional path so that svelte's automatic + // prefixing of the base URL path can still resolve assets + copyFonts("builder/fonts") + ]; + return { + test: { + setupFiles: ["./vitest.setup.js"], + globals: true, + environment: "jsdom" + }, + server: { + fs: { + strict: false + }, + hmr: { + protocol: env.VITE_HMR_PROTOCOL || "ws", + clientPort: env.VITE_HMR_CLIENT_PORT || 3e3, + path: env.VITE_HMR_PATH || "/" + }, + port: 3e3 + }, + base: "/builder/", + build: { + minify: isProduction, + outDir: "../server/builder", + sourcemap: !isProduction + }, + plugins: [ + svelte({ + hot: !isProduction, + emitCss: true, + onwarn: (warning, handler) => { + if (!ignoredWarnings.includes(warning.code)) { + handler(warning); + } + } + }), + replace({ + preventAssignment: true, + "process.env.NODE_ENV": JSON.stringify( + isProduction ? "production" : "development" + ), + "process.env.POSTHOG_TOKEN": JSON.stringify(process.env.POSTHOG_TOKEN) + }), + copyFonts("fonts"), + ...isProduction ? [] : devOnlyPlugins + ], + optimizeDeps: { + exclude: ["@roxi/routify", "fsevents"] + }, + resolve: { + dedupe: ["@roxi/routify"], + alias: [ + { + find: "assets", + replacement: path.resolve("./assets") + }, + { + find: "components", + replacement: path.resolve("./src/components") + }, + { + find: "pages", + replacement: path.resolve("./src/pages") + }, + { + find: "templates", + replacement: path.resolve("./src/templates") + }, + { + find: "stores", + replacement: path.resolve("./src/stores") + }, + { + find: "dataBinding", + replacement: path.resolve("./src/dataBinding.js") + }, + { + find: "api", + replacement: path.resolve("./src/api.js") + }, + { + find: "constants", + replacement: path.resolve("./src/constants") + }, + { + find: "analytics", + replacement: path.resolve("./src/analytics") + }, + { + find: "actions", + replacement: path.resolve("./src/actions") + }, + { + find: "helpers", + replacement: path.resolve("./src/helpers") + }, + { + find: "@budibase/types", + replacement: path.resolve("../types/src") + }, + { + find: "@budibase/shared-core", + replacement: path.resolve("../shared-core/src") + }, + { + find: "@budibase/bbui", + replacement: path.resolve("../bbui/src") + } + ] + } + }; +}); +export { + vite_config_default as default +}; +//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcubWpzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZGlybmFtZSA9IFwiL1VzZXJzL2FwdGsvZGV2L2J1ZGliYXNlL3BhY2thZ2VzL2J1aWxkZXJcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIi9Vc2Vycy9hcHRrL2Rldi9idWRpYmFzZS9wYWNrYWdlcy9idWlsZGVyL3ZpdGUuY29uZmlnLm1qc1wiO2NvbnN0IF9fdml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xuICAgICAgZGVkdXBlOiBbXCJAcm94aS9yb3V0aWZ5XCJdLFxuICAgICAgYWxpYXM6IFtcbiAgICAgICAge1xuICAgICAgICAgIGZpbmQ6IFwiYXNzZXRzXCIsXG4gICAgICAgICAgcmVwbGFjZW1lbnQ6IHBhdGgucmVzb2x2ZShcIi4vYXNzZXRzXCIpLFxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgZmluZDogXCJjb21wb25lbnRzXCIsXG4gICAgICAgICAgcmVwbGFjZW1lbnQ6IHBhdGgucmVzb2x2ZShcIi4vc3JjL2NvbXBvbmVudHNcIiksXG4gICAgICAgIH0sXG4gICAgICAgIHtcbiAgICAgICAgICBmaW5kOiBcInBhZ2VzXCIsXG4gICAgICAgICAgcmVwbGFjZW1lbnQ6IHBhdGgucmVzb2x2ZShcIi4vc3JjL3BhZ2VzXCIpLFxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgZmluZDogXCJ0ZW1wbGF0ZXNcIixcbiAgICAgICAgICByZXBsYWNlbWVudDogcGF0aC5yZXNvbHZlKFwiLi9zcmMvdGVtcGxhdGVzXCIpLFxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgZmluZDogXCJzdG9yZXNcIixcbiAgICAgICAgICByZXBsYWNlbWVudDogcGF0aC5yZXNvbHZlKFwiLi9zcmMvc3RvcmVzXCIpLFxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgZmluZDogXCJkYXRhQmluZGluZ1wiLFxuICAgICAgICAgIHJlcGxhY2VtZW50OiBwYXRoLnJlc29sdmUoXCIuL3NyYy9kYXRhQmluZGluZy5qc1wiKSxcbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIGZpbmQ6IFwiYXBpXCIsXG4gICAgICAgICAgcmVwbGFjZW1lbnQ6IHBhdGgucmVzb2x2ZShcIi4vc3JjL2FwaS5qc1wiKSxcbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIGZ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RjtBQUNGLENBQUM7IiwKICAibmFtZXMiOiBbXQp9Cg== diff --git a/packages/frontend-core/src/components/grid/stores/config.js b/packages/frontend-core/src/components/grid/stores/config.js index d0cda1e114..d4ef44545b 100644 --- a/packages/frontend-core/src/components/grid/stores/config.js +++ b/packages/frontend-core/src/components/grid/stores/config.js @@ -43,6 +43,14 @@ export const deriveStores = context => { // Disable some features if we're editing a view if (type === "viewV2") { config.canEditColumns = false + + // Disable features for calculation views + if ($definition?.type === ViewV2Type.CALCULATION) { + config.canAddRows = false + config.canEditRows = false + config.canDeleteRows = false + config.canExpandRows = false + } } // Disable adding rows if we don't have any valid columns @@ -60,19 +68,7 @@ export const deriveStores = context => { config.canEditColumns = false } - // Disable features for calculation views - if (type === "viewV2" && $definition?.type === ViewV2Type.CALCULATION) { - config.canAddRows = false - config.canEditRows = false - config.canDeleteRows = false - config.canExpandRows = false - } - return config } ) - - return { - config, - } } diff --git a/packages/frontend-core/src/components/grid/stores/datasource.js b/packages/frontend-core/src/components/grid/stores/datasource.js index 869cd56730..6aa607f7ed 100644 --- a/packages/frontend-core/src/components/grid/stores/datasource.js +++ b/packages/frontend-core/src/components/grid/stores/datasource.js @@ -2,6 +2,7 @@ import { derived, get } from "svelte/store" import { getDatasourceDefinition, getDatasourceSchema } from "../../../fetch" import { enrichSchemaWithRelColumns, memo } from "../../../utils" import { cloneDeep } from "lodash" +import { ViewV2Type } from "@budibase/types" export const createStores = () => { const definition = memo(null) @@ -81,13 +82,20 @@ export const deriveStores = context => { } ) - const hasBudibaseIdentifiers = derived(datasource, $datasource => { - let type = $datasource?.type - if (type === "provider") { - type = $datasource.value?.datasource?.type + const hasBudibaseIdentifiers = derived( + [datasource, definition], + ([$datasource, $definition]) => { + let type = $datasource?.type + if (type === "provider") { + type = $datasource.value?.datasource?.type + } + // Handle calculation views + if (type === "viewV2" && $definition?.type === ViewV2Type.CALCULATION) { + return false + } + return ["table", "viewV2", "link"].includes(type) } - return ["table", "viewV2", "link"].includes(type) - }) + ) return { schema, diff --git a/packages/frontend-core/src/fetch/ViewV2Fetch.js b/packages/frontend-core/src/fetch/ViewV2Fetch.js index 191cb87b54..40135746df 100644 --- a/packages/frontend-core/src/fetch/ViewV2Fetch.js +++ b/packages/frontend-core/src/fetch/ViewV2Fetch.js @@ -39,18 +39,6 @@ export default class ViewV2Fetch extends DataFetch { this.options const { cursor, query, definition } = get(this.store) - // If this is a calculation view and there are no schema fields then do nothing - console.log(definition) - if ( - definition.calculation && - !Object.keys(definition.schema || {}).length - ) { - return { - rows: [], - hasNextPage: false, - } - } - // If sort/filter params are not defined, update options to store the // params built in to this view. This ensures that we can accurately // compare old and new params and skip a redundant API call.