Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CodecServerErrorBanner component #2399

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/lib/components/codec-server-error-banner.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script lang="ts">
import { page } from '$app/stores';

import Banner from '$lib/holocene/banner/banner.svelte';
import { translate } from '$lib/i18n/translate';
import { dataEncoder } from '$lib/stores/data-encoder';
import { lastUsedNamespace } from '$lib/stores/namespaces';

$: namespace = $page.params?.namespace ?? $lastUsedNamespace;
$: pathNameSplit = $page.url.pathname.split('/');
$: showNamespaceSpecificNav =
namespace &&
(pathNameSplit.includes('workflows') ||
pathNameSplit.includes('schedules') ||
pathNameSplit.includes('batch-operations') ||
pathNameSplit.includes('task-queues') ||
pathNameSplit.includes('import'));
</script>

{#if $dataEncoder.hasError && showNamespaceSpecificNav}
<Banner
message={translate('data-encoder.codec-server-error')}
id="transcoder-error"
icon="transcoder-error"
type="danger"
/>
{:else}
<slot name="fallback" />
{/if}
23 changes: 4 additions & 19 deletions src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { page, updated } from '$app/stores';

import BottomNavigation from '$lib/components/bottom-nav.svelte';
import CodecServerErrorBanner from '$lib/components/codec-server-error-banner.svelte';
import DataEncoderSettings from '$lib/components/data-encoder-settings.svelte';
import SideNavigation from '$lib/components/side-nav.svelte';
import SkipNavigation from '$lib/components/skip-nav.svelte';
Expand All @@ -16,7 +17,6 @@
import { translate } from '$lib/i18n/translate';
import { clearAuthUser } from '$lib/stores/auth-user';
import { inProgressBatchOperation } from '$lib/stores/batch-operations';
import { dataEncoder } from '$lib/stores/data-encoder';
import { lastUsedNamespace, namespaces } from '$lib/stores/namespaces';
import { toaster } from '$lib/stores/toaster';
import type { NamespaceListItem, NavLinkListItem } from '$lib/types/global';
Expand Down Expand Up @@ -53,15 +53,6 @@
};
});

$: pathNameSplit = $page.url.pathname.split('/');
$: showNamespaceSpecificNav =
activeNamespaceName &&
(pathNameSplit.includes('workflows') ||
pathNameSplit.includes('schedules') ||
pathNameSplit.includes('batch-operations') ||
pathNameSplit.includes('task-queues') ||
pathNameSplit.includes('import'));

$: linkList = getLinkList(activeNamespaceName, !!$inProgressBatchOperation);

const getLinkList = (
Expand Down Expand Up @@ -200,21 +191,15 @@
<TopNavigation {namespaceList}>
<UserMenu {logout} />
</TopNavigation>
{#if $dataEncoder.hasError && showNamespaceSpecificNav}
<Banner
message={translate('data-encoder.codec-server-error')}
id="transcoder-error"
icon="transcoder-error"
type="danger"
/>
{:else}
<CodecServerErrorBanner>
<Banner
id="settings-banner-text"
message={$page.data.settings?.bannerText}
dismissable
dismissLabel={translate('common.close')}
slot="fallback"
/>
{/if}
</CodecServerErrorBanner>
<div
slot="main"
class="flex h-[calc(100%-2.5rem)] w-full flex-col gap-4 p-4 md:p-8"
Expand Down
Loading