diff --git a/src/lib/components/actionDropdown.svelte b/src/lib/components/actionDropdown.svelte new file mode 100644 index 000000000..5cbdedea0 --- /dev/null +++ b/src/lib/components/actionDropdown.svelte @@ -0,0 +1,212 @@ + + + +
+ {#if !$isSmallViewport} + + {:else} + + {/if} + + +
+ + + diff --git a/src/lib/components/breadcrumbs.svelte b/src/lib/components/breadcrumbs.svelte index 9f7220410..39aafa526 100644 --- a/src/lib/components/breadcrumbs.svelte +++ b/src/lib/components/breadcrumbs.svelte @@ -62,20 +62,8 @@ } } = createMenu(); - const { - elements: { - trigger: triggerArtifacts, - menu: menuArtifacts, - item: itemArtifacts, - separator: separatorArtifacts - } - } = createMenu(); - export let organizations: Organization[] = []; - $: displayArtifacts = ( - $page.url.pathname.includes('artifact') && isStudio ? $page.data.artifacts.artifacts : [] - ) as Artifact[]; $: selectedOrg = organizations.find((organization) => organization.isSelected); $: selectedProject = selectedOrg?.projects.find((project) => project.isSelected); diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts index 0e077aedb..20ae1593f 100644 --- a/src/lib/components/index.ts +++ b/src/lib/components/index.ts @@ -83,3 +83,4 @@ export { default as Confirm } from './confirm.svelte'; export { default as UsageCard } from './usageCard.svelte'; export { default as ViewToggle } from './viewToggle.svelte'; export { default as Terminal } from './studio/terminal.svelte'; +export { default as ActionDropdown } from './actionDropdown.svelte'; diff --git a/src/lib/helpers/artifact.ts b/src/lib/helpers/artifact.ts new file mode 100644 index 000000000..89fe65526 --- /dev/null +++ b/src/lib/helpers/artifact.ts @@ -0,0 +1,13 @@ +import { sdk } from '$lib/stores/sdk'; +import { ID } from '@appwrite.io/console'; +import { goto, invalidate } from '$app/navigation'; +import { base } from '$app/paths'; +import { page } from '$app/state'; +import { Dependencies } from '$lib/constants'; + +export async function createArtifact() { + const artifact = await sdk.forProject.imagine.create(ID.unique()); + + await goto(`${base}/project-${page.params.project}/studio/artifact-${artifact.$id}`); + invalidate(Dependencies.ARTIFACTS); +} diff --git a/src/routes/(console)/project-[project]/studio/+page.svelte b/src/routes/(console)/project-[project]/studio/+page.svelte index 3ba73038e..e717788bb 100644 --- a/src/routes/(console)/project-[project]/studio/+page.svelte +++ b/src/routes/(console)/project-[project]/studio/+page.svelte @@ -8,15 +8,9 @@ import { ID } from '@appwrite.io/console'; import { goto, invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; + import { createArtifact } from '$lib/helpers/artifact.js'; const { data } = $props(); - - async function createArtifact() { - const artifact = await sdk.forProject.imagine.create(ID.unique()); - - await goto(`${base}/project-${page.params.project}/studio/artifact-${artifact.$id}`); - invalidate(Dependencies.ARTIFACTS); - } diff --git a/src/routes/(console)/project-[project]/studio/artifact-[artifact]/+layout.svelte b/src/routes/(console)/project-[project]/studio/artifact-[artifact]/+layout.svelte index 95bf8588d..b9681edf8 100644 --- a/src/routes/(console)/project-[project]/studio/artifact-[artifact]/+layout.svelte +++ b/src/routes/(console)/project-[project]/studio/artifact-[artifact]/+layout.svelte @@ -9,7 +9,7 @@ } from '@appwrite.io/pink-svelte'; import { isTabSelected } from '$lib/helpers/load'; import { page } from '$app/state'; - import { Tab, Tabs, Terminal } from '$lib/components'; + import { ActionDropdown, Tab, Tabs, Terminal } from '$lib/components'; import { base } from '$app/paths'; import { isSmallViewport } from '$lib/stores/viewport'; import { @@ -19,7 +19,7 @@ IconChevronDown, IconPlusSm, IconTerminal, - IconWifi + IconPlus } from '@appwrite.io/pink-icons-svelte'; import { previewFrameRef } from '$routes/(console)/project-[project]/store'; import { @@ -42,6 +42,7 @@ import { filesystem } from '$lib/components/editor/filesystem'; import { InputSelect } from '$lib/elements/forms/index.js'; import { SvelteMap } from 'svelte/reactivity'; + import { createArtifact } from '$lib/helpers/artifact'; const { children } = $props(); @@ -149,8 +150,34 @@ terminals.set(symbol, createSynapse(endpoint, page.params.artifact)); currentTerminal = symbol; } + + let artifacts = $derived.by(() => { + const mappedArtifacts = page.data.artifacts?.artifacts + ? page.data.artifacts.artifacts.map((artifact) => { + return { + name: artifact.name, + isActive: page.params.artifact === artifact.$id, + href: `${base}/project-${page.params.project}/studio/artifact-${artifact.$id}` + }; + }) + : []; + + mappedArtifacts.push({ + name: 'Create artifact', + isActive: false, + onClick: createArtifact, + icon: IconPlus + }); + return mappedArtifacts; + }); +{#snippet artifactSelector()} + {#if page.data.artifacts?.artifacts} + + {/if} +{/snippet} +
- Dashboard + {@render artifactSelector()}
@@ -189,8 +215,7 @@ {#if !$isSmallViewport} - Dashboard + {@render artifactSelector()} {/if}