mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: build links for breadcrumbs
This commit is contained in:
1 parent
0ecc38540f
commit
5c3cea215e
19 files changed
+84
-31
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<script lang="ts">
|
||||
import { breadcrumbs as breadcrumbsStore, level, type Breadcrumb } from '$lib/stores/layout';
|
||||
|
||||
$: breadcrumbs = [...$breadcrumbsStore]
|
||||
.map(([level, value]) => ({ level, value }))
|
||||
.sort((a, b) => (a.level > b.level ? 1 : -1))
|
||||
.filter((n) => n.level <= $level);
|
||||
|
||||
function truncate(
|
||||
breadcrumbs: {
|
||||
value: Breadcrumb;
|
||||
}[]
|
||||
) {
|
||||
/**
|
||||
* Maximum of 4 Breadcrumbs, truncated from the left.
|
||||
*/
|
||||
if ($level > 4) {
|
||||
breadcrumbs = [
|
||||
{
|
||||
value: {
|
||||
href: null,
|
||||
title: '...'
|
||||
}
|
||||
},
|
||||
...breadcrumbs.slice(-3)
|
||||
];
|
||||
}
|
||||
|
||||
return breadcrumbs;
|
||||
}
|
||||
|
||||
function buildHref(index: number) {
|
||||
return breadcrumbs
|
||||
.slice(0, index + 1)
|
||||
.reduce((prev, next) => `${prev}/${next.value.href}`, '');
|
||||
}
|
||||
</script>
|
||||
|
||||
<nav class="breadcrumbs is-only-desktop" aria-label="breadcrumb">
|
||||
<ol class="breadcrumbs-list">
|
||||
{#each truncate(breadcrumbs) as breadcrumb, i}
|
||||
<li class="breadcrumbs-item">
|
||||
{#if breadcrumb.value.href}
|
||||
<a href={buildHref(breadcrumbs.length > 4 ? i + breadcrumbs.length - 4 : i)}
|
||||
>{breadcrumb.value.title}</a>
|
||||
{:else}
|
||||
<span>{breadcrumb.value.title}</span>
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
</nav>
|
||||
@@ -9,28 +9,16 @@
|
||||
import LightMode from '$lib/images/mode/light-mode.svg';
|
||||
import DarkMode from '$lib/images/mode/dark-mode.svg';
|
||||
import SystemMode from '$lib/images/mode/system-mode.svg';
|
||||
import { breadcrumbs as breadcrumbsStore, level } from '$lib/stores/layout';
|
||||
import Breadcrumbs from './breadcrumbs.svelte';
|
||||
|
||||
let showDropdown = false;
|
||||
|
||||
$: breadcrumbs = [...$breadcrumbsStore]
|
||||
.map(([level, value]) => ({ level, value }))
|
||||
.sort((a, b) => (a.level > b.level ? 1 : -1))
|
||||
.filter((n) => n.level <= $level);
|
||||
</script>
|
||||
|
||||
<a class="logo" href={`${base}/console`}>
|
||||
<img src={AppwriteLogo} width="132" height="34" alt="Appwrite" />
|
||||
</a>
|
||||
<nav class="breadcrumbs is-only-desktop" aria-label="breadcrumb">
|
||||
<ol class="breadcrumbs-list">
|
||||
{#each breadcrumbs as breadcrumb}
|
||||
<li class="breadcrumbs-item">
|
||||
<a href={breadcrumb.value.href}>{breadcrumb.value.title}</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<Breadcrumbs />
|
||||
|
||||
<div class="main-header-end">
|
||||
<nav class="u-flex is-only-desktop">
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
afterNavigate(handle);
|
||||
|
||||
let loaded = false;
|
||||
const path = 'console';
|
||||
async function handle(event = null) {
|
||||
if ($project?.$id !== projectId) {
|
||||
setProject(projectId);
|
||||
@@ -62,12 +63,12 @@
|
||||
level: 2,
|
||||
breadcrumbs: [
|
||||
{
|
||||
href: '#',
|
||||
href: path,
|
||||
title: $organisation.name,
|
||||
level: 1
|
||||
},
|
||||
{
|
||||
href: '#',
|
||||
href: $project.$id,
|
||||
title: $project.name
|
||||
}
|
||||
]
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
title: 'Databases',
|
||||
level: 3,
|
||||
breadcrumbs: {
|
||||
href: '#',
|
||||
href: 'databases',
|
||||
title: 'Databases'
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
title: $database.name,
|
||||
level: 4,
|
||||
breadcrumbs: {
|
||||
href: '#',
|
||||
href: `database/${databaseId}`,
|
||||
title: $database.name
|
||||
},
|
||||
tabs: [
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
title: $collection.name,
|
||||
level: 5,
|
||||
breadcrumbs: {
|
||||
href: '#',
|
||||
href: `collection/${collectionId}`,
|
||||
title: $collection.name
|
||||
},
|
||||
back: `${base}/console/${$page.params.project}/database`,
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
level: 6,
|
||||
breadcrumbs: {
|
||||
title: $doc.$id,
|
||||
href: '#'
|
||||
href: `document/${documentId}`
|
||||
},
|
||||
tabs: [
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
title: 'Functions',
|
||||
level: 3,
|
||||
breadcrumbs: {
|
||||
href: '#',
|
||||
href: 'functions',
|
||||
title: 'Functions'
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
level: 4,
|
||||
breadcrumbs: {
|
||||
title: $func.name,
|
||||
href: '#'
|
||||
href: `function/${functionId}`
|
||||
},
|
||||
tabs: [
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
title: 'API Keys',
|
||||
level: 3,
|
||||
breadcrumbs: {
|
||||
href: '#',
|
||||
href: 'keys',
|
||||
title: 'API Keys'
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
level: 3,
|
||||
breadcrumbs: {
|
||||
title: 'Settings',
|
||||
href: '#'
|
||||
href: 'settings'
|
||||
},
|
||||
tabs: [
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
level: 3,
|
||||
breadcrumbs: {
|
||||
title: 'Storage',
|
||||
href: '#'
|
||||
href: 'storage'
|
||||
},
|
||||
tabs: [
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
level: 4,
|
||||
breadcrumbs: {
|
||||
title: $bucket.name,
|
||||
href: '#'
|
||||
href: `bucket/${bucketId}`
|
||||
},
|
||||
copy: {
|
||||
text: 'Bucket ID',
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
navigate: event,
|
||||
level: 5,
|
||||
breadcrumbs: {
|
||||
href: '#',
|
||||
href: `file/${fileId}`,
|
||||
title: $file.name
|
||||
},
|
||||
back: `${base}/console/${$page.params.project}/storage/bucket/${bucketId}`,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
level: 3,
|
||||
breadcrumbs: {
|
||||
title: 'Users',
|
||||
href: '#'
|
||||
href: path
|
||||
},
|
||||
tabs: [
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
back: `${base}/console/${$page.params.project}/users/teams`,
|
||||
breadcrumbs: {
|
||||
title: $team.name,
|
||||
href: '#'
|
||||
href: `teams/${teamId}`
|
||||
},
|
||||
copy: {
|
||||
text: 'Team ID',
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
level: 4,
|
||||
breadcrumbs: {
|
||||
title: $user.name,
|
||||
href: '#'
|
||||
href: `user/${userId}`
|
||||
},
|
||||
back: `${base}/console/${$page.params.project}/users`,
|
||||
copy: {
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
<script lang="ts">
|
||||
import Shell from '$lib/layout/shell.svelte';
|
||||
import Header from '$lib/layout/header.svelte';
|
||||
import { updateLayout } from '$lib/stores/layout';
|
||||
|
||||
updateLayout({
|
||||
title: 'Projects',
|
||||
level: 0
|
||||
});
|
||||
</script>
|
||||
|
||||
<Shell>
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
import Shell from '$lib/layout/shell.svelte';
|
||||
import SideNavigation from '$lib/layout/navigation.svelte';
|
||||
import Header from '$lib/layout/header.svelte';
|
||||
import { updateLayout } from '$lib/stores/layout';
|
||||
|
||||
updateLayout({
|
||||
title: 'Projects',
|
||||
level: 0
|
||||
});
|
||||
</script>
|
||||
|
||||
<Shell showSideNavigation>
|
||||
|
||||
Reference in new issue
Block a user