UX: Disable comparison tool if not logged in

This commit is contained in:
Pieter Vander Vennet 2024-08-27 19:37:21 +02:00
parent 5c56651b5e
commit 065f03691f

View file

@ -15,6 +15,7 @@
import AccordionSingle from "../Flowbite/AccordionSingle.svelte"
import GlobeAlt from "@babeard/svelte-heroicons/mini/GlobeAlt"
import { ComparisonState } from "./ComparisonState"
import LoginToggle from "../Base/LoginToggle.svelte"
export let externalData: Store<
| { success: { content: Record<string, string> } }
@ -45,35 +46,38 @@
let enableLogin = state.featureSwitches.featureSwitchEnableLogin
</script>
{#if !$sourceUrl || !$enableLogin}
<!-- empty block -->
{:else if $externalData === undefined}
<Loading />
{:else if $externalData["error"] !== undefined}
<div class="subtle low-interaction rounded p-2 px-4 italic">
<Tr t={Translations.t.external.error} />
</div>
{:else if $propertyKeysExternal.length === 0 && $knownImages.size + $unknownImages.length === 0}
<Tr cls="subtle" t={t.noDataLoaded} />
{:else if !$hasDifferencesAtStart}
<LoginToggle {state} silentFail>
{#if !$sourceUrl || !$enableLogin}
<!-- empty block -->
{:else if $externalData === undefined}
<Loading />
{:else if $externalData["error"] !== undefined}
<div class="subtle low-interaction rounded p-2 px-4 italic">
<Tr t={Translations.t.external.error} />
</div>
{:else if $propertyKeysExternal.length === 0 && $knownImages.size + $unknownImages.length === 0}
<Tr cls="subtle" t={t.noDataLoaded} />
{:else if !$hasDifferencesAtStart}
<span class="subtle text-sm">
<Tr t={t.allIncluded.Subs({ source: $sourceUrl })} />
</span>
{:else if $comparisonState !== undefined}
<AccordionSingle expanded={!collapsed}>
{:else if $comparisonState !== undefined}
<AccordionSingle expanded={!collapsed}>
<span slot="header" class="flex">
<GlobeAlt class="h-6 w-6" />
<Tr t={Translations.t.external.title} />
</span>
<ComparisonTable
externalProperties={$externalData["success"]}
{state}
{feature}
{layer}
{tags}
{readonly}
sourceUrl={$sourceUrl}
comparisonState={$comparisonState}
/>
</AccordionSingle>
{/if}
<ComparisonTable
externalProperties={$externalData["success"]}
{state}
{feature}
{layer}
{tags}
{readonly}
sourceUrl={$sourceUrl}
comparisonState={$comparisonState}
/>
</AccordionSingle>
{/if}
</LoginToggle>