### What problem does this PR solve? Feat: Display the input parameters of begin in the output result table #3355 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
100 lines
3.1 KiB
TypeScript
100 lines
3.1 KiB
TypeScript
import { useFetchFlow } from '@/hooks/flow-hooks';
|
|
import get from 'lodash/get';
|
|
import React, { MouseEventHandler, useCallback, useMemo } from 'react';
|
|
import JsonView from 'react18-json-view';
|
|
import 'react18-json-view/src/style.css';
|
|
import { useGetComponentLabelByValue, useReplaceIdWithText } from '../../hooks';
|
|
|
|
import {
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
} from '@/components/ui/popover';
|
|
import {
|
|
Table,
|
|
TableBody,
|
|
TableCell,
|
|
TableHead,
|
|
TableHeader,
|
|
TableRow,
|
|
} from '@/components/ui/table';
|
|
import { useTranslate } from '@/hooks/common-hooks';
|
|
|
|
interface IProps extends React.PropsWithChildren {
|
|
nodeId: string;
|
|
name?: string;
|
|
}
|
|
|
|
export function NextNodePopover({ children, nodeId, name }: IProps) {
|
|
const { t } = useTranslate('flow');
|
|
|
|
const { data } = useFetchFlow();
|
|
const component = useMemo(() => {
|
|
return get(data, ['dsl', 'components', nodeId], {});
|
|
}, [nodeId, data]);
|
|
|
|
const inputs: Array<{ component_id: string; content: string }> = get(
|
|
component,
|
|
['obj', 'params', 'inputs'],
|
|
[],
|
|
);
|
|
const output = get(component, ['obj', 'params', 'output'], {});
|
|
const { replacedOutput } = useReplaceIdWithText(output);
|
|
const stopPropagation: MouseEventHandler = useCallback((e) => {
|
|
e.stopPropagation();
|
|
}, []);
|
|
|
|
const getLabel = useGetComponentLabelByValue(nodeId);
|
|
|
|
return (
|
|
<Popover>
|
|
<PopoverTrigger onClick={stopPropagation} asChild>
|
|
{children}
|
|
</PopoverTrigger>
|
|
<PopoverContent
|
|
align={'start'}
|
|
side={'right'}
|
|
sideOffset={20}
|
|
onClick={stopPropagation}
|
|
className="w-[400px]"
|
|
>
|
|
<div className="mb-3 font-semibold text-[16px]">
|
|
{name} {t('operationResults')}
|
|
</div>
|
|
<div className="flex w-full gap-4 flex-col">
|
|
<div className="flex flex-col space-y-1.5">
|
|
<span className="font-semibold text-[14px]">{t('input')}</span>
|
|
<div className="bg-gray-100 p-1 rounded">
|
|
<Table>
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHead>{t('componentId')}</TableHead>
|
|
<TableHead className="w-[60px]">{t('content')}</TableHead>
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{inputs.map((x, idx) => (
|
|
<TableRow key={idx}>
|
|
<TableCell>{getLabel(x.component_id)}</TableCell>
|
|
<TableCell className="truncate">{x.content}</TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
</div>
|
|
</div>
|
|
<div className="flex flex-col space-y-1.5">
|
|
<span className="font-semibold text-[14px]">{t('output')}</span>
|
|
<div className="bg-gray-100 p-1 rounded">
|
|
<JsonView
|
|
src={replacedOutput}
|
|
displaySize={30}
|
|
className="w-full max-h-[300px] break-words overflow-auto"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</PopoverContent>
|
|
</Popover>
|
|
);
|
|
}
|