fix(web): show shared link download button when logged in (#26629)

This commit is contained in:
Snowknight26 2026-03-02 15:00:23 -06:00 committed by GitHub
parent 5bc08f8654
commit b282d83e95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 2 deletions

View 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);
});
});
});

View File

@ -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 = {