Skip to content

Commit 8ac9380

Browse files
committed
Dynamic user input form
1 parent 35939e2 commit 8ac9380

24 files changed

+388
-65
lines changed

SPFx/config/package-solution.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"solution": {
44
"name": "doc-enhanced-power-automate-trigger-client-side-solution",
55
"id": "5DA1DC8B-F9A4-43D4-9A0B-C2E89E2D5FBE",
6-
"version": "1.2.0.0",
6+
"version": "1.3.0.0",
77
"includeClientSideAssets": true,
88
"skipFeatureDeployment": false,
99
"isDomainIsolated": false,

SPFx/gulp-tasks/update-settings.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ var UpdateSettings = {
6767
`Using flow button display limit: ${inputJson.environments[targetEnv].FlowButtonDisplayLimit}`
6868
)
6969
);
70+
gutil.log(
71+
gutil.colors.yellow(
72+
`Using origin secret: ${inputJson.environments[targetEnv].OriginSecret}`
73+
)
74+
);
7075

7176
/* UPDATE APPSETTINGS.JSON */
7277
if (updateAppSettingsUponEnvironmentSwitch) {
@@ -96,6 +101,15 @@ var UpdateSettings = {
96101
appSettingsIsUpdated = true;
97102
}
98103

104+
if (
105+
appSettings.OriginSecret !==
106+
inputJson.environments[targetEnv].OriginSecret
107+
) {
108+
appSettings.OriginSecret =
109+
inputJson.environments[targetEnv].OriginSecret;
110+
appSettingsIsUpdated = true;
111+
}
112+
99113
// This prevents the function from unnecessarily updating the AppSettings.json file,
100114
// which, during gulp serve, will cause an annoying infinite rebuild loop
101115
if (appSettingsIsUpdated) {

SPFx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "enhanced-power-automate-trigger",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"private": true,
55
"main": "lib/index.js",
66
"description": "Trigger a Power Automate flow from SharePoint while selecting one or more items.",

SPFx/sharepoint/assets/triggerConfigListSchema.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ContentTypes></ContentTypes>
55
<Fields>
66
<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" DisplayName="Title" Required="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" FromBaseType="TRUE" Description="The title of the button displayed to the user for this trigger. Ex: Start an approval."/>
7-
<Field ID="{a41adbe7-8251-4ffd-9bc9-95299c8f472d}" Type="Text" Name="TriggerURL" DisplayName="Trigger URL" Required="TRUE" StaticName="TriggerURL" Description="The HTTP URL with which the flow can be triggered with. Ex: https://prod-178.westeurope.logic.azure.com:443/workflows/.../triggers/manual/paths/invoke..." />
7+
<Field ID="{a41adbe7-8251-4ffd-9bc9-95299c8f472d}" Type="Note" Name="TriggerURL" DisplayName="Trigger URL" Required="TRUE" StaticName="TriggerURL" NumLines="10" RichText="FALSE" AppendOnly="FALSE" Description="The HTTP URL with which the flow can be triggered with. Ex: https://prod-178.westeurope.logic.azure.com:443/workflows/.../triggers/manual/paths/invoke..." />
88
<Field ID="{7b215765-2770-4ce6-992a-ed3cdf084033}" Type="Choice" DisplayName="HTTP Type" EnforceUniqueValues="FALSE" Indexed="FALSE" Name="HTTPType" StaticName="HTTPType" Required="TRUE" FillInChoice="FALSE" Description="The HTTP method to use for this trigger. Ex: POST.">
99
<CHOICES>
1010
<CHOICE>POST</CHOICE>
@@ -32,9 +32,7 @@
3232
<Field ID="{2a9fd430-c7a1-43a5-b349-18fe46b7c049}" Type="Number" Name="SelectionLimit" DisplayName="Selection limit" Required="TRUE" StaticName="SelectionLimit" Description="The selected items limit for this trigger. Ex: 30.">
3333
<Default>30</Default>
3434
</Field>
35-
<Field ID="{2574742f-477c-4243-8f14-87048e83e6ee}" Type="Boolean" Name="UserInput" DisplayName="User input" Required="TRUE" StaticName="UserInput" Description="Whether additional user input is required before triggering the flow. NOTE: you have to code this functionality yourself in the command set.">
36-
<Default>0</Default>
37-
</Field>
35+
<Field ID="{2574742f-477c-4243-8f14-87048e83e6ee}" Type="Note" Name="RequestedUserInput" DisplayName="Requested user input" Required="FALSE" StaticName="RequestedUserInput" NumLines="500" RichText="FALSE" AppendOnly="FALSE" Description="An array with objects of input fields to request and pass to the flow. An example value can be found here: https://github.com/cupo365/enhanced-power-automate-command-set/blob/main/resources/request-user-input-example.jsonc. Leave empty to not request any user input." />
3836
</Fields>
3937
<Views>
4038
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
@@ -51,7 +49,7 @@
5149
<FieldRef Name="ContentTypeBlacklist"></FieldRef>
5250
<FieldRef Name="FileExtensionBlacklist"></FieldRef>
5351
<FieldRef Name="SelectionLimit"></FieldRef>
54-
<FieldRef Name="UserInput"></FieldRef>
52+
<FieldRef Name="RequestedUserInput"></FieldRef>
5553
</ViewFields>
5654
<Query>
5755
<OrderBy>
Binary file not shown.

SPFx/src/AppSettings.all.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22
"environments": {
33
"production": {
44
"ConfigListTitle": "Enhanced Power Automate Trigger Configuration",
5-
"FlowButtonDisplayLimit": 25
5+
"FlowButtonDisplayLimit": 25,
6+
"OriginSecret": "{YOUR_SECRET}"
67
},
78
"uat": {
89
"ConfigListTitle": "(UAT) Enhanced Power Automate Trigger Configuration",
9-
"FlowButtonDisplayLimit": 25
10+
"FlowButtonDisplayLimit": 25,
11+
"OriginSecret": "{YOUR_SECRET}"
1012
},
1113
"test": {
1214
"ConfigListTitle": "(TST) Enhanced Power Automate Trigger Configuration",
13-
"FlowButtonDisplayLimit": 25
15+
"FlowButtonDisplayLimit": 25,
16+
"OriginSecret": "{YOUR_SECRET}"
1417
},
1518
"development": {
1619
"ConfigListTitle": "(DEV) Enhanced Power Automate Trigger Configuration",
17-
"FlowButtonDisplayLimit": 25
20+
"FlowButtonDisplayLimit": 25,
21+
"OriginSecret": "{YOUR_SECRET}"
1822
}
1923
}
2024
}

SPFx/src/AppSettings.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
declare interface IAppSettings {
22
ConfigListTitle: string;
33
FlowButtonDisplayLimit: number;
4+
OriginSecret: string;
45
}
56

67
declare module 'AppSettings' {

SPFx/src/AppSettings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"ConfigListTitle": "Enhanced Power Automate Trigger Configuration",
3-
"FlowButtonDisplayLimit": 25
4-
}
3+
"FlowButtonDisplayLimit": 25,
4+
"OriginSecret": "{YOUR_SECRET}"
5+
}

SPFx/src/extensions/enhancedPowerAutomateTrigger/components/EnhancedPowerAutomateTriggerDialog.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ export const EnhancedPowerAutomateTriggerDialog: React.FC<IEnhancedPowerAutomate
8080
* Invokes the flow of the selected trigger button and handles its response
8181
*
8282
* @param flowConfig The selected flow to invoke
83+
* @param userInput Dictionary type mapping of the user input
8384
*/
84-
const onTriggerInvoke = async (flowConfig: ITriggerConfig): Promise<void> => {
85+
const onTriggerInvoke = async (flowConfig: ITriggerConfig, userInput: Map<string, string>): Promise<void> => {
8586
if (showUserInput) toggleShowUserInput();
8687
toggleIsWaitingForResponse();
87-
await flowService.invokeFlow(context, flowConfig, selectedItems)
88+
await flowService.invokeFlow(context, flowConfig, selectedItems, userInput)
8889
.then((response: IFlowResponse): void => {
8990
setFlowResponse(response);
9091
toggleIsWaitingForResponse();

SPFx/src/extensions/enhancedPowerAutomateTrigger/components/FlowButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import styles from "../styles/FlowButton.module.scss";
66

77
export interface IFlowButtonProps {
88
triggerConfig: ITriggerConfig;
9-
onTriggerInvoke(flowConfig: ITriggerConfig): Promise<void>;
9+
onTriggerInvoke(flowConfig: ITriggerConfig, userInput: object): Promise<void>;
1010
toggleShowUserInput(): void;
1111
setSelectedFlowTrigger(triggerConfig: ITriggerConfig): void;
1212
}
@@ -23,8 +23,8 @@ export const FlowButton: React.FC<IFlowButtonProps> = (
2323
className={styles.flowButton}
2424
onClick={async (): Promise<void> => {
2525
setSelectedFlowTrigger(triggerConfig);
26-
if (triggerConfig.userInput) toggleShowUserInput();
27-
else await onTriggerInvoke(triggerConfig);
26+
if (triggerConfig.requestedUserInput) toggleShowUserInput();
27+
else await onTriggerInvoke(triggerConfig, {});
2828
}}
2929
/>
3030
</div>

0 commit comments

Comments
 (0)