|
1 | 1 | <script lang="ts"> |
2 | 2 | import { Button, InputText } from '$lib/elements/forms'; |
3 | | - import { DropList, GridItem1, CardContainer, Modal } from '$lib/components'; |
| 3 | + import { GridItem1, CardContainer, Modal } from '$lib/components'; |
4 | 4 | import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; |
5 | 5 | import { |
6 | 6 | Badge, |
7 | 7 | Icon, |
8 | 8 | Typography, |
9 | | - Tag, |
10 | 9 | Accordion, |
11 | 10 | ActionMenu, |
12 | 11 | Popover, |
|
20 | 19 | IconFlutter, |
21 | 20 | IconReact, |
22 | 21 | IconUnity, |
23 | | - IconInfo, |
24 | 22 | IconDotsHorizontal, |
25 | 23 | IconInboxIn, |
26 | 24 | IconSwitchHorizontal, |
|
29 | 27 | import { getPlatformInfo } from '$lib/helpers/platform'; |
30 | 28 | import { Status, type Models } from '@appwrite.io/console'; |
31 | 29 | import type { ComponentType } from 'svelte'; |
32 | | - import { BillingPlan } from '$lib/constants'; |
33 | 30 | import { goto } from '$app/navigation'; |
34 | 31 | import { base } from '$app/paths'; |
35 | 32 | import { sdk } from '$lib/stores/sdk'; |
|
52 | 49 |
|
53 | 50 | let { projectsToArchive, organization, currentPlan }: Props = $props(); |
54 | 51 |
|
55 | | - // Track Read-only info droplist per archived project |
56 | | - let readOnlyInfoOpen = $state<Record<string, boolean>>({}); |
| 52 | + // Check if current plan order is less than Pro (order < 1 means FREE plan) |
| 53 | + let isPlanBelowPro = $derived(currentPlan?.order < 1); |
| 54 | +
|
57 | 55 | let showUnarchiveModal = $state(false); |
58 | 56 | let projectToUnarchive = $state<Models.Project | null>(null); |
59 | 57 | let showDeleteModal = $state(false); |
|
97 | 95 | function isUnarchiveDisabled(): boolean { |
98 | 96 | if (!organization || !currentPlan) return true; |
99 | 97 |
|
100 | | - if (organization.billingPlan === BillingPlan.FREE) { |
| 98 | + if (isPlanBelowPro) { |
101 | 99 | const currentProjectCount = organization.projects?.length || 0; |
102 | 100 | const projectLimit = currentPlan.projects || 0; |
103 | 101 |
|
|
196 | 194 |
|
197 | 195 | {#if projectsToArchive.length > 0} |
198 | 196 | <div class="archive-projects-margin-top"> |
199 | | - <Accordion title="Archived projects" badge={`${projectsToArchive.length}`}> |
| 197 | + <Accordion |
| 198 | + title={isPlanBelowPro ? 'Archived projects' : 'Pending archive'} |
| 199 | + badge={`${projectsToArchive.length}`}> |
200 | 200 | <Typography.Text tag="p" size="s"> |
201 | | - These projects have been archived and are read-only. You can view and migrate their |
202 | | - data. |
| 201 | + {#if isPlanBelowPro} |
| 202 | + These projects are archived and require a plan upgrade to restore access. |
| 203 | + {:else} |
| 204 | + These projects will be archived at the end of your billing cycle. |
| 205 | + {/if} |
203 | 206 | </Typography.Text> |
204 | 207 |
|
205 | 208 | <div class="archive-projects-margin"> |
|
216 | 219 | <svelte:fragment slot="title">{formatted}</svelte:fragment> |
217 | 220 | <svelte:fragment slot="status"> |
218 | 221 | <div class="status-container"> |
219 | | - <DropList |
220 | | - bind:show={readOnlyInfoOpen[project.$id]} |
221 | | - placement="bottom-start" |
222 | | - noArrow> |
223 | | - <Tag |
224 | | - size="s" |
225 | | - style="white-space: nowrap;" |
226 | | - on:click={(e) => { |
227 | | - e.preventDefault(); |
228 | | - e.stopPropagation(); |
229 | | - readOnlyInfoOpen = { |
230 | | - ...readOnlyInfoOpen, |
231 | | - [project.$id]: !readOnlyInfoOpen[project.$id] |
232 | | - }; |
233 | | - }}> |
234 | | - <Icon icon={IconInfo} size="s" /> |
235 | | - <span>Read only</span> |
236 | | - </Tag> |
237 | | - <svelte:fragment slot="list"> |
238 | | - <li |
239 | | - class="drop-list-item u-width-250" |
240 | | - style="padding: var(--space-5, 12px) var(--space-6, 16px)"> |
241 | | - <span class="u-block u-mb-8"> |
242 | | - Archived projects are read-only. You can view |
243 | | - and migrate their data, but they no longer |
244 | | - accept edits or requests. |
245 | | - </span> |
246 | | - </li> |
247 | | - </svelte:fragment> |
248 | | - </DropList> |
249 | 222 | <Popover let:toggle padding="none" placement="bottom-end"> |
250 | 223 | <Button |
251 | 224 | text |
|
267 | 240 | >Unarchive project</ActionMenu.Item.Button> |
268 | 241 | <ActionMenu.Item.Button |
269 | 242 | leadingIcon={IconSwitchHorizontal} |
| 243 | + disabled={isUnarchiveDisabled()} |
270 | 244 | on:click={() => handleMigrateProject(project)} |
271 | 245 | >Migrate project</ActionMenu.Item.Button> |
272 | 246 | <div class="action-menu-divider"> |
|
0 commit comments