Skip to content
Merged
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
5 changes: 3 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"cedar-embeddable-editor",
"cedar-artifact-viewer",
"markdown-it-video",
"ace-builds/src-noconflict/ext-language_tools"
"ace-builds/src-noconflict/ext-language_tools",
"@traptitech/markdown-it-katex"
],
"assets": [
"src/assets",
Expand Down Expand Up @@ -63,7 +64,7 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "7MB",
"maximumWarning": "9MB",
"maximumError": "10MB"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
constructor() {
this.initializeProvider();
this.setupEffects();
this.setupCleanup();
}

handleProjectSelected(): void {
Expand Down Expand Up @@ -154,16 +155,6 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
}

private setupEffects(): void {
effect(() => {
this.destroyRef.onDestroy(() => {
this.actions.clearAddToCollectionState();
this.allowNavigation.set(false);

HeaderStyleHelper.resetToDefaults();
BrandService.resetBranding();
});
});

effect(() => {
const provider = this.collectionProvider();

Expand All @@ -174,6 +165,16 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
});
}

private setupCleanup() {
this.destroyRef.onDestroy(() => {
this.actions.clearAddToCollectionState();
this.allowNavigation.set(false);

HeaderStyleHelper.resetToDefaults();
BrandService.resetBranding();
});
}

@HostListener('window:beforeunload', ['$event'])
onBeforeUnload($event: BeforeUnloadEvent): boolean {
$event.preventDefault();
Expand Down
21 changes: 5 additions & 16 deletions src/app/features/files/pages/files/files.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,11 @@
</div>
</div>

<div class="flex absolute upload-dialog">
<p-dialog
[header]="'files.dialogs.uploadFile.title' | translate"
[modal]="true"
[(visible)]="fileIsUploading"
class="upload-dialog"
>
<div class="flex flex-column align-items-center justify-content-center gap-3 w-full">
<span class="p-text-secondary filename">{{ fileName() }}</span>
<div class="w-6">
<osf-loading-spinner></osf-loading-spinner>
</div>
<p>{{ progress() }} %</p>
</div>
</p-dialog>
</div>
<osf-file-upload-dialog
[(visible)]="fileIsUploading"
[fileName]="fileName()"
[progress]="progress()"
></osf-file-upload-dialog>

<osf-files-tree
[files]="files()"
Expand Down
25 changes: 14 additions & 11 deletions src/app/features/files/pages/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { TranslatePipe, TranslateService } from '@ngx-translate/core';

import { TreeDragDropService } from 'primeng/api';
import { Button } from 'primeng/button';
import { Dialog } from 'primeng/dialog';
import { Select } from 'primeng/select';
import { TableModule } from 'primeng/table';

Expand All @@ -18,7 +17,6 @@ import {
forkJoin,
Observable,
of,
skip,
switchMap,
take,
} from 'rxjs';
Expand Down Expand Up @@ -63,6 +61,7 @@ import { getViewOnlyParamFromUrl, hasViewOnlyParam, IS_MEDIUM } from '@osf/share
import { CurrentResourceSelectors, GetResourceDetails } from '@osf/shared/stores';
import {
FilesTreeComponent,
FileUploadDialogComponent,
FormSelectComponent,
GoogleFilePickerComponent,
LoadingSpinnerComponent,
Expand All @@ -82,7 +81,7 @@ import { FilesSelectors } from '../../store';
selector: 'osf-files',
imports: [
Button,
Dialog,
FileUploadDialogComponent,
FilesTreeComponent,
FormSelectComponent,
FormsModule,
Expand All @@ -104,6 +103,7 @@ import { FilesSelectors } from '../../store';
})
export class FilesComponent {
googleFilePickerComponent = viewChild(GoogleFilePickerComponent);
filesTree = viewChild<FilesTreeComponent>(FilesTreeComponent);

@HostBinding('class') classes = 'flex flex-column flex-1 w-full h-full';

Expand Down Expand Up @@ -297,6 +297,7 @@ export class FilesComponent {
}
this.actions.setCurrentProvider(provider ?? FileProvider.OsfStorage);
this.actions.setCurrentFolder(currentRootFolder.folder);
this.filesTree()?.resetPagination();
}
});

Expand All @@ -307,25 +308,27 @@ export class FilesComponent {
});

this.searchControl.valueChanges
.pipe(skip(1), takeUntilDestroyed(this.destroyRef), distinctUntilChanged(), debounceTime(500))
.pipe(takeUntilDestroyed(this.destroyRef), distinctUntilChanged(), debounceTime(500))
.subscribe((searchText) => {
this.actions.setSearch(searchText ?? '');
this.filesTree()?.resetPagination();

if (!this.isFolderOpening()) {
this.updateFilesList();
}
});

this.sortControl.valueChanges.pipe(skip(1), takeUntilDestroyed(this.destroyRef)).subscribe((sort) => {
this.sortControl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((sort) => {
this.actions.setSort(sort ?? '');
this.filesTree()?.resetPagination();

if (!this.isFolderOpening()) {
this.updateFilesList();
}
});

effect(() => {
this.destroyRef.onDestroy(() => {
this.actions.resetState();
});
this.destroyRef.onDestroy(() => {
this.actions.resetState();
});
}

Expand Down Expand Up @@ -491,15 +494,15 @@ export class FilesComponent {
});
}

public updateFilesList = (): Observable<void> => {
updateFilesList(): Observable<void> {
const currentFolder = this.currentFolder();
if (currentFolder?.relationships.filesLink) {
this.filesTreeActions.setFilesIsLoading?.(true);
return this.actions.getFiles(currentFolder?.relationships.filesLink).pipe(take(1));
}

return EMPTY;
};
}

folderIsOpening(value: boolean): void {
this.isFolderOpening.set(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
input,
model,
signal,
viewChild,
} from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';

Expand Down Expand Up @@ -50,6 +51,8 @@ import { ProjectModel } from '@osf/shared/models/projects';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FilesWidgetComponent {
filesTree = viewChild<FilesTreeComponent>(FilesTreeComponent);

rootOption = input.required<SelectOption>();
components = input.required<NodeShortInfoModel[]>();
areComponentsLoading = input<boolean>(false);
Expand Down Expand Up @@ -144,13 +147,12 @@ export class FilesWidgetComponent {
const currentRootFolder = this.currentRootFolder();
if (currentRootFolder) {
this.actions.setCurrentFolder(currentRootFolder.folder);
this.filesTree()?.resetPagination();
}
});

effect(() => {
this.destroyRef.onDestroy(() => {
this.actions.resetState();
});
this.destroyRef.onDestroy(() => {
this.actions.resetState();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ export class ConfigureAddonComponent implements OnInit {
constructor() {
this.initializeAddon();

effect(() => {
this.destroyRef.onDestroy(() => {
this.actions.clearOperationInvocations();
});
this.destroyRef.onDestroy(() => {
this.actions.clearOperationInvocations();
});

effect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,11 @@
</div>
}

<div class="flex absolute">
<p-dialog
[header]="'files.dialogs.uploadFile.title' | translate"
[modal]="true"
[(visible)]="fileIsUploading"
class="upload-dialog"
>
<div class="flex flex-column align-items-center justify-content-center gap-3 w-full">
<span class="p-text-secondary filename">{{ fileName() }}</span>
<div class="w-6">
<osf-loading-spinner></osf-loading-spinner>
</div>
<p>{{ progress() }} %</p>
</div>
</p-dialog>
</div>
<osf-file-upload-dialog
[(visible)]="fileIsUploading"
[fileName]="fileName()"
[progress]="progress()"
></osf-file-upload-dialog>

<osf-files-tree
[files]="files()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { TranslatePipe } from '@ngx-translate/core';

import { TreeDragDropService } from 'primeng/api';
import { Button } from 'primeng/button';
import { Dialog } from 'primeng/dialog';

import { EMPTY, filter, finalize, Observable, shareReplay, take } from 'rxjs';

Expand All @@ -25,7 +24,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { HelpScoutService } from '@core/services/help-scout.service';
import { CreateFolderDialogComponent } from '@osf/features/files/components';
import { FilesTreeComponent, LoadingSpinnerComponent } from '@osf/shared/components';
import { FilesTreeComponent, FileUploadDialogComponent, LoadingSpinnerComponent } from '@osf/shared/components';
import { FILE_SIZE_LIMIT } from '@osf/shared/constants';
import { ClearFileDirective } from '@osf/shared/directives';
import { FilesTreeActions, OsfFile } from '@osf/shared/models';
Expand All @@ -47,7 +46,7 @@ import {
FilesTreeComponent,
Button,
LoadingSpinnerComponent,
Dialog,
FileUploadDialogComponent,
FormsModule,
ReactiveFormsModule,
TranslatePipe,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ export class StorageItemSelectorComponent implements OnInit {
}
});

effect(() => {
this.destroyRef.onDestroy(() => {
this.actions.clearOperationInvocations();
});
this.destroyRef.onDestroy(() => {
this.actions.clearOperationInvocations();
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p-dialog
[header]="'files.dialogs.uploadFile.title' | translate"
[modal]="true"
[(visible)]="visible"
class="upload-dialog"
>
<div class="flex flex-column align-items-center justify-content-center gap-3 w-full">
<span class="p-text-secondary filename">{{ fileName() }}</span>
<div class="w-6">
<osf-loading-spinner></osf-loading-spinner>
</div>
<p>{{ progress() }} %</p>
</div>
</p-dialog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.filename {
word-break: break-all;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { TranslatePipe } from '@ngx-translate/core';

import { DialogModule } from 'primeng/dialog';

import { ChangeDetectionStrategy, Component, input, model } from '@angular/core';

import { LoadingSpinnerComponent } from '../loading-spinner/loading-spinner.component';

@Component({
selector: 'osf-file-upload-dialog',
imports: [DialogModule, TranslatePipe, LoadingSpinnerComponent],
templateUrl: './file-upload-dialog.component.html',
styleUrl: './file-upload-dialog.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FileUploadDialogComponent {
visible = model<boolean>(false);
fileName = input<string>('');
progress = input<number>(0);
}
1 change: 1 addition & 0 deletions src/app/shared/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export { EducationHistoryDialogComponent } from './education-history-dialog/educ
export { EmploymentHistoryComponent } from './employment-history/employment-history.component';
export { EmploymentHistoryDialogComponent } from './employment-history-dialog/employment-history-dialog.component';
export { FileMenuComponent } from './file-menu/file-menu.component';
export { FileUploadDialogComponent } from './file-upload-dialog/file-upload-dialog.component';
export { FilesTreeComponent } from './files-tree/files-tree.component';
export { FilterChipsComponent } from './filter-chips/filter-chips.component';
export { FormSelectComponent } from './form-select/form-select.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class ResourceCitationsComponent {
this.setupFilterDebounce();
this.setupDefaultCitationsEffect();
this.setupCitationStylesEffect();
this.setupDestroyEffect();
this.setupCleanup();
}

setupDefaultCitationsEffect(): void {
Expand Down Expand Up @@ -210,7 +210,7 @@ export class ResourceCitationsComponent {
});
}

private setupDestroyEffect(): void {
private setupCleanup(): void {
this.destroyRef.onDestroy(() => {
this.destroy$.next();
this.destroy$.complete();
Expand Down
Loading