Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import { api, failureMessage, isForbidden, isUnauthorized } from "$lib/api";
|
||||
import type { MeResponse } from "$lib/types";
|
||||
import PageShell from "$lib/components/PageShell.svelte";
|
||||
import Spinner from "$lib/components/Spinner.svelte";
|
||||
import ForbiddenEmptyState from "$lib/components/ForbiddenEmptyState.svelte";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle
|
||||
} from "$lib/components/ui";
|
||||
import { i18n } from "$lib/i18n";
|
||||
|
||||
let loading = $state(true);
|
||||
let accessDenied = $state(false);
|
||||
let error = $state("");
|
||||
let me = $state<MeResponse | null>(null);
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
me = await api<MeResponse>("/api/auth/me");
|
||||
} catch (err) {
|
||||
if (isUnauthorized(err)) {
|
||||
await goto("/login");
|
||||
return;
|
||||
}
|
||||
if (isForbidden(err)) {
|
||||
accessDenied = true;
|
||||
return;
|
||||
}
|
||||
error = failureMessage(err, i18n.t("admin.bootstrap.loadFailed"));
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<PageShell
|
||||
title={i18n.t("admin.bootstrap.title")}
|
||||
description={i18n.t("admin.bootstrap.description")}
|
||||
>
|
||||
{#if loading}
|
||||
<Spinner />
|
||||
{:else if accessDenied}
|
||||
<ForbiddenEmptyState kind="platform" />
|
||||
{:else}
|
||||
<Card class="mx-auto max-w-md">
|
||||
<CardHeader>
|
||||
<CardTitle>{i18n.t("admin.bootstrap.statusTitle")}</CardTitle>
|
||||
<CardDescription>
|
||||
{i18n.t("admin.bootstrap.statusDesc")}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{#if me?.user?.is_platform_admin}
|
||||
<div class="rounded-md border border-green-500/30 bg-green-500/10 p-4 text-sm">
|
||||
<p class="font-medium">{i18n.t("admin.bootstrap.alreadyAdmin")}</p>
|
||||
<p class="mt-2 text-muted-foreground">
|
||||
{i18n.t("admin.bootstrap.signedInAs", { email: me.user.email })}
|
||||
</p>
|
||||
</div>
|
||||
{:else if error}
|
||||
<div class="rounded-md border border-destructive/30 bg-destructive/10 p-4 text-sm">
|
||||
<p>{error}</p>
|
||||
</div>
|
||||
{:else}
|
||||
<ForbiddenEmptyState
|
||||
kind="platform"
|
||||
title={i18n.t("admin.bootstrap.notAdminTitle")}
|
||||
message={i18n.t("admin.bootstrap.notAdminMsg")}
|
||||
/>
|
||||
{#if me?.user}
|
||||
<p class="mt-3 text-center text-sm text-muted-foreground">{i18n.t("admin.bootstrap.signedInAsShort", { email: me.user.email })}</p>
|
||||
{/if}
|
||||
{/if}
|
||||
</CardContent>
|
||||
<CardFooter class="flex justify-between gap-2">
|
||||
{#if me?.user?.is_platform_admin}
|
||||
<Button class="w-full" onclick={() => goto("/admin")}>{i18n.t("admin.bootstrap.goToPanel")}</Button>
|
||||
{:else}
|
||||
<Button variant="outline" class="w-full" onclick={() => goto("/dashboard")}>
|
||||
{i18n.t("admin.chrome.backToApp")}
|
||||
</Button>
|
||||
{/if}
|
||||
</CardFooter>
|
||||
</Card>
|
||||
{/if}
|
||||
</PageShell>
|
||||
Reference in New Issue
Block a user