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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"start:test": "ng serve --configuration test-osf",
"start:docker": "ng serve --host 0.0.0.0 --port 4200 --poll 2000",
"start:docker:local": "ng serve --host 0.0.0.0 --port 4200 --poll 2000 --configuration local",
"test": "jest && npm run test:display",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage && npm run test:display",
"test:check-coverage-thresholds": "node .github/scripts/check-coverage-thresholds.js",
Expand Down
7 changes: 3 additions & 4 deletions src/app/core/components/root/root.component.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use "styles/mixins" as mix;
@use "styles/variables" as var;

:host {
display: flex;
Expand All @@ -10,12 +9,12 @@
.layout-desktop {
display: flex;
flex: 1;
background-color: var.$dark-blue-1;
background-color: var(--dark-blue-1);
max-width: 100vw;

.content-wrapper {
position: relative;
background-color: var.$bg-blue-3;
background-color: var(--bg-blue-3);
border-radius: mix.rem(12px);
margin: mix.rem(6px);
display: flex;
Expand All @@ -36,7 +35,7 @@
height: 100%;
flex: 1;
overflow-y: auto;
background-color: var.$bg-blue-3;
background-color: var(--bg-blue-3);

.content {
position: relative;
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/components/root/root.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { HeaderComponent } from '@core/components/header/header.component';
import { TopnavComponent } from '@core/components/topnav/topnav.component';
import { IS_WEB, IS_XSMALL } from '@osf/shared/helpers';

import { MaintenanceBannerComponent } from '../maintenance-banner/maintenance-banner.component';
import { SidenavComponent } from '../sidenav/sidenav.component';

import { RootComponent } from './root.component';
Expand All @@ -36,7 +37,8 @@ describe('RootComponent', () => {
TopnavComponent,
ConfirmDialog,
BreadcrumbComponent,
SidenavComponent
SidenavComponent,
MaintenanceBannerComponent
),
],
providers: [
Expand Down
12 changes: 7 additions & 5 deletions src/app/core/components/root/root.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { RouterOutlet } from '@angular/router';

import { MaintenanceBannerComponent, SidenavComponent } from '@core/components';
import { BreadcrumbComponent } from '@core/components/breadcrumb/breadcrumb.component';
import { FooterComponent } from '@core/components/footer/footer.component';
import { HeaderComponent } from '@core/components/header/header.component';
import { TopnavComponent } from '@core/components/topnav/topnav.component';
import { IS_MEDIUM, IS_WEB } from '@osf/shared/helpers';

import { BreadcrumbComponent } from '../breadcrumb/breadcrumb.component';
import { FooterComponent } from '../footer/footer.component';
import { HeaderComponent } from '../header/header.component';
import { MaintenanceBannerComponent } from '../maintenance-banner/maintenance-banner.component';
import { SidenavComponent } from '../sidenav/sidenav.component';
import { TopnavComponent } from '../topnav/topnav.component';

@Component({
selector: 'osf-root',
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createDispatchMap, select } from '@ngxs/store';

import { TranslateModule } from '@ngx-translate/core';
import { TranslatePipe } from '@ngx-translate/core';

import { TabsModule } from 'primeng/tabs';

Expand All @@ -17,7 +17,7 @@ import { AdminInstitutionResourceTab } from './enums';

@Component({
selector: 'osf-admin-institutions',
imports: [TabsModule, TranslateModule, RouterOutlet, NgOptimizedImage, LoadingSpinnerComponent, SelectComponent],
imports: [TabsModule, TranslatePipe, RouterOutlet, NgOptimizedImage, LoadingSpinnerComponent, SelectComponent],
templateUrl: './admin-institutions.component.html',
styleUrl: './admin-institutions.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h2 class="flex align-items-center gap-2">
<span class="font-bold">{{ 'common.labels.contributors' | translate }}:</span>
@for (contributor of duplicate.contributors; track contributor.id) {
<div>
<a [href]="contributor.id" target="_blank" class="font-bold"> {{ contributor.fullName }}</a>
<a [routerLink]="['/user', contributor.id]" class="font-bold"> {{ contributor.fullName }}</a>
<span>{{ $last ? '' : ',' }}</span>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<p>
{{ 'collections.common.by' | translate }}
@for (contributor of item?.contributors; track contributor.id) {
<a [href]="contributor.url" class="font-bold cursor-pointer">{{ contributor.name }}{{ $last ? '' : ', ' }}</a>
<a [routerLink]="['/user', contributor.id]" class="font-bold cursor-pointer">
{{ contributor.name }}{{ $last ? '' : ', ' }}
</a>
}
</p>
<p class="card-description">{{ item?.description }}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { TranslatePipe } from '@ngx-translate/core';

import { DatePipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
import { RouterLink } from '@angular/router';

import { collectionFilterNames } from '@osf/features/collections/constants';
import { CollectionSubmissionWithGuid } from '@shared/models';

@Component({
selector: 'osf-collections-search-result-card',
imports: [DatePipe, TranslatePipe],
imports: [DatePipe, TranslatePipe, RouterLink],
templateUrl: './collections-search-result-card.component.html',
styleUrl: './collections-search-result-card.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h4>{{ 'files.detail.resourceMetadata.fields.contributors' | translate }}</h4>

<div class="flex flex-wrap">
@for (contributor of contributors(); track $index) {
<a [href]="contributor.id" class="font-bold">{{ contributor.fullName }}</a>
<a [routerLink]="['/user', contributor.userId]" class="font-bold">{{ contributor.fullName }}</a>
@if (!$last) {
<span>,&nbsp;</span>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { Skeleton } from 'primeng/skeleton';

import { DatePipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { RouterLink } from '@angular/router';

import { FilesSelectors } from '../../store';

@Component({
selector: 'osf-file-resource-metadata',
imports: [DatePipe, TranslatePipe, Skeleton],
imports: [DatePipe, TranslatePipe, Skeleton, RouterLink],
templateUrl: './file-resource-metadata.component.html',
styleUrl: './file-resource-metadata.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/files/pages/files/files.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

<p-button icon="fas fa-info-circle blue-icon" severity="secondary" text (onClick)="showInfoDialog()"></p-button>

@if (!isViewOnly() && !hasViewOnly()) {
@if (!isReadonly() && !hasViewOnly()) {
<p-button
[disabled]="isButtonDisabled()"
outlined
Expand Down Expand Up @@ -129,7 +129,7 @@
[storage]="currentRootFolder()"
[isLoading]="isFilesLoading()"
[actions]="filesTreeActions"
[viewOnly]="isViewOnly()"
[viewOnly]="isReadonly()"
[viewOnlyDownloadable]="isViewOnlyDownloadable()"
[resourceId]="resourceId()"
[provider]="provider()"
Expand Down
44 changes: 23 additions & 21 deletions src/app/features/files/pages/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ import {
SetSort,
} from '@osf/features/files/store';
import { ALL_SORT_OPTIONS } from '@osf/shared/constants';
import { ResourceType } from '@osf/shared/enums';
import { ResourceType, UserPermissions } from '@osf/shared/enums';
import { hasViewOnlyParam, IS_MEDIUM } from '@osf/shared/helpers';
import { CurrentResourceSelectors, GetResourceDetails } from '@osf/shared/stores';
import {
FilesTreeComponent,
FormSelectComponent,
Expand Down Expand Up @@ -101,6 +102,8 @@ export class FilesComponent {
private readonly dialogService = inject(DialogService);
private readonly translateService = inject(TranslateService);
private readonly router = inject(Router);
private readonly dataciteService = inject(DataciteService);

private readonly actions = createDispatchMap({
createFolder: CreateFolder,
deleteEntry: DeleteEntry,
Expand All @@ -115,28 +118,26 @@ export class FilesComponent {
getConfiguredStorageAddons: GetConfiguredStorageAddons,
setCurrentProvider: SetCurrentProvider,
resetState: ResetState,
getResourceDetails: GetResourceDetails,
});

isMedium = toSignal(inject(IS_MEDIUM));

readonly hasViewOnly = computed(() => {
return hasViewOnlyParam(this.router);
});
readonly files = select(FilesSelectors.getFiles);
readonly filesTotalCount = select(FilesSelectors.getFilesTotalCount);
readonly isFilesLoading = select(FilesSelectors.isFilesLoading);
readonly currentFolder = select(FilesSelectors.getCurrentFolder);
readonly provider = select(FilesSelectors.getProvider);
readonly resourceDetails = select(CurrentResourceSelectors.getResourceDetails);
readonly rootFolders = select(FilesSelectors.getRootFolders);
readonly isRootFoldersLoading = select(FilesSelectors.isRootFoldersLoading);
readonly configuredStorageAddons = select(FilesSelectors.getConfiguredStorageAddons);
readonly isConfiguredStorageAddonsLoading = select(FilesSelectors.isConfiguredStorageAddonsLoading);

isMedium = toSignal(inject(IS_MEDIUM));

readonly isGoogleDrive = signal<boolean>(false);
readonly accountId = signal<string>('');
readonly selectedRootFolder = signal<StorageItemModel>({});
readonly resourceId = signal<string>('');
readonly rootFolders = select(FilesSelectors.getRootFolders);
readonly isRootFoldersLoading = select(FilesSelectors.isRootFoldersLoading);
readonly configuredStorageAddons = select(FilesSelectors.getConfiguredStorageAddons);
readonly isConfiguredStorageAddonsLoading = select(FilesSelectors.isConfiguredStorageAddonsLoading);
readonly dataciteService = inject(DataciteService);

readonly progress = signal(0);
readonly fileName = signal('');
Expand Down Expand Up @@ -175,13 +176,16 @@ export class FilesComponent {
this.activeRoute.parent?.parent?.snapshot.data['resourceType'] || ResourceType.Project
);

readonly isViewOnly = computed(() => {
return this.resourceType() === ResourceType.Registration;
});
readonly hasViewOnly = computed(() => hasViewOnlyParam(this.router));

readonly isViewOnlyDownloadable = computed(() => {
return this.resourceType() === ResourceType.Registration;
});
readonly isReadonly = computed(
() =>
this.resourceDetails().isRegistration ||
this.resourceDetails().currentUserPermissions.includes(UserPermissions.Read)
);
readonly isViewOnlyDownloadable = computed(() => this.resourceType() === ResourceType.Registration);

isButtonDisabled = computed(() => this.fileIsUploading() || this.isFilesLoading());

readonly filesTreeActions: FilesTreeActions = {
setCurrentFolder: (folder) => this.actions.setCurrentFolder(folder),
Expand All @@ -206,6 +210,8 @@ export class FilesComponent {
const resourcePath = this.urlMap.get(this.resourceType()!);
const folderLink = `${environment.apiDomainUrl}/v2/${resourcePath}/${resourceId}/files/`;
const iriLink = `${environment.webUrl}/${resourceId}`;

this.actions.getResourceDetails(resourceId, this.resourceType()!);
this.actions.getRootFolders(folderLink);
this.actions.getConfiguredStorageAddons(iriLink);
});
Expand Down Expand Up @@ -265,10 +271,6 @@ export class FilesComponent {
});
}

isButtonDisabled(): boolean {
return this.fileIsUploading() || this.isFilesLoading();
}

uploadFile(file: File): void {
const currentFolder = this.currentFolder();
const uploadLink = currentFolder?.links.upload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ <h3>{{ 'preprints.preprintStepper.review.sections.metadata.authors' | translate
@if (contributor.isUnregisteredContributor) {
<span>{{ contributor.fullName }}</span>
} @else {
<a
class="font-bold"
[href]="`${webUrl}/${contributor.userId}`"
target="_blank"
rel="noopener noreferrer"
>
<a class="font-bold" [routerLink]="['/user', contributor.userId]">
{{ contributor.fullName }}
</a>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Skeleton } from 'primeng/skeleton';

import { ChangeDetectionStrategy, Component, computed, effect, input, OnDestroy, output } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterLink } from '@angular/router';

import { PreprintDoiSectionComponent } from '@osf/features/preprints/components/preprint-details/preprint-doi-section/preprint-doi-section.component';
import { ApplicabilityStatus, PreregLinkInfo } from '@osf/features/preprints/enums';
Expand All @@ -30,6 +31,7 @@ import { environment } from 'src/environments/environment';
PreprintDoiSectionComponent,
IconComponent,
AffiliatedInstitutionsViewComponent,
RouterLink,
],
templateUrl: './general-information.component.html',
styleUrl: './general-information.component.scss',
Expand All @@ -45,7 +47,6 @@ export class GeneralInformationComponent implements OnDestroy {
fetchPreprintById: FetchPreprintById,
fetchResourceInstitutions: FetchResourceInstitutions,
});
readonly webUrl = environment.webUrl;

preprintProvider = input.required<PreprintProviderDetails | undefined>();
preprintVersionSelected = output<string>();
Expand All @@ -57,15 +58,11 @@ export class GeneralInformationComponent implements OnDestroy {

contributors = select(ContributorsSelectors.getContributors);
areContributorsLoading = select(ContributorsSelectors.isContributorsLoading);
bibliographicContributors = computed(() => {
return this.contributors().filter((contributor) => contributor.isBibliographic);
});
bibliographicContributors = computed(() => this.contributors().filter((contributor) => contributor.isBibliographic));

skeletonData = Array.from({ length: 5 }, () => null);

nodeLink = computed(() => {
return `${environment.webUrl}/${this.preprint()?.nodeId}`;
});
nodeLink = computed(() => `${environment.webUrl}/${this.preprint()?.nodeId}`);

constructor() {
effect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ export class ModerationStatusBannerComponent {
latestWithdrawalRequest = input.required<PreprintRequest | null>();

isPendingWithdrawal = input.required<boolean>();
noActions = computed(() => {
return this.latestAction() === null;
});

noActions = computed(() => this.latestAction() === null);

documentType = computed(() => {
const provider = this.provider();
Expand Down Expand Up @@ -106,20 +105,9 @@ export class ModerationStatusBannerComponent {
return recentActivityMessageByState[ReviewsState.PendingWithdrawal];
});

actionCreatorName = computed(() => {
return this.latestAction()?.creator.name;
});
actionCreatorLink = computed(() => {
return `${environment.webUrl}/${this.actionCreatorId()}`;
});
actionCreatorId = computed(() => {
return this.latestAction()?.creator.id;
});

withdrawalRequesterName = computed(() => {
return this.latestWithdrawalRequest()?.creator.name;
});
withdrawalRequesterId = computed(() => {
return this.latestWithdrawalRequest()?.creator.id;
});
actionCreatorName = computed(() => this.latestAction()?.creator.name);
actionCreatorLink = computed(() => `${environment.webUrl}/${this.actionCreatorId()}`);
actionCreatorId = computed(() => this.latestAction()?.creator.id);
withdrawalRequesterName = computed(() => this.latestWithdrawalRequest()?.creator.name);
withdrawalRequesterId = computed(() => this.latestWithdrawalRequest()?.creator.id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h3>{{ 'preprints.preprintStepper.review.sections.metadata.authors' | translate
<div class="flex flex-column gap-1 line-height-2 md:flex-row">
@for (contributor of bibliographicContributors(); track contributor.id) {
<div>
<a class="font-bold"> {{ contributor.fullName }}</a>
<a [routerLink]="['/user', contributor.userId]" class="font-bold"> {{ contributor.fullName }}</a>
<span>{{ $last ? '' : ',' }}</span>
</div>
}
Expand Down
Loading
Loading