Skip to content

Commit b900c53

Browse files
committed
[PER-10107] Fix linting and prettier
1 parent 0377d7e commit b900c53

File tree

12 files changed

+108
-94
lines changed

12 files changed

+108
-94
lines changed

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ import { ngIfFadeInAnimation } from '@shared/animations';
6767
import { RouteData } from '@root/app/app.routes';
6868
import { ThumbnailCache } from '@shared/utilities/thumbnail-cache/thumbnail-cache';
6969
import { GetThumbnail } from '@models/get-thumbnail';
70+
import { ShareLinksService } from '@root/app/share-links/services/share-links.service';
7071
import { ItemClickEvent } from '../file-list/file-list.component';
7172
import { SharingComponent } from '../sharing/sharing.component';
7273
import { PublishComponent } from '../publish/publish.component';
7374
import { EditTagsComponent } from '../edit-tags/edit-tags.component';
74-
import { ShareLinksService } from '@root/app/share-links/services/share-links.service';
7575

7676
export const ItemActions: { [key: string]: PromptButton } = {
7777
Rename: {
@@ -492,8 +492,9 @@ export class FileListItemComponent
492492
}
493493

494494
showUnlistedPreview() {
495-
if(this.router.routerState.snapshot.url.includes('/share/')) {
496-
if(this.item.isFolder) {
495+
if (this.isUnlistedShare) {
496+
//TO DO: make preview for folder --> story PER-10314
497+
if (this.item.isFolder) {
497498
return;
498499
}
499500
this.goToItem();
@@ -502,7 +503,7 @@ export class FileListItemComponent
502503
}
503504

504505
onItemClick(event: MouseEvent) {
505-
if(this.router.routerState.snapshot.url.includes('/share/')) {
506+
if (this.isUnlistedShare) {
506507
return;
507508
}
508509
if (this.device.isMobileWidth() || !this.canSelect) {
@@ -527,7 +528,7 @@ export class FileListItemComponent
527528
}
528529

529530
async goToItem() {
530-
if (!this.allowNavigation && !this.router.routerState.snapshot.url.includes('/share/')) {
531+
if (!this.allowNavigation && !this.isUnlistedShare) {
531532
return false;
532533
}
533534

@@ -537,16 +538,16 @@ export class FileListItemComponent
537538
return;
538539
}
539540

540-
// if (this.item.dataStatus < DataStatus.Lean) {
541-
// this.dataService.beginPreparingForNavigate();
542-
// if (!this.item.isFetching) {
543-
// this.dataService.fetchLeanItems([this.item]);
544-
// }
541+
if (this.item.dataStatus < DataStatus.Lean && !this.isUnlistedShare) {
542+
this.dataService.beginPreparingForNavigate();
543+
if (!this.item.isFetching) {
544+
this.dataService.fetchLeanItems([this.item]);
545+
}
545546

546-
// return await this.item.fetched.then((fetched) => {
547-
// this.goToItem();
548-
// });
549-
// }
547+
return await this.item.fetched.then((fetched) => {
548+
this.goToItem();
549+
});
550+
}
550551

551552
let rootUrl;
552553

@@ -595,7 +596,7 @@ export class FileListItemComponent
595596
this.dataService.currentFolder.type === 'type.folder.root.share'
596597
) {
597598
this.router.navigate(['/shares/record', this.item.archiveNbr]);
598-
} else if(this.isUnlistedShare) {
599+
} else if (this.isUnlistedShare) {
599600
this.router.navigate(['view/record', this.item.archiveNbr], {
600601
relativeTo: this.route,
601602
});

src/app/file-browser/components/file-list/file-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ export class FileListComponent
529529

530530
let itemsToFetch = visibleListItems.map((c) => c.item);
531531
const isUnlistedShare = await this.shareLinksService.isUnlistedShare();
532-
if(isUnlistedShare) {
532+
if (isUnlistedShare) {
533533
itemsToFetch = [];
534534
}
535535
if (itemsToFetch.length) {

src/app/file-browser/components/file-viewer/file-viewer.component.ts

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
Optional,
99
DOCUMENT,
1010
} from '@angular/core';
11-
import { Location } from '@angular/common';
1211

1312
import { Router, ActivatedRoute } from '@angular/router';
1413
import { Key } from 'ts-key-enum';
@@ -28,9 +27,9 @@ import { SearchService } from '@search/services/search.service';
2827
import { ZoomingImageViewerComponent } from '@shared/components/zooming-image-viewer/zooming-image-viewer.component';
2928
import { FileFormat } from '@models/file-vo';
3029
import { GetAccessFile } from '@models/get-access-file';
31-
import { TagsService } from '../../../core/services/tags/tags.service';
3230
import { ShareLinksService } from '@root/app/share-links/services/share-links.service';
3331
import { ApiService } from '@shared/services/api/api.service';
32+
import { TagsService } from '../../../core/services/tags/tags.service';
3433

3534
@Component({
3635
selector: 'pr-file-viewer',
@@ -91,7 +90,6 @@ export class FileViewerComponent implements OnInit, OnDestroy {
9190
private accountService: AccountService,
9291
private editService: EditService,
9392
private tagsService: TagsService,
94-
private location: Location,
9593
@Optional() publicProfile: PublicProfileService,
9694
private shareLinksService: ShareLinksService,
9795
private api: ApiService,
@@ -119,11 +117,12 @@ export class FileViewerComponent implements OnInit, OnDestroy {
119117
});
120118
}
121119

122-
this.canEdit = this.router.routerState.snapshot.url.includes('/share/') ? false :
123-
this.accountService.checkMinimumAccess(
124-
this.currentRecord.accessRole,
125-
AccessRole.Editor,
126-
) && !route.snapshot.data?.isPublicArchive;
120+
this.canEdit = this.isUnlistedShare
121+
? false
122+
: this.accountService.checkMinimumAccess(
123+
this.currentRecord.accessRole,
124+
AccessRole.Editor,
125+
) && !route.snapshot.data?.isPublicArchive;
127126

128127
this.tagSubscription = this.tagsService
129128
.getItemTags$()
@@ -138,13 +137,15 @@ export class FileViewerComponent implements OnInit, OnDestroy {
138137
}
139138

140139
async ngOnInit() {
141-
142-
this.isUnlistedShare = await this.shareLinksService.isUnlistedShare();
143-
144-
if(this.isUnlistedShare) {
145-
const response = await this.api.record.getWithShareTokenAuth([this.currentRecord.recordId], this.shareLinksService.currentShareToken);
146-
this.setRecordsToPreview(response.getRecordVO());
147-
}
140+
this.isUnlistedShare = await this.shareLinksService.isUnlistedShare();
141+
142+
if (this.isUnlistedShare) {
143+
const response = await this.api.record.getWithShareTokenAuth(
144+
[this.currentRecord.recordId],
145+
this.shareLinksService.currentShareToken,
146+
);
147+
this.setRecordsToPreview(response.getRecordVO());
148+
}
148149

149150
this.initRecord();
150151

@@ -176,19 +177,19 @@ export class FileViewerComponent implements OnInit, OnDestroy {
176177
}
177178

178179
private setRecordsToPreview(resolvedRecord: RecordVO) {
179-
this.records = filter(
180-
this.dataService.currentFolder.ChildItemVOs,
181-
'isRecord',
182-
) as RecordVO[];
183-
this.currentIndex = findIndex(this.records, {
184-
folder_linkId: resolvedRecord.folder_linkId,
185-
});
186-
this.currentRecord = this.records[this.currentIndex];
187-
if (resolvedRecord !== this.currentRecord) {
188-
this.currentRecord.update(resolvedRecord);
189-
}
180+
this.records = filter(
181+
this.dataService.currentFolder.ChildItemVOs,
182+
'isRecord',
183+
) as RecordVO[];
184+
this.currentIndex = findIndex(this.records, {
185+
folder_linkId: resolvedRecord.folder_linkId,
186+
});
187+
this.currentRecord = this.records[this.currentIndex];
188+
if (resolvedRecord !== this.currentRecord) {
189+
this.currentRecord.update(resolvedRecord);
190+
}
190191

191-
this.loadQueuedItems();
192+
this.loadQueuedItems();
192193
}
193194

194195
@HostListener('window:resize', [])
@@ -388,8 +389,10 @@ export class FileViewerComponent implements OnInit, OnDestroy {
388389
}
389390

390391
close() {
391-
if(this.isUnlistedShare) {
392-
this.router.navigate([`/share/${this.shareLinksService.currentShareToken}`]);
392+
if (this.isUnlistedShare) {
393+
this.router.navigate([
394+
`/share/${this.shareLinksService.currentShareToken}`,
395+
]);
393396
} else {
394397
this.router.navigate(['.'], { relativeTo: this.route.parent });
395398
}

src/app/file-browser/file-browser.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { FileListItemComponent } from '@fileBrowser/components/file-list-item/fi
1010
import { FileViewerComponent } from '@fileBrowser/components/file-viewer/file-viewer.component';
1111
import { VideoComponent } from '@shared/components/video/video.component';
1212
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
13-
import { FileBrowserComponentsModule } from './file-browser-components.module';
1413
import { EditService } from '@core/services/edit/edit.service';
1514
import { FolderPickerService } from '@core/services/folder-picker/folder-picker.service';
1615
import { ShareLinksApiService } from '../share-links/services/share-links-api.service';
16+
import { FileBrowserComponentsModule } from './file-browser-components.module';
1717

1818
@NgModule({
1919
providers: [EditService, FolderPickerService, ShareLinksApiService],

src/app/filesystem/filesystem-api.service.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,36 @@ import { firstValueFrom } from 'rxjs';
44
import { FolderVO, RecordVO } from '@models/index';
55
import { ApiService } from '@shared/services/api/api.service';
66
import { DataStatus } from '@models/data-status.enum';
7+
import { FolderResponse } from '@shared/services/api/folder.repo';
8+
import { ShareLinksService } from '../share-links/services/share-links.service';
79
import { FilesystemApi } from './types/filesystem-api';
810
import {
911
FolderIdentifier,
1012
RecordIdentifier,
1113
} from './types/filesystem-identifier';
1214
import { ArchiveIdentifier } from './types/archive-identifier';
13-
import { ShareLinksService } from '../share-links/services/share-links.service';
14-
import { FolderResponse } from '@shared/services/api/folder.repo';
1515

1616
@Injectable({
1717
providedIn: 'root',
1818
})
1919
export class FilesystemApiService implements FilesystemApi {
20-
constructor(private api: ApiService,
20+
constructor(
21+
private api: ApiService,
2122
private shareLinksService: ShareLinksService,
2223
) {}
2324

2425
public async navigate(folder: FolderIdentifier): Promise<FolderVO> {
2526
const isUnlistedShare = await this.shareLinksService.isUnlistedShare();
2627
let response: FolderResponse = null;
27-
if(isUnlistedShare) {
28-
response = await this.api.folder.getWithChildren([new FolderVO(folder)], this.shareLinksService.currentShareToken);
28+
if (isUnlistedShare) {
29+
response = await this.api.folder.getWithChildren(
30+
[new FolderVO(folder)],
31+
this.shareLinksService.currentShareToken,
32+
);
2933
} else {
30-
response = await firstValueFrom(
31-
this.api.folder.navigateLean(new FolderVO(folder)),
32-
);
34+
response = await firstValueFrom(
35+
this.api.folder.navigateLean(new FolderVO(folder)),
36+
);
3337
}
3438
if (!response.isSuccessful) {
3539
throw response;

src/app/share-links/services/share-links-api.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class ShareLinksApiService {
1111

1212
public async getShareLinksById(shareLinkIds: number[]): Promise<ShareLink[]> {
1313
const response = await firstValueFrom(
14-
this.http.get<{ items: ShareLink[]}>(
14+
this.http.get<{ items: ShareLink[] }>(
1515
'v2/share-links',
1616
{ shareLinkIds },
1717
null,
@@ -24,13 +24,13 @@ export class ShareLinksApiService {
2424
shareTokens: string[],
2525
): Promise<ShareLink[]> {
2626
const response = await firstValueFrom(
27-
this.http.get<{ items: ShareLink[]}>(
27+
this.http.get<{ items: ShareLink[] }>(
2828
'v2/share-links',
2929
{ shareTokens: shareTokens },
3030
null,
3131
{
3232
authToken: false,
33-
}
33+
},
3434
),
3535
);
3636
return response[0].items;

src/app/share-links/services/share-links.service.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import { Injectable } from '@angular/core';
2-
import { ShareLinksApiService } from './share-links-api.service';
32
import { ShareLink } from '../models/share-link';
3+
import { ShareLinksApiService } from './share-links-api.service';
44

55
@Injectable({
66
providedIn: 'root',
77
})
88
export class ShareLinksService {
9-
109
private _currentShareToken = '';
1110
private _shareLinks: ShareLink[] = undefined;
1211

13-
constructor(
14-
private shareLinksApiService: ShareLinksApiService) {
15-
16-
}
12+
constructor(private shareLinksApiService: ShareLinksApiService) {}
1713

1814
public get currentShareToken() {
1915
return this._currentShareToken;
@@ -24,13 +20,15 @@ export class ShareLinksService {
2420
}
2521

2622
public async isUnlistedShare() {
27-
if(!this._currentShareToken) {
23+
if (!this._currentShareToken) {
2824
return false;
2925
}
30-
if(!this._shareLinks) {
31-
this._shareLinks = await this.shareLinksApiService.getShareLinksByToken([this._currentShareToken]);
26+
if (!this._shareLinks) {
27+
this._shareLinks = await this.shareLinksApiService.getShareLinksByToken([
28+
this._currentShareToken,
29+
]);
3230
}
33-
if(this._shareLinks && this._shareLinks.length) {
31+
if (this._shareLinks && this._shareLinks.length) {
3432
return this._shareLinks[0].accessRestrictions === 'none';
3533
} else {
3634
return false;

src/app/share-preview/components/share-preview/share-preview.component.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ describe('SharePreviewComponent', () => {
8080
const dialogSpy = spyOn(dialog, 'open').and.returnValue(dialogRefSpy);
8181

8282
component.isLoggedIn = false;
83-
component.ngAfterViewInit();
8483
tick(1005);
8584

8685
expect(dialogSpy).toHaveBeenCalled();
@@ -90,7 +89,6 @@ describe('SharePreviewComponent', () => {
9089
const dialogSpy = spyOn(dialog, 'open');
9190

9291
component.isLoggedIn = true;
93-
component.ngAfterViewInit();
9492
tick(1005);
9593

9694
expect(dialogSpy).not.toHaveBeenCalled();

src/app/share-preview/components/share-preview/share-preview.component.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
Component,
3-
OnInit,
4-
AfterViewInit,
5-
HostListener,
6-
OnDestroy,
7-
} from '@angular/core';
1+
import { Component, OnInit, HostListener, OnDestroy } from '@angular/core';
82
import {
93
Router,
104
ActivatedRoute,
@@ -35,8 +29,8 @@ import { READ_ONLY_FIELD } from '@shared/components/prompt/prompt-fields';
3529
import { PromptService } from '@shared/services/prompt/prompt.service';
3630
import { Deferred } from '@root/vendor/deferred';
3731
import { DialogCdkService } from '@root/app/dialog-cdk/dialog-cdk.service';
38-
import { CreateAccountDialogComponent } from '../create-account-dialog/create-account-dialog.component';
3932
import { ShareLinksService } from '@root/app/share-links/services/share-links.service';
33+
import { CreateAccountDialogComponent } from '../create-account-dialog/create-account-dialog.component';
4034

4135
const MIN_PASSWORD_LENGTH = APP_CONFIG.passwordMinLength;
4236

@@ -193,10 +187,9 @@ export class SharePreviewComponent implements OnInit, OnDestroy {
193187
}
194188

195189
async ngOnInit() {
196-
197190
this.shareLinksService.currentShareToken = this.shareToken;
198191
this.isUnlistedShare = await this.shareLinksService.isUnlistedShare();
199-
192+
200193
this.checkAccess();
201194

202195
if (!this.hasAccess) {
@@ -241,7 +234,6 @@ export class SharePreviewComponent implements OnInit, OnDestroy {
241234
}
242235

243236
ngOnDestroy(): void {
244-
245237
this.shareLinksService.currentShareToken = undefined;
246238

247239
this.routerListener.unsubscribe();

0 commit comments

Comments
 (0)