Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6815][ENG-6843] Update condition to show edit button #2460

Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 16 additions & 2 deletions app/preprints/detail/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,25 @@ export default class PrePrintsDetailController extends Controller {
DATE_LABEL.created;
}

get showEditButton() {
const providerIsPremod = this.model.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.PRE_MODERATION;
const preprintIsRejected = this.model.preprint.reviewsState === ReviewsState.REJECTED;
const preprintIsInitialVersion = this.model.preprint.version === 1;
if (this.userIsContrib && this.model.preprint.isLatestVersion) {
if (providerIsPremod && preprintIsRejected && !preprintIsInitialVersion) {
return false;
}
return true;
}
return false;
}
cslzchen marked this conversation as resolved.
Show resolved Hide resolved
get editButtonLabel(): string {
const providerIsPremod = this.model.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.PRE_MODERATION;
const preprintIsRejected = this.model.preprint.reviewsState === ReviewsState.REJECTED;

const editPreprint = 'preprints.detail.edit_preprint';
const editResubmitPreprint = 'preprints.detail.edit_resubmit_preprint';
const translation = this.model.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.PRE_MODERATION
&& this.model.preprint.reviewsState === ReviewsState.REJECTED && this.model.preprint.currentUserIsAdmin
const translation = providerIsPremod && preprintIsRejected && this.model.preprint.currentUserIsAdmin
? editResubmitPreprint : editPreprint;
return this.intl.t(translation, {
documentType: this.model.provider.documentType.singular,
Expand Down
2 changes: 1 addition & 1 deletion app/preprints/detail/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</dropdown.content>
</ResponsiveDropdown>
{{else}}
{{#if (and this.userIsContrib (not this.isPendingWithdrawal))}}
{{#if this.showEditButton}}
<OsfLink
data-test-edit-preprint-button
data-analytics-name='Edit preprint button'
Expand Down
3 changes: 1 addition & 2 deletions tests/acceptance/preprints/detail-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ module('Acceptance | preprints | detail', hooks => {
await visit('/preprints/osf/test');

// Check edit and new version buttons
assert.dom('[data-test-edit-preprint-button]').exists('Edit button is displayed');
assert.dom('[data-test-edit-preprint-button]').containsText('Edit', 'Edit button text is correct');
assert.dom('[data-test-edit-preprint-button]').doesNotExist('Edit button is not displayed for prior versions');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good opportunity to add tests for the other conditions this ticket covers.

assert.dom('[data-test-create-new-version-button]')
.doesNotExist('New version button is not displayed for prior versions');

Expand Down
Loading