From 40966731c9663828f0c82fa3bdd07f41f92dff8f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 16:56:52 +0200 Subject: [PATCH 1/7] Remove related fields popover --- .../grid/cells/RelationshipCell.svelte | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/packages/frontend-core/src/components/grid/cells/RelationshipCell.svelte b/packages/frontend-core/src/components/grid/cells/RelationshipCell.svelte index 73c8a99cc2..7532ee8b0e 100644 --- a/packages/frontend-core/src/components/grid/cells/RelationshipCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/RelationshipCell.svelte @@ -56,12 +56,6 @@ return acc }, {}) - $: showRelationshipFields = - relationshipFields && - Object.keys(relationshipFields).length && - focused && - !isOpen - const parseValue = value => { if (Array.isArray(value) && value.every(x => x?._id)) { return value @@ -358,21 +352,6 @@ {/if} -{#if showRelationshipFields} - -
- {#each Object.entries(relationshipFields) as [fieldName, fieldValue]} -
- {fieldName} -
-
- {fieldValue} -
- {/each} -
-
-{/if} - From 56aaacb437551752834a7578bb4da9a85805e6c9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 17:12:53 +0200 Subject: [PATCH 2/7] Lint --- .../components/grid/cells/RelationshipCell.svelte | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/frontend-core/src/components/grid/cells/RelationshipCell.svelte b/packages/frontend-core/src/components/grid/cells/RelationshipCell.svelte index 7532ee8b0e..8f773d3f90 100644 --- a/packages/frontend-core/src/components/grid/cells/RelationshipCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/RelationshipCell.svelte @@ -27,9 +27,7 @@ let candidateIndex let lastSearchId let searching = false - let container let anchor - let relationshipFields $: fieldValue = parseValue(value) $: oneRowOnly = schema?.relationshipType === "one-to-many" @@ -236,14 +234,6 @@ return value } - const displayRelationshipFields = relationship => { - relationshipFields = relationFields[relationship._id] - } - - const hideRelationshipFields = () => { - relationshipFields = undefined - } - onMount(() => { api = { focus: open, @@ -263,7 +253,7 @@ style="--color:{color};" bind:this={anchor} > -
+
1} @@ -275,9 +265,7 @@
displayRelationshipFields(relationship)} on:focus={() => {}} - on:mouseleave={() => hideRelationshipFields()} > {readable( From 964f8222babbdb7867ed1b3df834ac693d687851 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Thu, 10 Oct 2024 17:10:07 +0100 Subject: [PATCH 3/7] Allow sorting by calculation fields. --- packages/backend-core/src/sql/sql.ts | 24 +++- .../src/api/routes/tests/viewV2.spec.ts | 118 ++++++++++++++++++ .../src/sdk/app/rows/search/internal/sqs.ts | 27 ++-- 3 files changed, 156 insertions(+), 13 deletions(-) diff --git a/packages/backend-core/src/sql/sql.ts b/packages/backend-core/src/sql/sql.ts index f122ad1c41..382eca3f76 100644 --- a/packages/backend-core/src/sql/sql.ts +++ b/packages/backend-core/src/sql/sql.ts @@ -273,6 +273,7 @@ class InternalBuilder { const col = parts.pop()! const schema = this.table.schema[col] let identifier = this.quotedIdentifier(field) + if ( schema.type === FieldType.STRING || schema.type === FieldType.LONGFORM || @@ -957,6 +958,13 @@ class InternalBuilder { return query } + isAggregateField(field: string): boolean { + const found = this.query.resource?.aggregations?.find( + aggregation => aggregation.name === field + ) + return !!found + } + addSorting(query: Knex.QueryBuilder): Knex.QueryBuilder { let { sort, resource } = this.query const primaryKey = this.table.primary @@ -979,13 +987,17 @@ class InternalBuilder { nulls = value.direction === SortOrder.ASCENDING ? "first" : "last" } - let composite = `${aliased}.${key}` - if (this.client === SqlClient.ORACLE) { - query = query.orderByRaw( - `${this.convertClobs(composite)} ${direction} nulls ${nulls}` - ) + if (this.isAggregateField(key)) { + query = query.orderBy(key, direction, nulls) } else { - query = query.orderBy(composite, direction, nulls) + let composite = `${aliased}.${key}` + if (this.client === SqlClient.ORACLE) { + query = query.orderByRaw( + `${this.convertClobs(composite)} ${direction} nulls ${nulls}` + ) + } else { + query = query.orderBy(composite, direction, nulls) + } } } } diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index 0b4237406f..eae429d49d 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -3381,6 +3381,124 @@ describe.each([ expect(rows).toHaveLength(1) expect(rows[0].sum).toEqual(3) }) + + it("should be able to sort by group by field", async () => { + const table = await config.api.table.save( + saveTableRequest({ + schema: { + quantity: { + type: FieldType.NUMBER, + name: "quantity", + }, + price: { + type: FieldType.NUMBER, + name: "price", + }, + }, + }) + ) + + const view = await config.api.viewV2.create({ + tableId: table._id!, + name: generator.guid(), + type: ViewV2Type.CALCULATION, + schema: { + quantity: { visible: true }, + sum: { + visible: true, + calculationType: CalculationType.SUM, + field: "price", + }, + }, + }) + + await config.api.row.bulkImport(table._id!, { + rows: [ + { + quantity: 1, + price: 1, + }, + { + quantity: 1, + price: 2, + }, + { + quantity: 2, + price: 10, + }, + ], + }) + + const { rows } = await config.api.viewV2.search(view.id, { + query: {}, + sort: "quantity", + sortOrder: SortOrder.DESCENDING, + }) + + expect(rows).toEqual([ + expect.objectContaining({ quantity: 2, sum: 10 }), + expect.objectContaining({ quantity: 1, sum: 3 }), + ]) + }) + + it("should be able to sort by a calculation", async () => { + const table = await config.api.table.save( + saveTableRequest({ + schema: { + quantity: { + type: FieldType.NUMBER, + name: "quantity", + }, + price: { + type: FieldType.NUMBER, + name: "price", + }, + }, + }) + ) + + await config.api.row.bulkImport(table._id!, { + rows: [ + { + quantity: 1, + price: 1, + }, + { + quantity: 1, + price: 2, + }, + { + quantity: 2, + price: 10, + }, + ], + }) + + const view = await config.api.viewV2.create({ + tableId: table._id!, + name: generator.guid(), + type: ViewV2Type.CALCULATION, + schema: { + quantity: { visible: true }, + sum: { + visible: true, + calculationType: CalculationType.SUM, + field: "price", + }, + }, + }) + + const { rows } = await config.api.viewV2.search(view.id, { + query: {}, + sort: "sum", + sortOrder: SortOrder.DESCENDING, + }) + + expect(rows).toEqual([ + expect.objectContaining({ quantity: 2, sum: 10 }), + expect.objectContaining({ quantity: 1, sum: 3 }), + ]) + }) }) !isLucene && diff --git a/packages/server/src/sdk/app/rows/search/internal/sqs.ts b/packages/server/src/sdk/app/rows/search/internal/sqs.ts index ad323a8c12..916e20957b 100644 --- a/packages/server/src/sdk/app/rows/search/internal/sqs.ts +++ b/packages/server/src/sdk/app/rows/search/internal/sqs.ts @@ -418,13 +418,26 @@ export async function search( if (params.sort) { const sortField = table.schema[params.sort] - const sortType = - sortField.type === FieldType.NUMBER ? SortType.NUMBER : SortType.STRING - request.sort = { - [mapToUserColumn(sortField.name)]: { - direction: params.sortOrder || SortOrder.ASCENDING, - type: sortType as SortType, - }, + const isAggregateField = aggregations.some(agg => agg.name === params.sort) + + if (isAggregateField) { + request.sort = { + [params.sort]: { + direction: params.sortOrder || SortOrder.ASCENDING, + type: SortType.NUMBER, + }, + } + } else if (sortField) { + const sortType = + sortField.type === FieldType.NUMBER ? SortType.NUMBER : SortType.STRING + request.sort = { + [mapToUserColumn(sortField.name)]: { + direction: params.sortOrder || SortOrder.ASCENDING, + type: sortType as SortType, + }, + } + } else { + throw new Error(`Unable to sort by ${params.sort}`) } } From ecddd46fc6aee7a0551870e513c6cf3c7c068da8 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:59:01 +0100 Subject: [PATCH 4/7] Update pro (#14769) --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index aca9828117..fc4c7f4925 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit aca9828117bb97f54f40ee359f1a3f6e259174e7 +Subproject commit fc4c7f4925139af078480217965c3d6338dc0a7f From abb01ba98a5538fd295d4acadff60472d0fc1ab0 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Fri, 11 Oct 2024 11:58:51 +0000 Subject: [PATCH 5/7] Bump version to 2.32.17 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index ba3db109d0..13530e9aee 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.32.16", + "version": "2.32.17", "npmClient": "yarn", "packages": [ "packages/*", From c0e89c47adedc16ed62aa7d7ebcb5a12b0db2143 Mon Sep 17 00:00:00 2001 From: Christos Alexiou Date: Fri, 11 Oct 2024 17:29:09 +0300 Subject: [PATCH 6/7] Extend available labels --- .github/workflows/deploy-featurebranch.yml | 40 +++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-featurebranch.yml b/.github/workflows/deploy-featurebranch.yml index d86d301507..0e19f0649f 100644 --- a/.github/workflows/deploy-featurebranch.yml +++ b/.github/workflows/deploy-featurebranch.yml @@ -3,26 +3,50 @@ name: deploy-featurebranch on: pull_request: types: [ - labeled, - # default types below (https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) - opened, - synchronize, - reopened, - ] + labeled, + # default types below (https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) + opened, + synchronize, + reopened, + ] jobs: release: if: | (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase') && - contains(github.event.pull_request.labels.*.name, 'feature-branch') + ( + contains(github.event.pull_request.labels.*.name, 'feature-branch') || + contains(github.event.pull_request.labels.*.name, 'feature-branch-pro') || + contains(github.event.pull_request.labels.*.name, 'feature-branch-team') || + contains(github.event.pull_request.labels.*.name, 'feature-branch-business') || + contains(github.event.pull_request.labels.*.name, 'feature-branch-enterprise') + ) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - name: Set PAYLOAD_LICENSE_TYPE + id: set_license_type + run: | + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'feature-branch') }}" == "true" ]]; then + echo "PAYLOAD_LICENSE_TYPE=free" >> $GITHUB_ENV + elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'feature-branch-pro') }}" == "true" ]]; then + echo "PAYLOAD_LICENSE_TYPE=pro" >> $GITHUB_ENV + elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'feature-branch-team') }}" == "true" ]]; then + echo "PAYLOAD_LICENSE_TYPE=team" >> $GITHUB_ENV + elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'feature-branch-business') }}" == "true" ]]; then + echo "PAYLOAD_LICENSE_TYPE=business" >> $GITHUB_ENV + elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'feature-branch-enterprise') }}" == "true" ]]; then + echo "PAYLOAD_LICENSE_TYPE=enterprise" >> $GITHUB_ENV + else + echo "PAYLOAD_LICENSE_TYPE=free" >> $GITHUB_ENV + fi + - uses: passeidireto/trigger-external-workflow-action@main env: PAYLOAD_BRANCH: ${{ github.head_ref }} PAYLOAD_PR_NUMBER: ${{ github.event.pull_request.number }} - PAYLOAD_LICENSE_TYPE: "free" + PAYLOAD_LICENSE_TYPE: ${{ env.PAYLOAD_LICENSE_TYPE }} with: repository: budibase/budibase-deploys event: featurebranch-qa-deploy From 64d4aef87df03fd8fc2575fc56f149da7b006913 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 11 Oct 2024 16:41:51 +0200 Subject: [PATCH 7/7] Fix all or property --- packages/shared-core/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared-core/src/utils.ts b/packages/shared-core/src/utils.ts index 4847e911e9..bead5961f0 100644 --- a/packages/shared-core/src/utils.ts +++ b/packages/shared-core/src/utils.ts @@ -172,7 +172,7 @@ export const processSearchFilters = ( .sort((a, b) => { return a.localeCompare(b) }) - .filter(key => key in filter) + .filter(key => filter[key]) if (filterPropertyKeys.length == 1) { const key = filterPropertyKeys[0],