Skip to content

Commit 99e5e6f

Browse files
Eric-B-Wuhartra344
authored andcommitted
fix(Designer): Copy Paste Fixes (#4725)
* fixScopePaste * remove logs * fix test * fix tests * i forgot to update the original one
1 parent cd3cadc commit 99e5e6f

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
@@ -44,11 +44,11 @@ const verificationWorkflow = {
4444
and: [
4545
{
4646
not: {
47-
endsWith: ['@{concat(concat(concat(concat())))}', "@variables('goalOwner')"],
47+
endsWith: ['@concat(concat(concat(concat())))', "@variables('goalOwner')"],
4848
},
4949
},
5050
{
51-
equals: [null, "@variables('goalOwner')"],
51+
equals: ['', "@variables('goalOwner')"],
5252
},
5353
],
5454
},
@@ -112,11 +112,11 @@ const verificationWorkflow = {
112112
and: [
113113
{
114114
not: {
115-
endsWith: ['@{concat(concat(concat(concat())))}', "@variables('goalOwner')"],
115+
endsWith: ['@concat(concat(concat(concat())))', "@variables('goalOwner')"],
116116
},
117117
},
118118
{
119-
equals: [null, "@variables('goalOwner')"],
119+
equals: ['', "@variables('goalOwner')"],
120120
},
121121
],
122122
},

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)