Skip to content

Commit 1775dba

Browse files
nsemetsNazar690
andauthored
[ANG-1089] Fix/moderation limit (#667)
* fix(make-decision): added limit for make decision comment * fix(make-decision): updated make decision dialogs --------- Co-authored-by: Nazar Semets <nazar690@gmail.com>
1 parent b9a0802 commit 1775dba

20 files changed

+83
-72
lines changed

src/app/features/preprints/components/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ export { AdditionalInfoComponent } from './preprint-details/additional-info/addi
44
export { GeneralInformationComponent } from './preprint-details/general-information/general-information.component';
55
export { ModerationStatusBannerComponent } from './preprint-details/moderation-status-banner/moderation-status-banner.component';
66
export { PreprintFileSectionComponent } from './preprint-details/preprint-file-section/preprint-file-section.component';
7+
export { PreprintMakeDecisionComponent } from './preprint-details/preprint-make-decision/preprint-make-decision.component';
8+
export { PreprintTombstoneComponent } from './preprint-details/preprint-tombstone/preprint-tombstone.component';
9+
export { PreprintWarningBannerComponent } from './preprint-details/preprint-warning-banner/preprint-warning-banner.component';
710
export { ShareAndDownloadComponent } from './preprint-details/share-and-download/share-and-download.component';
811
export { StatusBannerComponent } from './preprint-details/status-banner/status-banner.component';
12+
export { WithdrawDialogComponent } from './preprint-details/withdraw-dialog/withdraw-dialog.component';
913
export { PreprintProviderFooterComponent } from './preprint-provider-footer/preprint-provider-footer.component';
1014
export { PreprintProviderHeroComponent } from './preprint-provider-hero/preprint-provider-hero.component';
1115
export { PreprintServicesComponent } from './preprint-services/preprint-services.component';
1216
export { PreprintsHelpDialogComponent } from './preprints-help-dialog/preprints-help-dialog.component';
1317
export { AuthorAssertionsStepComponent } from './stepper/author-assertion-step/author-assertions-step.component';
18+
export { FileStepComponent } from './stepper/file-step/file-step.component';
1419
export { PreprintsMetadataStepComponent } from './stepper/preprints-metadata-step/preprints-metadata-step.component';
20+
export { ReviewStepComponent } from './stepper/review-step/review-step.component';
1521
export { SupplementsStepComponent } from './stepper/supplements-step/supplements-step.component';
16-
export { MakeDecisionComponent } from '@osf/features/preprints/components/preprint-details/make-decision/make-decision.component';
17-
export { PreprintTombstoneComponent } from '@osf/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component';
18-
export { WithdrawDialogComponent } from '@osf/features/preprints/components/preprint-details/withdraw-dialog/withdraw-dialog.component';
19-
export { FileStepComponent } from '@osf/features/preprints/components/stepper/file-step/file-step.component';
20-
export { ReviewStepComponent } from '@osf/features/preprints/components/stepper/review-step/review-step.component';
21-
export { TitleAndAbstractStepComponent } from '@osf/features/preprints/components/stepper/title-and-abstract-step/title-and-abstract-step.component';
22+
export { TitleAndAbstractStepComponent } from './stepper/title-and-abstract-step/title-and-abstract-step.component';

src/app/features/preprints/components/preprint-details/make-decision/make-decision.component.html renamed to src/app/features/preprints/components/preprint-details/preprint-make-decision/preprint-make-decision.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ <h4 class="line-height-3">{{ 'preprints.details.decision.decline.label' | transl
5656
class="w-full"
5757
[rows]="4"
5858
[(ngModel)]="requestDecisionJustification"
59+
[maxlength]="decisionCommentLimit"
5960
></textarea>
6061

6162
@if (didValidate() && decision() === ReviewsState.Rejected) {
@@ -116,6 +117,7 @@ <h4 class="line-height-3">{{ rejectOptionLabel() | translate }}</h4>
116117
[placeholder]="'preprints.details.decision.commentPlaceholder' | translate"
117118
[rows]="4"
118119
[(ngModel)]="reviewerComment"
120+
[maxlength]="decisionCommentLimit"
119121
></textarea>
120122
@if (commentExceedsLimit()) {
121123
<p-message class="simple-variant flex mt-1" severity="error" variant="simple" size="small">

src/app/features/preprints/components/preprint-details/make-decision/make-decision.component.spec.ts renamed to src/app/features/preprints/components/preprint-details/preprint-make-decision/preprint-make-decision.component.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ProviderReviewsWorkflow, ReviewsState } from '@osf/features/preprints/e
55
import { PreprintProviderDetails, PreprintRequest } from '@osf/features/preprints/models';
66
import { PreprintSelectors } from '@osf/features/preprints/store/preprint';
77

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

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

17-
describe('MakeDecisionComponent', () => {
18-
let component: MakeDecisionComponent;
19-
let fixture: ComponentFixture<MakeDecisionComponent>;
17+
describe('PreprintMakeDecisionComponent', () => {
18+
let component: PreprintMakeDecisionComponent;
19+
let fixture: ComponentFixture<PreprintMakeDecisionComponent>;
2020

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

2626
beforeEach(async () => {
2727
await TestBed.configureTestingModule({
28-
imports: [MakeDecisionComponent, OSFTestingModule],
28+
imports: [PreprintMakeDecisionComponent, OSFTestingModule],
2929
providers: [
3030
provideMockStore({
3131
signals: [
@@ -38,7 +38,7 @@ describe('MakeDecisionComponent', () => {
3838
],
3939
}).compileComponents();
4040

41-
fixture = TestBed.createComponent(MakeDecisionComponent);
41+
fixture = TestBed.createComponent(PreprintMakeDecisionComponent);
4242
component = fixture.componentInstance;
4343

4444
fixture.componentRef.setInput('provider', mockProvider);

src/app/features/preprints/components/preprint-details/make-decision/make-decision.component.ts renamed to src/app/features/preprints/components/preprint-details/preprint-make-decision/preprint-make-decision.component.ts

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ import {
2323
SubmitRequestsDecision,
2424
SubmitReviewsDecision,
2525
} from '@osf/features/preprints/store/preprint';
26-
import { StringOrNull } from '@shared/helpers';
26+
import { InputLimits } from '@osf/shared/constants';
27+
import { StringOrNull } from '@osf/shared/helpers';
2728

2829
@Component({
29-
selector: 'osf-make-decision',
30+
selector: 'osf-preprint-make-decision',
3031
imports: [Button, TranslatePipe, TitleCasePipe, Dialog, Tooltip, RadioButton, FormsModule, Textarea, Message],
31-
templateUrl: './make-decision.component.html',
32-
styleUrl: './make-decision.component.scss',
32+
templateUrl: './preprint-make-decision.component.html',
33+
styleUrl: './preprint-make-decision.component.scss',
3334
changeDetection: ChangeDetectionStrategy.OnPush,
3435
})
35-
export class MakeDecisionComponent {
36+
export class PreprintMakeDecisionComponent {
3637
private readonly translateService = inject(TranslateService);
3738
private readonly router = inject(Router);
3839
private readonly actions = createDispatchMap({
@@ -55,6 +56,7 @@ export class MakeDecisionComponent {
5556
reviewerComment = signal<StringOrNull>(null);
5657
requestDecisionJustification = signal<StringOrNull>(null);
5758
saving = signal<boolean>(false);
59+
decisionCommentLimit = InputLimits.decisionComment.maxLength;
5860

5961
labelDecisionButton = computed(() => {
6062
const preprint = this.preprint()!;
@@ -102,9 +104,9 @@ export class MakeDecisionComponent {
102104
return 'preprints.details.decision.submitButton.modifyDecision';
103105
});
104106

105-
submitButtonDisabled = computed(() => {
106-
return (!this.decisionChanged() && !this.commentEdited()) || this.commentExceedsLimit();
107-
});
107+
submitButtonDisabled = computed(
108+
() => (!this.decisionChanged() && !this.commentEdited()) || this.commentExceedsLimit()
109+
);
108110

109111
acceptOptionExplanation = computed(() => {
110112
const reviewsWorkflow = this.provider().reviewsWorkflow;
@@ -146,9 +148,9 @@ export class MakeDecisionComponent {
146148
}
147149
});
148150

149-
rejectRadioButtonValue = computed(() => {
150-
return this.preprint()?.isPublished ? ReviewsState.Withdrawn : ReviewsState.Rejected;
151-
});
151+
rejectRadioButtonValue = computed(() =>
152+
this.preprint()?.isPublished ? ReviewsState.Withdrawn : ReviewsState.Rejected
153+
);
152154

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

163-
settingsModeration = computed(() => {
164-
return decisionSettings.moderation[this.provider().reviewsWorkflow || ProviderReviewsWorkflow.PreModeration];
165-
});
165+
settingsModeration = computed(
166+
() => decisionSettings.moderation[this.provider().reviewsWorkflow || ProviderReviewsWorkflow.PreModeration]
167+
);
166168

167-
commentEdited = computed(() => {
168-
return this.reviewerComment()?.trim() !== this.initialReviewerComment();
169-
});
169+
commentEdited = computed(() => this.reviewerComment()?.trim() !== this.initialReviewerComment());
170170

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

175-
return comment.length > formInputLimits.decisionComment.maxLength;
175+
return comment.length > this.decisionCommentLimit;
176176
});
177177

178-
commentLengthErrorMessage = computed(() => {
179-
const limit = formInputLimits.decisionComment.maxLength;
180-
return this.translateService.instant('preprints.details.decision.commentLengthError', {
181-
limit,
178+
commentLengthErrorMessage = computed(() =>
179+
this.translateService.instant('preprints.details.decision.commentLengthError', {
180+
limit: this.decisionCommentLimit,
182181
length: this.reviewerComment()!.length,
183-
});
184-
});
182+
})
183+
);
185184

186185
requestDecisionJustificationErrorMessage = computed(() => {
187186
const justification = this.requestDecisionJustification();
@@ -196,9 +195,7 @@ export class MakeDecisionComponent {
196195
return null;
197196
});
198197

199-
decisionChanged = computed(() => {
200-
return this.preprint()?.reviewsState !== this.decision();
201-
});
198+
decisionChanged = computed(() => this.preprint()?.reviewsState !== this.decision());
202199

203200
constructor() {
204201
effect(() => {

src/app/features/preprints/constants/create-new-version-steps.const.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { PreprintSteps } from '@osf/features/preprints/enums';
2-
import { StepOption } from '@shared/models';
1+
import { StepOption } from '@osf/shared/models';
2+
3+
import { PreprintSteps } from '../enums';
34

45
export const createNewVersionStepsConst: StepOption[] = [
56
{

src/app/features/preprints/constants/form-input-limits.const.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ export const formInputLimits = {
1212
withdrawalJustification: {
1313
minLength: 25,
1414
},
15-
decisionComment: {
16-
maxLength: 10000,
17-
},
1815
requestDecisionJustification: {
1916
minLength: 20,
2017
},

src/app/features/preprints/constants/make-decision.const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProviderReviewsWorkflow } from '@osf/features/preprints/enums';
1+
import { ProviderReviewsWorkflow } from '../enums';
22

33
export const decisionSettings = {
44
comments: {

src/app/features/preprints/constants/prereg-link-options.const.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { PreregLinkInfo } from '@osf/features/preprints/enums';
2-
import { SelectOption } from '@shared/models';
1+
import { SelectOption } from '@osf/shared/models';
2+
3+
import { PreregLinkInfo } from '../enums';
34

45
export const preregLinksOptions: SelectOption[] = [
56
{

src/app/features/preprints/constants/status-banner.const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProviderReviewsWorkflow, ReviewsState } from '@osf/features/preprints/enums';
1+
import { ProviderReviewsWorkflow, ReviewsState } from '../enums';
22

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

0 commit comments

Comments
 (0)