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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<osf-component-checkbox-item
[item]="item"
[tooltipText]="'myProjects.settings.parentsNeedToBeChecked'"
(checkboxChange)="onCheckboxChange(item)"
(itemChange)="onCheckboxChange(item)"
/>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[iconClass]="reviewStatusIcon[submission().reviewsState].icon"
></osf-icon>

<p-button class="link-btn-no-padding" link (click)="handleNavigation()" [label]="submission().title" />
<p-button class="link-btn-no-padding" link (onClick)="handleNavigation()" [label]="submission().title" />
</div>

<p class="flex flex-wrap gap-1 mt-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,6 @@ describe('CollectionSubmissionItemComponent', () => {
expect(attributes!.length).toBeGreaterThan(0);
});

it('should handle navigation correctly', () => {
fixture.componentRef.setInput('submission', mockSubmission);
fixture.detectChanges();

component.handleNavigation();

expect(mockRouter.navigate).toHaveBeenCalledWith(['../', mockSubmission.nodeId], {
relativeTo: expect.any(Object),
queryParams: { status: 'pending', mode: 'moderation' },
});
});

it('should have SubmissionReviewStatus enum available', () => {
expect(component.SubmissionReviewStatus).toBe(SubmissionReviewStatus);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class CollectionSubmissionItemComponent {
collectionProvider = select(CollectionsSelectors.getCollectionProvider);

readonly reviewStatusIcon = ReviewStatusIcon;
readonly SubmissionReviewStatus = SubmissionReviewStatus;

currentReviewAction = computed(() => {
const actions = this.submission().actions;
Expand All @@ -57,11 +58,13 @@ export class CollectionSubmissionItemComponent {
const currentStatus = this.activatedRoute.snapshot.queryParams['status'];
const queryParams = currentStatus ? { status: currentStatus, mode: 'moderation' } : {};

this.router.navigate(['../', this.submission().nodeId], {
relativeTo: this.activatedRoute,
queryParams,
});
}
const url = this.router.serializeUrl(
this.router.createUrlTree(['../', this.submission().nodeId], {
relativeTo: this.activatedRoute,
queryParams,
})
);

readonly SubmissionReviewStatus = SubmissionReviewStatus;
window.open(url, '_blank');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,6 @@ describe('PreprintSubmissionsComponent', () => {
expect(component.first()).toBe(0);
});

it('should navigate to preprint', () => {
const mockItem = mockSubmissions[0];
component.navigateToPreprint(mockItem);
expect(mockRouter.navigate).toHaveBeenCalledWith(['/preprints/', mockProviderId, mockItem.id], {
queryParams: { mode: 'moderator' },
});
});

it('should get status from query params on init', () => {
expect(component.selectedReviewOption()).toBe(SubmissionReviewStatus.Pending);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ export class PreprintSubmissionsComponent implements OnInit {
}

navigateToPreprint(item: PreprintSubmission) {
this.router.navigate(['/preprints/', this.providerId(), item.id], { queryParams: { mode: 'moderator' } });
const url = this.router.serializeUrl(
this.router.createUrlTree(['/preprints/', this.providerId(), item.id], { queryParams: { mode: 'moderator' } })
);

window.open(url, '_blank');
}

private getStatusFromQueryParams() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ <h4>{{ submission().title }}</h4>
link
styleClass="text-left"
[label]="submission().title"
[routerLink]="['/', submission().id, 'overview']"
[queryParams]="{
mode: 'moderator',
revisionId: isPendingModeration && !isPending ? submission().revisionId : null,
}"
(onClick)="selected.emit()"
/>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ describe('RegistrySubmissionItemComponent', () => {
expect(component.showAll).toBe(false);
});

it('should compute isPendingModeration correctly', () => {
expect(component.isPendingModeration).toBe(true);
});

it('should compute isPending correctly', () => {
expect(component.isPending).toBe(true);
});

it('should accept custom input values', () => {
const customStatus = SubmissionReviewStatus.Accepted;
const customSubmission = { ...mockSubmission, title: 'Custom Registry Submission' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { TranslatePipe } from '@ngx-translate/core';
import { Button } from 'primeng/button';

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

import { IconComponent } from '@osf/shared/components';
import { RegistrationReviewStates, RevisionReviewStates } from '@osf/shared/enums';
import { DateAgoPipe } from '@osf/shared/pipes';

import { REGISTRY_ACTION_LABEL, ReviewStatusIcon } from '../../constants';
Expand All @@ -16,7 +14,7 @@ import { RegistryModeration } from '../../models';

@Component({
selector: 'osf-registry-submission-item',
imports: [IconComponent, DateAgoPipe, Button, TranslatePipe, RouterLink, DatePipe],
imports: [IconComponent, DateAgoPipe, Button, TranslatePipe, DatePipe],
templateUrl: './registry-submission-item.component.html',
styleUrl: './registry-submission-item.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -25,24 +23,15 @@ export class RegistrySubmissionItemComponent {
status = input.required<SubmissionReviewStatus>();
submission = input.required<RegistryModeration>();

selected = output<void>();

readonly reviewStatusIcon = ReviewStatusIcon;
readonly registryActionLabel = REGISTRY_ACTION_LABEL;
readonly registryActionState = ActionStatus;

limitValue = 1;
showAll = false;

get isPendingModeration(): boolean {
return this.submission().revisionStatus === RevisionReviewStates.RevisionPendingModeration;
}

get isPending(): boolean {
return (
this.submission().reviewsState === RegistrationReviewStates.Pending ||
this.submission().reviewsState === RegistrationReviewStates.PendingWithdraw
);
}

get isRejected(): boolean {
return this.status() === SubmissionReviewStatus.Rejected;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<osf-registry-submission-item
[submission]="item"
[status]="selectedReviewOption()"
(selected)="navigateToRegistration(item)"
></osf-registry-submission-item>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import {
LoadingSpinnerComponent,
SelectComponent,
} from '@osf/shared/components';
import { RegistrationReviewStates, RevisionReviewStates } from '@osf/shared/enums';
import { Primitive } from '@osf/shared/helpers';

import { REGISTRY_SORT_OPTIONS, SUBMITTED_SUBMISSION_REVIEW_OPTIONS } from '../../constants';
import { RegistrySort, SubmissionReviewStatus } from '../../enums';
import { RegistryModeration } from '../../models';
import { GetRegistrySubmissions, RegistryModerationSelectors } from '../../store/registry-moderation';
import { RegistrySubmissionItemComponent } from '..';

Expand Down Expand Up @@ -93,6 +95,24 @@ export class RegistrySubmissionsComponent implements OnInit {
this.fetchSubmissions();
}

navigateToRegistration(item: RegistryModeration) {
const isPendingModeration = item.revisionStatus === RevisionReviewStates.RevisionPendingModeration;
const isPending =
item.reviewsState === RegistrationReviewStates.Pending ||
item.reviewsState === RegistrationReviewStates.PendingWithdraw;

const url = this.router.serializeUrl(
this.router.createUrlTree(['/', item.id, 'overview'], {
queryParams: {
mode: 'moderator',
revisionId: isPendingModeration && !isPending ? item.revisionId : null,
},
})
);

window.open(url, '_blank');
}

private getStatusFromQueryParams() {
const queryParams = this.route.snapshot.queryParams;
const statusValues = Object.values(SubmissionReviewStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('TokenAddEditFormComponent', () => {

component.handleSubmitForm();

expect(showDialogSpy).toHaveBeenCalledWith(MOCK_TOKEN.name, MOCK_TOKEN.id);
expect(showDialogSpy).toHaveBeenCalledWith(MOCK_TOKEN.name, MOCK_TOKEN.tokenId);
});

it('should show success toast and navigate after updating token', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
variant="filled"
binary="true"
[inputId]="item().id"
[ngModel]="item().checked"
[(ngModel)]="item().checked"
(ngModelChange)="onCheckboxChange($event)"
[disabled]="item().disabled"
></p-checkbox>
Expand Down
1 change: 1 addition & 0 deletions src/testing/mocks/token.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { TokenModel } from '@osf/features/settings/tokens/models';
export const MOCK_TOKEN: TokenModel = {
id: '1',
name: 'Test Token',
tokenId: 'abcd1234efgh5678',
scopes: ['read', 'write'],
};
Loading