Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): migration svelte 5 syntax #13883

Merged
merged 78 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
87d13ac
chore(web): migration svelte 5 syntax
alextran1502 Nov 2, 2024
d6a3d47
chore(web): migration svelte 5 syntax
alextran1502 Nov 2, 2024
0f83ebf
chore(web): migration svelte 5 syntax
alextran1502 Nov 2, 2024
ffe7274
chore(web): migration svelte 5 syntax
alextran1502 Nov 2, 2024
f308e01
chore(web): migration svelte 5 syntax
alextran1502 Nov 2, 2024
1c69e9f
chore(web): migration svelte 5 syntax
alextran1502 Nov 2, 2024
b977585
chore(web): migration svelte 5 syntax
alextran1502 Nov 3, 2024
c70b866
formatting
alextran1502 Nov 3, 2024
3a9d559
bind:this to call component's method in Svelte 5
alextran1502 Nov 3, 2024
111e721
it is aliveee
alextran1502 Nov 3, 2024
8f7cb4b
chore(web): migration svelte 5 syntax
alextran1502 Nov 4, 2024
b5de150
refactor: combobox
alextran1502 Nov 4, 2024
c4c2a36
refactor: search filter modal
alextran1502 Nov 4, 2024
a782b63
refactor: asset viewer context menu
alextran1502 Nov 4, 2024
6f5d53a
refactor: asset viewer copy image
alextran1502 Nov 4, 2024
2564703
refactor: copyImage
alextran1502 Nov 4, 2024
0d56122
refactor: asset grid and photos page
alextran1502 Nov 4, 2024
d66c644
refactor: favorite action
alextran1502 Nov 4, 2024
24d1070
refactor: settings
alextran1502 Nov 4, 2024
bde70d8
refactor: settings
alextran1502 Nov 5, 2024
ab00493
Merge branch 'main' of github.com:immich-app/immich into migrate-svel…
alextran1502 Nov 5, 2024
4bbdcd3
Merge branch 'main' of github.com:immich-app/immich into migrate-svel…
alextran1502 Nov 5, 2024
fa2347a
refactor: user settings
alextran1502 Nov 5, 2024
6e61ace
refactor: on:click
alextran1502 Nov 5, 2024
89028b2
onboarding, albums, onclick
alextran1502 Nov 6, 2024
ac9857a
Merge branch 'main' of github.com:immich-app/immich into migrate-svel…
alextran1502 Nov 6, 2024
dfd095a
refactor: on:click complete
alextran1502 Nov 6, 2024
dbb72c2
refactor: map
alextran1502 Nov 6, 2024
12ff3d8
people page
alextran1502 Nov 7, 2024
5fa2490
migration script
alextran1502 Nov 7, 2024
c25b93b
Successfully run migration script
alextran1502 Nov 7, 2024
ba771f7
chore(web): migration svelte 5 syntax
alextran1502 Nov 7, 2024
b9e5077
wip
alextran1502 Nov 7, 2024
d8018ef
wip
alextran1502 Nov 8, 2024
8e0a33b
wip
alextran1502 Nov 8, 2024
7d24bc8
wip
alextran1502 Nov 8, 2024
2cdf48f
pr feedback
alextran1502 Nov 8, 2024
46da39e
fix: lint
alextran1502 Nov 8, 2024
3099d8c
fix: test
alextran1502 Nov 8, 2024
dd37893
Merge branch 'main' of github.com:immich-app/immich into migrate-svel…
alextran1502 Nov 8, 2024
0ebd96e
fix: combobox - change-date test
alextran1502 Nov 8, 2024
05dbc02
fix: photo-viewer test
alextran1502 Nov 8, 2024
8f91053
merge main
alextran1502 Nov 8, 2024
a8e7f57
skip a test
alextran1502 Nov 8, 2024
cbfb256
fix album card test
michelheusschen Nov 8, 2024
ba39e4e
fix: slideshow-progressbar
alextran1502 Nov 8, 2024
788dfa0
remove console.log
alextran1502 Nov 8, 2024
f42593a
remove console.log
alextran1502 Nov 8, 2024
cd0cdb1
fix: preload asset causes infinite loop when change stack item
alextran1502 Nov 9, 2024
4d2621d
$derived tidy up
michelheusschen Nov 9, 2024
d9bc17b
fix: description not updating when navigating between assets
alextran1502 Nov 9, 2024
471827b
fix: cannot close slideshow setting
alextran1502 Nov 9, 2024
e104e95
fix: slideshow auto jump to end
alextran1502 Nov 9, 2024
1cdc152
fix: toggle location settings cause error
alextran1502 Nov 9, 2024
e3a6b50
fix: toggle album activity reactivity
alextran1502 Nov 9, 2024
48221c1
fix: add/remove user from album reactivity
alextran1502 Nov 9, 2024
10c1da5
merge main
alextran1502 Nov 9, 2024
9688c0e
fix: change favorite status doesn't update icon on thumbnail
alextran1502 Nov 10, 2024
62e3f38
fix: confirmation prompt show generic message
alextran1502 Nov 10, 2024
9ddf3b4
revert: asset-date-group to use old syntax to keep favorite and selec…
alextran1502 Nov 11, 2024
5f21825
fix: shift+select
alextran1502 Nov 11, 2024
07b55e0
fix: change location - search location input
alextran1502 Nov 11, 2024
cd18432
fix: user notification setting is saved twice
alextran1502 Nov 11, 2024
f05ac38
fix: change name not show up in person asset view
alextran1502 Nov 11, 2024
58fa43b
fix: admin repair page
alextran1502 Nov 11, 2024
da4416a
fix: tag page render timeline's skeleton
alextran1502 Nov 11, 2024
4802fd2
Merge branch 'main' of github.com:immich-app/immich into migrate-svel…
alextran1502 Nov 12, 2024
05421d9
fix: duplicate list not updating
alextran1502 Nov 12, 2024
53e28e2
fix: memory auto player jump to the end
alextran1502 Nov 12, 2024
589373f
fix: flashing error icon when playing video
alextran1502 Nov 12, 2024
7fc8736
fix: video refresh when changing asset info and cannot autoplay
alextran1502 Nov 13, 2024
3f90eb6
chore: lint
alextran1502 Nov 13, 2024
936dbde
chore: remove compose change
alextran1502 Nov 13, 2024
d04ab27
Merge branch 'main' of github.com:immich-app/immich into migrate-svel…
alextran1502 Nov 13, 2024
5db15ff
fix: merge people doesn't refersh assets
alextran1502 Nov 13, 2024
981bad5
chore: remove unused variable
alextran1502 Nov 13, 2024
6820800
pr feedback
alextran1502 Nov 13, 2024
eeac9a7
pr feedback
alextran1502 Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@faker-js/faker": "^9.0.0",
"@socket.io/component-emitter": "^3.1.0",
"@sveltejs/adapter-static": "^3.0.5",
"@sveltejs/enhanced-img": "^0.3.0",
"@sveltejs/enhanced-img": "^0.3.9",
"@sveltejs/kit": "^2.7.2",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@testing-library/jest-dom": "^6.4.2",
Expand All @@ -45,7 +45,7 @@
"dotenv": "^16.4.5",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.43.0",
"eslint-plugin-svelte": "^2.45.1",
"eslint-plugin-unicorn": "^55.0.0",
"factory.ts": "^1.4.1",
"globals": "^15.9.0",
Expand All @@ -60,7 +60,7 @@
"tailwindcss": "^3.4.1",
"tslib": "^2.6.2",
"typescript": "^5.5.0",
"vite": "^5.1.4",
"vite": "^5.4.4",
"vitest": "^2.0.5"
},
"type": "module",
Expand Down
10 changes: 7 additions & 3 deletions web/src/lib/actions/__test__/focus-trap-test.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<script lang="ts">
import { focusTrap } from '$lib/actions/focus-trap';

export let show: boolean;
interface Props {
show: boolean;
}

let { show = $bindable() }: Props = $props();
</script>

<button type="button" on:click={() => (show = true)}>Open</button>
<button type="button" onclick={() => (show = true)}>Open</button>

{#if show}
<div use:focusTrap>
<div>
<span>text</span>
<button data-testid="one" type="button" on:click={() => (show = false)}>Close</button>
<button data-testid="one" type="button" onclick={() => (show = false)}>Close</button>
</div>
<input data-testid="two" disabled />
<input data-testid="three" />
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/actions/autogrow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const autoGrowHeight = (textarea: HTMLTextAreaElement, height = 'auto') => {
export const autoGrowHeight = (textarea?: HTMLTextAreaElement, height = 'auto') => {
if (!textarea) {
return;
}
Expand Down
8 changes: 6 additions & 2 deletions web/src/lib/actions/context-menu-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Options {
/**
* The container element that with direct children that should be navigated.
*/
container: HTMLElement;
container?: HTMLElement;
/**
* Indicates if the dropdown is open.
*/
Expand Down Expand Up @@ -52,7 +52,11 @@ export const contextMenuNavigation: Action<HTMLElement, Options> = (node, option
await tick();
}

const children = Array.from(container?.children).filter((child) => child.tagName !== 'HR') as HTMLElement[];
if (!container) {
return;
}

const children = Array.from(container.children).filter((child) => child.tagName !== 'HR') as HTMLElement[];
if (children.length === 0) {
return;
}
Expand Down
9 changes: 8 additions & 1 deletion web/src/lib/actions/list-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ import type { Action } from 'svelte/action';
* @param node Element which listens for keyboard events
* @param container Element containing the list of elements
*/
export const listNavigation: Action<HTMLElement, HTMLElement> = (node, container: HTMLElement) => {
export const listNavigation: Action<HTMLElement, HTMLElement | undefined> = (
node: HTMLElement,
container?: HTMLElement,
) => {
const moveFocus = (direction: 'up' | 'down') => {
if (!container) {
return;
}

const children = Array.from(container?.children);
if (children.length === 0) {
return;
Expand Down
35 changes: 21 additions & 14 deletions web/src/lib/components/admin-page/delete-confirm-dialogue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
import { deleteUserAdmin, type UserResponseDto } from '@immich/sdk';
import { t } from 'svelte-i18n';

export let user: UserResponseDto;
export let onSuccess: () => void;
export let onFail: () => void;
export let onCancel: () => void;
interface Props {
user: UserResponseDto;
onSuccess: () => void;
onFail: () => void;
onCancel: () => void;
}

let forceDelete = false;
let deleteButtonDisabled = false;
let { user, onSuccess, onFail, onCancel }: Props = $props();

let forceDelete = $state(false);
let deleteButtonDisabled = $state(false);
let userIdInput: string = '';

const handleDeleteUser = async () => {
Expand Down Expand Up @@ -47,22 +51,25 @@
{onCancel}
disabled={deleteButtonDisabled}
>
<svelte:fragment slot="prompt">
{#snippet promptSnippet()}
<div class="flex flex-col gap-4">
{#if forceDelete}
<p>
<FormatMessage key="admin.user_delete_immediately" values={{ user: user.name }} let:message>
<b>{message}</b>
<FormatMessage key="admin.user_delete_immediately" values={{ user: user.name }}>
{#snippet children({ message })}
<b>{message}</b>
{/snippet}
</FormatMessage>
</p>
{:else}
<p>
<FormatMessage
key="admin.user_delete_delay"
values={{ user: user.name, delay: $serverConfig.userDeleteDelay }}
let:message
>
<b>{message}</b>
{#snippet children({ message })}
<b>{message}</b>
{/snippet}
</FormatMessage>
</p>
{/if}
Expand All @@ -73,7 +80,7 @@
label={$t('admin.user_delete_immediately_checkbox')}
labelClass="text-sm dark:text-immich-dark-fg"
bind:checked={forceDelete}
on:change={() => {
onchange={() => {
deleteButtonDisabled = forceDelete;
}}
/>
Expand All @@ -92,9 +99,9 @@
aria-describedby="confirm-user-desc"
name="confirm-user-id"
type="text"
on:input={handleConfirm}
oninput={handleConfirm}
/>
{/if}
</div>
</svelte:fragment>
{/snippet}
</ConfirmDialog>
18 changes: 13 additions & 5 deletions web/src/lib/components/admin-page/jobs/job-tile-button.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<script lang="ts" context="module">
<script lang="ts" module>
export type Colors = 'light-gray' | 'gray' | 'dark-gray';
</script>

<script lang="ts">
export let color: Colors;
export let disabled = false;
import type { Snippet } from 'svelte';

interface Props {
color: Colors;
disabled?: boolean;
children?: Snippet;
onClick?: () => void;
}

let { color, disabled = false, onClick = () => {}, children }: Props = $props();

const colorClasses: Record<Colors, string> = {
'light-gray': 'bg-gray-300/80 dark:bg-gray-700',
Expand All @@ -23,7 +31,7 @@
class="flex h-full w-full flex-col place-content-center place-items-center gap-2 px-8 py-2 text-xs text-gray-600 transition-colors dark:text-gray-200 {colorClasses[
color
]} {hoverClasses}"
on:click
onclick={onClick}
>
<slot />
{@render children?.()}
</button>
13 changes: 10 additions & 3 deletions web/src/lib/components/admin-page/jobs/job-tile-status.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<script lang="ts" context="module">
<script lang="ts" module>
export type Color = 'success' | 'warning';
</script>

<script lang="ts">
export let color: Color;
import type { Snippet } from 'svelte';

interface Props {
color: Color;
children?: Snippet;
}

let { color, children }: Props = $props();

const colorClasses: Record<Color, string> = {
success: 'bg-green-500/70 text-gray-900 dark:bg-green-700/90 dark:text-gray-100',
Expand All @@ -12,5 +19,5 @@
</script>

<div class="w-full p-2 text-center text-sm {colorClasses[color]}">
<slot />
{@render children?.()}
</div>
64 changes: 40 additions & 24 deletions web/src/lib/components/admin-page/jobs/job-tile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,37 @@
import JobTileButton from './job-tile-button.svelte';
import JobTileStatus from './job-tile-status.svelte';

export let title: string;
export let subtitle: string | undefined;
export let description: Component | undefined;
export let jobCounts: JobCountsDto;
export let queueStatus: QueueStatusDto;
export let icon: string;
export let disabled = false;
interface Props {
title: string;
subtitle: string | undefined;
description: Component | undefined;
jobCounts: JobCountsDto;
queueStatus: QueueStatusDto;
icon: string;
disabled?: boolean;
allText: string | undefined;
refreshText: string | undefined;
missingText: string;
onCommand: (command: JobCommandDto) => void;
}

export let allText: string | undefined;
export let refreshText: string | undefined;
export let missingText: string;
export let onCommand: (command: JobCommandDto) => void;
let {
title,
subtitle,
description,
jobCounts,
queueStatus,
icon,
disabled = false,
allText,
refreshText,
missingText,
onCommand,
}: Props = $props();

$: waitingCount = jobCounts.waiting + jobCounts.paused + jobCounts.delayed;
$: isIdle = !queueStatus.isActive && !queueStatus.isPaused;
$: multipleButtons = allText || refreshText;
let waitingCount = $derived(jobCounts.waiting + jobCounts.paused + jobCounts.delayed);
let isIdle = $derived(!queueStatus.isActive && !queueStatus.isPaused);
let multipleButtons = $derived(allText || refreshText);

const commonClasses = 'flex place-items-center justify-between w-full py-2 sm:py-4 pr-4 pl-6';
</script>
Expand Down Expand Up @@ -67,7 +82,7 @@
title={$t('clear_message')}
size="12"
padding="1"
on:click={() => onCommand({ command: JobCommand.ClearFailed, force: false })}
onclick={() => onCommand({ command: JobCommand.ClearFailed, force: false })}
/>
</div>
</Badge>
Expand All @@ -87,8 +102,9 @@
{/if}

{#if description}
{@const SvelteComponent = description}
<div class="text-sm dark:text-white">
<svelte:component this={description} />
<SvelteComponent />
</div>
{/if}

Expand Down Expand Up @@ -118,7 +134,7 @@
<JobTileButton
disabled={true}
color="light-gray"
on:click={() => onCommand({ command: JobCommand.Start, force: false })}
onClick={() => onCommand({ command: JobCommand.Start, force: false })}
>
<Icon path={mdiAlertCircle} size="36" />
{$t('disabled').toUpperCase()}
Expand All @@ -127,20 +143,20 @@

{#if !disabled && !isIdle}
{#if waitingCount > 0}
<JobTileButton color="gray" on:click={() => onCommand({ command: JobCommand.Empty, force: false })}>
<JobTileButton color="gray" onClick={() => onCommand({ command: JobCommand.Empty, force: false })}>
<Icon path={mdiClose} size="24" />
{$t('clear').toUpperCase()}
</JobTileButton>
{/if}
{#if queueStatus.isPaused}
{@const size = waitingCount > 0 ? '24' : '48'}
<JobTileButton color="light-gray" on:click={() => onCommand({ command: JobCommand.Resume, force: false })}>
<JobTileButton color="light-gray" onClick={() => onCommand({ command: JobCommand.Resume, force: false })}>
<!-- size property is not reactive, so have to use width and height -->
<Icon path={mdiFastForward} {size} />
{$t('resume').toUpperCase()}
</JobTileButton>
{:else}
<JobTileButton color="light-gray" on:click={() => onCommand({ command: JobCommand.Pause, force: false })}>
<JobTileButton color="light-gray" onClick={() => onCommand({ command: JobCommand.Pause, force: false })}>
<Icon path={mdiPause} size="24" />
{$t('pause').toUpperCase()}
</JobTileButton>
Expand All @@ -149,25 +165,25 @@

{#if !disabled && multipleButtons && isIdle}
{#if allText}
<JobTileButton color="dark-gray" on:click={() => onCommand({ command: JobCommand.Start, force: true })}>
<JobTileButton color="dark-gray" onClick={() => onCommand({ command: JobCommand.Start, force: true })}>
<Icon path={mdiAllInclusive} size="24" />
{allText}
</JobTileButton>
{/if}
{#if refreshText}
<JobTileButton color="gray" on:click={() => onCommand({ command: JobCommand.Start, force: undefined })}>
<JobTileButton color="gray" onClick={() => onCommand({ command: JobCommand.Start, force: undefined })}>
<Icon path={mdiImageRefreshOutline} size="24" />
{refreshText}
</JobTileButton>
{/if}
<JobTileButton color="light-gray" on:click={() => onCommand({ command: JobCommand.Start, force: false })}>
<JobTileButton color="light-gray" onClick={() => onCommand({ command: JobCommand.Start, force: false })}>
<Icon path={mdiSelectionSearch} size="24" />
{missingText}
</JobTileButton>
{/if}

{#if !disabled && !multipleButtons && isIdle}
<JobTileButton color="light-gray" on:click={() => onCommand({ command: JobCommand.Start, force: false })}>
<JobTileButton color="light-gray" onClick={() => onCommand({ command: JobCommand.Start, force: false })}>
<Icon path={mdiPlay} size="48" />
{$t('start').toUpperCase()}
</JobTileButton>
Expand Down
Loading
Loading