Skip to content

Commit

Permalink
Add version selector to preprint tombstone page
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed Dec 23, 2024
1 parent 1b83dfa commit 1ae93c6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
17 changes: 16 additions & 1 deletion app/preprints/detail/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;

.withdrawn-container {
padding: 0 15px;
width: 100%;
Expand Down Expand Up @@ -259,3 +259,18 @@
}
}
}

.version-dropdown {
display: inline-block;
}

.version-picker-list {
list-style: none;
margin: 0;
padding-inline-start: 0;
padding: 10px;

.version:not(:first-child) {
padding-top: 10px;
}
}
38 changes: 36 additions & 2 deletions app/preprints/detail/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,41 @@
<div local-class='preprint-title-container'>
<h1 data-test-preprint-title>{{this.displayTitle}}</h1>
<div>
{{#unless this.model.preprint.isWithdrawn}}
{{#if this.model.preprint.isWithdrawn}}
<ResponsiveDropdown
local-class='version-dropdown'
@renderInPlace={{true}}
@horizontalPosition='left'
as |dropdown|>
<dropdown.trigger>
<Button
data-test-previous-versions-button
data-analytics-name='View previous preprint versions'
local-class='btn btn-primary'
@type='default'
>
{{t 'preprints.detail.other_versions'}}
</Button>
</dropdown.trigger>
<dropdown.content>
<ul local-class='version-picker-list'>
{{#each this.model.versions as |version|}}
<li local-class='version'>
<OsfLink
data-test-version-link='{{version.preprintVersion}}'
@route='preprints.detail'
@models={{array this.model.provider.id version.id}}
>
{{t 'preprints.detail.preprint_version_number' number=version.preprintVersion}}
</OsfLink>
</li>
{{else}}
<li data-test-no-other-versions>{{t 'preprints.detail.no_other_versions'}}</li>
{{/each}}
</ul>
</dropdown.content>
</ResponsiveDropdown>
{{else}}
{{#if (and this.userIsContrib (not this.isPendingWithdrawal))}}
<OsfLink
data-test-edit-preprint-button
Expand All @@ -23,7 +57,7 @@

</OsfLink>
{{/if}}
{{/unless}}
{{/if}}
{{#if this.model.preprint.canCreateNewVersion}}
<Button
data-test-create-new-version-button
Expand Down
21 changes: 19 additions & 2 deletions tests/acceptance/preprints/detail-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
import PreprintModel from 'ember-osf-web/models/preprint';
import { PreprintProviderReviewsWorkFlow, ReviewsState } from 'ember-osf-web/models/provider';
import { Permission } from 'ember-osf-web/models/osf-model';
import { click } from 'ember-osf-web/tests/helpers';

interface PreprintDetailTestContext extends TestContext {
provider: ModelInstance<PreprintProviderModel>;
Expand Down Expand Up @@ -121,7 +122,7 @@ module('Acceptance | preprints | detail', hooks => {
});


test('Withdrawn preprint, latest version detail page', async function(this: PreprintDetailTestContext, assert) {
test('Withdrawn preprint, only version detail page', async function(this: PreprintDetailTestContext, assert) {
this.preprint.update({
dateWithdrawn: new Date(),
});
Expand All @@ -135,18 +136,34 @@ module('Acceptance | preprints | detail', hooks => {
assert.dom('[data-test-edit-preprint-button]').doesNotExist('Edit button is not displayed');
assert.dom('[data-test-create-new-version-button]')
.exists('New version button is displayed for latest withdrawn preprint version');
assert.dom('[data-test-previous-versions-button]').exists('Previous versions button is displayed');
await click('[data-test-previous-versions-button]');
assert.dom('[data-test-no-other-versions]').exists({ count: 1 }, 'No other versions message is displayed');
assert.dom('[data-test-version-link]').doesNotExist('No links to previous versions are displayed');
});

test('Withdrawn preprint, prior version detail page', async function(this: PreprintDetailTestContext, assert) {
this.preprint.update({
this.preprint = server.create('preprint', {
id: 'test',
dateWithdrawn: new Date(),
currentUserPermissions: Object.values(Permission),
title: 'Test Preprint',
description: 'This is a test preprint',
}, 'withVersions');
this.preprint.update({
isLatestVersion: false,
provider: this.provider,
});

await visit('/preprints/osf/test');

// Check no new version button and no edit button
assert.dom('[data-test-edit-preprint-button]').doesNotExist('Edit button is not displayed');
assert.dom('[data-test-create-new-version-button]')
.doesNotExist('New version button is not displayed for prior withdrawn preprint version');
assert.dom('[data-test-previous-versions-button]').exists('Previous versions button is displayed');
await click('[data-test-previous-versions-button]');
assert.dom('[data-test-version-link]').exists({ count: 3 }, 'Link to previous version is displayed');
assert.dom('[data-test-no-other-versions]').doesNotExist('No other versions message is not displayed');
});
});
3 changes: 3 additions & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1453,6 +1453,9 @@ preprints:
edit_preprint: 'Edit {documentType}'
edit_resubmit_preprint: 'Edit and resubmit'
create_new_version: 'Create new version'
other_versions: 'Other versions'
preprint_version_number: 'Version {number}'
no_other_versions: 'No other versions'
see_less: 'See less'
see_more: 'See more'
share:
Expand Down

0 comments on commit 1ae93c6

Please sign in to comment.