Skip to content

Commit

Permalink
Fix bug where preprint status banner does not update
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed Jan 10, 2025
1 parent 9366206 commit 0c3dfcc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
44 changes: 22 additions & 22 deletions app/preprints/-components/preprint-status-banner/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
@service theme!: Theme;
@service media!: Media;

submission = this.args.submission;
isWithdrawn = this.args.submission.isWithdrawn;

provider = this.args.provider;

@tracked displayComment = false;
isPendingWithdrawal = false;
isWithdrawalRejected = false;
Expand All @@ -101,6 +96,10 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
taskFor(this.loadPreprintState).perform();
}

get isWithdrawn() {
return this.args.submission.isWithdrawn;
}

public get getClassName(): string {
if (this.isPendingWithdrawal) {
return CLASS_NAMES[PENDING_WITHDRAWAL];
Expand All @@ -109,19 +108,20 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
} else if (this.isWithdrawalRejected) {
return CLASS_NAMES[WITHDRAWAL_REJECTED];
} else {
return this.submission.reviewsState === PENDING ?
CLASS_NAMES[this.provider?.reviewsWorkflow || UNKNOWN] :
CLASS_NAMES[this.submission.reviewsState];
return this.args.submission.reviewsState === PENDING ?
CLASS_NAMES[this.args.provider.reviewsWorkflow || UNKNOWN] :
CLASS_NAMES[this.args.submission.reviewsState];
}
}

public get bannerContent(): string {
const { provider } = this.args;
if (this.isPendingWithdrawal) {
return this.intl.t(this.statusExplanation, { documentType: this.provider?.documentType.singular });
return this.intl.t(this.statusExplanation, { documentType: provider.documentType.singular });
} else if (this.isWithdrawn) {
return this.intl.t(MESSAGE[WITHDRAWN], { documentType: this.provider?.documentType.singular });
return this.intl.t(MESSAGE[WITHDRAWN], { documentType: provider.documentType.singular });
} else if (this.isWithdrawalRejected) {
return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: this.provider?.documentType.singular });
return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: provider.documentType.singular });
} else {
const tName = this.theme.isProvider ?
this.theme.provider?.name :
Expand All @@ -132,7 +132,7 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
name: tName,
reviewsWorkflow:
tWorkflow,
documentType: this.provider?.documentType.singular,
documentType: this.args.provider.documentType.singular,
}));
return `${base} ${tStatusExplanation}`;
}
Expand All @@ -144,14 +144,14 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
} else if (this.isWithdrawalRejected) {
return MESSAGE[WITHDRAWAL_REJECTED];
} else {
return this.submission.reviewsState === PENDING ?
MESSAGE[this.provider?.reviewsWorkflow || UNKNOWN ] :
MESSAGE[this.submission.reviewsState];
return this.args.submission.reviewsState === PENDING ?
MESSAGE[this.args.provider.reviewsWorkflow || UNKNOWN ] :
MESSAGE[this.args.submission.reviewsState];
}
}

public get status(): string {
let currentState = this.submission.reviewsState;
let currentState = this.args.submission.reviewsState;
if (this.isPendingWithdrawal) {
currentState = ReviewsState.PENDING_WITHDRAWAL;
} else if (this.isWithdrawalRejected) {
Expand All @@ -161,7 +161,7 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
}

public get icon(): string {
let currentState = this.submission.reviewsState;
let currentState = this.args.submission.reviewsState;
if (this.isPendingWithdrawal) {
currentState = ReviewsState.PENDING_WITHDRAWAL;
} else if (this.isWithdrawalRejected) {
Expand All @@ -173,18 +173,18 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
}

private get workflow(): string {
return WORKFLOW[this.provider?.reviewsWorkflow || UNKNOWN];
return WORKFLOW[this.args.provider.reviewsWorkflow || UNKNOWN];
}

@task
@waitFor
async loadPreprintState() {
async loadPreprintState() {
if (this.isWithdrawn) {
return;
}
const submissionActions = await this.submission.reviewActions;
const submissionActions = await this.args.submission.reviewActions;
const latestSubmissionAction = submissionActions.firstObject;
const withdrawalRequests = await this.submission.requests;
const withdrawalRequests = await this.args.submission.requests;
const withdrawalRequest = withdrawalRequests.firstObject;
if (withdrawalRequest) {
const requestActions = await withdrawalRequest.queryHasMany('actions', {
Expand All @@ -203,7 +203,7 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
}
}

if (this.provider.reviewsCommentsPrivate) {
if (this.args.provider.reviewsCommentsPrivate) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions app/preprints/-components/preprint-status-banner/template.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div local-class='preprint-banner-status-container {{if this.isMobile 'mobile'}}'>
{{#if (or this.submission.provider?.isPending this.loadPreprintState.isRunning) }}
{{#if this.loadPreprintState.isRunning}}
{{ t 'preprints.detail.status_banner.loading' }}
{{else}}
<div local-class='preprint-banner-status {{this.getClassName}}'>
Expand All @@ -15,15 +15,15 @@
<strong data-test-status>{{t this.status }}:</strong>
<span data-test-status-explanation>{{this.bannerContent}}</span>
</div>
{{#if (and this.reviewerComment (not this.submission.provider.reviewsCommentsPrivate))}}
{{#if (and this.reviewerComment (not @submission.provider.reviewsCommentsPrivate))}}
<div local-class='reviewer-feedback'>
<Button
data-test-view-comments
data-analytics-name='View comments'
@type='default'
{{on 'click' (action (mut this.displayComment) (not this.displayComment))}}
>
{{t this.labelModeratorFeedback}}
{{t this.labelModeratorFeedback}}
<FaIcon @icon='caret-down' @prefix='fas' aria-hidden='true'/>
</Button>
<OsfDialog
Expand All @@ -42,7 +42,7 @@
</div>
<div local-class='moderator-comment' aria-labelledby='moderator-feedback'>
<p>{{this.reviewerComment}}</p>
{{#unless this.submission.provider.reviewsCommentsAnonymous}}
{{#unless @submission.provider.reviewsCommentsAnonymous}}
<div>{{this.reviewerName}}</div>
{{/unless}}
{{if this.theme.isProvider this.theme.provider.name (t 'preprints.detail.status_banner.brand_name')}} {{t this.moderator}}
Expand Down

0 comments on commit 0c3dfcc

Please sign in to comment.