feat(saved-routes): require server capability
Some checks failed
TrafficCue CI / check (push) Failing after 34s
TrafficCue CI / build (push) Failing after 34s

This commit is contained in:
Cfp
2025-08-19 12:48:44 +02:00
parent 64ed0c8204
commit 2f6f17ca52
3 changed files with 34 additions and 29 deletions

View File

@ -98,21 +98,23 @@
<VehicleSelector />
{#await getSaved() then saved}
{#if saved.length != 0}
<div>
<h2 style="margin: 5px; margin-left: 0; font-size: 1.2em;">Saved Routes</h2>
<RequiresCapability capability="saved-routes">
{#await getSaved() then saved}
{#if saved.length != 0}
<div>
<h2 style="margin: 5px; margin-left: 0; font-size: 1.2em;">Saved Routes</h2>
<div style="display: flex; flex-direction: column; gap: 10px;">
{#each saved as save}
<Button variant="secondary" onclick={() => {
view.switch("trip", { route: JSON.parse(save.data) })
}}>{save.name}</Button>
{/each}
<div style="display: flex; flex-direction: column; gap: 10px;">
{#each saved as save}
<Button variant="secondary" onclick={() => {
view.switch("trip", { route: JSON.parse(save.data) })
}}>{save.name}</Button>
{/each}
</div>
</div>
</div>
{/if}
{/await}
{/if}
{/await}
</RequiresCapability>
<RequiresCapability capability="post">
<div>

View File

@ -12,6 +12,7 @@
import { m } from "$lang/messages";
import { deleteSaved, isSaved, putSaved } from "$lib/services/lnv";
import { view } from "../view.svelte";
import RequiresCapability from "../RequiresCapability.svelte";
let {
route,
@ -45,21 +46,23 @@
<RouteIcon />
{m["sidebar.trip.start"]()}
</Button>
{#await isSaved($state.snapshot(route)) then saved}
<Button variant="secondary" onclick={async () => {
if(saved) {
await deleteSaved(saved);
view.back();
} else {
const name = prompt("Trip name?");
if(!name) return;
await putSaved(name, route);
}
}}>
<SaveIcon />
{saved ? m.unsave() : m["sidebar.trip.save"]()}
</Button>
{/await}
<RequiresCapability capability="saved-routes">
{#await isSaved($state.snapshot(route)) then saved}
<Button variant="secondary" onclick={async () => {
if(saved) {
await deleteSaved(saved);
view.back();
} else {
const name = prompt("Trip name?");
if(!name) return;
await putSaved(name, route);
}
}}>
<SaveIcon />
{saved ? m.unsave() : m["sidebar.trip.save"]()}
</Button>
{/await}
</RequiresCapability>
<Button variant="secondary" disabled>
<SendIcon />
{m["sidebar.trip.send"]()}

View File

@ -1,7 +1,7 @@
import { LNV_SERVER } from "./hosts";
import type { OIDCUser } from "./oidc";
export type Capabilities = ("auth" | "reviews" | "ai" | "fuel" | "post")[];
export type Capabilities = ("auth" | "reviews" | "ai" | "fuel" | "post" | "saved-routes")[];
export let capabilities: Capabilities = [];
export let oidcConfig: {
AUTH_URL: string;