Skip to content

Per 10107 implement unlisted share page UI #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/app/apps/resolves/apps-folder-resolve.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ApiService } from '@shared/services/api/api.service';
import { AccountService } from '@shared/services/account/account.service';

import { FolderVO } from '@root/app/models';
import { FolderResponse } from '@shared/services/api/folder.repo';

@Injectable()
export class AppsFolderResolveService {
Expand All @@ -29,6 +30,6 @@ export class AppsFolderResolveService {
new FolderVO(appsFolder),
]);

return folderResponse.getFolderVO(true);
return (folderResponse as FolderResponse).getFolderVO(true);
}
}
3 changes: 2 additions & 1 deletion src/app/core/components/left-menu/left-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import { PayerService } from '@shared/services/payer/payer.service';
import { EventService } from '@shared/services/event/event.service';
import { GetThumbnail } from '@models/get-thumbnail';
import { FolderResponse } from '@shared/services/api/folder.repo';
import { ConnectionsDialogComponent } from '../connections-dialog/connections-dialog.component';
import { ProfileEditComponent } from '../profile-edit/profile-edit.component';
import { MyArchivesDialogComponent } from '../my-archives-dialog/my-archives-dialog.component';
Expand Down Expand Up @@ -213,7 +214,7 @@
const folderResponse = await this.api.folder.getWithChildren([
new FolderVO(apps),
]);
const appsFolder = folderResponse.getFolderVO(true);
const appsFolder = (folderResponse as FolderResponse).getFolderVO(true);

Check warning on line 217 in src/app/core/components/left-menu/left-menu.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/core/components/left-menu/left-menu.component.ts#L217

Added line #L217 was not covered by tests
this.appsSubfolders = appsFolder.ChildItemVOs as FolderVO[];
} catch (err) {
Sentry.captureException(err);
Expand Down
12 changes: 9 additions & 3 deletions src/app/core/resolves/folder-resolve.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@
type: 'type.folder.root.app',
});
targetFolder = new FolderVO(apps);
} else if (state.url.includes('/share/')) {
const sharedFolder = route.parent.data.sharePreviewVO.FolderVO;
const sharedRecord = route.parent.data.sharePreviewVO.RecordVO;
} else if (state.url.includes('/share')) {
const sharedFolder =
route.parent.data.sharePreviewItem?.FolderVO ||
route.parent.data.sharePreviewVO?.FolderVO;
const sharedRecord =
route.parent.data.sharePreviewItem?.RecordVO ||
route.parent.data.sharePreviewVO?.RecordVO;
if (sharedFolder) {
sharedFolder.folder_linkId = sharedFolder.folderLinkId;
sharedFolder.archiveNbr = sharedFolder.archiveNumber;

Check warning on line 54 in src/app/core/resolves/folder-resolve.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/core/resolves/folder-resolve.service.ts#L53-L54

Added lines #L53 - L54 were not covered by tests
targetFolder = new FolderVO(sharedFolder);
} else {
const folder = new FolderVO(cloneDeep(route.parent.data.currentFolder));
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/resolves/record-resolve.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class RecordResolveService {
const response = await this.api.record.get([
new RecordVO({ archiveNbr: route.params.recArchiveNbr }),
]);
const record = response.getRecordVO();
const record = (response as RecordResponse).getRecordVO();
record.dataStatus = DataStatus.Full;
return record;
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/services/edit/edit.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -18,6 +19,8 @@ const mockDataService = {
itemUnshared: (item) => {},
};

const mockSharelinkApiService = {};

describe('EditService', () => {
let service: EditService;
let apiService: jasmine.SpyObj<ApiService>;
Expand All @@ -44,6 +47,7 @@ describe('EditService', () => {
{ provide: DataService, useValue: mockDataService },
{ provide: ApiService, useValue: apiService },
{ provide: AccountService, useValue: accountService },
{ provide: ShareLinksApiService, useValue: mockSharelinkApiService },
],
});

Expand Down
17 changes: 14 additions & 3 deletions src/app/core/services/edit/edit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
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 { 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 } = {
Expand Down Expand Up @@ -132,6 +133,7 @@
private device: DeviceService,
private secrets: SecretsService,
private event: EventService,
private shareLinkService: ShareLinksApiService,
) {
this.loadGoogleMapsApi();
}
Expand Down Expand Up @@ -253,6 +255,7 @@
const response: ShareResponse = await this.api.share.getShareLink(
items[0],
);

actionDeferred.resolve();
this.dialog.open(SharingComponent, {
data: {
Expand Down Expand Up @@ -526,18 +529,26 @@
}

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({

Check warning on line 536 in src/app/core/services/edit/edit.service.ts

View check run for this annotation

Codecov / codecov/patch

src/app/core/services/edit/edit.service.ts#L536

Added line #L536 was not covered by tests
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',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'drag-target': isDragTarget,
'drop-target': isDropTarget,
dragging: isDragging,
disabled: item.isPendingAction,
disabled: item?.isPendingAction,
'public-archive': isPublicArchive
}"
(mousedown)="onItemMouseDown($event)"
Expand Down Expand Up @@ -46,7 +46,11 @@
<div
*ngIf="!item.isFolder && !isZip"
prBgImage
[bgSrc]="!inGridView ? item.thumbURL200 : item.thumbURL500"
[bgSrc]="
!inGridView
? item.thumbURL200 || item.thumbUrl200
: item.thumbURL500 || item.thumbUrl500
"
[cover]="inGridView"
></div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
} from '@shared/utilities/hasSubscriptions';
import { Subscription } from 'rxjs';
import { DOCUMENT } from '@angular/common';
import { ShareLinksApiService } from '@root/app/share-links/services/share-links-api.service';
import { ngIfFadeInAnimation } from '@shared/animations';
import { RouteData } from '@root/app/app.routes';
import { ThumbnailCache } from '@shared/utilities/thumbnail-cache/thumbnail-cache';
Expand Down Expand Up @@ -239,6 +240,7 @@
@Optional() private drag: DragService,
private storage: StorageService,
@Inject(DOCUMENT) private document: Document,
private shareLinksApiService: ShareLinksApiService,

Check warning on line 243 in src/app/file-browser/components/file-list-item/file-list-item.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/file-browser/components/file-list-item/file-list-item.component.ts#L243

Added line #L243 was not covered by tests
) {}

ngOnInit() {
Expand All @@ -258,6 +260,7 @@
if (this.router.routerState.snapshot.url.includes('/share/')) {
this.allowActions = false;
this.isInSharePreview = true;
this.canSelect = true;

Check warning on line 263 in src/app/file-browser/components/file-list-item/file-list-item.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/file-browser/components/file-list-item/file-list-item.component.ts#L263

Added line #L263 was not covered by tests
}

if (this.router.routerState.snapshot.url.includes('/apps')) {
Expand Down Expand Up @@ -409,7 +412,6 @@
break;
}
}

onItemMouseDown(mouseDownEvent: MouseEvent) {
if (this.isShareRoot || this.isInApps) {
return;
Expand Down Expand Up @@ -776,14 +778,24 @@
});
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

Check warning on line 788 in src/app/file-browser/components/file-list-item/file-list-item.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/file-browser/components/file-list-item/file-list-item.component.ts#L788

Added line #L788 was not covered by tests
.generateShareLink({
itemId,
itemType,
})
.then((response) => {
actionDeferred.resolve();
this.dialog.open(SharingComponent, {
data: {
item: this.item,
link: response.getShareByUrlVO(),
shareLinkResponse: response,
},
});
});
Expand Down Expand Up @@ -1040,7 +1052,7 @@
} else {
this.api.folder
.getWithChildren([this.item as FolderVO])
.then((resp) => {
.then((resp: FolderResponse) => {
if (resp.isSuccessful) {
const newFolderVO = resp.Results[0].data[0].FolderVO as FolderVO;
const allChildren = newFolderVO.ChildItemVOs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<pr-file-list-item
*ngFor="let item of currentFolder.ChildItemVOs"
[@ngIfScaleAnimationDynamic]="
item.isPendingAction || item.isNewlyCreated ? 'animate' : 'static'
item?.isPendingAction || item?.isNewlyCreated ? 'animate' : 'static'
"
[item]="item"
[folderView]="folderView"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export class FileListComponent
this.currentFolder = this.route.snapshot.data.currentFolder;
this.showSidebar = this.route.snapshot.data.showSidebar;
this.dataService.setCurrentFolder(this.currentFolder);

this.isRootFolder = this.currentFolder.type.includes('root');
this.showFolderDescription = this.route.snapshot.data.showFolderDescription;

Expand Down
Loading