new archive projects ui

This commit is contained in:
Harsh Mahajan committed 2025-08-25 17:21:13 +05:30
1 parent 0f0c76b1cd
commit 5cd65a3752
6 files changed
+176 -18

No files matched your search

+154
View File
@@ -0,0 +1,154 @@
<script lang="ts">
import { Button } from '$lib/elements/forms';
import { CardContainer, DropList, GridItem1 } from '$lib/components';
import {
Badge,
Icon,
Typography,
Tag,
Accordion,
ActionMenu,
Popover
} from '@appwrite.io/pink-svelte';
import {
IconAndroid,
IconApple,
IconCode,
IconFlutter,
IconReact,
IconUnity,
IconInfo,
IconDotsHorizontal,
IconInboxIn,
IconSwitchHorizontal
} from '@appwrite.io/pink-icons-svelte';
import { getPlatformInfo } from '$lib/helpers/platform';
import type { Models } from '@appwrite.io/console';
import type { ComponentType } from 'svelte';
// props
interface Props {
projectsToArchive: Models.Project[];
}
let { projectsToArchive }: Props = $props();
// Track Read-only info droplist per archived project
let readOnlyInfoOpen = $state<Record<string, boolean>>({});
function filterPlatforms(platforms: { name: string; icon: string }[]) {
return platforms.filter(
(value, index, self) => index === self.findIndex((t) => t.name === value.name)
);
}
function getIconForPlatform(platform: string): ComponentType {
switch (platform) {
case 'code':
return IconCode;
case 'flutter':
return IconFlutter;
case 'apple':
return IconApple;
case 'android':
return IconAndroid;
case 'react-native':
return IconReact;
case 'unity':
return IconUnity;
default:
return IconCode;
}
}
</script>
{#if projectsToArchive.length > 0}
<div style="margin-top: 36px;">
<Accordion title="Archived projects" badge={`${projectsToArchive.length}`}>
<Typography.Text tag="p" size="s">
These projects have been archived and are read-only. You can view and migrate their
data.
</Typography.Text>
<div style="margin-top: 16px; margin-bottom: 36px;">
<CardContainer>
{#each projectsToArchive as project}
{@const platforms = filterPlatforms(
project.platforms.map((platform) => getPlatformInfo(platform.type))
)}
<GridItem1>
<svelte:fragment slot="eyebrow">
{project?.platforms?.length ? project?.platforms?.length : 'No'} apps
</svelte:fragment>
<svelte:fragment slot="title">{project.name}</svelte:fragment>
<svelte:fragment slot="status">
<span style="display: flex; align-items: center; gap: 8px;">
<DropList
bind:show={readOnlyInfoOpen[project.$id]}
placement="bottom-start"
noArrow>
<Tag
size="s"
style="white-space: nowrap; max-width: none;"
on:click={(e) => {
e.preventDefault();
e.stopPropagation();
readOnlyInfoOpen = {
...readOnlyInfoOpen,
[project.$id]: !readOnlyInfoOpen[project.$id]
};
}}>
<Icon icon={IconInfo} size="s" />
<span>Read only</span>
</Tag>
<svelte:fragment slot="list">
<li
class="drop-list-item u-width-250"
style="padding: var(--space-5, 12px) var(--space-6, 16px)">
<span class="u-block u-mb-8">
Archived projects are read-only. You can view
and migrate their data, but they no longer
accept edits or requests.
</span>
</li>
</svelte:fragment>
</DropList>
<Popover let:toggle padding="none" placement="bottom-end">
<Button
text
icon
size="s"
ariaLabel="more options"
on:click={(e) => {
e.preventDefault();
e.stopPropagation();
toggle(e);
}}>
<Icon icon={IconDotsHorizontal} size="s" />
</Button>
<ActionMenu.Root slot="tooltip">
<ActionMenu.Item.Button leadingIcon={IconInboxIn}
>Unarchive project</ActionMenu.Item.Button>
<ActionMenu.Item.Button
leadingIcon={IconSwitchHorizontal}
>Migrate project</ActionMenu.Item.Button>
</ActionMenu.Root>
</Popover>
</span>
</svelte:fragment>
{#each platforms.slice(0, 2) as platform}
{@const icon = getIconForPlatform(platform.icon)}
<Badge
variant="secondary"
content={platform.name}
style="width: max-content;">
<Icon {icon} size="s" slot="start" />
</Badge>
{/each}
</GridItem1>
{/each}
</CardContainer>
</div>
</Accordion>
</div>
{/if}
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { Card, Layout, Typography } from '@appwrite.io/pink-svelte';
export let href: string;
export let href: string = null;
</script>
<Card.Link class="card" {href}>
+3 -3
View File
@@ -207,7 +207,7 @@ export type AggregationTeam = {
* Aggregation billing plan
*/
plan: string;
projectBreakdown: ProjectBreakdown[]
projectBreakdown: ProjectBreakdown[];
};
export type ProjectBreakdown = {
@@ -215,13 +215,13 @@ export type ProjectBreakdown = {
name: string;
amount: number;
resources: InvoiceUsage[];
}
};
export type InvoiceUsage = {
resourceId: string;
value: number;
amount: number;
}
};
export type AvailableCredit = {
available: number;
@@ -40,6 +40,7 @@
import CreateProjectCloud from './createProjectCloud.svelte';
import { currentPlan, regions as regionsStore } from '$lib/stores/organization';
import SelectProjectCloud from '$lib/components/billing/alerts/selectProjectCloud.svelte';
import ArchiveProject from '$lib/components/archiveProject.svelte';
import { toLocaleDate } from '$lib/helpers/date';
export let data;
@@ -138,6 +139,10 @@
$: projectsToArchive = data.projects.projects.filter(
(project) => !data.organization.projects?.includes(project.$id)
);
$: activeProjects = data.projects.projects.filter((project) =>
data.organization.projects?.includes(project.$id)
);
</script>
<SelectProjectCloud selectedProjects={data.organization.projects || []} bind:showSelectProject />
@@ -167,9 +172,9 @@
</DropList>
</div>
{#if isCloud && $currentPlan?.projects && $currentPlan?.projects > 0 && data.organization.projects.length > 0 && data.projects.total > 2 && $canWriteProjects}
{#if isCloud && $currentPlan?.projects && $currentPlan?.projects > 0 && data.organization.projects.length > 0 && projectsToArchive.length > 0 && $canWriteProjects}
<Alert.Inline
title={`${data.projects.total - data.organization.projects.length} projects will be archived on ${toLocaleDate(billingProjectsLimitDate)}`}>
title={`${projectsToArchive.length} projects will be archived on ${toLocaleDate(billingProjectsLimitDate)}`}>
<Typography.Text>
{#each projectsToArchive as project, index}{@const text = `<b>${project.name}</b>`}
{@html text}{index == projectsToArchive.length - 2
@@ -199,13 +204,13 @@
</Alert.Inline>
{/if}
{#if data.projects.total}
{#if activeProjects.length > 0}
<CardContainer
disableEmpty={!$canWriteProjects}
total={data.projects.total}
total={activeProjects.length}
offset={data.offset}
on:click={handleCreateProject}>
{#each data.projects.projects as project}
{#each activeProjects as project}
{@const platforms = filterPlatforms(
project.platforms.map((platform) => getPlatformInfo(platform.type))
)}
@@ -270,7 +275,7 @@
<p>Create a new project</p>
</svelte:fragment>
</CardContainer>
{:else}
{:else if data.projects.total === 0}
<Empty
single
allowCreate={$canWriteProjects}
@@ -283,7 +288,10 @@
name="Projects"
limit={data.limit}
offset={data.offset}
total={data.projects.total} />
total={activeProjects.length} />
<!-- Archived Projects Section -->
<ArchiveProject {projectsToArchive} />
</Container>
<CreateOrganization bind:show={addOrganization} />
@@ -85,7 +85,7 @@
</Table.Row.Base>
{/each}
{#each currentAggregation.projectBreakdown as projectBreakdown}
<Accordion title="{projectBreakdown.name}">
<Accordion title={projectBreakdown.name}>
<svelte:fragment slot="end">
{formatCurrency(projectBreakdown.amount)}
</svelte:fragment>
@@ -96,9 +96,7 @@
{/if}
<Layout.Stack gap="xxxs">
<Layout.Stack
direction="row"
justifyContent="space-between">
<Layout.Stack direction="row" justifyContent="space-between">
<Typography.Text color="--fgcolor-neutral-primary">
{resource.resourceId}
</Typography.Text>
@@ -7,9 +7,7 @@ export const load: PageLoad = async ({ depends, parent }) => {
const { members, currentPlan, organizations } = await parent();
depends(Dependencies.UPGRADE_PLAN);
const [plans] = await Promise.all([
sdk.forConsole.billing.listPlans()
]);
const [plans] = await Promise.all([sdk.forConsole.billing.listPlans()]);
let plan: BillingPlan;
if (currentPlan?.$id === BillingPlan.SCALE) {