Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 73 additions & 54 deletions GUI/src/components/FlowElementsPopup/PreviousVariables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ const PreviousVariables: FC<PreviousVariablesProps> = ({ node }) => {
const endpointNodes = previousNodes.filter((node) => node.data.stepType === StepType.UserDefined);
const names = endpointNodes.map((node) => node.data.label?.toString().split(' ')[0]);
const filteredEndpointsVariables = endpointsVariables.filter((endpoint) => names.includes(endpoint.name));
setEndpoints(filteredEndpointsVariables);
const uniqueEndpointsVariables = Array.from(
new Map(filteredEndpointsVariables.map((endpoint) => [endpoint.name, endpoint])).values(),
);
setEndpoints(uniqueEndpointsVariables);

// Get Assign variables
const assignNodes: Node<NodeDataProps>[] =
Expand Down Expand Up @@ -196,59 +199,75 @@ const PreviousVariables: FC<PreviousVariablesProps> = ({ node }) => {
style={{ borderBottom: border, borderTop: border }}
/>
)}
{endpoints.map((endpoint) => (
<Track key={v4()} direction="vertical" align="left" style={{ ...popupBodyCss, borderBottom: border }}>
<label
htmlFor="json"
style={{ marginBottom: '10px', textTransform: 'capitalize', cursor: 'auto' }}
>{`${endpoint.name}`}</label>
<Track
direction="horizontal"
gap={4}
justify="start"
isMultiline
style={{ maxHeight: '30vh', overflow: 'auto' }}
>
{endpoint.chips.map((chip) => {
const typeColor = getTypeColor(chip.data);
const dragData: Assign = {
id: v4(),
key: chip.name,
value: stringToTemplate(chip.value),
data: chip.data,
};

return isObject(chip.data) ? (
<Tooltip content={`${JSON.stringify(chip.data)} : ${typeColor.type}`} key={dragData.id}>
<OutputElementBox
dragData={dragData}
style={{ cursor: 'pointer' }}
borderColor={typeColor.color}
onClick={() => {
setEndpointsObjectTree(
endpointsObjectTree?.path === chip.value
? null
: {
data: chip.data,
path: chip.value,
},
);
}}
>
{endpointsObjectTree?.path === chip.value ? chip.name + ' ▲' : chip.name + ' ▼'}
</OutputElementBox>
</Tooltip>
) : (
<Tooltip content={`${chip.data} : ${typeColor.type}`} key={dragData.id}>
<OutputElementBox borderColor={typeColor.color} dragData={dragData}>
{chip.name}
</OutputElementBox>
</Tooltip>
);
})}
</Track>
</Track>
))}
{endpoints.length > 0 && (
<Collapsible
title={t('serviceFlow.previousVariables.apiResponses.title')}
appearance="normal"
defaultOpen={true}
contentStyle={{ padding: '0px' }}
headerDivider={false}
style={{ borderRadius: '0px', borderBottom: '1px solid #d2d3d8', borderTop: '0px' }}
>
{endpoints.map((endpoint) => (
<Track
key={endpoint.name}
direction="vertical"
align="left"
style={{ ...popupBodyCss, borderBottom: border }}
>
<label
htmlFor="json"
style={{ marginBottom: '10px', textTransform: 'capitalize', cursor: 'auto' }}
>{`${endpoint.name}`}</label>
<Track
direction="horizontal"
gap={4}
justify="start"
isMultiline
style={{ maxHeight: '30vh', overflow: 'auto' }}
>
{endpoint.chips.map((chip) => {
const typeColor = getTypeColor(chip.data);
const dragData: Assign = {
id: v4(),
key: chip.name,
value: stringToTemplate(chip.value),
data: chip.data,
};

return isObject(chip.data) ? (
<Tooltip content={`${JSON.stringify(chip.data)} : ${typeColor.type}`} key={dragData.id}>
<OutputElementBox
dragData={dragData}
style={{ cursor: 'pointer' }}
borderColor={typeColor.color}
onClick={() => {
setEndpointsObjectTree(
endpointsObjectTree?.path === chip.value
? null
: {
data: chip.data,
path: chip.value,
},
);
}}
>
{endpointsObjectTree?.path === chip.value ? chip.name + ' ▲' : chip.name + ' ▼'}
</OutputElementBox>
</Tooltip>
) : (
<Tooltip content={`${chip.data} : ${typeColor.type}`} key={dragData.id}>
<OutputElementBox borderColor={typeColor.color} dragData={dragData}>
{chip.name}
</OutputElementBox>
</Tooltip>
);
})}
</Track>
</Track>
))}
</Collapsible>
)}
</>
)}
{isObject(endpointsObjectTree?.data) && (
Expand Down
3 changes: 3 additions & 0 deletions GUI/src/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@
"environmentVariables": {
"title": "Environment Variables"
},
"apiResponses": {
"title": "API Responses"
},
"helpers": {
"title": "Tools",
"map": "Change items",
Expand Down
3 changes: 3 additions & 0 deletions GUI/src/i18n/et/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@
"environmentVariables": {
"title": "Keskkonnamuutujad"
},
"apiResponses": {
"title": "API vastused"
},
"dateAndTime": {
"title": "Kuupäev ja kellaaeg",
"base": "Põhi",
Expand Down
4 changes: 3 additions & 1 deletion GUI/src/store/new-services.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ const useServiceStore = create<ServiceStoreState>((set, get) => ({
variables.push(variable);
});

set({ endpointsResponseVariables: variables });
const uniqueVariables = Array.from(new Map(variables.map((variable) => [variable.name, variable])).values());

set({ endpointsResponseVariables: uniqueVariables });
} catch (e) {
console.error(e);
}
Expand Down
Loading