mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
fix(web): show shared link download button when logged in (#26629)
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
import { getAssetActions } from '$lib/services/asset.service';
|
||||||
|
import { user as userStore } from '$lib/stores/user.store';
|
||||||
|
import { setSharedLink } from '$lib/utils';
|
||||||
|
import { assetFactory } from '@test-data/factories/asset-factory';
|
||||||
|
import { sharedLinkFactory } from '@test-data/factories/shared-link-factory';
|
||||||
|
import { userAdminFactory } from '@test-data/factories/user-factory';
|
||||||
|
|
||||||
|
describe('AssetService', () => {
|
||||||
|
describe('getAssetActions', () => {
|
||||||
|
it('should allow shared link downloads if the user owns the asset and shared link downloads are disabled', () => {
|
||||||
|
const ownerId = 'owner';
|
||||||
|
const user = userAdminFactory.build({ id: ownerId });
|
||||||
|
const asset = assetFactory.build({ ownerId });
|
||||||
|
userStore.set(user);
|
||||||
|
setSharedLink(sharedLinkFactory.build({ allowDownload: false }));
|
||||||
|
const assetActions = getAssetActions(() => '', asset);
|
||||||
|
expect(assetActions.SharedLinkDownload.$if?.()).toStrictEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not allow shared link downloads if the user does not own the asset and shared link downloads are disabled', () => {
|
||||||
|
const ownerId = 'owner';
|
||||||
|
const user = userAdminFactory.build({ id: 'non-owner' });
|
||||||
|
const asset = assetFactory.build({ ownerId });
|
||||||
|
userStore.set(user);
|
||||||
|
setSharedLink(sharedLinkFactory.build({ allowDownload: false }));
|
||||||
|
const assetActions = getAssetActions(() => '', asset);
|
||||||
|
expect(assetActions.SharedLinkDownload.$if?.()).toStrictEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should allow shared link downloads if shared link downloads are enabled regardless of user', () => {
|
||||||
|
const asset = assetFactory.build();
|
||||||
|
setSharedLink(sharedLinkFactory.build({ allowDownload: true }));
|
||||||
|
const assetActions = getAssetActions(() => '', asset);
|
||||||
|
expect(assetActions.SharedLinkDownload.$if?.()).toStrictEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -106,7 +106,7 @@ export const getAssetActions = ($t: MessageFormatter, asset: AssetResponseDto) =
|
|||||||
title: $t('share'),
|
title: $t('share'),
|
||||||
icon: mdiShareVariantOutline,
|
icon: mdiShareVariantOutline,
|
||||||
type: $t('assets'),
|
type: $t('assets'),
|
||||||
$if: () => !!(get(authUser) && !asset.isTrashed && asset.visibility !== AssetVisibility.Locked),
|
$if: () => !!(currentAuthUser && !asset.isTrashed && asset.visibility !== AssetVisibility.Locked),
|
||||||
onAction: () => modalManager.show(SharedLinkCreateModal, { assetIds: [asset.id] }),
|
onAction: () => modalManager.show(SharedLinkCreateModal, { assetIds: [asset.id] }),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ export const getAssetActions = ($t: MessageFormatter, asset: AssetResponseDto) =
|
|||||||
|
|
||||||
const SharedLinkDownload: ActionItem = {
|
const SharedLinkDownload: ActionItem = {
|
||||||
...Download,
|
...Download,
|
||||||
$if: () => !currentAuthUser && sharedLink && sharedLink.allowDownload,
|
$if: () => isOwner || !!sharedLink?.allowDownload,
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlayMotionPhoto: ActionItem = {
|
const PlayMotionPhoto: ActionItem = {
|
||||||
|
|||||||
Reference in New Issue
Block a user