From 9ce54bfc375709eab6bc6767b2a092a05b2b9da7 Mon Sep 17 00:00:00 2001 From: ccastrotrejo Date: Mon, 1 Apr 2024 15:22:01 -0700 Subject: [PATCH 1/2] Add erros button to open errors side panel --- .../app/designer/DesignerCommandBar/index.tsx | 55 ++++++++++++------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/apps/vs-code-react/src/app/designer/DesignerCommandBar/index.tsx b/apps/vs-code-react/src/app/designer/DesignerCommandBar/index.tsx index 3e7c359d05c..3c738712190 100644 --- a/apps/vs-code-react/src/app/designer/DesignerCommandBar/index.tsx +++ b/apps/vs-code-react/src/app/designer/DesignerCommandBar/index.tsx @@ -9,6 +9,9 @@ import { validateParameter, updateParameterValidation, openPanel, + useWorkflowParameterValidationErrors, + useAllSettingsValidationErrors, + useAllConnectionErrors, } from '@microsoft/logic-apps-designer'; import type { RootState } from '@microsoft/logic-apps-designer'; import { RUN_AFTER_COLORS, isNullOrEmpty } from '@microsoft/logic-apps-shared'; @@ -38,6 +41,8 @@ export const DesignerCommandBar: React.FC = ({ isRefres ) ); + const designerIsDirty = useIsDesignerDirty(); + const { isLoading: isSaving, mutate: saveWorkflowMutate } = useMutation(async () => { const designerState = DesignerStore.getState(); const { definition, parameters, connectionReferences } = await serializeBJSWorkflow(designerState, { @@ -87,6 +92,11 @@ export const DesignerCommandBar: React.FC = ({ isRefres id: '+0ua83', description: 'Button text for parameters', }), + DESIGNER_ERRORS: intl.formatMessage({ + defaultMessage: 'Errors', + id: 'ohOaXj', + description: 'Button text for errors', + }), MONITORING_VIEW_REFRESH: intl.formatMessage({ defaultMessage: 'Refresh', id: 'pr9GwA', @@ -110,8 +120,6 @@ export const DesignerCommandBar: React.FC = ({ isRefres disableGrey: [{ color: 'rgb(121, 119, 117)' }, iconClass], }); - const designerIsDirty = useIsDesignerDirty(); - const allInputErrors = useSelector((state: RootState) => { return (Object.entries(state.operations.inputParameters) ?? []).filter(([_id, nodeInputs]) => Object.values(nodeInputs.parameterGroups).some((parameterGroup) => @@ -120,22 +128,20 @@ export const DesignerCommandBar: React.FC = ({ isRefres ); }); - const allWorkflowParameterErrors = useSelector((state: RootState) => { - let validationErrorToShow = null; - for (const parameter of Object.entries(state.workflowParameters.validationErrors) ?? []) { - if (parameter?.[1]?.value) { - validationErrorToShow = { - name: state.workflowParameters.definitions[parameter[0]]?.name, - msg: parameter[1].value, - }; - } - } - return validationErrorToShow; - }); - - const haveErrors = useMemo(() => allInputErrors.length > 0 || !!allWorkflowParameterErrors, [allInputErrors, allWorkflowParameterErrors]); + const haveInputErrors = allInputErrors.length > 0; + const allWorkflowParameterErrors = useWorkflowParameterValidationErrors(); + const haveWorkflowParameterErrors = Object.keys(allWorkflowParameterErrors ?? {}).length > 0; + const allSettingsErrors = useAllSettingsValidationErrors(); + const haveSettingsErrors = Object.keys(allSettingsErrors ?? {}).length > 0; + const allConnectionErrors = useAllConnectionErrors(); + const haveConnectionErrors = Object.keys(allConnectionErrors ?? {}).length > 0; + + const haveErrors = useMemo( + () => haveInputErrors || haveWorkflowParameterErrors || haveSettingsErrors || haveConnectionErrors, + [haveInputErrors, haveWorkflowParameterErrors, haveSettingsErrors, haveConnectionErrors] + ); - const isSaveDisabled = isSaving || haveErrors || !designerIsDirty; + const isSaveDisabled = useMemo(() => isSaving || haveErrors || !designerIsDirty, [isSaving, haveErrors, designerIsDirty]); const desingerItems: ICommandBarItemProps[] = [ { @@ -166,7 +172,7 @@ export const DesignerCommandBar: React.FC = ({ isRefres return ( <> {item.text} - {allWorkflowParameterErrors ? ( + {haveWorkflowParameterErrors ? (
@@ -176,6 +182,17 @@ export const DesignerCommandBar: React.FC = ({ isRefres }, onClick: () => !!dispatch(openPanel({ panelMode: 'WorkflowParameters' })), }, + { + key: 'errors', + disabled: !haveErrors, + text: Resources.DESIGNER_ERRORS, + ariaLabel: Resources.DESIGNER_ERRORS, + iconProps: { + iconName: haveErrors ? 'StatusErrorFull' : 'ErrorBadge', + style: haveErrors ? { color: RUN_AFTER_COLORS[isDarkMode ? 'dark' : 'light']['FAILED'] } : undefined, + }, + onClick: () => !!dispatch(openPanel({ panelMode: 'Error' })), + }, ]; const monitoringViewItems: ICommandBarItemProps[] = [ @@ -204,7 +221,7 @@ export const DesignerCommandBar: React.FC = ({ isRefres items={isMonitoringView ? monitoringViewItems : desingerItems} ariaLabel="Use left and right arrow keys to navigate between commands" styles={{ - root: { borderBottom: `1px solid ${isDarkMode ? '#333333' : '#d6d6d6'}` }, + root: { borderBottom: `1px solid ${isDarkMode ? '#333333' : '#d6d6d6'}`, padding: '0 20px' }, }} /> ); From 5699cad04f7c079a902e067cc2ef5ac2bfc68137 Mon Sep 17 00:00:00 2001 From: ccastrotrejo Date: Mon, 1 Apr 2024 16:38:37 -0700 Subject: [PATCH 2/2] Update strings json --- Localize/lang/strings.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Localize/lang/strings.json b/Localize/lang/strings.json index c8976cc60d4..ffdc2941bd2 100644 --- a/Localize/lang/strings.json +++ b/Localize/lang/strings.json @@ -1,6 +1,7 @@ { "++ZVe/": "Testing", "+0H8Or": "Warning: input node type does not match the schema node's type", + "+0ua83": "Parameters", "+0yxlR": "Function display", "+3rROX": "Protected", "+FcXe9": "Faulted", @@ -905,9 +906,11 @@ "Zi9gQK": "Add new item", "ZihyUf": "Close", "ZkjTbp": "Learn more about dynamic content.", + "ZvAp7m": "Save", "ZyDq4/": "Show a different suggestion", "_++ZVe/.comment": "Title for testing section", "_+0H8Or.comment": "Warning message for when input node type does not match schema node type", + "_+0ua83.comment": "Button text for parameters", "_+0yxlR.comment": "Label for the function display radio group", "_+3rROX.comment": "Label in the chatbot header stating that the users information is protected in this chatbot", "_+FcXe9.comment": "The status message to show in monitoring view.", @@ -1812,6 +1815,7 @@ "_Zi9gQK.comment": "Label to add item to property editor", "_ZihyUf.comment": "Label for the close button in the chatbot header", "_ZkjTbp.comment": "Text for dynamic content link", + "_ZvAp7m.comment": "Button text for save", "_ZyDq4/.comment": "Text for the show different suggestion flow button", "_a7j3gS.comment": "Required number parameter to divide in mod function", "_aAXnqw.comment": "Required number of occurrences to get nthIndexOf function with", @@ -2161,6 +2165,7 @@ "_oWGaw9.comment": "Click to view less token options.", "_oZMhX/.comment": "Text of Tooltip to expand", "_odQ554.comment": "Response body for test map API", + "_ohOaXj.comment": "Button text for errors", "_onXUu0.comment": "Text to tell users to click to add comments", "_osKNnl.comment": "Error validation message for doubles", "_ox2Ou7.comment": "Placeholder for empty collapsed dictionary", @@ -2243,6 +2248,7 @@ "_sEqLTV.comment": "An accessability label that describes the testing tab", "_sFbnCs.comment": "Time zone value ", "_sFwHQc.comment": "aria label description for cancel button", + "_sOnphB.comment": "Button text for resubmit", "_sQ2vRs.comment": "add a case to switch statement", "_sRpETS.comment": "Warning message for when custom value does not match schema node type", "_sVQe34.comment": "The description for the test tab parameters.", @@ -2790,6 +2796,7 @@ "oWGaw9": "See Less", "oZMhX/": "Expand", "odQ554": "Response body", + "ohOaXj": "Errors", "onXUu0": "Add a note", "osKNnl": "Enter a valid Double number.", "ox2Ou7": "Enter a valid JSON", @@ -2872,6 +2879,7 @@ "sEqLTV": "Testing Tab", "sFbnCs": "(UTC-05:00) Chetumal", "sFwHQc": "Cancel creating a connection", + "sOnphB": "Resubmit", "sQ2vRs": "Add Case", "sRpETS": "Warning: custom value does not match the schema node's type", "sVQe34": "Provide parameters to test the output.",