Skip to content

Commit 9d7015e

Browse files
Eric-B-Wuccastrotrejohartra344
authored
feat(designer): Custom Code (#4376)
* temp * first look * custom code bugfixes * filtering out files to be deleted that have no data * update to segment property * feat(designer): Resizable side panel (#4134) * Initial implementation * Specify for resizable custom sidepanels * Implement Math.max * adding resize support * reseting custom code state on save * fix comment * update based on comments --------- Co-authored-by: Carlos Emiliano Castro Trejo <102700317+ccastrotrejo@users.noreply.github.com> Co-authored-by: Travis Harris <travisharris@microsoft.com>
1 parent 0f9196c commit 9d7015e

File tree

100 files changed

+2032
-530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2032
-530
lines changed

CHANGELOG.md

+46-55
Large diffs are not rendered by default.

Localize/lang/strings.json

+4
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@
569569
"Mb+Eaq": "Bool",
570570
"Mb/Vp8": "Next failed",
571571
"Mc6ITJ": "Search",
572+
"Mcvr0B": "To use modules or dependecies, please add at Custom Code Dependenncies in Portal TOC",
572573
"MfAdfx": "Edit in advanced mode",
573574
"MirIsS": "Show code",
574575
"MmBfD1": "Unexpected error",
@@ -731,6 +732,7 @@
731732
"TgcgXE": "Tags",
732733
"Tiqnir": "Custom",
733734
"TjMkDP": "(UTC-06:00) Easter Island",
735+
"TjkOzp": "Close",
734736
"TlX98E": "(UTC+02:00) Kaliningrad",
735737
"Tla33B": "Required. The value for which to find the index.",
736738
"Tmr/9e": "Invalid parameters",
@@ -1474,6 +1476,7 @@
14741476
"_Mb+Eaq.comment": "This is an option in a dropdown where users can select type Boolean for their parameter.",
14751477
"_Mb/Vp8.comment": "Button indicating to go to the next page with failed options",
14761478
"_Mc6ITJ.comment": "Placeholder text to search token picker",
1479+
"_Mcvr0B.comment": "This is a message to inform the user to add dependencies to use this action",
14771480
"_MfAdfx.comment": "Button Label when clicked to swith to advanced editor",
14781481
"_MirIsS.comment": "Button to display the code view",
14791482
"_MmBfD1.comment": "This is the default message shown in case of an error. It can be shown in multiple contexts but generally would be a notification",
@@ -1636,6 +1639,7 @@
16361639
"_TgcgXE.comment": "Label For Tags in About Panel",
16371640
"_Tiqnir.comment": "Option text for table column type in table editor",
16381641
"_TjMkDP.comment": "Time zone value ",
1642+
"_TjkOzp.comment": "This is the aria label for the close button in the message bar",
16391643
"_TlX98E.comment": "Time zone value ",
16401644
"_Tla33B.comment": "Required. The text parameter for which to find the index with the 'indexOf' function.",
16411645
"_Tmr/9e.comment": "Text to explain that there are invalid parameters for this node",

apps/data-mapper-standalone/src/components/DevApiTester.tsx

+30-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import {
1313
tokens,
1414
} from '@fluentui/react-components';
1515
import type { MonacoProps } from '@microsoft/designer-ui';
16-
import { EditorLanguage, MonacoEditor } from '@microsoft/designer-ui';
16+
import { MonacoEditor } from '@microsoft/designer-ui';
1717
import { generateDataMapXslt, getFunctions, getSelectedSchema, testDataMap } from '@microsoft/logic-apps-data-mapper';
18+
import { EditorLanguage } from '@microsoft/logic-apps-shared';
1819
import { useState } from 'react';
1920

2021
const RequestTab = {
@@ -138,7 +139,14 @@ export const DevApiTester = () => {
138139
onChange={(_e, newValue) => setXsltFilename(newValue ?? '')}
139140
/>
140141

141-
<Text style={{ fontWeight: 'bold', fontSize: '22px', display: 'block', marginBottom: '12px' }}>
142+
<Text
143+
style={{
144+
fontWeight: 'bold',
145+
fontSize: '22px',
146+
display: 'block',
147+
marginBottom: '12px',
148+
}}
149+
>
142150
Input schema value
143151
</Text>
144152
<MonacoEditor
@@ -156,7 +164,16 @@ export const DevApiTester = () => {
156164

157165
{selectedTab === RequestTab.GenerateXslt && (
158166
<Stack tokens={{ childrenGap: '8px' }}>
159-
<Text style={{ fontWeight: 'bold', fontSize: '22px', display: 'block', marginBottom: '12px' }}>Map definition</Text>
167+
<Text
168+
style={{
169+
fontWeight: 'bold',
170+
fontSize: '22px',
171+
display: 'block',
172+
marginBottom: '12px',
173+
}}
174+
>
175+
Map definition
176+
</Text>
160177
<MonacoEditor
161178
{...commonCodeEditorProps}
162179
language={EditorLanguage.yaml}
@@ -173,7 +190,16 @@ export const DevApiTester = () => {
173190
</StackItem>
174191

175192
<StackItem>
176-
<Text style={{ fontWeight: 'bold', fontSize: '22px', display: 'block', marginBottom: '12px' }}>Response</Text>
193+
<Text
194+
style={{
195+
fontWeight: 'bold',
196+
fontSize: '22px',
197+
display: 'block',
198+
marginBottom: '12px',
199+
}}
200+
>
201+
Response
202+
</Text>
177203
<MonacoEditor
178204
{...commonCodeEditorProps}
179205
language={EditorLanguage.json}

apps/data-mapper-standalone/src/components/DevSerializationTester.tsx

+42-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import {
1414
tokens,
1515
} from '@fluentui/react-components';
1616
import type { MonacoProps } from '@microsoft/designer-ui';
17-
import { EditorLanguage, MonacoEditor } from '@microsoft/designer-ui';
17+
import { MonacoEditor } from '@microsoft/designer-ui';
1818
import {
1919
convertSchemaToSchemaExtended,
2020
convertToMapDefinition,
2121
flattenSchemaIntoSortArray,
2222
loadMapDefinition,
2323
MapDefinitionDeserializer,
2424
} from '@microsoft/logic-apps-data-mapper';
25+
import { EditorLanguage } from '@microsoft/logic-apps-shared';
2526
import { useMemo, useState } from 'react';
2627
import { useSelector } from 'react-redux';
2728

@@ -145,7 +146,16 @@ export const DevSerializationTester = () => {
145146
{selectedTab === SerializationTab.Deserialization && (
146147
<>
147148
<Stack tokens={{ childrenGap: '8px' }}>
148-
<Text style={{ fontWeight: 'bold', fontSize: '22px', display: 'block', marginBottom: '12px' }}>Map definition</Text>
149+
<Text
150+
style={{
151+
fontWeight: 'bold',
152+
fontSize: '22px',
153+
display: 'block',
154+
marginBottom: '12px',
155+
}}
156+
>
157+
Map definition
158+
</Text>
149159
<MonacoEditor
150160
{...commonCodeEditorProps}
151161
language={EditorLanguage.yaml}
@@ -159,7 +169,16 @@ export const DevSerializationTester = () => {
159169
</Stack>
160170

161171
<Stack tokens={{ childrenGap: '8px' }}>
162-
<Text style={{ fontWeight: 'bold', fontSize: '22px', display: 'block', marginBottom: '12px' }}>Connections</Text>
172+
<Text
173+
style={{
174+
fontWeight: 'bold',
175+
fontSize: '22px',
176+
display: 'block',
177+
marginBottom: '12px',
178+
}}
179+
>
180+
Connections
181+
</Text>
163182
<MonacoEditor
164183
{...commonCodeEditorProps}
165184
language={EditorLanguage.json}
@@ -175,7 +194,16 @@ export const DevSerializationTester = () => {
175194
{selectedTab === SerializationTab.Serialization && (
176195
<>
177196
<Stack tokens={{ childrenGap: '8px' }}>
178-
<Text style={{ fontWeight: 'bold', fontSize: '22px', display: 'block', marginBottom: '12px' }}>Connections</Text>
197+
<Text
198+
style={{
199+
fontWeight: 'bold',
200+
fontSize: '22px',
201+
display: 'block',
202+
marginBottom: '12px',
203+
}}
204+
>
205+
Connections
206+
</Text>
179207
<MonacoEditor
180208
{...commonCodeEditorProps}
181209
language={EditorLanguage.json}
@@ -189,7 +217,16 @@ export const DevSerializationTester = () => {
189217
</Stack>
190218

191219
<Stack tokens={{ childrenGap: '8px' }}>
192-
<Text style={{ fontWeight: 'bold', fontSize: '22px', display: 'block', marginBottom: '12px' }}>Map definition</Text>
220+
<Text
221+
style={{
222+
fontWeight: 'bold',
223+
fontSize: '22px',
224+
display: 'block',
225+
marginBottom: '12px',
226+
}}
227+
>
228+
Map definition
229+
</Text>
193230
<MonacoEditor
194231
{...commonCodeEditorProps}
195232
language={EditorLanguage.json}

apps/designer-standalone/src/app/AzureLogicAppsDesigner/DesignerCommandBar.tsx

+28-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CommandBar } from '@fluentui/react/lib/CommandBar';
55
import { Spinner, SpinnerSize } from '@fluentui/react/lib/Spinner';
66
import type { ILoggerService } from '@microsoft/logic-apps-shared';
77
import { LogEntryLevel, LoggerService, isNullOrEmpty, RUN_AFTER_COLORS } from '@microsoft/logic-apps-shared';
8-
import type { RootState, Workflow } from '@microsoft/logic-apps-designer';
8+
import type { CustomCodeFileNameMapping, RootState, Workflow } from '@microsoft/logic-apps-designer';
99
import {
1010
store as DesignerStore,
1111
serializeBJSWorkflow,
@@ -19,6 +19,8 @@ import {
1919
updateParameterValidation,
2020
openPanel,
2121
useNodesInitialized,
22+
getCustomCodeFilesWithData,
23+
resetCustomCode,
2224
} from '@microsoft/logic-apps-designer';
2325
import { useMemo } from 'react';
2426
import { useMutation } from 'react-query';
@@ -48,7 +50,7 @@ export const DesignerCommandBar = ({
4850
location: string;
4951
isReadOnly: boolean;
5052
discard: () => unknown;
51-
saveWorkflow: (workflow: Workflow) => Promise<void>;
53+
saveWorkflow: (workflow: Workflow, customCodeData: CustomCodeFileNameMapping | undefined) => Promise<void>;
5254
isDarkMode: boolean;
5355
isConsumption?: boolean;
5456
showConnectionsPanel?: boolean;
@@ -70,7 +72,14 @@ export const DesignerCommandBar = ({
7072
return parameterGroup.parameters.some((parameter) => {
7173
const validationErrors = validateParameter(parameter, parameter.value);
7274
if (validationErrors.length > 0) {
73-
dispatch(updateParameterValidation({ nodeId: id, groupId: parameterGroup.id, parameterId: parameter.id, validationErrors }));
75+
dispatch(
76+
updateParameterValidation({
77+
nodeId: id,
78+
groupId: parameterGroup.id,
79+
parameterId: parameter.id,
80+
validationErrors,
81+
})
82+
);
7483
}
7584
return validationErrors.length;
7685
});
@@ -80,9 +89,12 @@ export const DesignerCommandBar = ({
8089

8190
const hasParametersErrors = !isNullOrEmpty(validationErrorsList);
8291

92+
const customCodeFilesWithData = getCustomCodeFilesWithData(designerState.customCode);
93+
8394
if (!hasParametersErrors) {
84-
await saveWorkflow(serializedWorkflow);
95+
await saveWorkflow(serializedWorkflow, customCodeFilesWithData);
8596
updateCallbackUrl(designerState, DesignerStore.dispatch);
97+
DesignerStore.dispatch(resetCustomCode());
8698
}
8799
});
88100

@@ -167,7 +179,11 @@ export const DesignerCommandBar = ({
167179
disabled: !haveErrors,
168180
iconProps: {
169181
iconName: haveErrors ? 'StatusErrorFull' : 'ErrorBadge',
170-
style: haveErrors ? { color: RUN_AFTER_COLORS[isDarkMode ? 'dark' : 'light']['FAILED'] } : undefined,
182+
style: haveErrors
183+
? {
184+
color: RUN_AFTER_COLORS[isDarkMode ? 'dark' : 'light']['FAILED'],
185+
}
186+
: undefined,
171187
},
172188
onClick: () => !!dispatch(openPanel({ panelMode: 'Error' })),
173189
},
@@ -227,7 +243,13 @@ export const DesignerCommandBar = ({
227243
);
228244
};
229245

230-
const CustomCommandBarButton = ({ text, showError }: { text: string; showError?: boolean }) => (
246+
const CustomCommandBarButton = ({
247+
text,
248+
showError,
249+
}: {
250+
text: string;
251+
showError?: boolean;
252+
}) => (
231253
<div style={{ margin: '2px', display: 'flex', gap: '8px', alignItems: 'center' }}>
232254
{text}
233255
{showError && <Badge size="extra-small" color="danger" />}

0 commit comments

Comments
 (0)