Skip to content

Commit

Permalink
nits whitelabel
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Aug 14, 2024
1 parent 9363e6d commit 2aa40c4
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 64 deletions.
2 changes: 2 additions & 0 deletions frontend/src/lib/components/FlowStatusViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
export let workspaceId: string | undefined = undefined
export let flowStateStore: Writable<FlowState> = writable({})
export let selectedJobStep: string | undefined = undefined
export let hideFlowResult = false
export let isOwner = false
export let wideResults = false
Expand Down Expand Up @@ -45,6 +46,7 @@
</script>

<FlowStatusViewerInner
{hideFlowResult}
on:jobsLoaded={({ detail }) => {
let { job } = detail
if (job.script_path != lastScriptPath && job.script_path) {
Expand Down
23 changes: 13 additions & 10 deletions frontend/src/lib/components/FlowStatusViewerInner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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`) ?? []
Expand Down Expand Up @@ -642,16 +643,18 @@
<Loader2 class="animate-spin" />
</div>
{:else if `result` in job}
<div class="w-full h-full">
<FlowJobResult
workspaceId={job?.workspace_id}
jobId={job?.id}
loading={job['running'] == true}
result={job.result}
logs={job.logs}
durationStates={localDurationStatuses}
/>
</div>
{#if !hideFlowResult}
<div class="w-full h-full">
<FlowJobResult
workspaceId={job?.workspace_id}
jobId={job?.id}
loading={job['running'] == true}
result={job.result}
logs={job.logs}
durationStates={localDurationStatuses}
/>
</div>
{/if}
{:else if job.flow_status?.modules?.[job?.flow_status?.step]?.type === 'WaitingForEvents'}
<FlowStatusWaitingForEvents {workspaceId} {job} {isOwner} />
{:else if $suspendStatus && Object.keys($suspendStatus).length > 0}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/components/common/table/AppRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/lib/components/common/table/FlowRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/common/table/RawAppRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/lib/components/common/table/ScriptRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/home/Item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/lib/forLater.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down
32 changes: 0 additions & 32 deletions frontend/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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']
}
33 changes: 33 additions & 0 deletions frontend/src/lib/utils_deployable.ts
Original file line number Diff line number Diff line change
@@ -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']
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/routes/(root)/(logged)/resources/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<script lang="ts">
import { page } from '$app/stores'
import { base } from '$lib/base'
import { JobService, ScriptService, WorkspaceService, type Script, type WorkspaceDeployUISettings } from '$lib/gen'
import {
defaultIfEmptyString,
emptyString,
canWrite,
truncateHash,
isDeployable,
ALL_DEPLOYABLE
} from '$lib/utils'
JobService,
ScriptService,
WorkspaceService,
type Script,
type WorkspaceDeployUISettings
} from '$lib/gen'
import { defaultIfEmptyString, emptyString, canWrite, truncateHash } from '$lib/utils'
import Tooltip from '$lib/components/Tooltip.svelte'
import ShareModal from '$lib/components/ShareModal.svelte'
import { enterpriseLicense, hubBaseUrlStore, userStore, workspaceStore } from '$lib/stores'
import { isDeployable, ALL_DEPLOYABLE } from '$lib/utils_deployable'
import SchemaViewer from '$lib/components/SchemaViewer.svelte'
import { onDestroy } from 'svelte'
import HighlightCode from '$lib/components/HighlightCode.svelte'
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/routes/(root)/(logged)/variables/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import { OauthService, VariableService, WorkspaceService } from '$lib/gen'
import { enterpriseLicense, userStore, workspaceStore } from '$lib/stores'
import { sendUserToast } from '$lib/toast'
import { ALL_DEPLOYABLE, canWrite, isDeployable, isOwner, truncate } from '$lib/utils'
import { canWrite, isOwner, truncate } from '$lib/utils'
import { isDeployable, ALL_DEPLOYABLE } from '$lib/utils_deployable'
import {
Plus,
FileUp,
Expand Down

0 comments on commit 2aa40c4

Please sign in to comment.