mirror of https://github.com/immich-app/immich.git
refactor: shared-link service (#23770)
parent
9e2208b8dd
commit
dea95ac2e6
@ -0,0 +1,19 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { IconButton, type MenuItem } from '@immich/ui';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
action: MenuItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
const { action }: Props = $props();
|
||||||
|
const { title, icon, onSelect } = $derived(action);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
shape="round"
|
||||||
|
color="secondary"
|
||||||
|
variant="ghost"
|
||||||
|
{icon}
|
||||||
|
aria-label={title}
|
||||||
|
onclick={(event: Event) => onSelect?.({ event, item: action })}
|
||||||
|
/>
|
||||||
@ -1,28 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
|
||||||
import { handleCopySharedLinkUrl } from '$lib/services/shared-link.service';
|
|
||||||
import type { SharedLinkResponseDto } from '@immich/sdk';
|
|
||||||
import { IconButton } from '@immich/ui';
|
|
||||||
import { mdiContentCopy } from '@mdi/js';
|
|
||||||
import { t } from 'svelte-i18n';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
sharedLink: SharedLinkResponseDto;
|
|
||||||
menuItem?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { sharedLink, menuItem = false }: Props = $props();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if menuItem}
|
|
||||||
<MenuOption text={$t('copy_link')} icon={mdiContentCopy} onClick={() => handleCopySharedLinkUrl(sharedLink)} />
|
|
||||||
{:else}
|
|
||||||
<IconButton
|
|
||||||
color="secondary"
|
|
||||||
shape="round"
|
|
||||||
variant="ghost"
|
|
||||||
aria-label={$t('copy_link')}
|
|
||||||
icon={mdiContentCopy}
|
|
||||||
onclick={() => handleCopySharedLinkUrl(sharedLink)}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
|
||||||
import { IconButton } from '@immich/ui';
|
|
||||||
import { mdiDelete } from '@mdi/js';
|
|
||||||
import { t } from 'svelte-i18n';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
menuItem?: boolean;
|
|
||||||
onDelete: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { menuItem = false, onDelete }: Props = $props();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if menuItem}
|
|
||||||
<MenuOption text={$t('delete_link')} icon={mdiDelete} onClick={onDelete} />
|
|
||||||
{:else}
|
|
||||||
<IconButton
|
|
||||||
color="secondary"
|
|
||||||
shape="round"
|
|
||||||
variant="ghost"
|
|
||||||
aria-label={$t('delete_link')}
|
|
||||||
icon={mdiDelete}
|
|
||||||
onclick={onDelete}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { goto } from '$app/navigation';
|
|
||||||
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
import type { SharedLinkResponseDto } from '@immich/sdk';
|
|
||||||
import { IconButton } from '@immich/ui';
|
|
||||||
import { mdiCircleEditOutline } from '@mdi/js';
|
|
||||||
import { t } from 'svelte-i18n';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
menuItem?: boolean;
|
|
||||||
sharedLink: SharedLinkResponseDto;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { sharedLink, menuItem = false }: Props = $props();
|
|
||||||
|
|
||||||
const onEdit = async () => {
|
|
||||||
await goto(`${AppRoute.SHARED_LINKS}/${sharedLink.id}`);
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if menuItem}
|
|
||||||
<MenuOption text={$t('edit_link')} icon={mdiCircleEditOutline} onClick={onEdit} />
|
|
||||||
{:else}
|
|
||||||
<IconButton
|
|
||||||
shape="round"
|
|
||||||
color="secondary"
|
|
||||||
variant="ghost"
|
|
||||||
aria-label={$t('edit_link')}
|
|
||||||
icon={mdiCircleEditOutline}
|
|
||||||
onclick={onEdit}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
Loading…
Reference in New Issue