From 2aa40c413e3ecda57b17fb8aada2bf28070ffa00 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 14 Aug 2024 02:09:22 +0200 Subject: [PATCH] nits whitelabel --- .../lib/components/FlowStatusViewer.svelte | 2 ++ .../components/FlowStatusViewerInner.svelte | 23 +++++++------ .../lib/components/common/table/AppRow.svelte | 3 +- .../components/common/table/FlowRow.svelte | 4 ++- .../components/common/table/RawAppRow.svelte | 2 +- .../components/common/table/ScriptRow.svelte | 4 ++- frontend/src/lib/components/home/Item.svelte | 2 +- frontend/src/lib/forLater.ts | 12 ++++--- frontend/src/lib/utils.ts | 32 ------------------ frontend/src/lib/utils_deployable.ts | 33 +++++++++++++++++++ .../(logged)/flows/get/[...path]/+page.svelte | 3 +- .../(root)/(logged)/resources/+page.svelte | 4 ++- .../scripts/get/[...hash]/+page.svelte | 19 +++++------ .../(root)/(logged)/variables/+page.svelte | 3 +- 14 files changed, 82 insertions(+), 64 deletions(-) create mode 100644 frontend/src/lib/utils_deployable.ts diff --git a/frontend/src/lib/components/FlowStatusViewer.svelte b/frontend/src/lib/components/FlowStatusViewer.svelte index d9daaaddfa597..35ca42b60803f 100644 --- a/frontend/src/lib/components/FlowStatusViewer.svelte +++ b/frontend/src/lib/components/FlowStatusViewer.svelte @@ -11,6 +11,7 @@ export let workspaceId: string | undefined = undefined export let flowStateStore: Writable = writable({}) export let selectedJobStep: string | undefined = undefined + export let hideFlowResult = false export let isOwner = false export let wideResults = false @@ -45,6 +46,7 @@ { let { job } = detail if (job.script_path != lastScriptPath && job.script_path) { diff --git a/frontend/src/lib/components/FlowStatusViewerInner.svelte b/frontend/src/lib/components/FlowStatusViewerInner.svelte index bc4fe65e62d45..c875fd1e30fd1 100644 --- a/frontend/src/lib/components/FlowStatusViewerInner.svelte +++ b/frontend/src/lib/components/FlowStatusViewerInner.svelte @@ -69,6 +69,7 @@ export let reducedPolling = false export let wideResults = false + export let hideFlowResult = false let jobResults: any[] = flowJobIds?.flowJobs?.map((x, id) => `iter #${id + 1} not loaded by frontend yet`) ?? [] @@ -642,16 +643,18 @@ {:else if `result` in job} -
- -
+ {#if !hideFlowResult} +
+ +
+ {/if} {:else if job.flow_status?.modules?.[job?.flow_status?.step]?.type === 'WaitingForEvents'} {:else if $suspendStatus && Object.keys($suspendStatus).length > 0} diff --git a/frontend/src/lib/components/common/table/AppRow.svelte b/frontend/src/lib/components/common/table/AppRow.svelte index 93afe04815f32..1ec6540b855ac 100644 --- a/frontend/src/lib/components/common/table/AppRow.svelte +++ b/frontend/src/lib/components/common/table/AppRow.svelte @@ -33,9 +33,10 @@ import { goto as gotoUrl } from '$app/navigation' import { page } from '$app/stores' import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte' - import { DELETE, copyToClipboard, isDeployable } from '$lib/utils' + import { DELETE, copyToClipboard } from '$lib/utils' import AppDeploymentHistory from '$lib/components/apps/editor/AppDeploymentHistory.svelte' import AppJsonEditor from '$lib/components/apps/editor/AppJsonEditor.svelte' + import { isDeployable } from '$lib/utils_deployable' export let app: ListableApp & { has_draft?: boolean; draft_only?: boolean; canWrite: boolean } export let marked: string | undefined diff --git a/frontend/src/lib/components/common/table/FlowRow.svelte b/frontend/src/lib/components/common/table/FlowRow.svelte index ab73ba060ec3d..6e96465f02b6f 100644 --- a/frontend/src/lib/components/common/table/FlowRow.svelte +++ b/frontend/src/lib/components/common/table/FlowRow.svelte @@ -14,7 +14,9 @@ import Row from './Row.svelte' import DraftBadge from '$lib/components/DraftBadge.svelte' import { sendUserToast } from '$lib/toast' - import { DELETE, copyToClipboard, isDeployable, isOwner } from '$lib/utils' + import { DELETE, copyToClipboard, isOwner } from '$lib/utils' + import { isDeployable } from '$lib/utils_deployable' + import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte' import { Pen, diff --git a/frontend/src/lib/components/common/table/RawAppRow.svelte b/frontend/src/lib/components/common/table/RawAppRow.svelte index 615de50e64c7b..e40f59a76f25e 100644 --- a/frontend/src/lib/components/common/table/RawAppRow.svelte +++ b/frontend/src/lib/components/common/table/RawAppRow.svelte @@ -15,7 +15,7 @@ import { goto } from '$lib/navigation' import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte' import { FileUp, Globe, Pen, Share, Trash } from 'lucide-svelte' - import { isDeployable } from '$lib/utils' + import { isDeployable } from '$lib/utils_deployable' export let app: ListableRawApp & { canWrite: boolean } export let marked: string | undefined diff --git a/frontend/src/lib/components/common/table/ScriptRow.svelte b/frontend/src/lib/components/common/table/ScriptRow.svelte index 12acd2774ca27..a962e17c32218 100644 --- a/frontend/src/lib/components/common/table/ScriptRow.svelte +++ b/frontend/src/lib/components/common/table/ScriptRow.svelte @@ -21,7 +21,9 @@ import Row from './Row.svelte' import DraftBadge from '$lib/components/DraftBadge.svelte' import { sendUserToast } from '$lib/toast' - import { copyToClipboard, DELETE, isDeployable, isOwner } from '$lib/utils' + import { copyToClipboard, DELETE, isOwner } from '$lib/utils' + import { isDeployable } from '$lib/utils_deployable' + import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte' import { LanguageIcon } from '../languageIcons' import { diff --git a/frontend/src/lib/components/home/Item.svelte b/frontend/src/lib/components/home/Item.svelte index 2e7b3c6967632..ccaabb68b0eee 100644 --- a/frontend/src/lib/components/home/Item.svelte +++ b/frontend/src/lib/components/home/Item.svelte @@ -12,7 +12,7 @@ import { ArrowBigUp } from 'lucide-svelte' import { enterpriseLicense, workspaceStore } from '$lib/stores' import { WorkspaceService, type WorkspaceDeployUISettings } from '$lib/gen' - import { ALL_DEPLOYABLE } from '$lib/utils' + import { ALL_DEPLOYABLE } from '$lib/utils_deployable' export let item export let depth: number = 0 diff --git a/frontend/src/lib/forLater.ts b/frontend/src/lib/forLater.ts index ecbf2215452d1..ea290e2a530e2 100644 --- a/frontend/src/lib/forLater.ts +++ b/frontend/src/lib/forLater.ts @@ -1,6 +1,7 @@ import { get } from 'svelte/store' import { dbClockDrift } from './stores' import { JobService } from './gen' +import pLimit from 'p-limit' function subtractSeconds(date: Date, seconds: number): Date { date.setSeconds(date.getSeconds() - seconds) @@ -12,19 +13,22 @@ function adjustDate(drift: number): Date { } export async function computeDrift() { - const now = Date.now() - const dbClock = await JobService.getDbClock() - dbClockDrift.set(dbClock - now) + if (get(dbClockDrift) == undefined) { + const now = Date.now() + const dbClock = await JobService.getDbClock() + dbClockDrift.set(dbClock - now) + } } export function forLater(scheduledString: string): boolean { return getDbClockNow() < subtractSeconds(new Date(scheduledString), 5) } +const limit = pLimit(1) export function getDbClockNow() { let drift = get(dbClockDrift) if (drift == undefined) { - computeDrift() + limit(() => computeDrift()) drift = 0 } return adjustDate(drift) diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 896e3a73a458e..1a278c9c79e65 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -14,7 +14,6 @@ import { sendUserToast } from './toast' import type { Script, WorkspaceDeployUISettings } from './gen' import type { EnumType, SchemaProperty } from './common' import type { Schema } from './common' -import { minimatch } from 'minimatch' export { sendUserToast } export function validateUsername(username: string): string { @@ -941,34 +940,3 @@ export function getSchemaFromProperties(properties: { [name: string]: SchemaProp order: Object.keys(properties).filter((k) => k !== 'label') } } - -type DeployUIType = 'script' | 'flow' | 'app' | 'resource' | 'variable' | 'secret' - -export function isDeployable( - type: DeployUIType, - path: string, - deployUiSettings: WorkspaceDeployUISettings | undefined -) { - if (deployUiSettings == undefined) { - return false - } - - if (deployUiSettings.include_type != undefined && !deployUiSettings.include_type.includes(type)) { - return false - } - - if ( - deployUiSettings.include_path != undefined && - deployUiSettings.include_path.length != 0 && - deployUiSettings.include_path.every((x) => !minimatch(path, x)) - ) { - return false - } - - return true -} - -export const ALL_DEPLOYABLE: WorkspaceDeployUISettings = { - include_path: [], - include_type: ['script', 'flow', 'app', 'resource', 'variable', 'secret'] -} diff --git a/frontend/src/lib/utils_deployable.ts b/frontend/src/lib/utils_deployable.ts new file mode 100644 index 0000000000000..9a8efc6ef8746 --- /dev/null +++ b/frontend/src/lib/utils_deployable.ts @@ -0,0 +1,33 @@ +import { minimatch } from 'minimatch' +import type { WorkspaceDeployUISettings } from './gen' + +type DeployUIType = 'script' | 'flow' | 'app' | 'resource' | 'variable' | 'secret' + +export function isDeployable( + type: DeployUIType, + path: string, + deployUiSettings: WorkspaceDeployUISettings | undefined +) { + if (deployUiSettings == undefined) { + return false + } + + if (deployUiSettings.include_type != undefined && !deployUiSettings.include_type.includes(type)) { + return false + } + + if ( + deployUiSettings.include_path != undefined && + deployUiSettings.include_path.length != 0 && + deployUiSettings.include_path.every((x) => !minimatch(path, x)) + ) { + return false + } + + return true +} + +export const ALL_DEPLOYABLE: WorkspaceDeployUISettings = { + include_path: [], + include_type: ['script', 'flow', 'app', 'resource', 'variable', 'secret'] +} diff --git a/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte index 76973ddeac536..eeea7c7ff767a 100644 --- a/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte @@ -8,7 +8,8 @@ type FlowModule, type WorkspaceDeployUISettings } from '$lib/gen' - import { ALL_DEPLOYABLE, canWrite, defaultIfEmptyString, emptyString, isDeployable } from '$lib/utils' + import { canWrite, defaultIfEmptyString, emptyString } from '$lib/utils' + import { isDeployable, ALL_DEPLOYABLE } from '$lib/utils_deployable' import DetailPageLayout from '$lib/components/details/DetailPageLayout.svelte' import { goto } from '$lib/navigation' diff --git a/frontend/src/routes/(root)/(logged)/resources/+page.svelte b/frontend/src/routes/(root)/(logged)/resources/+page.svelte index 14cf5166a806e..87b5b0cd4bff7 100644 --- a/frontend/src/routes/(root)/(logged)/resources/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/resources/+page.svelte @@ -31,7 +31,9 @@ import { OauthService, ResourceService, WorkspaceService, type ListableResource } from '$lib/gen' import { enterpriseLicense, userStore, workspaceStore } from '$lib/stores' import { sendUserToast } from '$lib/toast' - import { ALL_DEPLOYABLE, canWrite, classNames, emptySchema, isDeployable, removeMarkdown, truncate } from '$lib/utils' + import { canWrite, classNames, emptySchema, removeMarkdown, truncate } from '$lib/utils' + import { isDeployable, ALL_DEPLOYABLE } from '$lib/utils_deployable' + import { convert } from '@redocly/json-to-json-schema' import { Braces, diff --git a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte index bdf1ffca5a53c..0b7229d65fd89 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte @@ -1,20 +1,19 @@