feat: header dropdown organization implementation

This commit is contained in:
Arman committed 2022-08-24 10:49:43 +02:00
1 parent a609a741c7
commit 3abad19f02
3 files changed
+39 -5

No files matched your search

+31 -4
View File
@@ -10,8 +10,18 @@
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 { organizationList, organization, newOrgModal } from '../../routes/console/store';
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
let showDropdown = false;
onMount(async () => {
await organizationList.load();
if (!$organization) {
await organization.load($organizationList.teams[0].$id);
}
});
</script>
<a class="logo" href={`${base}/console`}>
@@ -41,8 +51,8 @@
src={sdkForConsole.avatars.getInitials($user.name, 40, 40).toString()} />
<span class="user-profile-info is-only-desktop">
<span class="name">{$user.name}</span>
{#if $project}
<span class="title">{$project.name}</span>
{#if $organization}
<span class="title">{$organization.name}</span>
{/if}
</span>
<span
@@ -52,10 +62,27 @@
class:icon-cheveron-down={!showDropdown} />
</button>
<svelte:fragment slot="list">
<DropListItem icon="plus">New organization</DropListItem>
<DropListLink href="/console/$me">Your Account</DropListLink>
{#each $organizationList.teams as org}
<DropListItem
on:click={() => {
showDropdown = false;
goto(`/console`);
organization.set(org);
}}>{org.name}</DropListItem>
{/each}
</svelte:fragment>
<svelte:fragment slot="other">
<section class="drop-section">
<ul class="drop-list">
<DropListItem
icon="plus"
on:click={() => {
showDropdown = false;
newOrgModal.set(true);
}}>New organization</DropListItem>
<DropListLink href="/console/$me">Your Account</DropListLink>
</ul>
</section>
<section class="drop-section">
<ul class="u-flex u-gap-12">
<li>
+6 -1
View File
@@ -3,7 +3,8 @@
import SideNavigation from '$lib/layout/navigation.svelte';
import Header from '$lib/layout/header.svelte';
import { updateLayout } from '$lib/stores/layout';
import { organization } from './store';
import { organization, newOrgModal } from './store';
import Create from './_createOrganization.svelte';
updateLayout({
title: $organization.name ?? 'Projects',
@@ -21,3 +22,7 @@
<slot />
<footer class="main-footer" />
</Shell>
{#if $newOrgModal}
<Create bind:show={$newOrgModal} />
{/if}
@@ -7,6 +7,7 @@
import { createEventDispatcher } from 'svelte';
import { organization, organizationList } from './store';
import { titleDropdown } from '$lib/stores/layout';
import { goto } from '$app/navigation';
export let show = false;
@@ -24,6 +25,7 @@
await organizationList.load();
titleDropdown.set($organizationList.teams);
organization.set(team);
goto('/console');
addNotification({
type: 'success',
message: `${name} has been created`