|
11 | 11 | import { page } from '$app/state';
|
12 | 12 | import { toLocaleDateTime } from '$lib/helpers/date';
|
13 | 13 |
|
14 |
| - const showSelectProject = $props.showSelectProject; |
15 |
| - const selectedProjects = $state([]); |
| 14 | + let { showSelectProject = $bindable(false) } = $props(); |
| 15 | + let selectedProjects = $state([]); |
16 | 16 |
|
17 | 17 | let projects = $state<Array<Models.Project>>([]);
|
18 | 18 | let error = $state<string | null>(null);
|
|
31 | 31 | projects[0].teamId,
|
32 | 32 | selectedProjects
|
33 | 33 | );
|
34 |
| - showSelectProject.set(false); |
| 34 | + showSelectProject = false; |
35 | 35 | invalidate(Dependencies.ORGANIZATION);
|
36 | 36 | addNotification({
|
37 | 37 | type: 'success',
|
|
41 | 41 | error = e.message;
|
42 | 42 | }
|
43 | 43 | }
|
44 |
| - |
45 |
| - function formatProjectsToArchive(projects: Array<Models.Project>) { |
| 44 | +
|
| 45 | + function formatProjectsToArchive() { |
46 | 46 | let result = '';
|
47 |
| - |
| 47 | +
|
48 | 48 | projectsToArchive.forEach((project, index) => {
|
49 | 49 | const text = `${index === 0 ? '' : ' '}<b>${project.name}</b> `;
|
50 | 50 | result += text;
|
51 |
| - |
| 51 | +
|
52 | 52 | if (index < projectsToArchive.length - 1) {
|
53 | 53 | if (index == projectsToArchive.length - 2) {
|
54 | 54 | result += 'and ';
|
|
58 | 58 | }
|
59 | 59 | }
|
60 | 60 | });
|
61 |
| - |
| 61 | +
|
62 | 62 | return result;
|
63 | 63 | }
|
64 | 64 | </script>
|
65 | 65 |
|
66 |
| -<Modal bind:show={$showSelectProject} title={'Manage projects'} onSubmit={updateSelected}></Modal> |
| 66 | +<Modal bind:show={showSelectProject} title={'Manage projects'} onSubmit={updateSelected}> |
67 | 67 | <svelte:fragment slot="description">
|
68 | 68 | Choose which two projects to keep. Projects over the limit will be blocked after this date.
|
69 | 69 | </svelte:fragment>
|
|
73 | 73 | <Table.Root
|
74 | 74 | let:root
|
75 | 75 | allowSelection
|
76 |
| - bind:selectedRows={$selectedProjects} |
| 76 | + bind:selectedRows={selectedProjects} |
77 | 77 | columns={[{ id: 'name' }, { id: 'created' }]}>
|
78 | 78 | <svelte:fragment slot="header" let:root>
|
79 | 79 | <Table.Header.Cell column="name" {root}>Project Name</Table.Header.Cell>
|
|
87 | 87 | </Table.Row.Base>
|
88 | 88 | {/each}
|
89 | 89 | </Table.Root>
|
90 |
| - {#if $selectedProjects.length > 2} |
| 90 | + {#if selectedProjects.length > 2} |
91 | 91 | <div class="u-text-warning u-mb-4">
|
92 | 92 | You can only select two projects. Please deselect others to continue.
|
93 | 93 | </div>
|
94 | 94 | {/if}
|
95 |
| - {#if $selectedProjects.length === 2} |
| 95 | + {#if selectedProjects.length === 2} |
96 | 96 | <Alert.Inline
|
97 | 97 | status="warning"
|
98 |
| - title={`${projects.length - $selectedProjects.length} projects will be archived on ${billingProjectsLimitDate}`}> |
| 98 | + title={`${projects.length - selectedProjects.length} projects will be archived on ${billingProjectsLimitDate}`}> |
99 | 99 | <span>
|
100 |
| - {@html formatProjectsToArchive(projectsToArchive)} |
| 100 | + {@html formatProjectsToArchive()} |
101 | 101 | will be archived.
|
102 | 102 | </span>
|
103 | 103 | </Alert.Inline>
|
104 | 104 | {/if}
|
105 | 105 | <svelte:fragment slot="footer">
|
106 |
| - <Button.Button size="s" variant="secondary" on:click={() => ($showSelectProject = false)} |
| 106 | + <Button.Button size="s" variant="secondary" on:click={() => (showSelectProject = false)} |
107 | 107 | >Cancel</Button.Button>
|
108 |
| - <Button.Button size="s" disabled={$selectedProjects.length !== 2}>Save</Button.Button> |
| 108 | + <Button.Button size="s" disabled={selectedProjects.length !== 2}>Save</Button.Button> |
109 | 109 | </svelte:fragment>
|
110 | 110 | </Modal>
|
0 commit comments