-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard):
WfSpec
var values are shown for current ThreadRun
(
#850)
- Loading branch information
Showing
6 changed files
with
86 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
dashboard/src/app/(authenticated)/(diagram)/hooks/useReplaceQueryValue.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { usePathname, useSearchParams } from 'next/navigation' | ||
import { useCallback } from 'react' | ||
|
||
export const useReplaceQueryValue = () => { | ||
const pathname = usePathname() | ||
const searchParams = useSearchParams() | ||
|
||
// Get a new searchParams string by merging the current | ||
// searchParams with a provided key/value pair | ||
return useCallback( | ||
(name: string, value: string) => { | ||
const params = new URLSearchParams(searchParams.toString()) | ||
params.set(name, value) | ||
|
||
return pathname + '?' + params.toString() | ||
}, | ||
[pathname, searchParams] | ||
) | ||
} |
39 changes: 39 additions & 0 deletions
39
dashboard/src/app/(authenticated)/(diagram)/wfRun/[...ids]/components/Variables.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { VARIABLE_TYPES } from '@/app/constants' | ||
import { getVariableValue } from '@/app/utils' | ||
import { Variable } from 'littlehorse-client/dist/proto/variable' | ||
import { ThreadVarDef, WfRunVariableAccessLevel } from 'littlehorse-client/dist/proto/wf_spec' | ||
import { FC } from 'react' | ||
|
||
type VariablesProps = { | ||
variableDefs: ThreadVarDef[] | ||
variables: Variable[] | ||
} | ||
|
||
const accessLevels: { [key in WfRunVariableAccessLevel]: string } = { | ||
PUBLIC_VAR: 'Public', | ||
INHERITED_VAR: 'Inherited', | ||
PRIVATE_VAR: 'Private', | ||
UNRECOGNIZED: '', | ||
} | ||
|
||
export const Variables: FC<VariablesProps> = ({ variableDefs, variables }) => { | ||
if (variableDefs.length === 0) return <></> | ||
return ( | ||
<div className=""> | ||
<h2 className="text-md mb-2 font-bold">Variables</h2> | ||
{variableDefs.map(variable => ( | ||
<div key={variable.varDef?.name} className="mb-1 flex items-center gap-1"> | ||
<span className="rounded bg-gray-100 px-2 py-1 font-mono text-fuchsia-500">{variable.varDef?.name}</span> | ||
<span className="rounded bg-yellow-100 p-1 text-xs">{VARIABLE_TYPES[variable.varDef!.type]}</span> | ||
{variable.required && <span className="rounded bg-orange-300 p-1 text-xs">Required</span>} | ||
{variable.searchable && <span className="rounded bg-blue-300 p-1 text-xs">Searchable</span>} | ||
<span className="rounded bg-green-300 p-1 text-xs">{accessLevels[variable.accessLevel]}</span> | ||
<span>=</span> | ||
<span className="truncate"> | ||
{getVariableValue(variables.find(v => v.id?.name === variable.varDef?.name)?.value)} | ||
</span> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} |
18 changes: 13 additions & 5 deletions
18
dashboard/src/app/(authenticated)/(diagram)/wfRun/[...ids]/components/WfRun.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
'use client' | ||
import { Diagram } from '@/app/(authenticated)/(diagram)/components/Diagram' | ||
import { Navigation } from '@/app/(authenticated)/components/Navigation' | ||
import { useSearchParams } from 'next/navigation' | ||
import { FC } from 'react' | ||
import { Modals } from '../../../components/Modals' | ||
import { useModal } from '../../../hooks/useModal' | ||
import { WfRunResponse } from '../getWfRun' | ||
import { Details } from './Details' | ||
import { useModal } from '../../../hooks/useModal' | ||
import { Modals } from '../../../components/Modals' | ||
import { Variables } from './Variables'; | ||
|
||
export const WfRun: FC<WfRunResponse> = ({ wfRun, wfSpec, nodeRuns }) => { | ||
export const WfRun: FC<WfRunResponse> = ({ wfRun, wfSpec, nodeRuns, variables }) => { | ||
const { modal, showModal } = useModal() | ||
const searchParams = useSearchParams() | ||
const threadRunNumber = Number(searchParams.get('threadRunNumber')) | ||
return ( | ||
<> | ||
<div className='mb-16'> | ||
<Navigation | ||
href={`/wfSpec/${wfRun.wfSpecId?.name}/${wfRun.wfSpecId?.majorVersion}/${wfRun.wfSpecId?.revision}`} | ||
title="Go back to WfSpec" | ||
/> | ||
<Details {...wfRun} /> | ||
<Diagram spec={wfSpec} wfRun={wfRun} nodeRuns={nodeRuns} /> | ||
|
||
<Variables | ||
variableDefs={wfSpec.threadSpecs[wfRun.threadRuns[threadRunNumber].threadSpecName].variableDefs} | ||
variables={variables.filter(v => v.id?.threadRunNumber == Number(searchParams.get('threadRunNumber')))} | ||
/> | ||
<Modals /> | ||
</> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters