Skip to content

Commit

Permalink
fix(dashboard): retrieve parent wf variables (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryson-g authored Feb 14, 2025
1 parent e4daa3d commit 2b0c5e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@
import { Diagram } from '@/app/(authenticated)/[tenantId]/(diagram)/components/Diagram'
import { Navigation } from '@/app/(authenticated)/[tenantId]/components/Navigation'
import { useSearchParams } from 'next/navigation'
import { FC } from 'react'
import { FC, useCallback } from 'react'
import { Details } from './Details'
import { Variables } from './Variables'
import { useWfRun } from '@/app/hooks/useWfRun'
import { WfRunVariableAccessLevel } from 'littlehorse-client/proto'
import { isExternal } from 'util/types'

export const WfRun: FC<{ id: string, tenantId: string }> = ({ id, tenantId }) => {
const searchParams = useSearchParams()
const threadRunNumber = Number(searchParams.get('threadRunNumber'))
const { wfRunData, isLoading, isError } = useWfRun({ id: id, tenantId })
const { wfRunData: parentWfRunData } = useWfRun({ id: wfRunData?.wfRun?.id?.parentWfRunId?.id ?? '', tenantId })

if (!wfRunData) return null
const { wfRun, wfSpec, nodeRuns, variables } = wfRunData;

if (!wfRun) return null
if (!wfRun.id?.parentWfRunId || !parentWfRunData) return null

const variableDefs = wfSpec.threadSpecs[wfRun.threadRuns[threadRunNumber].threadSpecName].variableDefs;
const inheritedVariables = variableDefs.filter(vD => vD.accessLevel === WfRunVariableAccessLevel.INHERITED_VAR).map(vD => {
return parentWfRunData.variables.find(v => v.id?.name === vD.varDef?.name)!
});

return (
<div className="mb-16">
Expand All @@ -27,7 +37,7 @@ export const WfRun: FC<{ id: string, tenantId: string }> = ({ id, tenantId }) =>

<Variables
variableDefs={wfSpec.threadSpecs[wfRun.threadRuns[threadRunNumber].threadSpecName].variableDefs}
variables={variables.filter(v => v.id?.threadRunNumber == Number(searchParams.get('threadRunNumber')))}
variables={variables.filter(v => v.id?.threadRunNumber == Number(searchParams.get('threadRunNumber'))).concat(inheritedVariables)}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getWfRun } from '../../../../../actions/getWfRun'
type Props = { params: { ids: string[]; tenantId: string } }

export default async function Page({ params: { ids, tenantId } }: Props) {
const id = ids[0];
const id = ids.join('_');
try {
return <WfRun id={id} tenantId={tenantId} />
} catch (error) {
Expand Down

0 comments on commit 2b0c5e1

Please sign in to comment.