mirror of
https://github.com/immich-app/immich.git
synced 2026-03-04 08:00:19 -05:00
fix(web): show shared link download button when logged in (#26629)
This commit is contained in:
parent
5bc08f8654
commit
b282d83e95
37
web/src/lib/services/asset.service.spec.ts
Normal file
37
web/src/lib/services/asset.service.spec.ts
Normal file
@ -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'),
|
||||
icon: mdiShareVariantOutline,
|
||||
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] }),
|
||||
};
|
||||
|
||||
@ -129,7 +129,7 @@ export const getAssetActions = ($t: MessageFormatter, asset: AssetResponseDto) =
|
||||
|
||||
const SharedLinkDownload: ActionItem = {
|
||||
...Download,
|
||||
$if: () => !currentAuthUser && sharedLink && sharedLink.allowDownload,
|
||||
$if: () => isOwner || !!sharedLink?.allowDownload,
|
||||
};
|
||||
|
||||
const PlayMotionPhoto: ActionItem = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user