Skip to content

Commit

Permalink
fix(Designer): Showing secure workflow parameters in consumption (#4325)
Browse files Browse the repository at this point in the history
Fixed issue that was preventing secure WF params from showing in consumption workflows
  • Loading branch information
rllyy97 committed Mar 7, 2024
1 parent 8048bd8 commit ab07b14
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 17 deletions.
8 changes: 8 additions & 0 deletions Localize/lang/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion libs/designer-ui/src/lib/modals/DeleteNodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Modal titleAriaId={title} isOpen={isOpen} onDismiss={onDismiss}>
<div className="msla-modal-container">
{!nodeId ? (
<Spinner label={'Deleting...'} />
<Spinner label={deleteLoadingMessage} />
) : (
<>
<h2>{title}</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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<string | undefined>(stringifyValue(definition.value));
const [defaultValue, setDefaultValue] = useState<string | undefined>(stringifyValue(definition.defaultValue));
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -181,6 +198,7 @@ export const WorkflowparameterField = ({
defaultMessage: 'Enter default value for parameter.',
description: 'Parameter Field Value Placeholder Text',
});

const onNameChange = (_event: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string): void => {
setName(newValue);
onChange?.({
Expand All @@ -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<HTMLDivElement>, item?: IDropdownOption): void => {
const newType = item?.key.toString() as string;

Expand All @@ -200,7 +233,7 @@ export const WorkflowparameterField = ({
});

setType(newType);
setValueWarningMessage(getValueWarningMessage(defaultValue, newType));
setDefaultValueWarningMessage(getDefaultValueWarningMessage(defaultValue, newType));
};

const onValueChange = (_event: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string): void => {
Expand All @@ -209,7 +242,6 @@ export const WorkflowparameterField = ({

const handleValueChange = (value?: string) => {
setValue(value);
setValueWarningMessage(getValueWarningMessage(value, type));

onChange?.({
id: definition.id,
Expand All @@ -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,
Expand Down Expand Up @@ -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}
/>
) : (
Expand All @@ -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}
/>
) : (
Expand All @@ -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}
/>
) : (
<Text className="msla-workflow-parameter-read-only">{value}</Text>
Expand All @@ -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;
}
64 changes: 64 additions & 0 deletions libs/services/intl/src/compiled-lang/strings.en-XA.json
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,20 @@
"value": "]"
}
],
"HX3Xmx": [
{
"type": 0,
"value": "["
},
{
"type": 0,
"value": "Ḓḗḗŀḗḗŧīƞɠ..."
},
{
"type": 0,
"value": "]"
}
],
"HYhDYB": [
{
"type": 0,
Expand Down Expand Up @@ -10605,6 +10619,20 @@
"value": "]"
}
],
"TUdPdI": [
{
"type": 0,
"value": "["
},
{
"type": 0,
"value": "Şḗḗƈŭŭřḗḗ Ǿƀĵḗḗƈŧ"
},
{
"type": 0,
"value": "]"
}
],
"TX4Kdr": [
{
"type": 0,
Expand Down Expand Up @@ -13171,6 +13199,20 @@
"value": "]"
}
],
"ZKnJnh": [
{
"type": 0,
"value": "["
},
{
"type": 0,
"value": "Şḗḗƈŭŭřḗḗ Şŧřīƞɠ"
},
{
"type": 0,
"value": "]"
}
],
"ZM1mRy": [
{
"type": 0,
Expand Down Expand Up @@ -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,
Expand Down
32 changes: 32 additions & 0 deletions libs/services/intl/src/compiled-lang/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3031,6 +3031,12 @@
"value": "Headers"
}
],
"HX3Xmx": [
{
"type": 0,
"value": "Deleting..."
}
],
"HYhDYB": [
{
"type": 0,
Expand Down Expand Up @@ -4821,6 +4827,12 @@
"value": "Action Type"
}
],
"TUdPdI": [
{
"type": 0,
"value": "Secure Object"
}
],
"TX4Kdr": [
{
"type": 0,
Expand Down Expand Up @@ -6019,6 +6031,12 @@
"value": "Body"
}
],
"ZKnJnh": [
{
"type": 0,
"value": "Secure String"
}
],
"ZM1mRy": [
{
"type": 0,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ab07b14

Please sign in to comment.