Skip to content

Commit

Permalink
feat(frontend): add missing date in the previous run panel (#3693)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatonramadani authored May 9, 2024
1 parent 630ae7e commit 49867c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 8 additions & 3 deletions frontend/src/lib/components/SavedInputs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
type Job
} from '$lib/gen/index.js'
import { userStore, workspaceStore } from '$lib/stores.js'
import { classNames, displayDate, sendUserToast } from '$lib/utils.js'
import { classNames, displayDate, displayDateOnly, sendUserToast } from '$lib/utils.js'
import { createEventDispatcher } from 'svelte'
import { Pane, Splitpanes } from 'svelte-splitpanes'
import ObjectViewer from './propertyPicker/ObjectViewer.svelte'
Expand Down Expand Up @@ -377,11 +377,16 @@
{i.created_by}
</div>
<div
class="whitespace-nowrap col-span-3 !text-tertiary !text-2xs overflow-hidden text-ellipsis flex-shrink text-center"
class="whitespace-nowrap col-span-2 !text-tertiary !text-2xs overflow-hidden text-ellipsis flex-shrink text-center"
>
{displayDateOnly(new Date(i.created_at))}
</div>
<div
class="whitespace-nowrap col-span-2 !text-tertiary !text-2xs overflow-hidden text-ellipsis flex-shrink text-center"
>
<TimeAgo date={i.created_at ?? ''} />
</div>
<div class="col-span-2">
<div class="col-span-1">
<a
target="_blank"
href="/run/{i.id}?workspace={$workspaceStore}"
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ export function parseQueryParams(url: string | undefined) {
return params
}

export function displayDateOnly(dateString: string | Date | undefined): string {
const date = new Date(dateString ?? '')
if (date.toString() === 'Invalid Date') {
return ''
} else {
return date.toLocaleDateString([], {
year: 'numeric',
month: '2-digit',
day: '2-digit'
})
}
}

export function displayDate(
dateString: string | Date | undefined,
displaySecond = false,
Expand Down

0 comments on commit 49867c0

Please sign in to comment.