Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Designer): Copy Paste Fixes #4725

Merged
merged 5 commits into from
Apr 29, 2024
Merged
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
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
Loading