From ab07b14d24af81eb9a2d1380697c016dbfdc8f28 Mon Sep 17 00:00:00 2001 From: Riley Evans Date: Thu, 7 Mar 2024 17:50:13 -0600 Subject: [PATCH] fix(Designer): Showing secure workflow parameters in consumption (#4325) Fixed issue that was preventing secure WF params from showing in consumption workflows --- Localize/lang/strings.json | 8 +++ .../src/lib/modals/DeleteNodeModal.tsx | 7 +- .../workflowparametersField.tsx | 58 ++++++++++++----- .../intl/src/compiled-lang/strings.en-XA.json | 64 +++++++++++++++++++ .../intl/src/compiled-lang/strings.json | 32 ++++++++++ 5 files changed, 152 insertions(+), 17 deletions(-) diff --git a/Localize/lang/strings.json b/Localize/lang/strings.json index 0d3ca60d55a..7497b47edd4 100644 --- a/Localize/lang/strings.json +++ b/Localize/lang/strings.json @@ -457,6 +457,7 @@ "HILmmE": "Required. The collection to sort.", "HMiE+4": "Exit full screen", "HSJLCu": "Headers", + "HX3Xmx": "Deleting...", "HYhDYB": "(UTC-02:00) Coordinated Universal Time-02", "Hbqlzk": "Insert Expression", "HfinO2": "Switch to detail inputs for array item", @@ -722,6 +723,7 @@ "TNH/nK": "Search Workflow Actions", "TO7qos": "Returns the start of the month of a string timestamp", "TRpSCQ": "Action Type", + "TUdPdI": "Secure Object", "TX4Kdr": "Create a new connection", "TY4HzZ": "Add or replace your schemas.", "TZh8nV": "on {weekDays} {frequencyDesc}", @@ -893,6 +895,7 @@ "ZAdaBl": "Select an existing connection reference or create a new one", "ZBJiuD": "Status", "ZCFMoe": "Body", + "ZKnJnh": "Secure String", "ZM1mRy": "Concurrency Control", "ZME5hh": "Returns the day of month component of a string timestamp", "ZRdkFN": "Collapse Static Result", @@ -1363,6 +1366,7 @@ "_HILmmE.comment": "Required collection parameter to apply sort function on", "_HMiE+4.comment": "Token picker for 'Exit full screen'", "_HSJLCu.comment": "The title of the headers field in the static result http action", + "_HX3Xmx.comment": "Text for loading state of delete modal", "_HYhDYB.comment": "Time zone value ", "_Hbqlzk.comment": "Label for button to open expression token picker", "_HfinO2.comment": "Label for editor toggle button when in collapsed mode", @@ -1628,6 +1632,7 @@ "_TNH/nK.comment": "Aria label for a button that opens a search panel to search the actions in the users workflow", "_TO7qos.comment": "Label for description of custom startOfMonth Function", "_TRpSCQ.comment": "Filter by label", + "_TUdPdI.comment": "This is an option in a dropdown where users can select type Secure Object for their parameter.", "_TX4Kdr.comment": "aria label description for create button", "_TY4HzZ.comment": "Description for the schema section", "_TZh8nV.comment": "Recurrence schedule description on days of week", @@ -1799,6 +1804,7 @@ "_ZAdaBl.comment": "Select an existing connection reference or create a new one.", "_ZBJiuD.comment": "Status text", "_ZCFMoe.comment": "Display name for body outputs", + "_ZKnJnh.comment": "This is an option in a dropdown where users can select type Secure String for their parameter.", "_ZM1mRy.comment": "title for concurrency setting", "_ZME5hh.comment": "Label for description of custom dayOfMonth Function", "_ZRdkFN.comment": "An accessible label for collapse toggle icon", @@ -1828,6 +1834,7 @@ "_b9/1dK.comment": "A placeholder for the dictionary value field", "_b9P8SA.comment": "Exception for unsupported token types", "_b9Rvl9.comment": "The title of the body field in the static result parseJson action", + "_bC2LBK.comment": "Warning message for secure string parameter default value", "_bG9rjv.comment": "Filter by Actions category of connectors", "_bGtEPd.comment": "delete button", "_bIyTi7.comment": "Subscription dropdown label", @@ -2453,6 +2460,7 @@ "b9/1dK": "Value", "b9P8SA": "Unsupported Token Type: {controls}", "b9Rvl9": "Body", + "bC2LBK": "It is not recommended to set a default value for type ''{type}'' because it will be stored as plain text.", "bG9rjv": "Actions", "bGtEPd": "Delete", "bIyTi7": "Subscription", diff --git a/libs/designer-ui/src/lib/modals/DeleteNodeModal.tsx b/libs/designer-ui/src/lib/modals/DeleteNodeModal.tsx index 19038bca4fc..5643b76f8fb 100644 --- a/libs/designer-ui/src/lib/modals/DeleteNodeModal.tsx +++ b/libs/designer-ui/src/lib/modals/DeleteNodeModal.tsx @@ -76,13 +76,18 @@ export const DeleteNodeModal = (props: DeleteNodeModalProps) => { description: 'Text for delete node modal body', }); + const deleteLoadingMessage = intl.formatMessage({ + defaultMessage: 'Deleting...', + description: 'Text for loading state of delete modal', + }); + const bodyMessage = nodeType === WORKFLOW_NODE_TYPES['OPERATION_NODE'] ? operationBodyMessage : graphBodyMessage; return (
{!nodeId ? ( - + ) : ( <>

{title}

diff --git a/libs/designer-ui/src/lib/workflowparameters/workflowparametersField.tsx b/libs/designer-ui/src/lib/workflowparameters/workflowparametersField.tsx index 081e8744fe0..a64b6ff6b13 100644 --- a/libs/designer-ui/src/lib/workflowparameters/workflowparametersField.tsx +++ b/libs/designer-ui/src/lib/workflowparameters/workflowparametersField.tsx @@ -10,7 +10,7 @@ import type { ITextStyles, } from '@fluentui/react'; import { Dropdown, FontWeights, getTheme, Label, Text, TextField } from '@fluentui/react'; -import { equals, format } from '@microsoft/logic-apps-shared'; +import { equals } from '@microsoft/logic-apps-shared'; import { useState } from 'react'; import { useIntl } from 'react-intl'; @@ -89,7 +89,6 @@ export const WorkflowparameterField = ({ isReadOnly, useLegacy, }: WorkflowparameterFieldProps): JSX.Element => { - const [valueWarningMessage, setValueWarningMessage] = useState(getValueWarningMessage(definition.value, definition.type)); const [type, setType] = useState(definition.type); const [value, setValue] = useState(stringifyValue(definition.value)); const [defaultValue, setDefaultValue] = useState(stringifyValue(definition.defaultValue)); @@ -148,6 +147,24 @@ export const WorkflowparameterField = ({ description: 'This is an option in a dropdown where users can select type String for their parameter.', }), }, + ...(useLegacy + ? [ + { + key: Constants.WORKFLOW_PARAMETER_SERIALIZED_TYPE.SECURE_STRING, + text: intl.formatMessage({ + defaultMessage: 'Secure String', + description: 'This is an option in a dropdown where users can select type Secure String for their parameter.', + }), + }, + { + key: Constants.WORKFLOW_PARAMETER_SERIALIZED_TYPE.SECURE_OBJECT, + text: intl.formatMessage({ + defaultMessage: 'Secure Object', + description: 'This is an option in a dropdown where users can select type Secure Object for their parameter.', + }), + }, + ] + : []), ]; const nameTitle = intl.formatMessage({ defaultMessage: 'Name', @@ -181,6 +198,7 @@ export const WorkflowparameterField = ({ defaultMessage: 'Enter default value for parameter.', description: 'Parameter Field Value Placeholder Text', }); + const onNameChange = (_event: React.FormEvent, newValue?: string): void => { setName(newValue); onChange?.({ @@ -190,6 +208,21 @@ export const WorkflowparameterField = ({ }); }; + const getDefaultValueWarningMessage = (value?: string, type?: string) => { + const secureParameterWarningMessage = intl.formatMessage( + { + defaultMessage: "It is not recommended to set a default value for type ''{type}'' because it will be stored as plain text.", + description: 'Warning message for secure string parameter default value', + }, + { type } + ); + return isSecureParameter(type) && !!value ? secureParameterWarningMessage : undefined; + }; + + const [defaultValueWarningMessage, setDefaultValueWarningMessage] = useState( + getDefaultValueWarningMessage(definition.defaultValue, definition.type) + ); + const onTypeChange = (_event?: React.FormEvent, item?: IDropdownOption): void => { const newType = item?.key.toString() as string; @@ -200,7 +233,7 @@ export const WorkflowparameterField = ({ }); setType(newType); - setValueWarningMessage(getValueWarningMessage(defaultValue, newType)); + setDefaultValueWarningMessage(getDefaultValueWarningMessage(defaultValue, newType)); }; const onValueChange = (_event: React.FormEvent, newValue?: string): void => { @@ -209,7 +242,6 @@ export const WorkflowparameterField = ({ const handleValueChange = (value?: string) => { setValue(value); - setValueWarningMessage(getValueWarningMessage(value, type)); onChange?.({ id: definition.id, @@ -224,7 +256,7 @@ export const WorkflowparameterField = ({ const handleDefaultValueChange = (defaultValue?: string) => { setDefaultValue(defaultValue); - setValueWarningMessage(getValueWarningMessage(defaultValue, type)); + setDefaultValueWarningMessage(getDefaultValueWarningMessage(defaultValue, type)); onChange?.({ id: definition.id, @@ -293,12 +325,10 @@ export const WorkflowparameterField = ({ id={parameterDetails.value} ariaLabel={valueTitle} placeholder={valueDescription} - description={valueWarningMessage} value={value} errorMessage={errors[VALUE_KEY]} - styles={valueWarningMessage ? textFieldWithWarningStyles : textFieldStyles} + styles={textFieldStyles} onChange={onValueChange} - onRenderDescription={valueWarningMessage ? onRenderDescription : undefined} disabled={isReadOnly} /> ) : ( @@ -317,12 +347,12 @@ export const WorkflowparameterField = ({ id={parameterDetails.defaultValue} ariaLabel={defaultValueTitle} placeholder={defaultValueDescription} - description={valueWarningMessage} + description={defaultValueWarningMessage} value={defaultValue} errorMessage={errors[DEFAULT_VALUE_KEY]} - styles={valueWarningMessage ? textFieldWithWarningStyles : textFieldStyles} + styles={defaultValueWarningMessage ? textFieldWithWarningStyles : textFieldStyles} onChange={onDefaultValueChange} - onRenderDescription={valueWarningMessage ? onRenderDescription : undefined} + onRenderDescription={defaultValueWarningMessage ? onRenderDescription : undefined} disabled={isReadOnly} /> ) : ( @@ -338,10 +368,10 @@ export const WorkflowparameterField = ({ data-testid={parameterDetails.value} id={parameterDetails.value} ariaLabel={valueTitle} - description={valueWarningMessage} value={value} styles={textFieldStyles} disabled={true} + type={isSecureParameter(type) ? 'password' : undefined} /> ) : ( {value} @@ -357,10 +387,6 @@ function isSecureParameter(type?: string): boolean { return equals(type, Constants.WORKFLOW_PARAMETER_TYPE.SECURE_STRING) || equals(type, Constants.WORKFLOW_PARAMETER_TYPE.SECURE_OBJECT); } -function getValueWarningMessage(value?: string, type?: string): string | undefined { - return isSecureParameter(type) && !!value ? format('Warning Message', type) : undefined; -} - function stringifyValue(value: any): string { return typeof value !== 'string' ? JSON.stringify(value) : value; } diff --git a/libs/services/intl/src/compiled-lang/strings.en-XA.json b/libs/services/intl/src/compiled-lang/strings.en-XA.json index 4b4ab2990e3..b17d41c7b2d 100644 --- a/libs/services/intl/src/compiled-lang/strings.en-XA.json +++ b/libs/services/intl/src/compiled-lang/strings.en-XA.json @@ -6695,6 +6695,20 @@ "value": "]" } ], + "HX3Xmx": [ + { + "type": 0, + "value": "[" + }, + { + "type": 0, + "value": "Ḓḗḗŀḗḗŧīƞɠ..." + }, + { + "type": 0, + "value": "]" + } + ], "HYhDYB": [ { "type": 0, @@ -10605,6 +10619,20 @@ "value": "]" } ], + "TUdPdI": [ + { + "type": 0, + "value": "[" + }, + { + "type": 0, + "value": "Şḗḗƈŭŭřḗḗ Ǿƀĵḗḗƈŧ" + }, + { + "type": 0, + "value": "]" + } + ], "TX4Kdr": [ { "type": 0, @@ -13171,6 +13199,20 @@ "value": "]" } ], + "ZKnJnh": [ + { + "type": 0, + "value": "[" + }, + { + "type": 0, + "value": "Şḗḗƈŭŭřḗḗ Şŧřīƞɠ" + }, + { + "type": 0, + "value": "]" + } + ], "ZM1mRy": [ { "type": 0, @@ -13581,6 +13623,28 @@ "value": "]" } ], + "bC2LBK": [ + { + "type": 0, + "value": "[" + }, + { + "type": 0, + "value": "Īŧ īş ƞǿǿŧ řḗḗƈǿǿḿḿḗḗƞḓḗḗḓ ŧǿǿ şḗḗŧ ȧȧ ḓḗḗƒȧȧŭŭŀŧ ṽȧȧŀŭŭḗḗ ƒǿǿř ŧẏƥḗḗ '" + }, + { + "type": 1, + "value": "type" + }, + { + "type": 0, + "value": "' ƀḗḗƈȧȧŭŭşḗḗ īŧ ẇīŀŀ ƀḗḗ şŧǿǿřḗḗḓ ȧȧş ƥŀȧȧīƞ ŧḗḗẋŧ." + }, + { + "type": 0, + "value": "]" + } + ], "bG9rjv": [ { "type": 0, diff --git a/libs/services/intl/src/compiled-lang/strings.json b/libs/services/intl/src/compiled-lang/strings.json index 8d96e9c765e..77248940df2 100644 --- a/libs/services/intl/src/compiled-lang/strings.json +++ b/libs/services/intl/src/compiled-lang/strings.json @@ -3031,6 +3031,12 @@ "value": "Headers" } ], + "HX3Xmx": [ + { + "type": 0, + "value": "Deleting..." + } + ], "HYhDYB": [ { "type": 0, @@ -4821,6 +4827,12 @@ "value": "Action Type" } ], + "TUdPdI": [ + { + "type": 0, + "value": "Secure Object" + } + ], "TX4Kdr": [ { "type": 0, @@ -6019,6 +6031,12 @@ "value": "Body" } ], + "ZKnJnh": [ + { + "type": 0, + "value": "Secure String" + } + ], "ZM1mRy": [ { "type": 0, @@ -6197,6 +6215,20 @@ "value": "Body" } ], + "bC2LBK": [ + { + "type": 0, + "value": "It is not recommended to set a default value for type '" + }, + { + "type": 1, + "value": "type" + }, + { + "type": 0, + "value": "' because it will be stored as plain text." + } + ], "bG9rjv": [ { "type": 0,