|
1 |
| -@* |
| 1 | +@* |
2 | 2 | Copyright © 2022-Present The Synapse Authors
|
3 | 3 |
|
4 | 4 | Licensed under the Apache License, Version 2.0 (the "License");
|
|
16 | 16 |
|
17 | 17 | @namespace Synapse.Dashboard
|
18 | 18 |
|
19 |
| -@if(authentication != null) |
| 19 | +@if (authentication != null) |
20 | 20 | {
|
21 | 21 | <table class="table table-striped">
|
22 | 22 | <tbody>
|
23 | 23 | <tr>
|
24 | 24 | <td>Name</td>
|
25 |
| - <td><input type="text" value="@authentication.Name" required placeholder="Name" title="The authentication name" class="form-control" |
26 |
| - @onchange="async e => await OnPropertyChangedAsync(nameof(authentication.Name), a => a.Name = (string)e.Value!)"/></td> |
| 25 | + <td> |
| 26 | + <input type="text" value="@authentication.Name" required placeholder="Name" title="The authentication name" class="form-control" |
| 27 | + @onchange="async e => await OnPropertyChangedAsync(nameof(authentication.Name), a => a.Name = (string)e.Value!)" /> |
| 28 | + </td> |
27 | 29 | </tr>
|
28 | 30 | <tr>
|
29 | 31 | <td>Scheme</td>
|
30 | 32 | <td>
|
31 | 33 | <select class="form-select bg-secondary text-white"
|
32 |
| - @onchange="async e => await OnAuthenticationSchemeChangedAsync(EnumHelper.Parse<AuthenticationScheme>((string)e.Value!))"> |
33 |
| - @foreach(var scheme in Enum.GetValues<AuthenticationScheme>()) |
| 34 | + @onchange="async e => await OnAuthenticationSchemeChangedAsync(EnumHelper.Parse<AuthenticationScheme>((string)e.Value!))"> |
| 35 | + @foreach (var scheme in Enum.GetValues<AuthenticationScheme>()) |
34 | 36 | {
|
35 | 37 | var schemeStr = @EnumHelper.Stringify(scheme);
|
36 | 38 | <option value="@schemeStr" selected="@(authentication.Scheme == scheme)">@schemeStr</option>
|
|
40 | 42 | </tr>
|
41 | 43 | <ExpandableDataRow IsExpanded="true">
|
42 | 44 | <Header>
|
43 |
| - <td>Properties</td> |
44 |
| - <td> |
45 |
| - <div class="input-group"> |
46 |
| - <div class="input-group-text"> |
47 |
| - <input class="form-check-input mt-0 me-2" type="checkbox" value="@useSecretBasedProperties" checked="@useSecretBasedProperties" |
48 |
| - @onclick="OnUseSecretBasedPropertiesChanged"> |
49 |
| - <label title="Indicates whether or not to load the authentication properties from a secret">Load properties from secret</label> |
50 |
| - </div> |
| 45 | + <td>Properties</td> |
| 46 | + <td> |
| 47 | + <div class="input-group"> |
| 48 | + <div class="input-group-text"> |
| 49 | + <input class="form-check-input mt-0 me-2" type="checkbox" value="@useSecretBasedProperties" checked="@useSecretBasedProperties" |
| 50 | + @onclick="OnUseSecretBasedPropertiesChanged"> |
| 51 | + <label title="Indicates whether or not to load the authentication properties from a secret">Load properties from secret</label> |
| 52 | + </div> |
51 | 53 | @if (useSecretBasedProperties)
|
52 | 54 | {
|
53 |
| - <SecretSelector |
54 |
| - Secrets="Workflow.Secrets" |
| 55 | + <SecretSelector Secrets="Workflow.Secrets" |
55 | 56 | Selected="@(((SecretBasedAuthenticationProperties)authentication.Properties).Secret)"
|
56 |
| - OnChange="async secret => await OnPropertyChangedAsync(nameof(authentication.Properties), a => a.SecretRef = secret)"/> |
| 57 | + OnChange="async secret => await OnPropertyChangedAsync(nameof(authentication.Properties), a => a.SecretRef = secret)" /> |
57 | 58 | }
|
58 |
| - </div> |
59 |
| - </td> |
| 59 | + </div> |
| 60 | + </td> |
60 | 61 | </Header>
|
61 | 62 | <Body>
|
62 |
| - @if(!useSecretBasedProperties) |
| 63 | + @if (!useSecretBasedProperties) |
63 | 64 | {
|
64 |
| - <td colspan="3"> |
| 65 | + <td colspan="3"> |
65 | 66 | @switch (authentication.Scheme)
|
66 | 67 | {
|
67 | 68 | case AuthenticationScheme.Basic:
|
68 |
| - if(authentication.Properties is not BasicAuthenticationProperties basic) |
| 69 | + if (authentication.Properties is not BasicAuthenticationProperties basic) |
69 | 70 | {
|
70 | 71 | basic = new();
|
71 | 72 | authentication.Properties = basic;
|
72 | 73 | }
|
73 |
| - <table class="table table-striped"> |
74 |
| - <tbody> |
75 |
| - <tr> |
76 |
| - <td>Username</td> |
77 |
| - <td><input type="text" value="@basic.Username" required placeholder="Username" title="The username to use to authenticate" class="form-control" |
78 |
| - @onchange="async e => await OnAuthenticationPropertiesChangedAsync<BasicAuthenticationProperties>(p => p.Username = (string)e.Value!)"/></td> |
79 |
| - </tr> |
80 |
| - <tr> |
81 |
| - <td>Password</td> |
82 |
| - <td><input type="text" value="@basic.Password" required placeholder="Password" title="The password to use to authenticate" class="form-control" |
83 |
| - @onchange="async e => await OnAuthenticationPropertiesChangedAsync<BasicAuthenticationProperties>(p => p.Password = (string)e.Value!)"/></td> |
84 |
| - </tr> |
85 |
| - </tbody> |
86 |
| - </table> |
| 74 | + <table class="table table-striped"> |
| 75 | + <tbody> |
| 76 | + <tr> |
| 77 | + <td>Username</td> |
| 78 | + <td> |
| 79 | + <input type="text" value="@basic.Username" required placeholder="Username" title="The username to use to authenticate" class="form-control" |
| 80 | + @onchange="async e => await OnAuthenticationPropertiesChangedAsync<BasicAuthenticationProperties>(p => p.Username = (string)e.Value!)" /> |
| 81 | + </td> |
| 82 | + </tr> |
| 83 | + <tr> |
| 84 | + <td>Password</td> |
| 85 | + <td> |
| 86 | + <input type="text" value="@basic.Password" required placeholder="Password" title="The password to use to authenticate" class="form-control" |
| 87 | + @onchange="async e => await OnAuthenticationPropertiesChangedAsync<BasicAuthenticationProperties>(p => p.Password = (string)e.Value!)" /> |
| 88 | + </td> |
| 89 | + </tr> |
| 90 | + </tbody> |
| 91 | + </table> |
87 | 92 | break;
|
88 | 93 | case AuthenticationScheme.Bearer:
|
89 |
| - if(authentication.Properties is not BearerAuthenticationProperties bearer) |
| 94 | + if (authentication.Properties is not BearerAuthenticationProperties bearer) |
90 | 95 | {
|
91 | 96 | bearer = new();
|
92 | 97 | authentication.Properties = bearer;
|
93 | 98 | }
|
94 |
| - <table class="table table-striped"> |
95 |
| - <tbody> |
96 |
| - <tr> |
97 |
| - <td>Token</td> |
98 |
| - <td><textarea placeholder="Token" title="The token to use to authenticate" class="form-control" |
99 |
| - @onchange="async e => await OnPropertyChangedAsync(nameof(authentication.Properties), a => ((BearerAuthenticationProperties)a.Properties).Token = (string)e.Value!)">@bearer.Token</textarea></td> |
100 |
| - </tr> |
101 |
| - </tbody> |
102 |
| - </table> |
| 99 | + <table class="table table-striped"> |
| 100 | + <tbody> |
| 101 | + <tr> |
| 102 | + <td>Token</td> |
| 103 | + <td> |
| 104 | + <textarea placeholder="Token" title="The token to use to authenticate" class="form-control" |
| 105 | + @onchange="async e => await OnPropertyChangedAsync(nameof(authentication.Properties), a => ((BearerAuthenticationProperties)a.Properties).Token = (string)e.Value!)">@bearer.Token</textarea> |
| 106 | + </td> |
| 107 | + </tr> |
| 108 | + </tbody> |
| 109 | + </table> |
103 | 110 | break;
|
104 | 111 | case AuthenticationScheme.OAuth2:
|
105 |
| - if(authentication.Properties is not OAuth2AuthenticationProperties oauth2) |
| 112 | + if (authentication.Properties is not OAuth2AuthenticationProperties oauth2) |
106 | 113 | {
|
107 | 114 | oauth2 = new();
|
108 | 115 | authentication.Properties = oauth2;
|
109 | 116 | }
|
110 | 117 | break;
|
111 | 118 | default:
|
112 |
| - <span class="text-danger">The specified authentication scheme '@(EnumHelper.Stringify(authentication.Scheme))' is not supported</span> |
| 119 | + <span class="text-danger">The specified authentication scheme '@(EnumHelper.Stringify(authentication.Scheme))' is not supported</span> |
113 | 120 | break;
|
114 | 121 | }
|
115 |
| - </td> |
| 122 | + </td> |
116 | 123 | }
|
117 | 124 | </Body>
|
118 | 125 | </ExpandableDataRow>
|
|
147 | 154 | if (Authentication == null)
|
148 | 155 | return;
|
149 | 156 | this.useSecretBasedProperties = !useSecretBasedProperties;
|
150 |
| - if(!this.useSecretBasedProperties) |
| 157 | + if (!this.useSecretBasedProperties) |
151 | 158 | return;
|
152 | 159 | this.Authentication.SecretRef = "undefined";
|
153 | 160 | await this.OnChange.InvokeAsync(this.Authentication);
|
|
0 commit comments