From e94093ea2d4b597612a0194781232f1ef9ad7797 Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Tue, 29 Apr 2025 14:29:11 +0300 Subject: [PATCH 1/8] Display the shared file with the image viewer --- .../file-list-item/file-list-item.component.ts | 10 +++++++--- .../components/file-list/file-list.component.ts | 4 ++-- .../share-preview/share-preview.component.ts | 11 ++++++++--- src/app/share-preview/share-preview.module.ts | 11 ++++++++++- src/app/share-preview/share-preview.routes.ts | 13 ++++++++++++- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/app/file-browser/components/file-list-item/file-list-item.component.ts b/src/app/file-browser/components/file-list-item/file-list-item.component.ts index b7259451a..9b0d9ee2c 100644 --- a/src/app/file-browser/components/file-list-item/file-list-item.component.ts +++ b/src/app/file-browser/components/file-list-item/file-list-item.component.ts @@ -258,8 +258,11 @@ export class FileListItemComponent if (this.router.routerState.snapshot.url.includes('/share/')) { this.allowActions = false; this.isInSharePreview = true; + this.canSelect = true; } + console.log(this.canSelect) + if (this.router.routerState.snapshot.url.includes('/apps')) { this.isInApps = true; } @@ -409,7 +412,6 @@ export class FileListItemComponent break; } } - onItemMouseDown(mouseDownEvent: MouseEvent) { if (this.isShareRoot || this.isInApps) { return; @@ -494,8 +496,9 @@ export class FileListItemComponent event: event as MouseEvent, selectable: false, }); - } else { - this.onItemSingleClick(event); + } + else { + this.onItemSingleClick(event); } } @@ -590,6 +593,7 @@ export class FileListItemComponent } if (this.waitingForDoubleClick) { + console.log(this.waitingForDoubleClick); this.waitingForDoubleClick = false; return this.onItemDoubleClick(); } diff --git a/src/app/file-browser/components/file-list/file-list.component.ts b/src/app/file-browser/components/file-list/file-list.component.ts index 959ea8b4c..f549c0d20 100644 --- a/src/app/file-browser/components/file-list/file-list.component.ts +++ b/src/app/file-browser/components/file-list/file-list.component.ts @@ -361,7 +361,7 @@ export class FileListComponent } ngOnDestroy() { - this.dataService.setCurrentFolder(); + // this.dataService.setCurrentFolder(); unsubscribeAll(this.subscriptions); if (this.unlistenMouseMove) { this.unlistenMouseMove(); @@ -438,7 +438,7 @@ export class FileListComponent } onItemClick(itemClick: ItemClickEvent) { - this.itemClicked.emit(itemClick); + // this.itemClicked.emit(itemClick); if (!this.showSidebar || !itemClick.selectable) { return; diff --git a/src/app/share-preview/components/share-preview/share-preview.component.ts b/src/app/share-preview/components/share-preview/share-preview.component.ts index 9368063a6..caa57eb6b 100644 --- a/src/app/share-preview/components/share-preview/share-preview.component.ts +++ b/src/app/share-preview/components/share-preview/share-preview.component.ts @@ -659,9 +659,14 @@ export class SharePreviewComponent implements OnInit, OnDestroy { } this.fileListClickListener = componentReference.itemClicked.subscribe( - () => { - this.dispatchBannerClose(); - this.showCreateAccountDialog(); + (item) => { + console.log(item); + // this.dispatchBannerClose(); + // this.showCreateAccountDialog(); + + this.router.navigate(['record', item.item.archiveNbr], { + relativeTo: this.route, + }); }, ); } diff --git a/src/app/share-preview/share-preview.module.ts b/src/app/share-preview/share-preview.module.ts index 3ec9b3e61..81482c1d0 100644 --- a/src/app/share-preview/share-preview.module.ts +++ b/src/app/share-preview/share-preview.module.ts @@ -9,6 +9,9 @@ import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'; import { SharePreviewRoutingModule } from './share-preview.routes'; import { CreateAccountDialogComponent } from './components/create-account-dialog/create-account-dialog.component'; import { SharePreviewFooterComponent } from './components/share-preview-footer/share-preview-footer.component'; +import { RecordResolveService } from '@core/resolves/record-resolve.service'; +import { EditService } from '@core/services/edit/edit.service'; +import { FolderPickerService } from '@core/services/folder-picker/folder-picker.service'; @NgModule({ declarations: [], @@ -18,7 +21,13 @@ import { SharePreviewFooterComponent } from './components/share-preview-footer/s FormsModule, NgbTooltipModule, ], - providers: [DataService, FolderViewService], + providers: [ + DataService, + FolderViewService, + RecordResolveService, + EditService, + FolderPickerService + ], }) export class SharePreviewModule { constructor(folderView: FolderViewService) { diff --git a/src/app/share-preview/share-preview.routes.ts b/src/app/share-preview/share-preview.routes.ts index c355e1867..215258733 100644 --- a/src/app/share-preview/share-preview.routes.ts +++ b/src/app/share-preview/share-preview.routes.ts @@ -20,6 +20,8 @@ import { InviteShareResolveService } from './resolves/invite-share-resolve.servi import { RelationshipShareResolveService } from './resolves/relationship-share-resolve.service'; import { SharePreviewFooterComponent } from './components/share-preview-footer/share-preview-footer.component'; +import { RecordResolveService } from '@core/resolves/record-resolve.service'; +import { FileViewerComponent } from '@fileBrowser/components/file-viewer/file-viewer.component'; const archiveResolve = { archive: PreviewArchiveResolveService, @@ -96,7 +98,16 @@ export const routes: Routes = [ data: { noFileListPadding: true, }, - children: sharePreviewChildren, + children: [ + ...sharePreviewChildren, + { + path: 'record/:recArchiveNbr', + component: FileViewerComponent, + resolve: { + currentRecord: RecordResolveService, + }, + }, + ], }, ]; @NgModule({ From a6dc3e910c822e66059feeb91e85fa325aff0d2d Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Mon, 5 May 2025 17:06:04 +0300 Subject: [PATCH 2/8] add post api call for generating a share link --- src/app/core/services/edit/edit.service.ts | 36 +++++++----- .../sharing-dialog.component.html | 2 +- .../sharing-dialog.component.ts | 56 +++++++++++++------ src/app/file-browser/utils/utils.ts | 24 ++++++++ .../shared/components/prompt/prompt-fields.ts | 2 +- 5 files changed, 87 insertions(+), 33 deletions(-) create mode 100644 src/app/file-browser/utils/utils.ts diff --git a/src/app/core/services/edit/edit.service.ts b/src/app/core/services/edit/edit.service.ts index f29e873fd..c341b1d4f 100644 --- a/src/app/core/services/edit/edit.service.ts +++ b/src/app/core/services/edit/edit.service.ts @@ -41,6 +41,7 @@ import { EditTagsComponent } from '@fileBrowser/components/edit-tags/edit-tags.c import { LocationPickerComponent } from '@fileBrowser/components/location-picker/location-picker.component'; import { SharingDialogComponent } from '@fileBrowser/components/sharing-dialog/sharing-dialog.component'; import { FolderPickerService } from '../folder-picker/folder-picker.service'; +import { ShareLinksApiService } from '@root/app/share-links/services/share-links-api.service'; export const ItemActions: { [key: string]: PromptButton } = { Rename: { @@ -132,6 +133,7 @@ export class EditService { private device: DeviceService, private secrets: SecretsService, private event: EventService, + private shareLinkService: ShareLinksApiService, ) { this.loadGoogleMapsApi(); } @@ -250,16 +252,16 @@ export class EditService { this.openPublishDialog(items[0]); break; case 'share': - const response: ShareResponse = await this.api.share.getShareLink( - items[0], - ); - actionDeferred.resolve(); - this.dialog.open(SharingComponent, { - data: { - item: items[0], - link: response.getShareByUrlVO(), - }, - }); + // const response: ShareResponse = await this.api.share.getShareLink( + // items[0], + // ); + // actionDeferred.resolve(); + // this.dialog.open(SharingComponent, { + // data: { + // item: items[0], + // link: response.getShareByUrlVO(), + // }, + // }); break; default: actionDeferred.resolve(); @@ -526,18 +528,26 @@ export class EditService { } async openShareDialog(item: ItemVO) { - const response = await this.api.share.getShareLink(item); + const itemType = item.isRecord ? 'record' : 'folder'; + + const itemId = item instanceof RecordVO ? item.recordId : item.folderId; + + const response = await this.shareLinkService.generateShareLink({ + itemId, + itemType, + }); + if (this.device.isMobile()) { try { this.dialog.open(SharingComponent, { panelClass: 'dialog', - data: { item, link: response.getShareByUrlVO() }, + data: { item, shareLinkResponse: response }, }); } catch (err) {} } else { try { this.dialog.open(SharingDialogComponent, { - data: { item, link: response.getShareByUrlVO() }, + data: { item, shareLinkResponse: response }, width: '600px', panelClass: 'dialog', }); diff --git a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.html b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.html index b3c29651e..b771292f0 100644 --- a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.html +++ b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.html @@ -228,7 +228,7 @@ type="text" class="form-control" readonly - [value]="shareLink.shareUrl" + [value]="shareLink" #shareUrlInput /> diff --git a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.ts b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.ts index b3832b2fc..fbc5a589e 100644 --- a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.ts +++ b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.ts @@ -42,6 +42,8 @@ import { addDays, differenceInHours, isPast } from 'date-fns'; import { find, partition, remove } from 'lodash'; import { faTrash } from '@fortawesome/pro-regular-svg-icons'; import { FeatureFlagService } from '@root/app/feature-flag/services/feature-flag.service'; +import { ShareLinksApiService } from '@root/app/share-links/services/share-links-api.service'; +import { shareUrlBuilder } from '@fileBrowser/utils/utils'; enum Expiration { Never = 'Never', @@ -82,6 +84,7 @@ const EXPIRATION_OPTIONS: FormInputSelectOption[] = Object.values( }) export class SharingDialogComponent implements OnInit { public shareItem: ItemVO = null; + public shareLinkResponse = null; public originalRoles = new Map(); public canShare = false; @@ -89,12 +92,12 @@ export class SharingDialogComponent implements OnInit { public shares: ShareVO[] = []; public pendingShares: ShareVO[] = []; - public shareLink: ShareByUrlVO = null; + public shareLink = ''; public previewToggle: 0 | 1 = 1; public autoApproveToggle: 0 | 1 = 1; public expiration: Expiration; - public linkDefaultAccessRole: AccessRoleType = 'access.role.viewer'; + public linkDefaultAccessRole = 'viewer'; public updatingLink = false; public linkCopied = false; @@ -149,6 +152,7 @@ export class SharingDialogComponent implements OnInit { private ga: GoogleAnalyticsService, private route: ActivatedRoute, private feature: FeatureFlagService, + private shareLinkService: ShareLinksApiService, ) { this.invitationForm = this.fb.group({ fullName: ['', [Validators.required]], @@ -158,6 +162,7 @@ export class SharingDialogComponent implements OnInit { }); this.shareItem = this.data.item as ItemVO; + this.shareLinkResponse = this.data.shareLinkResponse; this.displayDropdown = feature.isEnabled('unlisted-share'); } @@ -178,7 +183,11 @@ export class SharingDialogComponent implements OnInit { this.relationshipService.update(); - this.shareLink = this.data.link; + this.shareLink = shareUrlBuilder( + this.data.shareLinkResponse.itemType, + this.data.shareLinkResponse.token, + this.data.shareLinkResponse.itemId, + ); this.setShareLinkFormValue(); this.checkQueryParams(); @@ -428,7 +437,7 @@ export class SharingDialogComponent implements OnInit { const diff = differenceInHours( new Date(expiresDT), - new Date(this.shareLink.createdDT), + new Date(this.shareLinkResponse.createdDT), ); if (diff <= 24 * ExpirationDays.Day) { @@ -449,24 +458,35 @@ export class SharingDialogComponent implements OnInit { case Expiration.Never: return null; case Expiration.Day: - return getSQLDateTime(addDays(new Date(this.shareLink.createdDT), 1)); + return getSQLDateTime( + addDays(new Date(this.shareLinkResponse.createdDT), 1), + ); case Expiration.Week: - return getSQLDateTime(addDays(new Date(this.shareLink.createdDT), 7)); + return getSQLDateTime( + addDays(new Date(this.shareLinkResponse.createdDT), 7), + ); case Expiration.Month: - return getSQLDateTime(addDays(new Date(this.shareLink.createdDT), 30)); + return getSQLDateTime( + addDays(new Date(this.shareLinkResponse.createdDT), 30), + ); case Expiration.Year: - return getSQLDateTime(addDays(new Date(this.shareLink.createdDT), 365)); + return getSQLDateTime( + addDays(new Date(this.shareLinkResponse.createdDT), 365), + ); } } setShareLinkFormValue(): void { - if (this.shareLink) { - this.previewToggle = this.shareLink.previewToggle; - this.autoApproveToggle = this.shareLink.autoApproveToggle || 0; + if (this.shareLinkResponse) { + console.log(this.shareLinkResponse); + this.previewToggle = this.shareLinkResponse.previewToggle; + this.autoApproveToggle = this.shareLinkResponse.autoApproveToggle || 0; this.expiration = this.getExpirationFromExpiresDT( - this.shareLink.expiresDT, + this.shareLinkResponse.expiresDT, ); - this.linkDefaultAccessRole = this.shareLink.defaultAccessRole; + console.log(this.shareLinkResponse); + console.log(this.shareLinkResponse.permissionsLevel); + this.linkDefaultAccessRole = this.shareLinkResponse.permissionLevel; this.expirationOptions = EXPIRATION_OPTIONS.filter((expiration) => { switch (expiration.value) { case Expiration.Never: @@ -492,10 +512,10 @@ export class SharingDialogComponent implements OnInit { this.updatingLink = true; try { const response = await this.api.share.generateShareLink(this.shareItem); - this.shareLink = response.getShareByUrlVO(); - this.shareLink.autoApproveToggle = this.autoApproveToggle || 0; - this.shareLink.previewToggle = this.previewToggle || 0; - await this.api.share.updateShareLink(this.shareLink); + this.shareLinkResponse = response; + this.shareLinkResponse.autoApproveToggle = this.autoApproveToggle || 0; + this.shareLinkResponse.previewToggle = this.previewToggle || 0; + await this.api.share.updateShareLink(this.shareLinkResponse); this.setShareLinkFormValue(); this.showLinkSettings = true; this.ga.sendEvent(EVENTS.SHARE.ShareByUrl.initiated.params); @@ -532,7 +552,7 @@ export class SharingDialogComponent implements OnInit { 'btn-danger', ); - await this.api.share.removeShareLink(this.shareLink); + await this.api.share.removeShareLink(this.shareLinkResponse); this.shareLink = null; this.setShareLinkFormValue(); deferred.resolve(); diff --git a/src/app/file-browser/utils/utils.ts b/src/app/file-browser/utils/utils.ts new file mode 100644 index 000000000..3bbea02f2 --- /dev/null +++ b/src/app/file-browser/utils/utils.ts @@ -0,0 +1,24 @@ +import { environment } from '@root/environments/environment'; + +export const shareUrlBuilder = ( + itemType: 'record' | 'folder', + token: string, + itemId: string, +) => { + const urlDict = { + local: 'https://local.permanent.org/share', + staging: 'https://staging.permanent.org/share', + dev: 'https://dev.permanent.org/share', + prod: 'https://prod.permanent.org/share', + }; + + const baseUrl = urlDict[environment.environment]; + + const url = new URL(baseUrl); + + url.searchParams.set('itemType', itemType); + url.searchParams.set('token', token); + url.searchParams.set('itemId', itemId); + + return url.toString(); +}; diff --git a/src/app/shared/components/prompt/prompt-fields.ts b/src/app/shared/components/prompt/prompt-fields.ts index 3a1ee4f38..85e21e144 100644 --- a/src/app/shared/components/prompt/prompt-fields.ts +++ b/src/app/shared/components/prompt/prompt-fields.ts @@ -99,7 +99,7 @@ export const SHARE_ACCESS_ROLE_FIELD: PromptField = { fieldName: 'accessRole', placeholder: 'Access Level', type: 'select', - initialValue: 'access.role.viewer', + initialValue: 'viewer', validators: [Validators.required], config: { autocomplete: 'off', From ea8326bb77af94fe13e004da5988455e4f8081fc Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Thu, 8 May 2025 17:31:42 +0300 Subject: [PATCH 3/8] Changes to the resolver --- .../resolves/share-url-resolve.service.ts | 15 +++++++++++++++ src/app/share-preview/share-preview.routes.ts | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/src/app/share-preview/resolves/share-url-resolve.service.ts b/src/app/share-preview/resolves/share-url-resolve.service.ts index 1161fe112..444d073a1 100644 --- a/src/app/share-preview/resolves/share-url-resolve.service.ts +++ b/src/app/share-preview/resolves/share-url-resolve.service.ts @@ -15,6 +15,7 @@ import { ShareResponse, } from '@shared/services/api/index.repo'; import { RecordVO, ArchiveVO, FolderVO } from '@models'; +import { ShareLinksApiService } from '@root/app/share-links/services/share-links-api.service'; @Injectable() export class ShareUrlResolveService { @@ -24,9 +25,23 @@ export class ShareUrlResolveService { private router: Router, private device: DeviceService, private accountService: AccountService, + private shareLinkApiService: ShareLinksApiService, ) {} resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + console.log(route.queryParams); + + const token = route.queryParams.token; + + return this.shareLinkApiService + .getShareLinksByToken([token]) + .then((response) => { + console.log(response); + + const shareResponse = response[0]; + return shareResponse; + }); + return this.api.share .checkShareLink(route.params.shareToken) .then((response: ShareResponse): any => { diff --git a/src/app/share-preview/share-preview.routes.ts b/src/app/share-preview/share-preview.routes.ts index 215258733..4843de26d 100644 --- a/src/app/share-preview/share-preview.routes.ts +++ b/src/app/share-preview/share-preview.routes.ts @@ -92,6 +92,14 @@ export const routes: Routes = [ }, children: sharePreviewChildren, }, + { + path: '', + resolve: shareResolve, + data: { + noFileListPadding: true, + }, + children: sharePreviewChildren, + }, { path: ':shareToken', resolve: shareResolve, From d6eca6a54315bf39bc4502c62e452ace7438ef8e Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Tue, 20 May 2025 15:11:21 +0300 Subject: [PATCH 4/8] Move Share link settings into its own component --- .../share-link-settings.component.html | 226 ++++++++++++++ .../share-link-settings.component.scss | 0 .../share-link-settings.component.spec.ts | 23 ++ .../share-link-settings.component.ts | 282 ++++++++++++++++++ .../sharing-dialog.component.html | 241 +-------------- .../sharing-dialog.component.spec.ts | 95 +++--- .../sharing-dialog.component.ts | 202 +------------ .../file-browser-components.module.ts | 3 + .../services/share-links-api.service.ts | 2 +- 9 files changed, 585 insertions(+), 489 deletions(-) create mode 100644 src/app/file-browser/components/share-link-settings/share-link-settings.component.html create mode 100644 src/app/file-browser/components/share-link-settings/share-link-settings.component.scss create mode 100644 src/app/file-browser/components/share-link-settings/share-link-settings.component.spec.ts create mode 100644 src/app/file-browser/components/share-link-settings/share-link-settings.component.ts diff --git a/src/app/file-browser/components/share-link-settings/share-link-settings.component.html b/src/app/file-browser/components/share-link-settings/share-link-settings.component.html new file mode 100644 index 000000000..34bf7c56a --- /dev/null +++ b/src/app/file-browser/components/share-link-settings/share-link-settings.component.html @@ -0,0 +1,226 @@ +
+
+
Create link to share
+ +
+
+

+ Generate a link to send via text or email for others to view this + material. Learn more. +

+
+
+
+ + + + +
+
diff --git a/src/app/file-browser/components/share-link-settings/share-link-settings.component.scss b/src/app/file-browser/components/share-link-settings/share-link-settings.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/file-browser/components/share-link-settings/share-link-settings.component.spec.ts b/src/app/file-browser/components/share-link-settings/share-link-settings.component.spec.ts new file mode 100644 index 000000000..21fe02886 --- /dev/null +++ b/src/app/file-browser/components/share-link-settings/share-link-settings.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ShareLinkSettingsComponent } from './share-link-settings.component'; + +describe('ShareLinkSettingsComponent', () => { + let component: ShareLinkSettingsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ShareLinkSettingsComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ShareLinkSettingsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/file-browser/components/share-link-settings/share-link-settings.component.ts b/src/app/file-browser/components/share-link-settings/share-link-settings.component.ts new file mode 100644 index 000000000..c8d488d66 --- /dev/null +++ b/src/app/file-browser/components/share-link-settings/share-link-settings.component.ts @@ -0,0 +1,282 @@ +import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; +import { shareUrlBuilder } from '@fileBrowser/utils/utils'; +import { ItemVO, ShareByUrlVO } from '@models/index'; +import { FeatureFlagService } from '@root/app/feature-flag/services/feature-flag.service'; +import { Deferred } from '@root/vendor/deferred'; +import { FormInputSelectOption } from '@shared/components/form-input/form-input.component'; +import { ApiService } from '@shared/services/api/api.service'; +import { ShareResponse } from '@shared/services/api/share.repo'; +import { EVENTS } from '@shared/services/google-analytics/events'; +import { GoogleAnalyticsService } from '@shared/services/google-analytics/google-analytics.service'; +import { MessageService } from '@shared/services/message/message.service'; +import { PromptService } from '@shared/services/prompt/prompt.service'; +import { getSQLDateTime } from '@shared/utilities/dateTime'; +import { copyFromInputElement } from '@shared/utilities/forms'; +import { addDays, differenceInHours, isPast } from 'date-fns'; +import { faTrash } from '@fortawesome/pro-regular-svg-icons'; + +enum Expiration { + Never = 'Never', + Day = '1 day', + Week = '1 week', + Month = '1 month', + Year = '1 year', + Other = 'Other', +} + +enum ExpirationDays { + Day = 1, + Week = 7, + Month = 30, + Year = 365, +} + +type ShareByUrlProps = + | 'defaultAccessRole' + | 'expiresDT' + | 'autoApproveToggle' + | 'previewToggle'; + +const EXPIRATION_OPTIONS: FormInputSelectOption[] = Object.values( + Expiration, +).map((x) => { + return { + value: x, + text: x, + }; +}); + +const accessRoles = [ + { + text: 'Owner', + value: 'owner', + }, + { + text: 'Curator', + value: 'curator', + }, + { + text: 'Editor', + value: 'editor', + }, + { + text: 'Contributor', + value: 'contributor', + }, + { + text: 'Viewer', + value: 'viewer', + }, +]; + +@Component({ + selector: 'pr-share-link-settings', + templateUrl: './share-link-settings.component.html', + styleUrl: './share-link-settings.component.scss', +}) +export class ShareLinkSettingsComponent implements OnInit { + @Input() shareLink = ''; + @Input() shareItem: ItemVO = null; + @Input() shareLinkResponse = null; + + @ViewChild('shareUrlInput', { static: false }) shareUrlInput: ElementRef; + + public displayDropdown: boolean = false; + public showLinkSettings: boolean = false; + public previewToggle: 0 | 1 = 1; + public autoApproveToggle: 0 | 1 = 1; + public expiration: Expiration; + public linkDefaultAccessRole = 'viewer'; + public expirationOptions: FormInputSelectOption[] = EXPIRATION_OPTIONS; + public updatingLink: boolean = false; + public linkCopied: boolean = false; + public linkType: string = 'private'; + public trashIcon = faTrash; + public shareLinkAccessRoles: FormInputSelectOption[] = accessRoles; + + public shareLinkTypes = [ + { + text: 'Anyone can view', + value: 'public', + description: 'Anyone with the link can view and download.', + }, + { + text: 'Restricted', + value: 'private', + description: 'Must be logged in to view.', + }, + ]; + + constructor( + private feature: FeatureFlagService, + private api: ApiService, + private ga: GoogleAnalyticsService, + private messageService: MessageService, + private promptService: PromptService, + ) { + this.displayDropdown = feature.isEnabled('unlisted-share'); + } + + ngOnInit(): void { + this.shareLink = shareUrlBuilder( + this.shareLinkResponse.itemType, + this.shareLinkResponse.token, + this.shareLinkResponse.itemId, + ); + } + + getExpirationFromExpiresDT(expiresDT: string): Expiration { + if (!expiresDT) { + return Expiration.Never; + } + + const diff = differenceInHours( + new Date(expiresDT), + new Date(this.shareLinkResponse.createdDT), + ); + + if (diff <= 24 * ExpirationDays.Day) { + return Expiration.Day; + } else if (diff <= 24 * ExpirationDays.Week) { + return Expiration.Week; + } else if (diff <= 24 * 7 * ExpirationDays.Month) { + return Expiration.Month; + } else if (diff <= 24 * 7 * ExpirationDays.Year) { + return Expiration.Year; + } else { + return Expiration.Other; + } + } + + getExpiresDTFromExpiration(expiration: Expiration): string { + switch (expiration) { + case Expiration.Never: + return null; + case Expiration.Day: + return getSQLDateTime( + addDays(new Date(this.shareLinkResponse.createdAt), 1), + ); + case Expiration.Week: + return getSQLDateTime( + addDays(new Date(this.shareLinkResponse.createdAt), 7), + ); + case Expiration.Month: + return getSQLDateTime( + addDays(new Date(this.shareLinkResponse.createdAt), 30), + ); + case Expiration.Year: + return getSQLDateTime( + addDays(new Date(this.shareLinkResponse.createdAt), 365), + ); + } + } + + setShareLinkFormValue(): void { + if (this.shareLinkResponse) { + console.log(this.shareLinkResponse); + this.previewToggle = this.shareLinkResponse.previewToggle; + this.autoApproveToggle = this.shareLinkResponse.autoApproveToggle || 0; + this.expiration = this.getExpirationFromExpiresDT( + this.shareLinkResponse.expirationTimestamp, + ); + console.log(this.shareLinkResponse); + console.log(this.shareLinkResponse.permissionsLevel); + this.linkDefaultAccessRole = this.shareLinkResponse.permissionLevel; + this.expirationOptions = EXPIRATION_OPTIONS.filter((expiration) => { + switch (expiration.value) { + case Expiration.Never: + case Expiration.Other: + return true; + default: + return !isPast( + new Date( + this.getExpiresDTFromExpiration(expiration.value as Expiration), + ), + ); + } + }); + } else { + this.previewToggle = 1; + this.autoApproveToggle = 1; + this.expiration = Expiration.Never; + this.expirationOptions = EXPIRATION_OPTIONS; + } + } + + async generateShareLink() { + this.updatingLink = true; + try { + const response = await this.api.share.generateShareLink(this.shareItem); + this.shareLinkResponse = response; + this.shareLinkResponse.autoApproveToggle = this.autoApproveToggle || 0; + this.shareLinkResponse.previewToggle = this.previewToggle || 0; + await this.api.share.updateShareLink(this.shareLinkResponse); + this.setShareLinkFormValue(); + this.showLinkSettings = true; + this.ga.sendEvent(EVENTS.SHARE.ShareByUrl.initiated.params); + } catch (err) { + if (err instanceof ShareResponse) { + this.messageService.showError({ + message: err.getMessage(), + translate: true, + }); + } + } finally { + this.updatingLink = false; + } + } + + copyShareLink() { + const element = this.shareUrlInput.nativeElement as HTMLInputElement; + + copyFromInputElement(element); + + this.linkCopied = true; + setTimeout(() => { + this.linkCopied = false; + }, 5000); + } + + async removeShareLink() { + const deferred = new Deferred(); + try { + await this.promptService.confirm( + 'Remove link', + 'Are you sure you want to remove this link?', + deferred.promise, + 'btn-danger', + ); + + await this.api.share.removeShareLink(this.shareLinkResponse); + this.shareLink = null; + this.setShareLinkFormValue(); + deferred.resolve(); + this.showLinkSettings = false; + } catch (response) { + deferred.resolve(); + if (response instanceof ShareResponse) { + this.messageService.showError({ message: response.getMessage() }); + } + } + } + + async onShareLinkPropChange(propName: ShareByUrlProps, value: any) { + this.updatingLink = true; + try { + const update = new ShareByUrlVO(this.shareLink); + update[propName] = value; + await this.api.share.updateShareLink(update); + this.shareLink[propName] = update[propName]; + } catch (err) { + if (err instanceof ShareResponse) { + this.messageService.showError({ + message: err.getMessage(), + translate: true, + }); + } + this.setShareLinkFormValue(); + } finally { + this.updatingLink = false; + } + } +} diff --git a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.html b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.html index b771292f0..e96cf68d1 100644 --- a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.html +++ b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.html @@ -206,239 +206,10 @@ -
-
-
Create link to share
- -
-
-

- Generate a link to send via text or email for others to view this - material. Learn more. -

-
-
-
- - - - -
-
+ diff --git a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.spec.ts b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.spec.ts index dd822e9f9..a513a7938 100644 --- a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.spec.ts +++ b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.spec.ts @@ -109,15 +109,6 @@ describe('SharingDialogComponent', () => { 'update', ).and.returnValue(Promise.resolve()); - showMessageSpy = spyOn( - TestBed.inject(MessageService), - 'showMessage', - ).and.returnValue(); - showErrorSpy = spyOn( - TestBed.inject(MessageService), - 'showError', - ).and.returnValue(); - apiService = TestBed.inject(ApiService); }); @@ -257,46 +248,46 @@ describe('SharingDialogComponent', () => { })); }); -describe('SharingDialogComponent - Shallow Rendering', () => { - it('should be able to save default access role on a share link', async () => { - MockApiService.reset(); - // We have to use another describe() here since we're creating a component with a - // different set up, and these unit tests (and Angular's testing utilities in general) - // only expect there to be one TestBed that you use per suite of unit tests. - @NgModule({ - imports: [FormsModule, CommonModule, ReactiveFormsModule], - }) - class ShallowTestingModule {} - - const shallow = new Shallow( - SharingDialogComponent, - ShallowTestingModule, - ) - .mock(AccountService, new MockAccountService()) - .mock(ApiService, new MockApiService()) - .mock(RelationshipService, new MockRelationshipService()) - .mock(Router, new NullDependency()) - .mock(DialogRef, new NullDependency()) - .mock(MessageService, new NullDependency()) - .mock(ActivatedRoute, new NullDependency()) - .mock(DIALOG_DATA, { - item: new RecordVO({ - displayName: 'Test File', - accessRole: 'access.role.owner', - }), - }); - const { instance } = await shallow.render(); - - await instance.generateShareLink(); - - expect(instance.shareLink.shareUrl).toContain('example.com'); - - instance.linkDefaultAccessRole = 'access.role.owner'; - await instance.onShareLinkPropChange( - 'defaultAccessRole', - 'access.role.owner', - ); - - expect(instance.shareLink.defaultAccessRole).toBe('access.role.owner'); - }); -}); +// describe('SharingDialogComponent - Shallow Rendering', () => { +// it('should be able to save default access role on a share link', async () => { +// MockApiService.reset(); +// // We have to use another describe() here since we're creating a component with a +// // different set up, and these unit tests (and Angular's testing utilities in general) +// // only expect there to be one TestBed that you use per suite of unit tests. +// @NgModule({ +// imports: [FormsModule, CommonModule, ReactiveFormsModule], +// }) +// class ShallowTestingModule {} + +// const shallow = new Shallow( +// SharingDialogComponent, +// ShallowTestingModule, +// ) +// .mock(AccountService, new MockAccountService()) +// .mock(ApiService, new MockApiService()) +// .mock(RelationshipService, new MockRelationshipService()) +// .mock(Router, new NullDependency()) +// .mock(DialogRef, new NullDependency()) +// .mock(MessageService, new NullDependency()) +// .mock(ActivatedRoute, new NullDependency()) +// .mock(DIALOG_DATA, { +// item: new RecordVO({ +// displayName: 'Test File', +// accessRole: 'access.role.owner', +// }), +// }); +// const { instance } = await shallow.render(); + +// await instance.generateShareLink(); + +// expect(instance.shareLink.shareUrl).toContain('example.com'); + +// instance.linkDefaultAccessRole = 'access.role.owner'; +// await instance.onShareLinkPropChange( +// 'defaultAccessRole', +// 'access.role.owner', +// ); + +// expect(instance.shareLink.defaultAccessRole).toBe('access.role.owner'); +// }); +// }); diff --git a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.ts b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.ts index fbc5a589e..8938a695d 100644 --- a/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.ts +++ b/src/app/file-browser/components/sharing-dialog/sharing-dialog.component.ts @@ -92,48 +92,16 @@ export class SharingDialogComponent implements OnInit { public shares: ShareVO[] = []; public pendingShares: ShareVO[] = []; - public shareLink = ''; - - public previewToggle: 0 | 1 = 1; - public autoApproveToggle: 0 | 1 = 1; - public expiration: Expiration; - public linkDefaultAccessRole = 'viewer'; - - public updatingLink = false; - public linkCopied = false; - public showLinkSettings = false; - - public linkType = 'private'; - - public trashIcon = faTrash; - public newAccessRole: AccessRoleType = 'access.role.viewer'; public accessRoleOptions: FormInputSelectOption[] = SHARE_ACCESS_ROLE_FIELD.selectOptions.reverse(); - public expirationOptions: FormInputSelectOption[] = EXPIRATION_OPTIONS; + public relationOptions: FormInputSelectOption[] = RELATION_OPTIONS; public sendingInvitation = false; public showInvitationForm = false; public invitationForm: UntypedFormGroup; - public shareLinkTypes = [ - { - text: 'Anyone can view', - value: 'public', - description: 'Anyone with the link can view and download.', - }, - { - text: 'Restricted', - value: 'private', - description: 'Must be logged in to view.', - }, - ]; - - public displayDropdown = false; - - @ViewChild('shareUrlInput', { static: false }) shareUrlInput: ElementRef; - public archiveFilterFn = (a: ArchiveVO) => { return ( !find(this.shares, { archiveId: a.archiveId }) && @@ -149,10 +117,7 @@ export class SharingDialogComponent implements OnInit { private api: ApiService, private messageService: MessageService, private relationshipService: RelationshipService, - private ga: GoogleAnalyticsService, private route: ActivatedRoute, - private feature: FeatureFlagService, - private shareLinkService: ShareLinksApiService, ) { this.invitationForm = this.fb.group({ fullName: ['', [Validators.required]], @@ -162,9 +127,6 @@ export class SharingDialogComponent implements OnInit { }); this.shareItem = this.data.item as ItemVO; - this.shareLinkResponse = this.data.shareLinkResponse; - - this.displayDropdown = feature.isEnabled('unlisted-share'); } ngOnInit(): void { @@ -183,13 +145,6 @@ export class SharingDialogComponent implements OnInit { this.relationshipService.update(); - this.shareLink = shareUrlBuilder( - this.data.shareLinkResponse.itemType, - this.data.shareLinkResponse.token, - this.data.shareLinkResponse.itemId, - ); - this.setShareLinkFormValue(); - this.checkQueryParams(); } @@ -429,159 +384,4 @@ export class SharingDialogComponent implements OnInit { } } } - - getExpirationFromExpiresDT(expiresDT: string): Expiration { - if (!expiresDT) { - return Expiration.Never; - } - - const diff = differenceInHours( - new Date(expiresDT), - new Date(this.shareLinkResponse.createdDT), - ); - - if (diff <= 24 * ExpirationDays.Day) { - return Expiration.Day; - } else if (diff <= 24 * ExpirationDays.Week) { - return Expiration.Week; - } else if (diff <= 24 * 7 * ExpirationDays.Month) { - return Expiration.Month; - } else if (diff <= 24 * 7 * ExpirationDays.Year) { - return Expiration.Year; - } else { - return Expiration.Other; - } - } - - getExpiresDTFromExpiration(expiration: Expiration): string { - switch (expiration) { - case Expiration.Never: - return null; - case Expiration.Day: - return getSQLDateTime( - addDays(new Date(this.shareLinkResponse.createdDT), 1), - ); - case Expiration.Week: - return getSQLDateTime( - addDays(new Date(this.shareLinkResponse.createdDT), 7), - ); - case Expiration.Month: - return getSQLDateTime( - addDays(new Date(this.shareLinkResponse.createdDT), 30), - ); - case Expiration.Year: - return getSQLDateTime( - addDays(new Date(this.shareLinkResponse.createdDT), 365), - ); - } - } - - setShareLinkFormValue(): void { - if (this.shareLinkResponse) { - console.log(this.shareLinkResponse); - this.previewToggle = this.shareLinkResponse.previewToggle; - this.autoApproveToggle = this.shareLinkResponse.autoApproveToggle || 0; - this.expiration = this.getExpirationFromExpiresDT( - this.shareLinkResponse.expiresDT, - ); - console.log(this.shareLinkResponse); - console.log(this.shareLinkResponse.permissionsLevel); - this.linkDefaultAccessRole = this.shareLinkResponse.permissionLevel; - this.expirationOptions = EXPIRATION_OPTIONS.filter((expiration) => { - switch (expiration.value) { - case Expiration.Never: - case Expiration.Other: - return true; - default: - return !isPast( - new Date( - this.getExpiresDTFromExpiration(expiration.value as Expiration), - ), - ); - } - }); - } else { - this.previewToggle = 1; - this.autoApproveToggle = 1; - this.expiration = Expiration.Never; - this.expirationOptions = EXPIRATION_OPTIONS; - } - } - - async generateShareLink() { - this.updatingLink = true; - try { - const response = await this.api.share.generateShareLink(this.shareItem); - this.shareLinkResponse = response; - this.shareLinkResponse.autoApproveToggle = this.autoApproveToggle || 0; - this.shareLinkResponse.previewToggle = this.previewToggle || 0; - await this.api.share.updateShareLink(this.shareLinkResponse); - this.setShareLinkFormValue(); - this.showLinkSettings = true; - this.ga.sendEvent(EVENTS.SHARE.ShareByUrl.initiated.params); - } catch (err) { - if (err instanceof ShareResponse) { - this.messageService.showError({ - message: err.getMessage(), - translate: true, - }); - } - } finally { - this.updatingLink = false; - } - } - - copyShareLink() { - const element = this.shareUrlInput.nativeElement as HTMLInputElement; - - copyFromInputElement(element); - - this.linkCopied = true; - setTimeout(() => { - this.linkCopied = false; - }, 5000); - } - - async removeShareLink() { - const deferred = new Deferred(); - try { - await this.promptService.confirm( - 'Remove link', - 'Are you sure you want to remove this link?', - deferred.promise, - 'btn-danger', - ); - - await this.api.share.removeShareLink(this.shareLinkResponse); - this.shareLink = null; - this.setShareLinkFormValue(); - deferred.resolve(); - this.showLinkSettings = false; - } catch (response) { - deferred.resolve(); - if (response instanceof ShareResponse) { - this.messageService.showError({ message: response.getMessage() }); - } - } - } - - async onShareLinkPropChange(propName: ShareByUrlProps, value: any) { - this.updatingLink = true; - try { - const update = new ShareByUrlVO(this.shareLink); - update[propName] = value; - await this.api.share.updateShareLink(update); - this.shareLink[propName] = update[propName]; - } catch (err) { - if (err instanceof ShareResponse) { - this.messageService.showError({ - message: err.getMessage(), - translate: true, - }); - } - this.setShareLinkFormValue(); - } finally { - this.updatingLink = false; - } - } } diff --git a/src/app/file-browser/file-browser-components.module.ts b/src/app/file-browser/file-browser-components.module.ts index e0887e4f3..63aa43b2a 100644 --- a/src/app/file-browser/file-browser-components.module.ts +++ b/src/app/file-browser/file-browser-components.module.ts @@ -28,6 +28,7 @@ import { SharingDialogComponent } from './components/sharing-dialog/sharing-dial import { ShareLinkDropdownComponent } from './components/share-link-dropdown/share-link-dropdown.component'; import { DownloadButtonComponent } from './components/download-button/download-button.component'; +import { ShareLinkSettingsComponent } from './components/share-link-settings/share-link-settings.component'; @NgModule({ imports: [ @@ -49,6 +50,7 @@ import { DownloadButtonComponent } from './components/download-button/download-b LocationPickerComponent, SharingDialogComponent, ShareLinkDropdownComponent, + ShareLinkSettingsComponent, ], declarations: [ FileListComponent, @@ -67,6 +69,7 @@ import { DownloadButtonComponent } from './components/download-button/download-b SharingDialogComponent, DownloadButtonComponent, ShareLinkDropdownComponent, + ShareLinkSettingsComponent, ], }) export class FileBrowserComponentsModule { diff --git a/src/app/share-links/services/share-links-api.service.ts b/src/app/share-links/services/share-links-api.service.ts index 4d6fc1bfb..a7215bb67 100644 --- a/src/app/share-links/services/share-links-api.service.ts +++ b/src/app/share-links/services/share-links-api.service.ts @@ -44,7 +44,7 @@ export class ShareLinksApiService { const response = await firstValueFrom( this.http.post( 'v2/share-links', - { itemId, itemType }, + { itemId: `${itemId}`, itemType }, null, ), ); From 9eb6d27a83701c16cb6aa66c0dbf34568fb0dd18 Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Thu, 22 May 2025 15:52:46 +0300 Subject: [PATCH 5/8] Replace the previous share api calls with the new service I have replaced the previous share link api calls with the new ones, so that we can generate the new share URLs manually. --- .../core/services/edit/edit.service.spec.ts | 4 + src/app/core/services/edit/edit.service.ts | 23 +- .../file-list-item.component.ts | 28 +- .../share-link-settings.component.html | 77 ++---- .../share-link-settings.component.scss | 260 ++++++++++++++++++ .../share-link-settings.component.spec.ts | 238 +++++++++++++++- .../share-link-settings.component.ts | 140 +++++++--- .../sharing-dialog.component.html | 1 + .../sharing-dialog.component.spec.ts | 53 +--- .../sharing-dialog.component.ts | 1 + .../components/sharing/sharing.component.html | 2 +- .../components/sharing/sharing.component.ts | 108 ++++---- src/app/share-links/models/share-link.ts | 3 +- .../share-preview.component.spec.ts | 16 -- .../share-preview/share-preview.component.ts | 1 - .../resolves/share-url-resolve.service.ts | 2 - src/app/share-preview/share-preview.module.ts | 6 +- src/app/share-preview/share-preview.routes.ts | 4 +- .../components/prompt/prompt.component.scss | 1 + .../services/http-v2/http-v2.service.ts | 2 +- 20 files changed, 718 insertions(+), 252 deletions(-) diff --git a/src/app/core/services/edit/edit.service.spec.ts b/src/app/core/services/edit/edit.service.spec.ts index ecf363a85..479316d3f 100644 --- a/src/app/core/services/edit/edit.service.spec.ts +++ b/src/app/core/services/edit/edit.service.spec.ts @@ -9,6 +9,7 @@ import { AccountService } from '@shared/services/account/account.service'; import { RecordRepo } from '@shared/services/api/record.repo'; import { MessageService } from '@shared/services/message/message.service'; import { DataService } from '@shared/services/data/data.service'; +import { ShareLinksApiService } from '@root/app/share-links/services/share-links-api.service'; import { FolderPickerService } from '../folder-picker/folder-picker.service'; const mockDataService = { @@ -18,6 +19,8 @@ const mockDataService = { itemUnshared: (item) => {}, }; +const mockSharelinkApiService = {}; + describe('EditService', () => { let service: EditService; let apiService: jasmine.SpyObj; @@ -44,6 +47,7 @@ describe('EditService', () => { { provide: DataService, useValue: mockDataService }, { provide: ApiService, useValue: apiService }, { provide: AccountService, useValue: accountService }, + { provide: ShareLinksApiService, useValue: mockSharelinkApiService }, ], }); diff --git a/src/app/core/services/edit/edit.service.ts b/src/app/core/services/edit/edit.service.ts index c341b1d4f..435a7016a 100644 --- a/src/app/core/services/edit/edit.service.ts +++ b/src/app/core/services/edit/edit.service.ts @@ -40,8 +40,8 @@ import { PublishComponent } from '@fileBrowser/components/publish/publish.compon import { EditTagsComponent } from '@fileBrowser/components/edit-tags/edit-tags.component'; import { LocationPickerComponent } from '@fileBrowser/components/location-picker/location-picker.component'; import { SharingDialogComponent } from '@fileBrowser/components/sharing-dialog/sharing-dialog.component'; -import { FolderPickerService } from '../folder-picker/folder-picker.service'; import { ShareLinksApiService } from '@root/app/share-links/services/share-links-api.service'; +import { FolderPickerService } from '../folder-picker/folder-picker.service'; export const ItemActions: { [key: string]: PromptButton } = { Rename: { @@ -252,16 +252,17 @@ export class EditService { this.openPublishDialog(items[0]); break; case 'share': - // const response: ShareResponse = await this.api.share.getShareLink( - // items[0], - // ); - // actionDeferred.resolve(); - // this.dialog.open(SharingComponent, { - // data: { - // item: items[0], - // link: response.getShareByUrlVO(), - // }, - // }); + const response: ShareResponse = await this.api.share.getShareLink( + items[0], + ); + + actionDeferred.resolve(); + this.dialog.open(SharingComponent, { + data: { + item: items[0], + link: response.getShareByUrlVO(), + }, + }); break; default: actionDeferred.resolve(); diff --git a/src/app/file-browser/components/file-list-item/file-list-item.component.ts b/src/app/file-browser/components/file-list-item/file-list-item.component.ts index 9b0d9ee2c..b5d6660dc 100644 --- a/src/app/file-browser/components/file-list-item/file-list-item.component.ts +++ b/src/app/file-browser/components/file-list-item/file-list-item.component.ts @@ -71,6 +71,7 @@ import { ItemClickEvent } from '../file-list/file-list.component'; import { SharingComponent } from '../sharing/sharing.component'; import { PublishComponent } from '../publish/publish.component'; import { EditTagsComponent } from '../edit-tags/edit-tags.component'; +import { ShareLinksApiService } from '@root/app/share-links/services/share-links-api.service'; export const ItemActions: { [key: string]: PromptButton } = { Rename: { @@ -239,6 +240,7 @@ export class FileListItemComponent @Optional() private drag: DragService, private storage: StorageService, @Inject(DOCUMENT) private document: Document, + private shareLinksApiService: ShareLinksApiService, ) {} ngOnInit() { @@ -261,8 +263,6 @@ export class FileListItemComponent this.canSelect = true; } - console.log(this.canSelect) - if (this.router.routerState.snapshot.url.includes('/apps')) { this.isInApps = true; } @@ -496,9 +496,8 @@ export class FileListItemComponent event: event as MouseEvent, selectable: false, }); - } - else { - this.onItemSingleClick(event); + } else { + this.onItemSingleClick(event); } } @@ -593,7 +592,6 @@ export class FileListItemComponent } if (this.waitingForDoubleClick) { - console.log(this.waitingForDoubleClick); this.waitingForDoubleClick = false; return this.onItemDoubleClick(); } @@ -780,14 +778,24 @@ export class FileListItemComponent }); break; case 'share': - this.api.share - .getShareLink(this.item) - .then((response: ShareResponse) => { + const itemType = this.item.isRecord ? 'record' : 'folder'; + + const itemId = + this.item instanceof RecordVO + ? this.item.recordId + : this.item.folderId; + + this.shareLinksApiService + .generateShareLink({ + itemId, + itemType, + }) + .then((response) => { actionDeferred.resolve(); this.dialog.open(SharingComponent, { data: { item: this.item, - link: response.getShareByUrlVO(), + shareLinkResponse: response, }, }); }); diff --git a/src/app/file-browser/components/share-link-settings/share-link-settings.component.html b/src/app/file-browser/components/share-link-settings/share-link-settings.component.html index 34bf7c56a..decf9f036 100644 --- a/src/app/file-browser/components/share-link-settings/share-link-settings.component.html +++ b/src/app/file-browser/components/share-link-settings/share-link-settings.component.html @@ -64,7 +64,8 @@ Link Type
- - - - Recipients can see a preview without being logged in. - - - Recipients must be granted access to view content. - - -