70 lines
2.4 KiB
Plaintext
70 lines
2.4 KiB
Plaintext
@using Moonlight.Frontend.UI.Admin.Components
|
|
@using Moonlight.Shared.Http.Requests.ApiKeys
|
|
@using ShadcnBlazor.Dialogs
|
|
@using ShadcnBlazor.Extras.Common
|
|
@using ShadcnBlazor.Extras.FormHandlers
|
|
@using ShadcnBlazor.Inputs
|
|
@using ShadcnBlazor.Labels
|
|
|
|
@inherits ShadcnBlazor.Extras.Dialogs.DialogBase
|
|
|
|
<DialogHeader>
|
|
<DialogTitle>Create new API key</DialogTitle>
|
|
<DialogDescription>
|
|
Define a name, description, and select the permissions that the key should have.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
|
|
<FormHandler @ref="FormHandler" Model="Request" OnValidSubmit="SubmitAsync">
|
|
<div class="flex flex-col gap-6">
|
|
<FormValidationSummary />
|
|
|
|
<div class="grid gap-2">
|
|
<Label for="keyName">Name</Label>
|
|
<InputField @bind-Value="Request.Name" id="keyName" placeholder="My API key" />
|
|
</div>
|
|
|
|
<div class="grid gap-2">
|
|
<Label for="keyDescription">Description</Label>
|
|
<textarea
|
|
@bind="Request.Description"
|
|
id="keyDescription"
|
|
maxlength="100"
|
|
class="border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"
|
|
placeholder="What this key is for">
|
|
|
|
</textarea>
|
|
</div>
|
|
|
|
<div class="grid gap-2">
|
|
<Label>Permissions</Label>
|
|
<PermissionSelector Permissions="Permissions" />
|
|
</div>
|
|
</div>
|
|
</FormHandler>
|
|
|
|
<DialogFooter ClassName="justify-end gap-x-1">
|
|
<WButtom OnClick="() => FormHandler.SubmitAsync()">Save changes</WButtom>
|
|
</DialogFooter>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public Func<CreateApiKeyDto, Task> OnSubmit { get; set; }
|
|
|
|
private CreateApiKeyDto Request;
|
|
private FormHandler FormHandler;
|
|
|
|
private List<string> Permissions = new();
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Request = new();
|
|
}
|
|
|
|
private async Task SubmitAsync()
|
|
{
|
|
Request.Permissions = Permissions.ToArray();
|
|
await OnSubmit.Invoke(Request);
|
|
await CloseAsync();
|
|
}
|
|
} |