From aa0389e8bdbef8d88ae14082d860363eb3c68350 Mon Sep 17 00:00:00 2001 From: Conor Webb <126772285+ConorWebb96@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:58:03 +0000 Subject: [PATCH 1/3] Added text colour option to tag component via manifest (#13215) * Added new colour select textColor to tag component manifest * Intergrated textColor into tag component * Reverted default text colour to white, avoids issues with the internal use * Updated conditional colour set --- packages/client/manifest.json | 6 ++++++ packages/client/src/components/app/Tag.svelte | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 10f9c5f412..531e2c968a 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -1137,6 +1137,12 @@ "key": "color", "showInBar": true }, + { + "type": "color", + "label": "Text Color", + "key": "textColor", + "showInBar": true + }, { "type": "boolean", "label": "Allow delete", diff --git a/packages/client/src/components/app/Tag.svelte b/packages/client/src/components/app/Tag.svelte index 2d0a26ac71..4644161506 100644 --- a/packages/client/src/components/app/Tag.svelte +++ b/packages/client/src/components/app/Tag.svelte @@ -6,6 +6,7 @@ export let onClick export let text = "" export let color + export let textColor export let closable = false export let size = "M" @@ -14,7 +15,7 @@ // Add color styles to main styles object, otherwise the styleable helper // overrides the color when it's passed as inline style. - $: styles = enrichStyles($component.styles, color) + $: styles = enrichStyles($component.styles, color, textColor) $: componentText = getComponentText(text, $builderStore, $component) const getComponentText = (text, builderState, componentState) => { @@ -24,7 +25,7 @@ return text || componentState.name || "Placeholder text" } - const enrichStyles = (styles, color) => { + const enrichStyles = (styles, color, textColor) => { if (!color) { return styles } @@ -34,7 +35,7 @@ ...styles?.normal, "background-color": color, "border-color": color, - color: "white", + color: textColor || "white", "--spectrum-clearbutton-medium-icon-color": "white", }, } From 9027e6e82aa23b53bd09f63c32652a2a85c345f4 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Fri, 8 Mar 2024 12:20:52 +0000 Subject: [PATCH 2/3] Initing doc writethrough cache as part of the worker/server init process, as well as part of doc writethrough tests. --- .../backend-core/src/cache/docWritethrough.ts | 15 +++++++++++++-- .../src/cache/tests/docWritethrough.spec.ts | 6 ++++++ packages/server/src/startup.ts | 2 ++ packages/worker/src/index.ts | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/backend-core/src/cache/docWritethrough.ts b/packages/backend-core/src/cache/docWritethrough.ts index 51018b2317..1b129bb26a 100644 --- a/packages/backend-core/src/cache/docWritethrough.ts +++ b/packages/backend-core/src/cache/docWritethrough.ts @@ -10,6 +10,7 @@ interface ProcessDocMessage { } const PERSIST_MAX_ATTEMPTS = 100 +let processor: DocWritethroughProcessor | undefined export const docWritethroughProcessorQueue = createQueue( JobQueue.DOC_WRITETHROUGH_QUEUE, @@ -61,8 +62,6 @@ class DocWritethroughProcessor { } } -export const processor = new DocWritethroughProcessor().init() - export class DocWritethrough { private db: Database private _docId: string @@ -84,3 +83,15 @@ export class DocWritethrough { }) } } + +export function init(): DocWritethroughProcessor { + processor = new DocWritethroughProcessor().init() + return processor +} + +export function getProcessor(): DocWritethroughProcessor { + if (!processor) { + return init() + } + return processor +} diff --git a/packages/backend-core/src/cache/tests/docWritethrough.spec.ts b/packages/backend-core/src/cache/tests/docWritethrough.spec.ts index d90c83afd3..bdab805db6 100644 --- a/packages/backend-core/src/cache/tests/docWritethrough.spec.ts +++ b/packages/backend-core/src/cache/tests/docWritethrough.spec.ts @@ -7,6 +7,7 @@ import { getDB } from "../../db" import { DocWritethrough, docWritethroughProcessorQueue, + init, } from "../docWritethrough" import InMemoryQueue from "../../queue/inMemoryQueue" @@ -19,6 +20,11 @@ async function waitForQueueCompletion() { } describe("docWritethrough", () => { + + beforeAll(() => { + init() + }) + const config = new DBTestConfiguration() const db = getDB(structures.db.id()) diff --git a/packages/server/src/startup.ts b/packages/server/src/startup.ts index abe931f503..2cedda1099 100644 --- a/packages/server/src/startup.ts +++ b/packages/server/src/startup.ts @@ -7,6 +7,7 @@ import { logging, tenancy, users, + cache, } from "@budibase/backend-core" import fs from "fs" import { watch } from "./watch" @@ -74,6 +75,7 @@ export async function startup(app?: Koa, server?: Server) { eventEmitter.emitPort(env.PORT) fileSystem.init() await redis.init() + cache.docWritethrough.init() eventInit() if (app && server) { initialiseWebsockets(app, server) diff --git a/packages/worker/src/index.ts b/packages/worker/src/index.ts index 3da9a42065..4e770c6ecb 100644 --- a/packages/worker/src/index.ts +++ b/packages/worker/src/index.ts @@ -17,6 +17,7 @@ import { env as coreEnv, timers, redis, + cache, } from "@budibase/backend-core" db.init() @@ -90,6 +91,7 @@ export default server.listen(parseInt(env.PORT || "4002"), async () => { console.log(`Worker running on ${JSON.stringify(server.address())}`) await initPro() await redis.clients.init() + cache.docWritethrough.init() // configure events to use the pro audit log write // can't integrate directly into backend-core due to cyclic issues await events.processors.init(proSdk.auditLogs.write) From 874a6fbd1254907eb7b8ab7d8b3152ddd732023c Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Fri, 8 Mar 2024 12:26:11 +0000 Subject: [PATCH 3/3] Linting. --- packages/backend-core/src/cache/tests/docWritethrough.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/backend-core/src/cache/tests/docWritethrough.spec.ts b/packages/backend-core/src/cache/tests/docWritethrough.spec.ts index bdab805db6..5fe09b95ff 100644 --- a/packages/backend-core/src/cache/tests/docWritethrough.spec.ts +++ b/packages/backend-core/src/cache/tests/docWritethrough.spec.ts @@ -20,7 +20,6 @@ async function waitForQueueCompletion() { } describe("docWritethrough", () => { - beforeAll(() => { init() })