Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ describe('RegistryOverviewComponent', () => {
expect(component.canMakeDecision()).toBe(false);
});

it('should compute canMakeDecision as false for a rejected registration in moderator mode', () => {
const { component } = setup({
registry: { ...MOCK_REGISTRATION_OVERVIEW_MODEL, reviewsState: RegistrationReviewStates.Rejected },
queryParams: { mode: 'moderator' },
});

expect(component.canMakeDecision()).toBe(false);
});

it('should compute canUpdate as true when admin access and provider updates are allowed', () => {
const { component } = setup({
registry: MOCK_REGISTRATION_OVERVIEW_MODEL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ export class RegistryOverviewComponent implements OnInit, OnDestroy {
readonly showToolbar = computed(() => !this.registry()?.archiving && !this.registry()?.withdrawn);
readonly isInitialState = computed(() => this.registry()?.reviewsState === RegistrationReviewStates.Initial);
readonly canMakeDecision = computed(
() => !this.registry()?.archiving && !this.registry()?.withdrawn && this.isModeration()
() =>
!this.registry()?.archiving &&
!this.registry()?.withdrawn &&
this.registry()?.reviewsState !== RegistrationReviewStates.Rejected &&
this.isModeration()
);

readonly canUpdate = computed(() => this.hasAdminAccess() && this.allowUpdates());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ describe('StatusBadgeComponent', () => {
expect(component.severity()).toBe('success');
});

it('should map rejected status to label and severity', () => {
setup(RegistryStatus.Rejected);

expect(component.label()).toBe('shared.statuses.rejected');
expect(component.severity()).toBe('danger');
});

it('should not render tag when status label is empty', () => {
setup(RegistryStatus.None);

Expand Down
1 change: 1 addition & 0 deletions src/app/shared/constants/registration-statuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const RegistryStatusMap: Record<RegistryStatus, StatusInfo> = {
[RegistryStatus.InProgress]: { label: 'shared.statuses.inProgress', severity: 'info' },
[RegistryStatus.PendingModeration]: { label: 'shared.statuses.pendingModeration', severity: 'warn' },
[RegistryStatus.Withdrawn]: { label: 'shared.statuses.withdrawn', severity: 'danger' },
[RegistryStatus.Rejected]: { label: 'shared.statuses.rejected', severity: 'danger' },
[RegistryStatus.UpdatePendingApproval]: { label: 'shared.statuses.updatePendingApproval', severity: 'warn' },
[RegistryStatus.InitialApproved]: { label: 'shared.statuses.initialApproved', severity: 'warn' },
};
1 change: 1 addition & 0 deletions src/app/shared/enums/registry-status.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum RegistryStatus {
InProgress = 'inProgress',
PendingModeration = 'pendingModeration',
Withdrawn = 'withdrawn',
Rejected = 'rejected',
UpdatePendingApproval = 'updatePendingApproval',
InitialApproved = 'initialApproved',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { RegistrationReviewStates } from '@osf/shared/enums/registration-review-states.enum';
import { RegistryStatus } from '@osf/shared/enums/registry-status.enum';
import { RevisionReviewStates } from '@osf/shared/enums/revision-review-states.enum';
import { RegistrationAttributesJsonApi } from '@shared/models/registration/registration-json-api.model';

import { MapRegistryStatus } from './map-registry-status.mapper';

describe('MapRegistryStatus', () => {
function attributes(overrides: Partial<RegistrationAttributesJsonApi>): RegistrationAttributesJsonApi {
return overrides as RegistrationAttributesJsonApi;
}

it('should map a moderator-rejected registration to the rejected status', () => {
const status = MapRegistryStatus(
attributes({
reviews_state: RegistrationReviewStates.Rejected,
revision_state: 'moderator_rejected' as RevisionReviewStates,
})
);

expect(status).toBe(RegistryStatus.Rejected);
});

it('should keep mapping an accepted registration to the accepted status', () => {
const status = MapRegistryStatus(
attributes({ reviews_state: RegistrationReviewStates.Accepted, revision_state: RevisionReviewStates.Approved })
);
expect(status).toBe(RegistryStatus.Accepted);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export function MapRegistryStatus(
return RegistryStatus.PendingWithdraw;
} else if (registry.reviews_state === RegistrationReviewStates.Withdrawn) {
return RegistryStatus.Withdrawn;
} else if (registry.reviews_state === RegistrationReviewStates.Rejected) {
return RegistryStatus.Rejected;
} else if (
registry.reviews_state === RegistrationReviewStates.Initial &&
registry.revision_state === RevisionReviewStates.Approved
Expand Down
6 changes: 6 additions & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,11 @@
"short": "Pending withdraw request",
"text": "Pending withdrawal"
},
"rejected": {
"long": "This registration was not accepted by the registry moderators and is visible only to its contributors and the registry moderators. Its draft was returned to the contributors so they can make edits and resubmit.",
"short": "Rejected by moderators",
"text": "Rejected"
},
"updatePendingApproval": {
"long": "This registration has an update that is waiting for approval from its contributors. Updates will be made available once approved.",
"short": "Update pending approval",
Expand Down Expand Up @@ -2938,6 +2943,7 @@
"pendingRegistrationApproval": "Pending registration approval",
"pendingWithdraw": "Pending withdrawal",
"pendingWithdrawRequest": "Pending withdraw request",
"rejected": "Rejected",
"unapproved": "Unapproved",
"updatePendingApproval": "Update pending approval",
"withdrawn": "Withdrawn"
Expand Down
Loading