Skip to content

Commit

Permalink
fix(Designer): Copy Paste Fixes (#4725)
Browse files Browse the repository at this point in the history
* fixScopePaste

* remove logs

* fix test

* fix tests

* i forgot to update the original one
  • Loading branch information
Eric-B-Wu committed Apr 29, 2024
1 parent 101e420 commit 9143118
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
4 changes: 2 additions & 2 deletions __mocks__/workflows/Conditionals.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
{
"not": {
"endsWith": [
"@{concat(concat(concat(concat())))}",
"@concat(concat(concat(concat())))",
"@variables('goalOwner')"
]
}
},
{
"equals": [null, "@variables('goalOwner')"]
"equals": ["", "@variables('goalOwner')"]
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions e2e/designer/mock-copypastescope.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ const verificationWorkflow = {
and: [
{
not: {
endsWith: ['@{concat(concat(concat(concat())))}', "@variables('goalOwner')"],
endsWith: ['@concat(concat(concat(concat())))', "@variables('goalOwner')"],
},
},
{
equals: [null, "@variables('goalOwner')"],
equals: ['', "@variables('goalOwner')"],
},
],
},
Expand Down Expand Up @@ -122,11 +122,11 @@ const verificationWorkflow = {
and: [
{
not: {
endsWith: ['@{concat(concat(concat(concat())))}', "@variables('goalOwner')"],
endsWith: ['@concat(concat(concat(concat())))', "@variables('goalOwner')"],
},
},
{
equals: [null, "@variables('goalOwner')"],
equals: ['', "@variables('goalOwner')"],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,19 @@ const updateTokenMetadataInParameters = (
const allParameters = getAllInputParameters(nodeInputs);
const repetitionInfo = getRecordEntry(repetitionInfos, id) ?? { repetitionReferences: [] };
for (const parameter of allParameters) {
const segments = parameter.value;
const { value: segments, editorViewModel, type } = parameter;
let error = '';
let hasToken = false;
if (segments && segments.length) {
parameter.value = segments.map((segment) => {
let updatedSegment = segment;

if (isTokenValueSegment(segment)) {
if (pasteParams) {
const result = updateScopePasteTokenMetadata(segment, pasteParams);
updatedSegment = result.updatedSegment;
error = result.error;
const { updatedTokenSegment, tokenError } = updateScopePasteTokenMetadata(segment, pasteParams);
updatedSegment = updatedTokenSegment;
error = tokenError;
hasToken = true;
}
return updateTokenMetadata(
updatedSegment,
Expand All @@ -397,20 +399,24 @@ const updateTokenMetadataInParameters = (
operations,
workflowParameters,
nodesMetadata,
parameter.type
type
);
}
return updatedSegment;
});
}
if (error) {
parameter.validationErrors = [error];
if (pasteParams) {
if (hasToken) {
parameter.preservedValue = undefined;
}
if (error) {
parameter.validationErrors = [error];
}
}
const viewModel = parameter.editorViewModel;
if (viewModel) {
if (editorViewModel) {
flattenAndUpdateViewModel(
repetitionInfo,
viewModel,
editorViewModel,
actionNodes,
triggerNodeId,
nodesData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ export const buildGraphFromActions = (
for (let [runAfterAction, runAfterValue] of Object.entries(action.runAfter ?? {})) {
// update the run after with the updated ids
if (pasteScopeParams && action.runAfter) {
runAfterAction = pasteScopeParams.renamedNodes[runAfterAction] ?? runAfterAction;
// delete existing runAfter action first
delete action.runAfter[runAfterAction];
// get the new id from the renamed nodes
runAfterAction = pasteScopeParams.renamedNodes[runAfterAction] ?? runAfterAction;
// add the new id to the runAfter object
action.runAfter[runAfterAction] = runAfterValue;
}
edges.push(createWorkflowEdge(runAfterAction, actionName));
Expand Down Expand Up @@ -494,7 +497,9 @@ export const getAllActionNames = (actions: LogicAppsV2.Actions | undefined, name
}
if (action.cases) {
for (const [caseName, caseAction] of Object.entries(action.cases)) {
names.push(caseName);
if (includeCase) {
names.push(caseName);
}
if (caseAction.actions) {
names.push(...getAllActionNames(caseAction.actions, [], includeCase));
}
Expand Down
4 changes: 2 additions & 2 deletions libs/designer/src/lib/core/utils/parameters/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ export const flattenAndUpdateViewModel = (
export const updateScopePasteTokenMetadata = (
valueSegment: ValueSegment,
pasteParams: PasteScopeAdditionalParams
): { updatedSegment: ValueSegment; error: string } => {
): { updatedTokenSegment: ValueSegment; tokenError: string } => {
let error = '';
let token = valueSegment?.token;
if (token) {
Expand Down Expand Up @@ -3069,7 +3069,7 @@ export const updateScopePasteTokenMetadata = (
}
valueSegment.token = token;
}
return { updatedSegment: valueSegment, error: error };
return { updatedTokenSegment: valueSegment, tokenError: error };
};

export function updateTokenMetadata(
Expand Down

0 comments on commit 9143118

Please sign in to comment.