Skip to content

Commit 4f4e704

Browse files
authored
fix(Designer): Copy Paste Fixes (#4725)
* fixScopePaste * remove logs * fix test * fix tests * i forgot to update the original one
1 parent 41a5f96 commit 4f4e704

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

__mocks__/workflows/Conditionals.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
{
4747
"not": {
4848
"endsWith": [
49-
"@{concat(concat(concat(concat())))}",
49+
"@concat(concat(concat(concat())))",
5050
"@variables('goalOwner')"
5151
]
5252
}
5353
},
5454
{
55-
"equals": [null, "@variables('goalOwner')"]
55+
"equals": ["", "@variables('goalOwner')"]
5656
}
5757
]
5858
}

e2e/designer/mock-copypastescope.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ const verificationWorkflow = {
5454
and: [
5555
{
5656
not: {
57-
endsWith: ['@{concat(concat(concat(concat())))}', "@variables('goalOwner')"],
57+
endsWith: ['@concat(concat(concat(concat())))', "@variables('goalOwner')"],
5858
},
5959
},
6060
{
61-
equals: [null, "@variables('goalOwner')"],
61+
equals: ['', "@variables('goalOwner')"],
6262
},
6363
],
6464
},
@@ -122,11 +122,11 @@ const verificationWorkflow = {
122122
and: [
123123
{
124124
not: {
125-
endsWith: ['@{concat(concat(concat(concat())))}', "@variables('goalOwner')"],
125+
endsWith: ['@concat(concat(concat(concat())))', "@variables('goalOwner')"],
126126
},
127127
},
128128
{
129-
equals: [null, "@variables('goalOwner')"],
129+
equals: ['', "@variables('goalOwner')"],
130130
},
131131
],
132132
},

libs/designer/src/lib/core/actions/bjsworkflow/operationdeserializer.ts

+16-10
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,19 @@ const updateTokenMetadataInParameters = (
376376
const allParameters = getAllInputParameters(nodeInputs);
377377
const repetitionInfo = getRecordEntry(repetitionInfos, id) ?? { repetitionReferences: [] };
378378
for (const parameter of allParameters) {
379-
const segments = parameter.value;
379+
const { value: segments, editorViewModel, type } = parameter;
380380
let error = '';
381+
let hasToken = false;
381382
if (segments && segments.length) {
382383
parameter.value = segments.map((segment) => {
383384
let updatedSegment = segment;
384385

385386
if (isTokenValueSegment(segment)) {
386387
if (pasteParams) {
387-
const result = updateScopePasteTokenMetadata(segment, pasteParams);
388-
updatedSegment = result.updatedSegment;
389-
error = result.error;
388+
const { updatedTokenSegment, tokenError } = updateScopePasteTokenMetadata(segment, pasteParams);
389+
updatedSegment = updatedTokenSegment;
390+
error = tokenError;
391+
hasToken = true;
390392
}
391393
return updateTokenMetadata(
392394
updatedSegment,
@@ -397,20 +399,24 @@ const updateTokenMetadataInParameters = (
397399
operations,
398400
workflowParameters,
399401
nodesMetadata,
400-
parameter.type
402+
type
401403
);
402404
}
403405
return updatedSegment;
404406
});
405407
}
406-
if (error) {
407-
parameter.validationErrors = [error];
408+
if (pasteParams) {
409+
if (hasToken) {
410+
parameter.preservedValue = undefined;
411+
}
412+
if (error) {
413+
parameter.validationErrors = [error];
414+
}
408415
}
409-
const viewModel = parameter.editorViewModel;
410-
if (viewModel) {
416+
if (editorViewModel) {
411417
flattenAndUpdateViewModel(
412418
repetitionInfo,
413-
viewModel,
419+
editorViewModel,
414420
actionNodes,
415421
triggerNodeId,
416422
nodesData,

libs/designer/src/lib/core/parsers/BJSWorkflow/BJSDeserializer.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,11 @@ export const buildGraphFromActions = (
193193
for (let [runAfterAction, runAfterValue] of Object.entries(action.runAfter ?? {})) {
194194
// update the run after with the updated ids
195195
if (pasteScopeParams && action.runAfter) {
196-
runAfterAction = pasteScopeParams.renamedNodes[runAfterAction] ?? runAfterAction;
196+
// delete existing runAfter action first
197197
delete action.runAfter[runAfterAction];
198+
// get the new id from the renamed nodes
199+
runAfterAction = pasteScopeParams.renamedNodes[runAfterAction] ?? runAfterAction;
200+
// add the new id to the runAfter object
198201
action.runAfter[runAfterAction] = runAfterValue;
199202
}
200203
edges.push(createWorkflowEdge(runAfterAction, actionName));
@@ -494,7 +497,9 @@ export const getAllActionNames = (actions: LogicAppsV2.Actions | undefined, name
494497
}
495498
if (action.cases) {
496499
for (const [caseName, caseAction] of Object.entries(action.cases)) {
497-
names.push(caseName);
500+
if (includeCase) {
501+
names.push(caseName);
502+
}
498503
if (caseAction.actions) {
499504
names.push(...getAllActionNames(caseAction.actions, [], includeCase));
500505
}

libs/designer/src/lib/core/utils/parameters/helper.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,7 @@ export const flattenAndUpdateViewModel = (
30203020
export const updateScopePasteTokenMetadata = (
30213021
valueSegment: ValueSegment,
30223022
pasteParams: PasteScopeAdditionalParams
3023-
): { updatedSegment: ValueSegment; error: string } => {
3023+
): { updatedTokenSegment: ValueSegment; tokenError: string } => {
30243024
let error = '';
30253025
let token = valueSegment?.token;
30263026
if (token) {
@@ -3069,7 +3069,7 @@ export const updateScopePasteTokenMetadata = (
30693069
}
30703070
valueSegment.token = token;
30713071
}
3072-
return { updatedSegment: valueSegment, error: error };
3072+
return { updatedTokenSegment: valueSegment, tokenError: error };
30733073
};
30743074

30753075
export function updateTokenMetadata(

0 commit comments

Comments
 (0)