standardize date display

This commit is contained in:
Ruben Fiszel
2024-06-04 16:55:55 +02:00
parent a9bf5a4683
commit 4408e4fb86
8 changed files with 16 additions and 7 deletions
@@ -25,7 +25,7 @@
{#if job['success'] != undefined}
Received job: {displayDate(job.created_at ?? '')}
{:else}
Received job <TimeAgo date={job.created_at ?? ''} />
Received job <TimeAgo withDate date={job.created_at ?? ''} />
{/if}
<Tooltip small>{job?.created_at}</Tooltip>
</span>
+1 -1
View File
@@ -89,7 +89,7 @@
<div class="flex items-center gap-2">
<span class="text-sm text-tertiary">
{#if runnable}
Edited <TimeAgo date={runnable.created_at || ''} /> by {runnable.created_by ||
Edited <TimeAgo withDate date={runnable.created_at || ''} /> by {runnable.created_by ||
'unknown'}
{/if}
</span>
@@ -168,7 +168,7 @@
</button>
{/if}
</span>
<FlowModuleScript path={scriptPath} hash={selectedVersion.script_hash} />
<FlowModuleScript showDate path={scriptPath} hash={selectedVersion.script_hash} />
</div>
{/key}
{:else}
@@ -414,7 +414,7 @@
type Callbacks = { done: (x: any) => void; cancel: () => void; error: (e: any) => void }
export async function runComponent(
noToast = false,
noToast = true,
inlineScriptOverride?: InlineScript,
setRunnableJobEditorPanel?: boolean,
dynamicArgsOverride?: Record<string, any>,
@@ -1,6 +1,7 @@
<script lang="ts">
import type { SupportedLanguage } from '$lib/common'
import HighlightCode from '$lib/components/HighlightCode.svelte'
import TimeAgo from '$lib/components/TimeAgo.svelte'
import { ScriptService } from '$lib/gen'
import { getScriptByPath } from '$lib/scripts'
import { workspaceStore } from '$lib/stores'
@@ -8,9 +9,11 @@
export let path: string
export let hash: string | undefined = undefined
export let showDate = false
let code: string
let language: SupportedLanguage
let lock: string | undefined = undefined
let date: string | undefined = undefined
let notFound = false
async function loadCode(path: string, hash: string | undefined) {
@@ -22,6 +25,7 @@
code = script.content
language = script.language
lock = script.lock
date = script.created_at
} catch (e) {
notFound = true
console.error(e)
@@ -32,6 +36,9 @@
</script>
<div class="flex flex-col flex-1 h-full overflow-auto p-2">
{#if showDate && date}
<span class="text-xs text-tertiary mb-4"><TimeAgo {date} /></span>
{/if}
{#if notFound}
<div class="text-red-400">script not found at {path} in workspace {$workspaceStore}</div>
{:else}
+3 -1
View File
@@ -119,6 +119,7 @@ export async function getScriptByPath(path: string): Promise<{
concurrent_limit: number | undefined
concurrency_time_window_s: number | undefined
lock?: string
created_at?: string
}> {
if (path.startsWith('hub/')) {
const { content, language, schema, lockfile } = await ScriptService.getHubScriptByPath({ path })
@@ -146,7 +147,8 @@ export async function getScriptByPath(path: string): Promise<{
tag: script.tag,
concurrent_limit: script.concurrent_limit,
concurrency_time_window_s: script.concurrency_time_window_s,
lock: script.lock
lock: script.lock,
created_at: script.created_at
}
}
}
@@ -375,7 +375,7 @@
{/if}
<div class="flex flex-row gap-x-2 flex-wrap items-center">
<span class="text-sm text-tertiary">
Edited <TimeAgo date={flow.edited_at ?? ''} /> by {flow.edited_by}
Edited <TimeAgo withDate date={flow.edited_at ?? ''} /> by {flow.edited_by}
</span>
{#if flow.archived}
@@ -607,7 +607,7 @@
{/if}
<div class="flex flex-row gap-x-2 flex-wrap items-center">
<span class="text-sm text-tertiary">
Edited <TimeAgo date={script.created_at || ''} /> by {script.created_by || 'unknown'}
Edited <TimeAgo withDate date={script.created_at || ''} /> by {script.created_by || 'unknown'}
</span>
<Badge small color="gray">
{truncateHash(script?.hash ?? '')}