|
4 | 4 | import RemoveProjectButton from './RemoveProjectButton.svelte'; |
5 | 5 | import notFoundSvg from '$lib/assets/illustrations/not-found.svg?raw'; |
6 | 6 | import { ProjectService } from '$lib/backend/projects'; |
7 | | - import InfoMessage from '$lib/shared/InfoMessage.svelte'; |
| 7 | + import InfoMessage, { type MessageStyle } from '$lib/shared/InfoMessage.svelte'; |
8 | 8 | import Spacer from '$lib/shared/Spacer.svelte'; |
9 | 9 | import { getContext } from '$lib/utils/context'; |
10 | 10 | import Button from '@gitbutler/ui/Button.svelte'; |
|
36 | 36 | await projectService.relocateProject(id); |
37 | 37 | } |
38 | 38 |
|
39 | | - function getDeletionStatusMessage(repoName: string) { |
40 | | - if (deleteSucceeded === undefined) return null; |
41 | | - if (deleteSucceeded) return `Project "${repoName}" successfully deleted`; |
42 | | - return `Failed to delete "${repoName}" project`; |
| 39 | + interface DeletionStatus { |
| 40 | + message: string; |
| 41 | + style: MessageStyle; |
| 42 | + } |
| 43 | +
|
| 44 | + function getDeletionStatus(repoName: string, deleteSucceeded: boolean): DeletionStatus { |
| 45 | + return deleteSucceeded |
| 46 | + ? { message: `Project "${repoName}" successfully deleted`, style: 'success' } |
| 47 | + : { message: `Failed to delete "${repoName}" project`, style: 'error' }; |
43 | 48 | } |
44 | 49 | </script> |
45 | 50 |
|
46 | 51 | <DecorativeSplitView img={notFoundSvg}> |
47 | 52 | <div class="container" data-tauri-drag-region> |
48 | | - {#if deleteSucceeded === undefined} |
49 | | - {#await projectPromise then project} |
| 53 | + {#await projectPromise then project} |
| 54 | + {#if deleteSucceeded === undefined} |
50 | 55 | <div class="text-content"> |
51 | 56 | <h2 class="title-text text-18 text-body text-bold" data-tauri-drag-region> |
52 | 57 | Can’t find "{project.title}" |
|
76 | 81 | onDeleteClicked={async () => await stopTracking(project.id)} |
77 | 82 | /> |
78 | 83 | </div> |
79 | | - |
80 | | - {#if deleteSucceeded !== undefined} |
81 | | - <InfoMessage filled outlined={false} style="success" icon="info"> |
82 | | - <svelte:fragment slot="content" |
83 | | - >{getDeletionStatusMessage(project.title)}</svelte:fragment |
84 | | - > |
85 | | - </InfoMessage> |
86 | | - {/if} |
87 | | - {:catch} |
88 | | - <div class="text-content"> |
89 | | - <h2 class="title-text text-18 text-body text-bold">Can’t find project</h2> |
90 | | - </div> |
91 | | - {/await} |
92 | | - {/if} |
| 84 | + {/if} |
| 85 | + |
| 86 | + {#if deleteSucceeded !== undefined} |
| 87 | + {@const deletionStatus = getDeletionStatus(project.title, deleteSucceeded)} |
| 88 | + <InfoMessage filled outlined={false} style={deletionStatus.style} icon="info"> |
| 89 | + <svelte:fragment slot="content"> |
| 90 | + {deletionStatus.message} |
| 91 | + </svelte:fragment> |
| 92 | + </InfoMessage> |
| 93 | + {/if} |
| 94 | + {:catch} |
| 95 | + <div class="text-content"> |
| 96 | + <h2 class="title-text text-18 text-body text-bold">Can’t find project</h2> |
| 97 | + </div> |
| 98 | + {/await} |
93 | 99 |
|
94 | 100 | <Spacer dotted margin={0} /> |
95 | 101 | <ProjectSwitcher /> |
|
0 commit comments