From e744e4ebb1cd5780b84dd71fe3704fd146965f7e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 11:52:19 +0200 Subject: [PATCH 1/6] Unify icons --- .../builder/src/constants/backend/index.js | 34 ++++++++++--------- .../src/components/grid/lib/utils.js | 22 +----------- packages/frontend-core/src/constants.js | 23 +++++++++++++ 3 files changed, 42 insertions(+), 37 deletions(-) diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index dd751d4e13..e4736892b9 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -5,6 +5,8 @@ import { AutoFieldSubType, Hosting, } from "@budibase/types" +import { Constants } from "@budibase/frontend-core" +const { TypeIconMap } = Constants export { RelationshipType } from "@budibase/types" @@ -22,7 +24,7 @@ export const FIELDS = { STRING: { name: "Text", type: FieldType.STRING, - icon: "Text", + icon: TypeIconMap[FieldType.STRING], constraints: { type: "string", length: {}, @@ -32,7 +34,7 @@ export const FIELDS = { BARCODEQR: { name: "Barcode/QR", type: FieldType.BARCODEQR, - icon: "Camera", + icon: TypeIconMap[FieldType.BARCODEQR], constraints: { type: "string", length: {}, @@ -42,7 +44,7 @@ export const FIELDS = { LONGFORM: { name: "Long Form Text", type: FieldType.LONGFORM, - icon: "TextAlignLeft", + icon: TypeIconMap[FieldType.LONGFORM], constraints: { type: "string", length: {}, @@ -52,7 +54,7 @@ export const FIELDS = { OPTIONS: { name: "Options", type: FieldType.OPTIONS, - icon: "Dropdown", + icon: TypeIconMap[FieldType.OPTIONS], constraints: { type: "string", presence: false, @@ -62,7 +64,7 @@ export const FIELDS = { ARRAY: { name: "Multi-select", type: FieldType.ARRAY, - icon: "Duplicate", + icon: TypeIconMap[FieldType.ARRAY], constraints: { type: "array", presence: false, @@ -72,7 +74,7 @@ export const FIELDS = { NUMBER: { name: "Number", type: FieldType.NUMBER, - icon: "123", + icon: TypeIconMap[FieldType.NUMBER], constraints: { type: "number", presence: false, @@ -82,12 +84,12 @@ export const FIELDS = { BIGINT: { name: "BigInt", type: FieldType.BIGINT, - icon: "TagBold", + icon: TypeIconMap[FieldType.BIGINT], }, BOOLEAN: { name: "Boolean", type: FieldType.BOOLEAN, - icon: "Boolean", + icon: TypeIconMap[FieldType.BOOLEAN], constraints: { type: "boolean", presence: false, @@ -96,7 +98,7 @@ export const FIELDS = { DATETIME: { name: "Date/Time", type: FieldType.DATETIME, - icon: "Calendar", + icon: TypeIconMap[FieldType.DATETIME], constraints: { type: "string", length: {}, @@ -110,7 +112,7 @@ export const FIELDS = { ATTACHMENT: { name: "Attachment", type: FieldType.ATTACHMENT, - icon: "Folder", + icon: TypeIconMap[FieldType.ATTACHMENT], constraints: { type: "array", presence: false, @@ -119,7 +121,7 @@ export const FIELDS = { LINK: { name: "Relationship", type: FieldType.LINK, - icon: "Link", + icon: TypeIconMap[FieldType.LINK], constraints: { type: "array", presence: false, @@ -128,19 +130,19 @@ export const FIELDS = { AUTO: { name: "Auto Column", type: FieldType.AUTO, - icon: "MagicWand", + icon: TypeIconMap[FieldType.AUTO], constraints: {}, }, FORMULA: { name: "Formula", type: FieldType.FORMULA, - icon: "Calculator", + icon: TypeIconMap[FieldType.FORMULA], constraints: {}, }, JSON: { name: "JSON", type: FieldType.JSON, - icon: "Brackets", + icon: TypeIconMap[FieldType.JSON], constraints: { type: "object", presence: false, @@ -150,13 +152,13 @@ export const FIELDS = { name: "User", type: FieldType.BB_REFERENCE, subtype: FieldSubtype.USER, - icon: "User", + icon: TypeIconMap[FieldType.USER], }, USERS: { name: "Users", type: FieldType.BB_REFERENCE, subtype: FieldSubtype.USERS, - icon: "User", + icon: TypeIconMap[FieldType.USERS], constraints: { type: "array", }, diff --git a/packages/frontend-core/src/components/grid/lib/utils.js b/packages/frontend-core/src/components/grid/lib/utils.js index 8382bfece8..c7c618e6f8 100644 --- a/packages/frontend-core/src/components/grid/lib/utils.js +++ b/packages/frontend-core/src/components/grid/lib/utils.js @@ -1,4 +1,4 @@ -import { FieldType, FieldTypeSubtypes } from "@budibase/types" +import { TypeIconMap } from "../../../constants" export const getColor = (idx, opacity = 0.3) => { if (idx == null || idx === -1) { @@ -7,26 +7,6 @@ export const getColor = (idx, opacity = 0.3) => { return `hsla(${((idx + 1) * 222) % 360}, 90%, 75%, ${opacity})` } -const TypeIconMap = { - [FieldType.STRING]: "Text", - [FieldType.OPTIONS]: "Dropdown", - [FieldType.DATETIME]: "Date", - [FieldType.BARCODEQR]: "Camera", - [FieldType.LONGFORM]: "TextAlignLeft", - [FieldType.ARRAY]: "Dropdown", - [FieldType.NUMBER]: "123", - [FieldType.BOOLEAN]: "Boolean", - [FieldType.ATTACHMENT]: "AppleFiles", - [FieldType.LINK]: "DataCorrelated", - [FieldType.FORMULA]: "Calculator", - [FieldType.JSON]: "Brackets", - [FieldType.BIGINT]: "TagBold", - [FieldType.BB_REFERENCE]: { - [FieldTypeSubtypes.BB_REFERENCE.USER]: "User", - [FieldTypeSubtypes.BB_REFERENCE.USERS]: "UserGroup", - }, -} - export const getColumnIcon = column => { if (column.schema.autocolumn) { return "MagicWand" diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index 68da439195..a05a0eeb7f 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -4,6 +4,7 @@ export { OperatorOptions, SqlNumberTypeRangeMap } from "@budibase/shared-core" export { Feature as Features } from "@budibase/types" import { BpmCorrelationKey } from "@budibase/shared-core" +import { FieldType, FieldTypeSubtypes } from "@budibase/types" // Cookie names export const Cookies = { @@ -113,3 +114,25 @@ export const ContextScopes = { Local: "local", Global: "global", } + +export const TypeIconMap = { + [FieldType.STRING]: "Text", + [FieldType.OPTIONS]: "Dropdown", + [FieldType.DATETIME]: "Date", + [FieldType.BARCODEQR]: "Camera", + [FieldType.LONGFORM]: "TextAlignLeft", + [FieldType.ARRAY]: "Dropdown", + [FieldType.NUMBER]: "123", + [FieldType.BOOLEAN]: "Boolean", + [FieldType.ATTACHMENT]: "AppleFiles", + [FieldType.LINK]: "DataCorrelated", + [FieldType.FORMULA]: "Calculator", + [FieldType.JSON]: "Brackets", + [FieldType.BIGINT]: "TagBold", + [FieldType.USER]: "User", + [FieldType.USERS]: "UserGroup", + [FieldType.BB_REFERENCE]: { + [FieldTypeSubtypes.BB_REFERENCE.USER]: "User", + [FieldTypeSubtypes.BB_REFERENCE.USERS]: "UserGroup", + }, +} From d821d04d5ba54c8311cd8bfad296e737840bd089 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:01:41 +0200 Subject: [PATCH 2/6] Change icon --- packages/frontend-core/src/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index a05a0eeb7f..de1f906ba9 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -121,7 +121,7 @@ export const TypeIconMap = { [FieldType.DATETIME]: "Date", [FieldType.BARCODEQR]: "Camera", [FieldType.LONGFORM]: "TextAlignLeft", - [FieldType.ARRAY]: "Dropdown", + [FieldType.ARRAY]: "Duplicate", [FieldType.NUMBER]: "123", [FieldType.BOOLEAN]: "Boolean", [FieldType.ATTACHMENT]: "AppleFiles", From 5cdbc75fef1dce318f6f15a88dd5ab13ad2de8b6 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:03:46 +0200 Subject: [PATCH 3/6] Change icon --- packages/frontend-core/src/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index de1f906ba9..94e1dce237 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -118,7 +118,7 @@ export const ContextScopes = { export const TypeIconMap = { [FieldType.STRING]: "Text", [FieldType.OPTIONS]: "Dropdown", - [FieldType.DATETIME]: "Date", + [FieldType.DATETIME]: "Calendar", [FieldType.BARCODEQR]: "Camera", [FieldType.LONGFORM]: "TextAlignLeft", [FieldType.ARRAY]: "Duplicate", From 61e235767dc2af88f6fdcb99a33a595f2c3c95c8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:06:53 +0200 Subject: [PATCH 4/6] Add auto icon --- packages/frontend-core/src/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index 94e1dce237..79b35bfb8e 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -129,6 +129,7 @@ export const TypeIconMap = { [FieldType.FORMULA]: "Calculator", [FieldType.JSON]: "Brackets", [FieldType.BIGINT]: "TagBold", + [FieldType.AUTO]: "MagicWand", [FieldType.USER]: "User", [FieldType.USERS]: "UserGroup", [FieldType.BB_REFERENCE]: { From 2322e430c47c484ec3abf7be04a846a6e6c5cf8f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:26:22 +0200 Subject: [PATCH 5/6] Lint --- packages/builder/src/constants/backend/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index e4736892b9..773e095f88 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -6,6 +6,7 @@ import { Hosting, } from "@budibase/types" import { Constants } from "@budibase/frontend-core" + const { TypeIconMap } = Constants export { RelationshipType } from "@budibase/types" From bc0b42bda6308d271cf426da057452e7da0b405a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:35:31 +0200 Subject: [PATCH 6/6] Fix test --- .../src/stores/builder/tests/sortedIntegrations.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/stores/builder/tests/sortedIntegrations.test.js b/packages/builder/src/stores/builder/tests/sortedIntegrations.test.js index 9b430b1621..d57aa19148 100644 --- a/packages/builder/src/stores/builder/tests/sortedIntegrations.test.js +++ b/packages/builder/src/stores/builder/tests/sortedIntegrations.test.js @@ -6,7 +6,10 @@ import { derived } from "svelte/store" import { integrations } from "stores/builder/integrations" vi.mock("svelte/store", () => ({ - derived: vi.fn(() => {}), + derived: vi.fn(), + writable: vi.fn(() => ({ + subscribe: vi.fn(), + })), })) vi.mock("stores/builder/integrations", () => ({ integrations: vi.fn() }))