|
8 | 8 | @inject IFlowSynxClient FlowSynxClient |
9 | 9 | @inject ISnackbar SnackBar |
10 | 10 |
|
11 | | -<MudDialog> |
12 | | - <TitleContent> |
13 | | - <MudText Typo="Typo.h6"> |
14 | | - <MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-3 mb-n1" /> Add workflow trigger |
15 | | - </MudText> |
16 | | - </TitleContent> |
| 11 | +<MudDialog MaxWidth="MaxWidth.Medium" |
| 12 | + FullWidth="true" |
| 13 | + DisableBackdropClick="@IsProcessing" |
| 14 | + CloseOnEscapeKey="false"> |
| 15 | + |
17 | 16 | <DialogContent> |
18 | | - <MudGrid> |
19 | | - <MudItem xs="12" md="12"> |
20 | | - <MudSelect T="string" |
21 | | - Label="Trigger Type" |
22 | | - For="@(() => AddWorkflowTriggerRequest.Type)" |
23 | | - @bind-Value="AddWorkflowTriggerRequest.Type" |
24 | | - Variant="Variant.Text" |
25 | | - Margin="Margin.Dense" |
26 | | - Clearable="false" |
27 | | - OpenIcon="@Icons.Material.Filled.ArrowDropDown" |
28 | | - CloseIcon="@Icons.Material.Filled.ArrowDropUp" |
29 | | - HelperText="Enter the type of workflow trigger"> |
30 | | - @foreach (var triggerType in Enum.GetValues<WorkflowTriggerType>()) |
31 | | - { |
32 | | - <MudSelectItem Value="@triggerType.ToString().ToLower()">@triggerType</MudSelectItem> |
33 | | - } |
34 | | - </MudSelect> |
35 | | - </MudItem> |
36 | | - <MudItem xs="12"> |
37 | | - <MudSwitch @bind-Value="AddWorkflowTriggerRequest.Status" |
38 | | - Converter="_statusConverter" |
39 | | - Label="Active" |
40 | | - Color="Color.Primary" /> |
41 | | - </MudItem> |
42 | | - <MudItem xs="12" md="12"> |
43 | | - <MudText Typo="Typo.h6" Color="Color.Primary">Properties</MudText> |
44 | | - <MudTable Items="Properties" Hover="true" Breakpoint="Breakpoint.Sm" Dense="true"> |
| 17 | + |
| 18 | + <MudCard Elevation="0" Class="rounded-xl"> |
| 19 | + |
| 20 | + <!-- Body --> |
| 21 | + <MudCardContent Class="pt-4"> |
| 22 | + |
| 23 | + <!-- Trigger basics --> |
| 24 | + <MudGrid Spacing="3"> |
| 25 | + |
| 26 | + <MudItem xs="12" md="6"> |
| 27 | + <MudSelect T="string" |
| 28 | + Label="Trigger Type" |
| 29 | + @bind-Value="AddWorkflowTriggerRequest.Type" |
| 30 | + Variant="Variant.Filled" |
| 31 | + StartIcon="@Icons.Material.Filled.Category" |
| 32 | + Disabled="@IsProcessing"> |
| 33 | + @foreach (var triggerType in Enum.GetValues<WorkflowTriggerType>()) |
| 34 | + { |
| 35 | + <MudSelectItem Value="@triggerType.ToString()"> |
| 36 | + @triggerType |
| 37 | + </MudSelectItem> |
| 38 | + } |
| 39 | + </MudSelect> |
| 40 | + </MudItem> |
| 41 | + |
| 42 | + <MudItem xs="12" md="6" Class="d-flex align-center"> |
| 43 | + <MudSwitch @bind-Value="AddWorkflowTriggerRequest.Status" |
| 44 | + Converter="_statusConverter" |
| 45 | + Color="Color.Primary" |
| 46 | + Label="Trigger Active" |
| 47 | + Disabled="@IsProcessing" /> |
| 48 | + </MudItem> |
| 49 | + |
| 50 | + </MudGrid> |
| 51 | + |
| 52 | + <MudDivider Class="my-4" /> |
| 53 | + |
| 54 | + <!-- Properties --> |
| 55 | + <MudText Typo="Typo.h6" Class="mb-2"> |
| 56 | + Trigger Properties |
| 57 | + </MudText> |
| 58 | + |
| 59 | + <MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-3"> |
| 60 | + Define key–value parameters used by the trigger. |
| 61 | + </MudText> |
| 62 | + |
| 63 | + <MudTable Items="Properties" |
| 64 | + Dense="true" |
| 65 | + Hover="true" |
| 66 | + Breakpoint="Breakpoint.Sm"> |
| 67 | + |
45 | 68 | <ToolBarContent> |
46 | | - <MudButton DisableElevation |
47 | | - Variant="Variant.Outlined" |
48 | | - Color="Color.Default" |
49 | | - Size="@Size.Small" |
50 | | - Class="size-small-button" |
51 | | - OnClick="AddProperty">Add properties</MudButton> |
| 69 | + <MudButton Variant="Variant.Text" |
| 70 | + Color="Color.Primary" |
| 71 | + StartIcon="@Icons.Material.Filled.Add" |
| 72 | + Disabled="@IsProcessing" |
| 73 | + OnClick="AddProperty"> |
| 74 | + Add Property |
| 75 | + </MudButton> |
52 | 76 | </ToolBarContent> |
| 77 | + |
53 | 78 | <HeaderContent> |
54 | 79 | <MudTh>Key</MudTh> |
55 | 80 | <MudTh>Value</MudTh> |
56 | 81 | <MudTh></MudTh> |
57 | 82 | </HeaderContent> |
| 83 | + |
58 | 84 | <RowTemplate> |
59 | 85 | <MudTd> |
60 | | - <MudTextField For="@(() => context.Key)" |
61 | | - @bind-Value="context.Key" |
62 | | - Variant="Variant.Text" |
63 | | - Margin="Margin.Dense" /> |
| 86 | + <MudTextField @bind-Value="context.Key" |
| 87 | + Variant="Variant.Filled" |
| 88 | + Placeholder="Key" |
| 89 | + Margin="Margin.Dense" |
| 90 | + Disabled="@IsProcessing" /> |
64 | 91 | </MudTd> |
| 92 | + |
65 | 93 | <MudTd> |
66 | | - <MudTextField For="@(() => context.Value)" |
67 | | - @bind-Value="context.Value" |
68 | | - Variant="Variant.Text" |
69 | | - Margin="Margin.Dense" /> |
| 94 | + <MudTextField @bind-Value="context.Value" |
| 95 | + Variant="Variant.Filled" |
| 96 | + Placeholder="Value" |
| 97 | + Margin="Margin.Dense" |
| 98 | + Disabled="@IsProcessing" /> |
70 | 99 | </MudTd> |
| 100 | + |
71 | 101 | <MudTd> |
72 | 102 | <MudIconButton Icon="@Icons.Material.Filled.Delete" |
73 | | - Variant="Variant.Text" |
74 | 103 | Color="Color.Error" |
75 | | - Size="Size.Small" |
76 | | - OnClick="@(() => DeleteProperty(context.Id))"></MudIconButton> |
| 104 | + Disabled="@IsProcessing" |
| 105 | + OnClick="@(() => DeleteProperty(context.Id))" /> |
77 | 106 | </MudTd> |
78 | 107 | </RowTemplate> |
| 108 | + <NoRecordsContent> |
| 109 | + <MudText>No properties defined.</MudText> |
| 110 | + </NoRecordsContent> |
| 111 | + <LoadingContent> |
| 112 | + <MudText>Loading...</MudText> |
| 113 | + </LoadingContent> |
79 | 114 | </MudTable> |
80 | | - </MudItem> |
81 | | - </MudGrid> |
| 115 | + |
| 116 | + </MudCardContent> |
| 117 | + |
| 118 | + <!-- Footer --> |
| 119 | + <MudDivider /> |
| 120 | + |
| 121 | + <MudCardActions Class="pa-4 d-flex justify-end gap-2"> |
| 122 | + |
| 123 | + <MudButton Variant="Variant.Text" |
| 124 | + Color="Color.Default" |
| 125 | + Disabled="@IsProcessing" |
| 126 | + OnClick="Cancel"> |
| 127 | + Cancel |
| 128 | + </MudButton> |
| 129 | + |
| 130 | + <MudButton Variant="Variant.Filled" |
| 131 | + Color="Color.Primary" |
| 132 | + Disabled="@IsProcessing" |
| 133 | + OnClick="Add" |
| 134 | + StartIcon="@Icons.Material.Filled.Add"> |
| 135 | + |
| 136 | + @if (IsProcessing) |
| 137 | + { |
| 138 | + <MudProgressCircular Indeterminate="true" |
| 139 | + Size="Size.Small" |
| 140 | + Class="mr-2" /> |
| 141 | + <span>Adding…</span> |
| 142 | + } |
| 143 | + else |
| 144 | + { |
| 145 | + <span>Add Trigger</span> |
| 146 | + } |
| 147 | + </MudButton> |
| 148 | + |
| 149 | + </MudCardActions> |
| 150 | + |
| 151 | + </MudCard> |
| 152 | + |
82 | 153 | </DialogContent> |
83 | | - <DialogActions> |
84 | | - <MudButton DisableElevation Variant="Variant.Outlined" |
85 | | - StartIcon="@Icons.Material.Filled.Close" |
86 | | - Color="Color.Default" |
87 | | - Disabled="@IsProcessing" |
88 | | - Size="Size.Small" |
89 | | - OnClick="Cancel">Cancel</MudButton> |
90 | | - |
91 | | - <MudButton DisableElevation Variant="Variant.Filled" |
92 | | - StartIcon="@Icons.Material.Filled.Add" |
93 | | - Color="Color.Primary" |
94 | | - Disabled="@IsProcessing" |
95 | | - Size="Size.Small" |
96 | | - OnClick="Add">@(IsProcessing ? "Adding..." : "Add")</MudButton> |
97 | | - </DialogActions> |
98 | 154 | </MudDialog> |
99 | 155 |
|
100 | 156 | @code { |
|
107 | 163 | private bool IsProcessing = false; |
108 | 164 | private List<TempKeyValue> Properties = new List<TempKeyValue>(); |
109 | 165 | private AddWorkflowTriggerRequest AddWorkflowTriggerRequest = new() |
110 | | - { |
111 | | - WorkflowId = Guid.Empty, |
112 | | - Status = WorkflowTriggerStatus.Active.ToString(), |
113 | | - Type = WorkflowTriggerType.TimeBased.ToString(), |
114 | | - Properties = new() |
115 | | - }; |
| 166 | + { |
| 167 | + WorkflowId = Guid.Empty, |
| 168 | + Status = WorkflowTriggerStatus.Active.ToString(), |
| 169 | + Type = WorkflowTriggerType.Time.ToString(), |
| 170 | + Properties = new() |
| 171 | + }; |
116 | 172 |
|
117 | 173 | private readonly MudBlazor.Converter<string, bool?> _statusConverter = new() |
118 | | - { |
119 | | - SetFunc = status => status == WorkflowTriggerStatus.Active.ToString(), |
120 | | - GetFunc = isActive => isActive == true ? |
121 | | - WorkflowTriggerStatus.Active.ToString() : |
122 | | - WorkflowTriggerStatus.DeActive.ToString() |
123 | | - }; |
| 174 | + { |
| 175 | + SetFunc = status => status == WorkflowTriggerStatus.Active.ToString(), |
| 176 | + GetFunc = isActive => isActive == true ? |
| 177 | + WorkflowTriggerStatus.Active.ToString() : |
| 178 | + WorkflowTriggerStatus.DeActive.ToString() |
| 179 | + }; |
124 | 180 |
|
125 | 181 | private void Cancel() |
126 | 182 | { |
|
224 | 280 |
|
225 | 281 | private enum WorkflowTriggerType |
226 | 282 | { |
227 | | - TimeBased |
| 283 | + Time |
228 | 284 | } |
229 | 285 |
|
230 | 286 | private enum WorkflowTriggerStatus |
|
0 commit comments