Skip to content

Commit 25693f3

Browse files
committed
feat(Dashboard): enabled custom functions and service accounts edition
Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
1 parent 1eda1a4 commit 25693f3

File tree

13 files changed

+1140
-25
lines changed

13 files changed

+1140
-25
lines changed

src/dashboard/Synapse.Dashboard/Components/Breadcrumb/Breadcrumbs.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public static class Breadcrumbs
5353
/// </summary>
5454
public static BreadcrumbItem[] Correlations = [new("Correlations", "/correlations")];
5555
/// <summary>
56+
/// Holds the breadcrumb items for <see cref="ServiceAccount"/> related routes
57+
/// </summary>
58+
public static BreadcrumbItem[] ServiceAccounts = [new("Service Accounts", "/service-accounts")];
59+
/// <summary>
5660
/// Holds the breadcrumb items for about related routes
5761
/// </summary>
5862
public static BreadcrumbItem[] About = [new("About", "/about")];
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
@*
2+
Copyright © 2024-Present The Synapse Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*@
16+
17+
@namespace Synapse.Dashboard.Components
18+
19+
@if (resource != null)
20+
{
21+
22+
<div class="container-fluid">
23+
<div class="row">
24+
<table class="table mb-3">
25+
<tbody>
26+
<tr>
27+
<td>API Version</td>
28+
<td>@resource.ApiVersion</td>
29+
</tr>
30+
<tr>
31+
<td>Kind</td>
32+
<td>@resource.Kind</td>
33+
</tr>
34+
<tr>
35+
<td>Name</td>
36+
<td>@resource.GetName()</td>
37+
</tr>
38+
@if (resource.IsNamespaced() == true)
39+
{
40+
<tr>
41+
<td>Namespace</td>
42+
<td>@resource.GetNamespace()</td>
43+
</tr>
44+
}
45+
<tr>
46+
<td>Creation Time</td>
47+
<td>@resource.Metadata.CreationTimestamp?.ToString("R")</td>
48+
</tr>
49+
<tr>
50+
<td>Generation</td>
51+
<td>@resource.Metadata.Generation</td>
52+
</tr>
53+
@if (resource.Metadata.Labels?.Any() == true)
54+
{
55+
<tr>
56+
<td>Labels</td>
57+
<td>
58+
@foreach (var label in resource.Metadata.Labels)
59+
{
60+
<span class="badge bg-primary text-dark m-1">@label.Key: @label.Value</span>
61+
}
62+
</td>
63+
</tr>
64+
}
65+
<tr>
66+
<td>Latest version</td>
67+
<td>@resource.Spec.Versions.GetLatestVersion()</td>
68+
</tr>
69+
<tr>
70+
<td colspan="2">
71+
Latest definition
72+
<br />
73+
<MonacoEditor Document="resource.Spec.Versions.GetLatest()" IsReadOnly="true" />
74+
</td>
75+
</tr>
76+
</tbody>
77+
</table>
78+
</div>
79+
</div>
80+
}
81+
82+
@code {
83+
84+
CustomFunction? resource;
85+
/// <summary>
86+
/// Gets/sets the resource to display details about
87+
/// </summary>
88+
[Parameter] public CustomFunction? Resource { get; set; }
89+
90+
/// <inheritdoc/>
91+
protected override Task OnParametersSetAsync()
92+
{
93+
if(this.resource != this.Resource)
94+
{
95+
this.resource = this.Resource;
96+
}
97+
return base.OnParametersSetAsync();
98+
}
99+
100+
}

src/dashboard/Synapse.Dashboard/Components/ResourceManagement/NamespacedResourceManagementComponentStore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void SetNamespace(string? @namespace)
6767
/// Lists all available <see cref="Namespace"/>s
6868
/// </summary>
6969
/// <returns>A new awaitable <see cref="Task"/></returns>
70-
public virtual async Task ListNamespaceAsync()
70+
public virtual async Task ListNamespacesAsync()
7171
{
7272
var namespaceList = new EquatableList<Namespace>(await (await this.ApiClient.Namespaces.ListAsync().ConfigureAwait(false)).OrderBy(ns => ns.GetQualifiedName()).ToListAsync().ConfigureAwait(false));
7373
this.Reduce(s => s with
@@ -85,7 +85,7 @@ public override async Task DeleteResourceAsync(TResource resource)
8585
/// <inheritdoc/>
8686
public override async Task InitializeAsync()
8787
{
88-
await this.ListNamespaceAsync().ConfigureAwait(false);
88+
await this.ListNamespacesAsync().ConfigureAwait(false);
8989
await base.InitializeAsync();
9090
}
9191

src/dashboard/Synapse.Dashboard/Components/ResourceManagement/ResourceManagementComponent.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public abstract class ResourceManagementComponent<TComponent, TStore, TState, TR
4040
/// Gets/sets the service used for JS interop
4141
/// </summary>
4242
[Inject]
43-
protected JSInterop jsInterop { get; set; } = default!;
43+
protected JSInterop JsInterop { get; set; } = default!;
4444

4545
/// <summary>
4646
/// Gets the service used to serialize/deserialize objects to/from JSON
@@ -118,15 +118,15 @@ protected override async Task OnInitializedAsync()
118118

119119
if (selectedResourceNames.Count == 0)
120120
{
121-
await this.jsInterop.SetCheckboxStateAsync(this.CheckboxAll.Value, CheckboxState.Unchecked);
121+
await this.JsInterop.SetCheckboxStateAsync(this.CheckboxAll.Value, CheckboxState.Unchecked);
122122
}
123123
else if (selectedResourceNames.Count == (resources?.Count ?? 0))
124124
{
125-
await this.jsInterop.SetCheckboxStateAsync(this.CheckboxAll.Value, CheckboxState.Checked);
125+
await this.JsInterop.SetCheckboxStateAsync(this.CheckboxAll.Value, CheckboxState.Checked);
126126
}
127127
else
128128
{
129-
await this.jsInterop.SetCheckboxStateAsync(this.CheckboxAll.Value, CheckboxState.Indeterminate);
129+
await this.JsInterop.SetCheckboxStateAsync(this.CheckboxAll.Value, CheckboxState.Indeterminate);
130130
}
131131
}
132132
}, cancellationToken: this.CancellationTokenSource.Token);
@@ -222,12 +222,12 @@ protected async Task OnDeleteSelectedResourcesAsync()
222222
/// Opens the targeted <see cref="Resource"/>'s details
223223
/// </summary>
224224
/// <param name="resource">The <see cref="Resource"/> to show the details for</param>
225-
protected Task OnShowResourceDetailsAsync(TResource resource)
225+
protected virtual Task OnShowResourceDetailsAsync(TResource resource)
226226
{
227227
if (this.DetailsOffCanvas == null) return Task.CompletedTask;
228228
var parameters = new Dictionary<string, object>
229229
{
230-
{ nameof(ResourceEditor<TResource>.Resource), resource }
230+
{ nameof(ResourceDetails<TResource>.Resource), resource }
231231
};
232232
return this.DetailsOffCanvas.ShowAsync<ResourceDetails<TResource>>(title: typeof(TResource).Name + " details", parameters: parameters);
233233
}

src/dashboard/Synapse.Dashboard/Layout/MainLayout.razor

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</li>
6262
<li class="nav-item">
6363
<div class="dropdown">
64-
<button class="btn nav-link dropdown-toggle @(IsActive("correlators", NavLinkMatch.Prefix) || IsActive("operators", NavLinkMatch.Prefix) ? "active" : "")" type="button" id="servicesDropdownButton" data-bs-toggle="dropdown" aria-expanded="false">
64+
<button class="btn nav-link dropdown-toggle @(IsActive("correlators", NavLinkMatch.Prefix) || IsActive("operators", NavLinkMatch.Prefix) || IsActive("service-accounts", NavLinkMatch.Prefix) ? "active" : "")" type="button" id="servicesDropdownButton" data-bs-toggle="dropdown" aria-expanded="false">
6565
<span class="btn-label">Services</span>
6666
</button>
6767
<ul class="dropdown-menu" aria-labelledby="servicesDropdownButton">
@@ -75,6 +75,11 @@
7575
<span class="btn-label">Operators</span>
7676
</NavLink>
7777
</li>
78+
<li>
79+
<NavLink class="nav-link" href="service-accounts" Match="NavLinkMatch.All">
80+
<span class="btn-label">Serivce Accounts</span>
81+
</NavLink>
82+
</li>
7883
</ul>
7984
</div>
8085
</li>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Copyright © 2024-Present The Synapse Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
using Semver;
15+
using ServerlessWorkflow.Sdk.Models;
16+
using Synapse.Resources;
17+
18+
namespace Synapse.Dashboard.Pages.Functions.Create;
19+
20+
/// <summary>
21+
/// The <see cref="State{TState}"/> of the workflow editor
22+
/// </summary>
23+
[Feature]
24+
public record CreateFunctionViewState
25+
{
26+
/// <summary>
27+
/// Gets a <see cref="EquatableList{T}"/> that contains all <see cref="Neuroglia.Data.Infrastructure.ResourceOriented.Namespace"/>s
28+
/// </summary>
29+
public EquatableList<Namespace>? Namespaces { get; set; }
30+
31+
/// <summary>
32+
/// Gets/sets the <see cref="CustomFunction"/>'s namespace
33+
/// </summary>
34+
public string? Namespace { get; set; }
35+
36+
/// <summary>
37+
/// Gets/sets the <see cref="CustomFunction"/>'s name
38+
/// </summary>
39+
public string? Name { get; set; }
40+
41+
/// <summary>
42+
/// Gets/sets the <see cref="CustomFunction"/>'s namespace, when the user is creating one
43+
/// </summary>
44+
public string? ChosenNamespace { get; set; }
45+
46+
/// <summary>
47+
/// Gets/sets the <see cref="CustomFunction"/>'s name, when the user is creating one
48+
/// </summary>
49+
public string? ChosenName { get; set; }
50+
51+
/// <summary>
52+
/// Gets/sets the function text representation
53+
/// </summary>
54+
public SemVersion Version { get; set; } = new SemVersion(1, 0, 0);
55+
56+
/// <summary>
57+
/// Gets/sets the definition of the workflow to create
58+
/// </summary>
59+
public TaskDefinition? Function { get; set; } = null;
60+
61+
/// <summary>
62+
/// Gets/sets the function text representation
63+
/// </summary>
64+
public string? FunctionText { get; set; }
65+
66+
/// <summary>
67+
/// Gets/sets a boolean indicating whether or not the state is being loaded
68+
/// </summary>
69+
public bool Loading { get; set; } = false;
70+
71+
/// <summary>
72+
/// Defines if the function is being updated
73+
/// </summary>
74+
public bool Updating { get; set; } = false;
75+
76+
/// <summary>
77+
/// Defines if the function is being saved
78+
/// </summary>
79+
public bool Saving { get; set; } = false;
80+
81+
/// <summary>
82+
/// Gets/sets the <see cref="ProblemDetails"/> type that occurred when trying to save the resource, if any
83+
/// </summary>
84+
public Uri? ProblemType { get; set; } = null;
85+
86+
/// <summary>
87+
/// Gets/sets the <see cref="ProblemDetails"/> title that occurred when trying to save the resource, if any
88+
/// </summary>
89+
public string ProblemTitle { get; set; } = string.Empty;
90+
91+
/// <summary>
92+
/// Gets/sets the <see cref="ProblemDetails"/> details that occurred when trying to save the resource, if any
93+
/// </summary>
94+
public string ProblemDetail { get; set; } = string.Empty;
95+
96+
/// <summary>
97+
/// Gets/sets the <see cref="ProblemDetails"/> status that occurred when trying to save the resource, if any
98+
/// </summary>
99+
public int ProblemStatus { get; set; } = 0;
100+
101+
/// <summary>
102+
/// Gets/sets the list of <see cref="ProblemDetails"/> errors that occurred when trying to save the resource, if any
103+
/// </summary>
104+
public IDictionary<string, string[]> ProblemErrors { get; set; } = new Dictionary<string, string[]>();
105+
106+
}

0 commit comments

Comments
 (0)