diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 840d580892..77867c8617 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -18,8 +18,7 @@ env: BASE_BRANCH: ${{ github.event.pull_request.base.ref}} PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} NX_BASE_BRANCH: origin/${{ github.base_ref }} - USE_NX_AFFECTED: ${{ github.event_name == 'pull_request' && github.base_ref != 'master'}} - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} + USE_NX_AFFECTED: ${{ github.event_name == 'pull_request' }} jobs: lint: @@ -231,7 +230,7 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile - name: Build packages - run: yarn build --scope @budibase/server --scope @budibase/worker --scope @budibase/client --scope @budibase/backend-core + run: yarn build --scope @budibase/server --scope @budibase/worker - name: Run tests run: | cd qa-core diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index c7a701535b..b12820344e 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -4,6 +4,8 @@ on: types: [created] pull_request_target: types: [opened,closed,synchronize] + branches: + - master jobs: CLAssistant: @@ -33,4 +35,4 @@ jobs: #custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA' #custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.' #lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true) - #use-dco-flag: true - If you are using DCO instead of CLA \ No newline at end of file + #use-dco-flag: true - If you are using DCO instead of CLA diff --git a/.github/workflows/deploy-qa.yml b/.github/workflows/deploy-qa.yml new file mode 100644 index 0000000000..d850d289ff --- /dev/null +++ b/.github/workflows/deploy-qa.yml @@ -0,0 +1,20 @@ +name: Deploy QA + +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + trigger-deploy-to-qa-env: + runs-on: ubuntu-latest + steps: + - uses: peter-evans/repository-dispatch@v2 + env: + PAYLOAD_VERSION: ${{ github.sha }} + REF_NAME: ${{ github.ref_name}} + with: + repository: budibase/budibase-deploys + event-type: budicloud-qa-deploy + token: ${{ secrets.GH_ACCESS_TOKEN }} diff --git a/.github/workflows/release-master.yml b/.github/workflows/release-master.yml index 4acd5088d2..9ab8530341 100644 --- a/.github/workflows/release-master.yml +++ b/.github/workflows/release-master.yml @@ -123,6 +123,7 @@ jobs: - uses: passeidireto/trigger-external-workflow-action@main env: PAYLOAD_VERSION: ${{ env.RELEASE_VERSION }} + REF_NAME: ${{ github.ref_name}} with: repository: budibase/budibase-deploys event: budicloud-qa-deploy diff --git a/.github/workflows/release-singleimage-test.yml b/.github/workflows/release-singleimage-test.yml index 79b9afdd44..c3a14226ce 100644 --- a/.github/workflows/release-singleimage-test.yml +++ b/.github/workflows/release-singleimage-test.yml @@ -54,6 +54,7 @@ jobs: push: true pull: true platforms: linux/amd64,linux/arm64 + build-args: BUDIBASE_VERSION=0.0.0+test tags: budibase/budibase-test:test file: ./hosting/single/Dockerfile.v2 cache-from: type=registry,ref=budibase/budibase-test:test @@ -64,6 +65,8 @@ jobs: context: . push: true platforms: linux/amd64 - build-args: TARGETBUILD=aas + build-args: | + TARGETBUILD=aas + BUDIBASE_VERSION=0.0.0+test tags: budibase/budibase-test:aas file: ./hosting/single/Dockerfile.v2 diff --git a/hosting/couchdb/Dockerfile b/hosting/couchdb/Dockerfile index ce77002052..792856cac7 100644 --- a/hosting/couchdb/Dockerfile +++ b/hosting/couchdb/Dockerfile @@ -5,7 +5,7 @@ ENV COUCHDB_PASSWORD admin EXPOSE 5984 RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common wget unzip curl && \ - wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add - && \ + wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add - && \ apt-add-repository 'deb http://security.debian.org/debian-security bullseye-security/updates main' && \ apt-add-repository 'deb http://archive.debian.org/debian stretch-backports main' && \ apt-add-repository 'deb https://packages.adoptium.net/artifactory/deb bullseye main' && \ diff --git a/hosting/docker-compose.build.yaml b/hosting/docker-compose.build.yaml index bc363fb0bf..7ead001a1c 100644 --- a/hosting/docker-compose.build.yaml +++ b/hosting/docker-compose.build.yaml @@ -4,7 +4,11 @@ version: "3" services: app-service: - build: ../packages/server + build: + context: .. + dockerfile: packages/server/Dockerfile.v2 + args: + - BUDIBASE_VERSION=0.0.0+dev-docker container_name: build-bbapps environment: SELF_HOSTED: 1 @@ -28,11 +32,13 @@ services: depends_on: - worker-service - redis-service - # volumes: - # - /some/path/to/plugins:/plugins worker-service: - build: ../packages/worker + build: + context: .. + dockerfile: packages/worker/Dockerfile.v2 + args: + - BUDIBASE_VERSION=0.0.0+dev-docker container_name: build-bbworker environment: SELF_HOSTED: 1 diff --git a/hosting/single/Dockerfile.v2 b/hosting/single/Dockerfile.v2 index b1abe6d53e..5b07a51b27 100644 --- a/hosting/single/Dockerfile.v2 +++ b/hosting/single/Dockerfile.v2 @@ -19,13 +19,15 @@ COPY packages/string-templates/package.json packages/string-templates/package.js COPY scripts/removeWorkspaceDependencies.sh scripts/removeWorkspaceDependencies.sh RUN chmod +x ./scripts/removeWorkspaceDependencies.sh -RUN ./scripts/removeWorkspaceDependencies.sh +RUN ./scripts/removeWorkspaceDependencies.sh packages/server/package.json +RUN ./scripts/removeWorkspaceDependencies.sh packages/worker/package.json # We will never want to sync pro, but the script is still required RUN echo '' > scripts/syncProPackage.js RUN jq 'del(.scripts.postinstall)' package.json > temp.json && mv temp.json package.json -RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install --production +RUN ./scripts/removeWorkspaceDependencies.sh package.json +RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install --production # copy the actual code COPY packages/server/dist packages/server/dist @@ -116,6 +118,10 @@ EXPOSE 443 EXPOSE 2222 VOLUME /data +ARG BUDIBASE_VERSION +# Ensuring the version argument is sent +RUN test -n "$BUDIBASE_VERSION" +ENV BUDIBASE_VERSION=$BUDIBASE_VERSION HEALTHCHECK --interval=15s --timeout=15s --start-period=45s CMD "/healthcheck.sh" diff --git a/lerna.json b/lerna.json index e01e5ae03e..4fd5161891 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.11.39", + "version": "2.11.42", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/nx.json b/nx.json index fef6893f9d..618395ec90 100644 --- a/nx.json +++ b/nx.json @@ -3,14 +3,16 @@ "default": { "runner": "nx-cloud", "options": { - "cacheableOperations": ["build", "test", "check:types"], - "accessToken": "MmM4OGYxNzItMDBlYy00ZmE3LTk4MTYtNmJhYWMyZjBjZTUyfHJlYWQ=" + "cacheableOperations": ["build", "test", "check:types"] } } }, "targetDefaults": { "build": { - "inputs": ["{workspaceRoot}/scripts/build.js"] + "inputs": [ + "{workspaceRoot}/scripts/build.js", + "{workspaceRoot}/lerna.json" + ] } } } diff --git a/package.json b/package.json index 7f5c971009..100a306a35 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && lerna run --stream dev:builder --ignore @budibase/backend-core --ignore @budibase/server --ignore @budibase/worker", "dev:server": "yarn run kill-server && lerna run --stream dev:builder --scope @budibase/worker --scope @budibase/server", "dev:built": "yarn run kill-all && cd packages/server && yarn dev:stack:up && cd ../../ && lerna run --stream dev:built", - "dev:docker": "yarn build && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0", + "dev:docker": "yarn build --scope @budibase/server --scope @budibase/worker && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0", "test": "lerna run --stream test --stream", "lint:eslint": "eslint packages qa-core --max-warnings=0", "lint:prettier": "prettier --check \"packages/**/*.{js,ts,svelte}\" && prettier --write \"examples/**/*.{js,ts,svelte}\" && prettier --check \"qa-core/**/*.{js,ts,svelte}\"", diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 22ca5b21cc..b23cd8e5b1 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -35,7 +35,7 @@ "dotenv": "16.0.1", "ioredis": "5.3.2", "joi": "17.6.0", - "jsonwebtoken": "9.0.0", + "jsonwebtoken": "9.0.2", "koa-passport": "4.1.4", "koa-pino-logger": "4.0.0", "lodash": "4.17.21", @@ -63,7 +63,7 @@ "@types/chance": "1.1.3", "@types/cookies": "0.7.8", "@types/jest": "29.5.5", - "@types/lodash": "4.14.180", + "@types/lodash": "4.14.200", "@types/node": "18.17.0", "@types/node-fetch": "2.6.4", "@types/pouchdb": "6.4.0", diff --git a/packages/backend-core/src/cache/writethrough.ts b/packages/backend-core/src/cache/writethrough.ts index c331d791a6..e64c116663 100644 --- a/packages/backend-core/src/cache/writethrough.ts +++ b/packages/backend-core/src/cache/writethrough.ts @@ -119,8 +119,8 @@ export class Writethrough { this.writeRateMs = writeRateMs } - async put(doc: any, writeRateMs: number = this.writeRateMs) { - return put(this.db, doc, writeRateMs) + async put(doc: any) { + return put(this.db, doc, this.writeRateMs) } async get(id: string) { diff --git a/packages/backend-core/src/environment.ts b/packages/backend-core/src/environment.ts index 3894bdd0f7..ed882fe96a 100644 --- a/packages/backend-core/src/environment.ts +++ b/packages/backend-core/src/environment.ts @@ -75,12 +75,12 @@ function getPackageJsonFields(): { const content = readFileSync(packageJsonFile!, "utf-8") const parsedContent = JSON.parse(content) return { - VERSION: parsedContent.version, + VERSION: process.env.BUDIBASE_VERSION || parsedContent.version, SERVICE_NAME: parsedContent.name, } } catch { // throwing an error here is confusing/causes backend-core to be hard to import - return { VERSION: "", SERVICE_NAME: "" } + return { VERSION: process.env.BUDIBASE_VERSION || "", SERVICE_NAME: "" } } } diff --git a/packages/backend-core/src/users/db.ts b/packages/backend-core/src/users/db.ts index 8bb6300d4e..a2539e836e 100644 --- a/packages/backend-core/src/users/db.ts +++ b/packages/backend-core/src/users/db.ts @@ -25,17 +25,12 @@ import { import { getAccountHolderFromUserIds, isAdmin, - isCreator, validateUniqueUser, } from "./utils" import { searchExistingEmails } from "./lookup" import { hash } from "../utils" -type QuotaUpdateFn = ( - change: number, - creatorsChange: number, - cb?: () => Promise -) => Promise +type QuotaUpdateFn = (change: number, cb?: () => Promise) => Promise type GroupUpdateFn = (groupId: string, userIds: string[]) => Promise type FeatureFn = () => Promise type GroupGetFn = (ids: string[]) => Promise @@ -164,14 +159,14 @@ export class UserDB { } } - static async getUsersByAppAccess(appId?: string) { - const opts: any = { + static async getUsersByAppAccess(opts: { appId?: string; limit?: number }) { + const params: any = { include_docs: true, - limit: 50, + limit: opts.limit || 50, } let response: User[] = await usersCore.searchGlobalUsersByAppAccess( - appId, - opts + opts.appId, + params ) return response } @@ -250,8 +245,7 @@ export class UserDB { } const change = dbUser ? 0 : 1 // no change if there is existing user - const creatorsChange = isCreator(dbUser) !== isCreator(user) ? 1 : 0 - return UserDB.quotas.addUsers(change, creatorsChange, async () => { + return UserDB.quotas.addUsers(change, async () => { await validateUniqueUser(email, tenantId) let builtUser = await UserDB.buildUser(user, opts, tenantId, dbUser) @@ -313,7 +307,6 @@ export class UserDB { let usersToSave: any[] = [] let newUsers: any[] = [] - let newCreators: any[] = [] const emails = newUsersRequested.map((user: User) => user.email) const existingEmails = await searchExistingEmails(emails) @@ -334,66 +327,59 @@ export class UserDB { } newUser.userGroups = groups newUsers.push(newUser) - if (isCreator(newUser)) { - newCreators.push(newUser) - } } const account = await accountSdk.getAccountByTenantId(tenantId) - return UserDB.quotas.addUsers( - newUsers.length, - newCreators.length, - async () => { - // create the promises array that will be called by bulkDocs - newUsers.forEach((user: any) => { - usersToSave.push( - UserDB.buildUser( - user, - { - hashPassword: true, - requirePassword: user.requirePassword, - }, - tenantId, - undefined, // no dbUser - account - ) + return UserDB.quotas.addUsers(newUsers.length, async () => { + // create the promises array that will be called by bulkDocs + newUsers.forEach((user: any) => { + usersToSave.push( + UserDB.buildUser( + user, + { + hashPassword: true, + requirePassword: user.requirePassword, + }, + tenantId, + undefined, // no dbUser + account ) - }) + ) + }) - const usersToBulkSave = await Promise.all(usersToSave) - await usersCore.bulkUpdateGlobalUsers(usersToBulkSave) + const usersToBulkSave = await Promise.all(usersToSave) + await usersCore.bulkUpdateGlobalUsers(usersToBulkSave) - // Post-processing of bulk added users, e.g. events and cache operations - for (const user of usersToBulkSave) { - // TODO: Refactor to bulk insert users into the info db - // instead of relying on looping tenant creation - await platform.users.addUser(tenantId, user._id, user.email) - await eventHelpers.handleSaveEvents(user, undefined) - } - - const saved = usersToBulkSave.map(user => { - return { - _id: user._id, - email: user.email, - } - }) - - // now update the groups - if (Array.isArray(saved) && groups) { - const groupPromises = [] - const createdUserIds = saved.map(user => user._id) - for (let groupId of groups) { - groupPromises.push(UserDB.groups.addUsers(groupId, createdUserIds)) - } - await Promise.all(groupPromises) - } - - return { - successful: saved, - unsuccessful, - } + // Post-processing of bulk added users, e.g. events and cache operations + for (const user of usersToBulkSave) { + // TODO: Refactor to bulk insert users into the info db + // instead of relying on looping tenant creation + await platform.users.addUser(tenantId, user._id, user.email) + await eventHelpers.handleSaveEvents(user, undefined) } - ) + + const saved = usersToBulkSave.map(user => { + return { + _id: user._id, + email: user.email, + } + }) + + // now update the groups + if (Array.isArray(saved) && groups) { + const groupPromises = [] + const createdUserIds = saved.map(user => user._id) + for (let groupId of groups) { + groupPromises.push(UserDB.groups.addUsers(groupId, createdUserIds)) + } + await Promise.all(groupPromises) + } + + return { + successful: saved, + unsuccessful, + } + }) } static async bulkDelete(userIds: string[]): Promise { @@ -433,12 +419,11 @@ export class UserDB { _deleted: true, })) const dbResponse = await usersCore.bulkUpdateGlobalUsers(toDelete) - const creatorsToDelete = usersToDelete.filter(isCreator) + await UserDB.quotas.removeUsers(toDelete.length) for (let user of usersToDelete) { await bulkDeleteProcessing(user) } - await UserDB.quotas.removeUsers(toDelete.length, creatorsToDelete.length) // Build Response // index users by id @@ -487,8 +472,7 @@ export class UserDB { await db.remove(userId, dbUser._rev) - const creatorsToDelete = isCreator(dbUser) ? 1 : 0 - await UserDB.quotas.removeUsers(1, creatorsToDelete) + await UserDB.quotas.removeUsers(1) await eventHelpers.handleDeleteEvents(dbUser) await cache.user.invalidateUser(userId) await sessions.invalidateSessions(userId, { reason: "deletion" }) diff --git a/packages/backend-core/src/users/users.ts b/packages/backend-core/src/users/users.ts index a64997224e..d259d5b560 100644 --- a/packages/backend-core/src/users/users.ts +++ b/packages/backend-core/src/users/users.ts @@ -14,15 +14,15 @@ import { } from "../db" import { BulkDocsResponse, + ContextUser, SearchQuery, SearchQueryOperators, SearchUsersRequest, User, - ContextUser, + DatabaseQueryOpts, } from "@budibase/types" -import { getGlobalDB } from "../context" import * as context from "../context" -import { isCreator } from "./utils" +import { getGlobalDB } from "../context" type GetOpts = { cleanup?: boolean } @@ -241,12 +241,14 @@ export const paginatedUsers = async ({ bookmark, query, appId, + limit, }: SearchUsersRequest = {}) => { const db = getGlobalDB() + const pageLimit = limit ? limit + 1 : PAGE_LIMIT + 1 // get one extra document, to have the next page - const opts: any = { + const opts: DatabaseQueryOpts = { include_docs: true, - limit: PAGE_LIMIT + 1, + limit: pageLimit, } // add a startkey if the page was specified (anchor) if (bookmark) { @@ -269,7 +271,7 @@ export const paginatedUsers = async ({ const response = await db.allDocs(getGlobalUserParams(null, opts)) userList = response.rows.map((row: any) => row.doc) } - return pagination(userList, PAGE_LIMIT, { + return pagination(userList, pageLimit, { paginate: true, property, getKey, @@ -284,19 +286,6 @@ export async function getUserCount() { return response.total_rows } -export async function getCreatorCount() { - let creators = 0 - async function iterate(startPage?: string) { - const page = await paginatedUsers({ bookmark: startPage }) - creators += page.data.filter(isCreator).length - if (page.hasNextPage) { - await iterate(page.nextPage) - } - } - await iterate() - return creators -} - // used to remove the builder/admin permissions, for processing the // user as an app user (they may have some specific role/group export function removePortalUserPermissions(user: User | ContextUser) { diff --git a/packages/backend-core/src/users/utils.ts b/packages/backend-core/src/users/utils.ts index 0ef4b77998..af0e8e10c7 100644 --- a/packages/backend-core/src/users/utils.ts +++ b/packages/backend-core/src/users/utils.ts @@ -10,7 +10,6 @@ import { getAccountByTenantId } from "../accounts" // extract from shared-core to make easily accessible from backend-core export const isBuilder = sdk.users.isBuilder export const isAdmin = sdk.users.isAdmin -export const isCreator = sdk.users.isCreator export const isGlobalBuilder = sdk.users.isGlobalBuilder export const isAdminOrBuilder = sdk.users.isAdminOrBuilder export const hasAdminPermissions = sdk.users.hasAdminPermissions diff --git a/packages/backend-core/tests/core/users/users.spec.js b/packages/backend-core/tests/core/users/users.spec.js deleted file mode 100644 index ae7109344a..0000000000 --- a/packages/backend-core/tests/core/users/users.spec.js +++ /dev/null @@ -1,54 +0,0 @@ -const _ = require('lodash/fp') -const {structures} = require("../../../tests") - -jest.mock("../../../src/context") -jest.mock("../../../src/db") - -const context = require("../../../src/context") -const db = require("../../../src/db") - -const {getCreatorCount} = require('../../../src/users/users') - -describe("Users", () => { - - let getGlobalDBMock - let getGlobalUserParamsMock - let paginationMock - - beforeEach(() => { - jest.resetAllMocks() - - getGlobalDBMock = jest.spyOn(context, "getGlobalDB") - getGlobalUserParamsMock = jest.spyOn(db, "getGlobalUserParams") - paginationMock = jest.spyOn(db, "pagination") - }) - - it("Retrieves the number of creators", async () => { - const getUsers = (offset, limit, creators = false) => { - const range = _.range(offset, limit) - const opts = creators ? {builder: {global: true}} : undefined - return range.map(() => structures.users.user(opts)) - } - const page1Data = getUsers(0, 8) - const page2Data = getUsers(8, 12, true) - getGlobalDBMock.mockImplementation(() => ({ - name : "fake-db", - allDocs: () => ({ - rows: [...page1Data, ...page2Data] - }) - })) - paginationMock.mockImplementationOnce(() => ({ - data: page1Data, - hasNextPage: true, - nextPage: "1" - })) - paginationMock.mockImplementation(() => ({ - data: page2Data, - hasNextPage: false, - nextPage: undefined - })) - const creatorsCount = await getCreatorCount() - expect(creatorsCount).toBe(4) - expect(paginationMock).toHaveBeenCalledTimes(2) - }) -}) diff --git a/packages/backend-core/tests/core/utilities/structures/licenses.ts b/packages/backend-core/tests/core/utilities/structures/licenses.ts index bb452f9ad5..5cce84edfd 100644 --- a/packages/backend-core/tests/core/utilities/structures/licenses.ts +++ b/packages/backend-core/tests/core/utilities/structures/licenses.ts @@ -72,11 +72,6 @@ export function quotas(): Quotas { value: 1, triggers: [], }, - creators: { - name: "Creators", - value: 1, - triggers: [], - }, userGroups: { name: "User Groups", value: 1, @@ -123,10 +118,6 @@ export function customer(): Customer { export function subscription(): Subscription { return { amount: 10000, - amounts: { - user: 10000, - creator: 0, - }, cancelAt: undefined, currency: "usd", currentPeriodEnd: 0, @@ -135,10 +126,6 @@ export function subscription(): Subscription { duration: PriceDuration.MONTHLY, pastDueAt: undefined, quantity: 0, - quantities: { - user: 0, - creator: 0, - }, status: "active", } } diff --git a/packages/backend-core/tests/core/utilities/structures/quotas.ts b/packages/backend-core/tests/core/utilities/structures/quotas.ts index 8d0b05fe1e..e82117053f 100644 --- a/packages/backend-core/tests/core/utilities/structures/quotas.ts +++ b/packages/backend-core/tests/core/utilities/structures/quotas.ts @@ -1,6 +1,6 @@ import { MonthlyQuotaName, QuotaUsage } from "@budibase/types" -export const usage = (users: number = 0, creators: number = 0): QuotaUsage => { +export const usage = (): QuotaUsage => { return { _id: "usage_quota", quotaReset: new Date().toISOString(), @@ -58,8 +58,7 @@ export const usage = (users: number = 0, creators: number = 0): QuotaUsage => { usageQuota: { apps: 0, plugins: 0, - users, - creators, + users: 0, userGroups: 0, rows: 0, triggers: {}, diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index 4569586762..f8087d8a39 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -3,13 +3,10 @@ import { goto, params } from "@roxi/routify" import { Table, Heading, Layout } from "@budibase/bbui" import Spinner from "components/common/Spinner.svelte" - import { - TableNames, - UNEDITABLE_USER_FIELDS, - UNSORTABLE_TYPES, - } from "constants" + import { TableNames, UNEDITABLE_USER_FIELDS } from "constants" import RoleCell from "./cells/RoleCell.svelte" import { createEventDispatcher } from "svelte" + import { canBeSortColumn } from "@budibase/shared-core" export let schema = {} export let data = [] @@ -32,12 +29,10 @@ $: isUsersTable = tableId === TableNames.USERS $: data && resetSelectedRows() $: { - UNSORTABLE_TYPES.forEach(type => { - Object.values(schema || {}).forEach(col => { - if (col.type === type) { - col.sortable = false - } - }) + Object.values(schema || {}).forEach(col => { + if (!canBeSortColumn(col.type)) { + col.sortable = false + } }) } $: { diff --git a/packages/builder/src/components/design/settings/controls/DataSourceSelect.svelte b/packages/builder/src/components/design/settings/controls/DataSourceSelect.svelte index d70929469a..29f32aa345 100644 --- a/packages/builder/src/components/design/settings/controls/DataSourceSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/DataSourceSelect.svelte @@ -1,5 +1,9 @@
@@ -172,7 +225,9 @@ on:click={dropdownRight.show} /> {#if value?.type === "query"} - +
+ +
@@ -198,6 +253,29 @@ {/if} + {#if value?.type === "custom"} +
+ +
+ +
+ + +
+
Provide a JSON array to use as data
+ (tmpCustomData = event.detail)} + {bindings} + allowJS + allowHelpers + /> +
+ {/if}
+ + + + + + diff --git a/packages/builder/src/components/design/settings/controls/SortableFieldSelect.svelte b/packages/builder/src/components/design/settings/controls/SortableFieldSelect.svelte index 21ed68ce68..350f59f456 100644 --- a/packages/builder/src/components/design/settings/controls/SortableFieldSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/SortableFieldSelect.svelte @@ -6,7 +6,7 @@ } from "builderStore/dataBinding" import { currentAsset } from "builderStore" import { createEventDispatcher } from "svelte" - import { UNSORTABLE_TYPES } from "constants" + import { canBeSortColumn } from "@budibase/shared-core" export let componentInstance = {} export let value = "" @@ -20,7 +20,7 @@ const getSortableFields = schema => { return Object.entries(schema || {}) - .filter(entry => !UNSORTABLE_TYPES.includes(entry[1].type)) + .filter(entry => canBeSortColumn(entry[1].type)) .map(entry => entry[0]) } diff --git a/packages/builder/src/constants/index.js b/packages/builder/src/constants/index.js index 66fd926a77..f556ee4b05 100644 --- a/packages/builder/src/constants/index.js +++ b/packages/builder/src/constants/index.js @@ -34,8 +34,6 @@ export const UNEDITABLE_USER_FIELDS = [ "lastName", ] -export const UNSORTABLE_TYPES = ["formula", "attachment", "array", "link"] - export const LAYOUT_NAMES = { MASTER: { PRIVATE: "layout_private_master", diff --git a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte index c93a41f541..a7d9584330 100644 --- a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte @@ -114,8 +114,9 @@ query: { appId: query || !filterByAppAccess ? null : prodAppId, email: query, - paginated: query || !filterByAppAccess ? null : false, }, + limit: 50, + paginate: query || !filterByAppAccess ? null : false, }) await usersFetch.refresh() diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte index 6eb4b4c440..0a4288b227 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte @@ -1,5 +1,5 @@