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
13 changes: 7 additions & 6 deletions src/app/features/preprints/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ export { AdditionalInfoComponent } from './preprint-details/additional-info/addi
export { GeneralInformationComponent } from './preprint-details/general-information/general-information.component';
export { ModerationStatusBannerComponent } from './preprint-details/moderation-status-banner/moderation-status-banner.component';
export { PreprintFileSectionComponent } from './preprint-details/preprint-file-section/preprint-file-section.component';
export { PreprintMakeDecisionComponent } from './preprint-details/preprint-make-decision/preprint-make-decision.component';
export { PreprintTombstoneComponent } from './preprint-details/preprint-tombstone/preprint-tombstone.component';
export { PreprintWarningBannerComponent } from './preprint-details/preprint-warning-banner/preprint-warning-banner.component';
export { ShareAndDownloadComponent } from './preprint-details/share-and-download/share-and-download.component';
export { StatusBannerComponent } from './preprint-details/status-banner/status-banner.component';
export { WithdrawDialogComponent } from './preprint-details/withdraw-dialog/withdraw-dialog.component';
export { PreprintProviderFooterComponent } from './preprint-provider-footer/preprint-provider-footer.component';
export { PreprintProviderHeroComponent } from './preprint-provider-hero/preprint-provider-hero.component';
export { PreprintServicesComponent } from './preprint-services/preprint-services.component';
export { PreprintsHelpDialogComponent } from './preprints-help-dialog/preprints-help-dialog.component';
export { AuthorAssertionsStepComponent } from './stepper/author-assertion-step/author-assertions-step.component';
export { FileStepComponent } from './stepper/file-step/file-step.component';
export { PreprintsMetadataStepComponent } from './stepper/preprints-metadata-step/preprints-metadata-step.component';
export { ReviewStepComponent } from './stepper/review-step/review-step.component';
export { SupplementsStepComponent } from './stepper/supplements-step/supplements-step.component';
export { MakeDecisionComponent } from '@osf/features/preprints/components/preprint-details/make-decision/make-decision.component';
export { PreprintTombstoneComponent } from '@osf/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component';
export { WithdrawDialogComponent } from '@osf/features/preprints/components/preprint-details/withdraw-dialog/withdraw-dialog.component';
export { FileStepComponent } from '@osf/features/preprints/components/stepper/file-step/file-step.component';
export { ReviewStepComponent } from '@osf/features/preprints/components/stepper/review-step/review-step.component';
export { TitleAndAbstractStepComponent } from '@osf/features/preprints/components/stepper/title-and-abstract-step/title-and-abstract-step.component';
export { TitleAndAbstractStepComponent } from './stepper/title-and-abstract-step/title-and-abstract-step.component';
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ <h4 class="line-height-3">{{ 'preprints.details.decision.decline.label' | transl
class="w-full"
[rows]="4"
[(ngModel)]="requestDecisionJustification"
[maxlength]="decisionCommentLimit"
></textarea>

@if (didValidate() && decision() === ReviewsState.Rejected) {
Expand Down Expand Up @@ -116,6 +117,7 @@ <h4 class="line-height-3">{{ rejectOptionLabel() | translate }}</h4>
[placeholder]="'preprints.details.decision.commentPlaceholder' | translate"
[rows]="4"
[(ngModel)]="reviewerComment"
[maxlength]="decisionCommentLimit"
></textarea>
@if (commentExceedsLimit()) {
<p-message class="simple-variant flex mt-1" severity="error" variant="simple" size="small">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ProviderReviewsWorkflow, ReviewsState } from '@osf/features/preprints/e
import { PreprintProviderDetails, PreprintRequest } from '@osf/features/preprints/models';
import { PreprintSelectors } from '@osf/features/preprints/store/preprint';

import { MakeDecisionComponent } from './make-decision.component';
import { PreprintMakeDecisionComponent } from './preprint-make-decision.component';

import { PREPRINT_MOCK } from '@testing/mocks/preprint.mock';
import { PREPRINT_PROVIDER_DETAILS_MOCK } from '@testing/mocks/preprint-provider-details';
Expand All @@ -14,9 +14,9 @@ import { REVIEW_ACTION_MOCK } from '@testing/mocks/review-action.mock';
import { OSFTestingModule } from '@testing/osf.testing.module';
import { provideMockStore } from '@testing/providers/store-provider.mock';

describe('MakeDecisionComponent', () => {
let component: MakeDecisionComponent;
let fixture: ComponentFixture<MakeDecisionComponent>;
describe('PreprintMakeDecisionComponent', () => {
let component: PreprintMakeDecisionComponent;
let fixture: ComponentFixture<PreprintMakeDecisionComponent>;

const mockPreprint = PREPRINT_MOCK;
const mockProvider: PreprintProviderDetails = PREPRINT_PROVIDER_DETAILS_MOCK;
Expand All @@ -25,7 +25,7 @@ describe('MakeDecisionComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MakeDecisionComponent, OSFTestingModule],
imports: [PreprintMakeDecisionComponent, OSFTestingModule],
providers: [
provideMockStore({
signals: [
Expand All @@ -38,7 +38,7 @@ describe('MakeDecisionComponent', () => {
],
}).compileComponents();

fixture = TestBed.createComponent(MakeDecisionComponent);
fixture = TestBed.createComponent(PreprintMakeDecisionComponent);
component = fixture.componentInstance;

fixture.componentRef.setInput('provider', mockProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ import {
SubmitRequestsDecision,
SubmitReviewsDecision,
} from '@osf/features/preprints/store/preprint';
import { StringOrNull } from '@shared/helpers';
import { InputLimits } from '@osf/shared/constants';
import { StringOrNull } from '@osf/shared/helpers';

@Component({
selector: 'osf-make-decision',
selector: 'osf-preprint-make-decision',
imports: [Button, TranslatePipe, TitleCasePipe, Dialog, Tooltip, RadioButton, FormsModule, Textarea, Message],
templateUrl: './make-decision.component.html',
styleUrl: './make-decision.component.scss',
templateUrl: './preprint-make-decision.component.html',
styleUrl: './preprint-make-decision.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MakeDecisionComponent {
export class PreprintMakeDecisionComponent {
private readonly translateService = inject(TranslateService);
private readonly router = inject(Router);
private readonly actions = createDispatchMap({
Expand All @@ -55,6 +56,7 @@ export class MakeDecisionComponent {
reviewerComment = signal<StringOrNull>(null);
requestDecisionJustification = signal<StringOrNull>(null);
saving = signal<boolean>(false);
decisionCommentLimit = InputLimits.decisionComment.maxLength;

labelDecisionButton = computed(() => {
const preprint = this.preprint()!;
Expand Down Expand Up @@ -102,9 +104,9 @@ export class MakeDecisionComponent {
return 'preprints.details.decision.submitButton.modifyDecision';
});

submitButtonDisabled = computed(() => {
return (!this.decisionChanged() && !this.commentEdited()) || this.commentExceedsLimit();
});
submitButtonDisabled = computed(
() => (!this.decisionChanged() && !this.commentEdited()) || this.commentExceedsLimit()
);

acceptOptionExplanation = computed(() => {
const reviewsWorkflow = this.provider().reviewsWorkflow;
Expand Down Expand Up @@ -146,9 +148,9 @@ export class MakeDecisionComponent {
}
});

rejectRadioButtonValue = computed(() => {
return this.preprint()?.isPublished ? ReviewsState.Withdrawn : ReviewsState.Rejected;
});
rejectRadioButtonValue = computed(() =>
this.preprint()?.isPublished ? ReviewsState.Withdrawn : ReviewsState.Rejected
);

settingsComments = computed(() => {
const commentType = this.provider().reviewsCommentsPrivate ? 'private' : 'public';
Expand All @@ -160,28 +162,25 @@ export class MakeDecisionComponent {
return decisionSettings.names[commentType];
});

settingsModeration = computed(() => {
return decisionSettings.moderation[this.provider().reviewsWorkflow || ProviderReviewsWorkflow.PreModeration];
});
settingsModeration = computed(
() => decisionSettings.moderation[this.provider().reviewsWorkflow || ProviderReviewsWorkflow.PreModeration]
);

commentEdited = computed(() => {
return this.reviewerComment()?.trim() !== this.initialReviewerComment();
});
commentEdited = computed(() => this.reviewerComment()?.trim() !== this.initialReviewerComment());

commentExceedsLimit = computed(() => {
const comment = this.reviewerComment();
if (!comment) return false;

return comment.length > formInputLimits.decisionComment.maxLength;
return comment.length > this.decisionCommentLimit;
});

commentLengthErrorMessage = computed(() => {
const limit = formInputLimits.decisionComment.maxLength;
return this.translateService.instant('preprints.details.decision.commentLengthError', {
limit,
commentLengthErrorMessage = computed(() =>
this.translateService.instant('preprints.details.decision.commentLengthError', {
limit: this.decisionCommentLimit,
length: this.reviewerComment()!.length,
});
});
})
);

requestDecisionJustificationErrorMessage = computed(() => {
const justification = this.requestDecisionJustification();
Expand All @@ -196,9 +195,7 @@ export class MakeDecisionComponent {
return null;
});

decisionChanged = computed(() => {
return this.preprint()?.reviewsState !== this.decision();
});
decisionChanged = computed(() => this.preprint()?.reviewsState !== this.decision());

constructor() {
effect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PreprintSteps } from '@osf/features/preprints/enums';
import { StepOption } from '@shared/models';
import { StepOption } from '@osf/shared/models';

import { PreprintSteps } from '../enums';

export const createNewVersionStepsConst: StepOption[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export const formInputLimits = {
withdrawalJustification: {
minLength: 25,
},
decisionComment: {
maxLength: 10000,
},
requestDecisionJustification: {
minLength: 20,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProviderReviewsWorkflow } from '@osf/features/preprints/enums';
import { ProviderReviewsWorkflow } from '../enums';

export const decisionSettings = {
comments: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PreregLinkInfo } from '@osf/features/preprints/enums';
import { SelectOption } from '@shared/models';
import { SelectOption } from '@osf/shared/models';

import { PreregLinkInfo } from '../enums';

export const preregLinksOptions: SelectOption[] = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProviderReviewsWorkflow, ReviewsState } from '@osf/features/preprints/enums';
import { ProviderReviewsWorkflow, ReviewsState } from '../enums';

export type StatusSeverity = 'warn' | 'secondary' | 'success' | 'error';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PreprintSteps } from '@osf/features/preprints/enums';
import { StepOption } from '@shared/models';
import { StepOption } from '@osf/shared/models';

import { PreprintSteps } from '../enums';

export const submitPreprintSteps: StepOption[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1>{{ preprint()?.title }}</h1>
) {
<p-skeleton width="10rem" height="2.25rem" />
} @else {
<osf-make-decision
<osf-preprint-make-decision
[provider]="preprintProvider()!"
[isPendingWithdrawal]="isPendingWithdrawal()"
[latestAction]="latestAction()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute, Router } from '@angular/router';

import { UserSelectors } from '@core/store/user';
import { UserPermissions } from '@osf/shared/enums';
import { CustomDialogService, MetaTagsService } from '@osf/shared/services';
import { DataciteService } from '@osf/shared/services/datacite/datacite.service';
import { ContributorsSelectors } from '@osf/shared/stores';

import {
MakeDecisionComponent,
AdditionalInfoComponent,
GeneralInformationComponent,
ModerationStatusBannerComponent,
PreprintFileSectionComponent,
PreprintMakeDecisionComponent,
PreprintTombstoneComponent,
PreprintWarningBannerComponent,
ShareAndDownloadComponent,
StatusBannerComponent,
} from '@osf/features/preprints/components';
import { AdditionalInfoComponent } from '@osf/features/preprints/components/preprint-details/additional-info/additional-info.component';
import { GeneralInformationComponent } from '@osf/features/preprints/components/preprint-details/general-information/general-information.component';
import { PreprintFileSectionComponent } from '@osf/features/preprints/components/preprint-details/preprint-file-section/preprint-file-section.component';
import { PreprintWarningBannerComponent } from '@osf/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component';
import { ShareAndDownloadComponent } from '@osf/features/preprints/components/preprint-details/share-and-download/share-and-download.component';
import { ReviewsState } from '@osf/features/preprints/enums';
import { PreprintSelectors } from '@osf/features/preprints/store/preprint';
import { PreprintProvidersSelectors } from '@osf/features/preprints/store/preprint-providers';
import { UserPermissions } from '@shared/enums';
import { CustomDialogService, MetaTagsService } from '@shared/services';
import { DataciteService } from '@shared/services/datacite/datacite.service';
import { ContributorsSelectors } from '@shared/stores';
} from '../../components';
import { ReviewsState } from '../../enums';
import { PreprintSelectors } from '../../store/preprint';
import { PreprintProvidersSelectors } from '../../store/preprint-providers';

import { PreprintDetailsComponent } from './preprint-details.component';

Expand Down Expand Up @@ -91,7 +92,7 @@ describe('PreprintDetailsComponent', () => {
PreprintTombstoneComponent,
PreprintWarningBannerComponent,
ModerationStatusBannerComponent,
MakeDecisionComponent
PreprintMakeDecisionComponent
),
],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import { UserSelectors } from '@core/store/user';
import {
AdditionalInfoComponent,
GeneralInformationComponent,
MakeDecisionComponent,
ModerationStatusBannerComponent,
PreprintFileSectionComponent,
PreprintMakeDecisionComponent,
PreprintTombstoneComponent,
ShareAndDownloadComponent,
StatusBannerComponent,
Expand Down Expand Up @@ -72,7 +72,7 @@ import { PreprintWarningBannerComponent } from '../../components/preprint-detail
PreprintTombstoneComponent,
PreprintWarningBannerComponent,
ModerationStatusBannerComponent,
MakeDecisionComponent,
PreprintMakeDecisionComponent,
RouterLink,
],
templateUrl: './preprint-details.component.html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
[formControlName]="ModerationDecisionFormControls.Comment"
[placeholder]="'moderation.makeDecision.remarksPlaceholder' | translate"
[rows]="6"
[maxlength]="decisionCommentLimit"
class="w-full mt-3"
></textarea>
</div>
Expand All @@ -94,6 +95,7 @@
[formControlName]="ModerationDecisionFormControls.Comment"
[placeholder]="'moderation.makeDecision.justificationPlaceholder' | translate"
[rows]="6"
[maxlength]="decisionCommentLimit"
class="w-full mt-3"
></textarea>
@if (isCommentInvalid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';

import { SubmissionReviewStatus } from '@osf/features/moderation/enums';
import { INPUT_VALIDATION_MESSAGES } from '@osf/shared/constants';
import { INPUT_VALIDATION_MESSAGES, InputLimits } from '@osf/shared/constants';
import {
ModerationDecisionFormControls,
RegistrationReviewStates,
Expand Down Expand Up @@ -68,6 +68,7 @@ export class RegistryMakeDecisionComponent {
RevisionReviewStates = RevisionReviewStates;
RegistrationReviewStates = RegistrationReviewStates;

decisionCommentLimit = InputLimits.decisionComment.maxLength;
readonly INPUT_VALIDATION_MESSAGES = INPUT_VALIDATION_MESSAGES;

get isPendingModeration(): boolean {
Expand Down Expand Up @@ -165,7 +166,7 @@ export class RegistryMakeDecisionComponent {
private initForm(): void {
this.requestForm = this.fb.group({
[ModerationDecisionFormControls.Action]: new FormControl('', [Validators.required]),
[ModerationDecisionFormControls.Comment]: new FormControl(''),
[ModerationDecisionFormControls.Comment]: new FormControl('', [Validators.maxLength(this.decisionCommentLimit)]),
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
[formControlName]="ModerationDecisionFormControls.Comment"
[placeholder]="'moderation.makeDecision.remarksPlaceholder' | translate"
[rows]="6"
[maxlength]="decisionCommentLimit"
class="w-full mt-3"
></textarea>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CollectionsModerationSelectors,
CreateCollectionSubmissionAction,
} from '@osf/features/moderation/store/collections-moderation';
import { InputLimits } from '@osf/shared/constants';
import { ModerationDecisionFormControls, ModerationSubmitType } from '@osf/shared/enums';
import { DateAgoPipe } from '@osf/shared/pipes';
import { CollectionsSelectors } from '@osf/shared/stores';
Expand All @@ -39,6 +40,8 @@ export class MakeDecisionDialogComponent implements OnInit {
isSubmitting = select(CollectionsModerationSelectors.getCollectionSubmissionSubmitting);
requestForm!: FormGroup;

decisionCommentLimit = InputLimits.decisionComment.maxLength;

actions = createDispatchMap({
createSubmissionAction: CreateCollectionSubmissionAction,
});
Expand Down Expand Up @@ -98,7 +101,7 @@ export class MakeDecisionDialogComponent implements OnInit {
private initForm(): void {
this.requestForm = this.fb.group({
[ModerationDecisionFormControls.Action]: new FormControl('', [Validators.required]),
[ModerationDecisionFormControls.Comment]: new FormControl(''),
[ModerationDecisionFormControls.Comment]: new FormControl('', [Validators.maxLength(this.decisionCommentLimit)]),
});
}
}
Loading
Loading