From a0acdc1217967562bb349a2b718c82af74b8bc45 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Thu, 23 May 2024 20:36:39 +0200 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20Add=20missing=20loading=20stat?= =?UTF-8?q?e=20for=20non-runnable=20components=20=E2=80=A6=20(#3797)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(frontend): Add missing loading state for non-runnable components + fix select and aggrid styling * fix(frontend): remove log * fix(frontend): improve code * fix(frontend): improve code * fix(frontend): Fix refreshIndicator styling --- .../display/table/AppAggridTable.svelte | 4 +- .../display/table/theme/windmill-theme.css | 2 +- .../helpers/NonRunnableComponent.svelte | 46 ++++++++++++++++++- .../helpers/RefreshIndicator.svelte | 21 +++++++++ .../apps/components/inputs/AppSelect.svelte | 4 +- frontend/src/lib/components/apps/rx.ts | 10 +++- frontend/src/lib/defaults.ts | 5 +- 7 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 frontend/src/lib/components/apps/components/helpers/RefreshIndicator.svelte diff --git a/frontend/src/lib/components/apps/components/display/table/AppAggridTable.svelte b/frontend/src/lib/components/apps/components/display/table/AppAggridTable.svelte index 59c990c1c3635..f46412a223042 100644 --- a/frontend/src/lib/components/apps/components/display/table/AppAggridTable.svelte +++ b/frontend/src/lib/components/apps/components/display/table/AppAggridTable.svelte @@ -304,8 +304,8 @@ $componentControl[id] = { agGrid: { api: e.api, columnApi: e.columnApi }, setSelectedIndex: (index) => { - if(index === null) { - e.api.deselectAll(); + if (index === null) { + e.api.deselectAll() outputs?.selectedRow?.set({}) outputs?.selectedRowIndex.set(0) } else { diff --git a/frontend/src/lib/components/apps/components/display/table/theme/windmill-theme.css b/frontend/src/lib/components/apps/components/display/table/theme/windmill-theme.css index 2a4bd70cf0191..577604d290159 100644 --- a/frontend/src/lib/components/apps/components/display/table/theme/windmill-theme.css +++ b/frontend/src/lib/components/apps/components/display/table/theme/windmill-theme.css @@ -7,7 +7,7 @@ .ag-theme-alpine, .ag-theme-alpine-dark, .ag-theme-alpine-auto-dark { - --ag-alpine-active-color: rgb(255, 239, 254); + --ag-alpine-active-color: rgb(96, 165, 250); --ag-selected-row-background-color: rgb(219, 234, 254, 0.5); --ag-row-hover-color: rgb(191, 219, 254, 0.5); --ag-column-hover-color: rgba(33, 150, 243, 0.1); diff --git a/frontend/src/lib/components/apps/components/helpers/NonRunnableComponent.svelte b/frontend/src/lib/components/apps/components/helpers/NonRunnableComponent.svelte index 8a7a19fe9023d..d183a5eef78df 100644 --- a/frontend/src/lib/components/apps/components/helpers/NonRunnableComponent.svelte +++ b/frontend/src/lib/components/apps/components/helpers/NonRunnableComponent.svelte @@ -1,10 +1,11 @@ @@ -39,6 +80,9 @@ {#if render || hasChildrens}
+
+ +
{:else}
diff --git a/frontend/src/lib/components/apps/components/helpers/RefreshIndicator.svelte b/frontend/src/lib/components/apps/components/helpers/RefreshIndicator.svelte new file mode 100644 index 0000000000000..020385c8ae3a9 --- /dev/null +++ b/frontend/src/lib/components/apps/components/helpers/RefreshIndicator.svelte @@ -0,0 +1,21 @@ + + +{#if loading} + +
+ +
+ + {#if loading} + Refreshing... + {:else} + Refresh + {/if} + +
+{/if} diff --git a/frontend/src/lib/components/apps/components/inputs/AppSelect.svelte b/frontend/src/lib/components/apps/components/inputs/AppSelect.svelte index 73cbb05b3cadb..8cc19b9edbd72 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppSelect.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppSelect.svelte @@ -21,7 +21,6 @@ import { Bug } from 'lucide-svelte' import Popover from '$lib/components/Popover.svelte' import ResolveStyle from '../helpers/ResolveStyle.svelte' - import { twMerge } from 'tailwind-merge' export let id: string export let configuration: RichConfigurations @@ -227,6 +226,7 @@ inAppEditor={true} --border-radius="0.250rem" --clear-icon-color="#6b7280" + --border={$darkMode ? '1px solid #6b7280' : '1px solid #d1d5db'} bind:filterText on:filter={handleFilter} on:clear={onClear} @@ -238,7 +238,7 @@ ? SELECT_INPUT_DEFAULT_STYLE.containerStylesDark : SELECT_INPUT_DEFAULT_STYLE.containerStyles) + css?.input?.style} {value} - class={twMerge($darkMode ? '!border-gray-500' : '!border-gray-300', css?.input?.class)} + class={css?.input?.class} placeholder={resolvedConfig.placeholder} disabled={resolvedConfig.disabled} on:focus={() => { diff --git a/frontend/src/lib/components/apps/rx.ts b/frontend/src/lib/components/apps/rx.ts index a8ff8308a48a5..16b795817a38a 100644 --- a/frontend/src/lib/components/apps/rx.ts +++ b/frontend/src/lib/components/apps/rx.ts @@ -8,7 +8,7 @@ export interface Subscriber { } export interface Observable { - subscribe(x: Subscriber, previousValue: T): void + subscribe(x: Subscriber, previousValue: T): () => void } export interface Output extends Observable { set(x: T, force?: boolean): void @@ -154,6 +154,14 @@ export function settableOutput(state: Writable, previousValue: T): Ou if (value !== undefined && !deepEqual(value, npreviousValue)) { x.next(value) } + + // return a callback to unsubscribe + return () => { + const index = subscribers.findIndex((y) => y === x || (y.id && y.id === x.id)) + if (index !== -1) { + subscribers.splice(index, 1) + } + } } let lastHash: any = undefined diff --git a/frontend/src/lib/defaults.ts b/frontend/src/lib/defaults.ts index 0e76a226c169a..03674449820ff 100644 --- a/frontend/src/lib/defaults.ts +++ b/frontend/src/lib/defaults.ts @@ -1,7 +1,6 @@ export const SELECT_INPUT_DEFAULT_STYLE = { inputStyles: 'border-radius: 0;', - containerStyles: - '--height: 34px; --padding: 0 0 0 8px; --font-size: 0.875rem; --border: 1px solid #d1d5db;', + containerStyles: '--height: 34px; --padding: 0 0 0 8px; --font-size: 0.875rem;', containerStylesDark: - '--height: 34px; --padding: 0 0 0 8px; --font-size: 0.875rem; --border: 1px solid #374151; --background: #3b4252; --disabled-background: #2a2f3a; --list-background: #3b4252;--item-is-active-bg:#434c5e;--item-hover-bg:#4c566a;' + '--height: 34px; --padding: 0 0 0 8px; --font-size: 0.875rem; --background: #3b4252; --disabled-background: #2a2f3a; --list-background: #3b4252;--item-is-active-bg:#434c5e;--item-hover-bg:#4c566a;' } as const