Skip to content

Commit

Permalink
Add link to version in DOI select (#2449)
Browse files Browse the repository at this point in the history
-   Ticket: [ENG-6804]
-   Feature flag: n/a

## Purpose
- Add a link to the version when selecting a different version in the DOI selection dropdown

## Summary of Changes
- Add link to preprint DOI dropdown
- Update tests
  • Loading branch information
futa-ikeda authored Jan 2, 2025
1 parent b99fe9f commit 5877c2f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/preprints/-components/preprint-doi/component-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import { ModelInstance } from 'ember-cli-mirage';
import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
import PreprintModel from 'ember-osf-web/models/preprint';
import { ReviewsState } from 'ember-osf-web/models/provider';
import { OsfLinkRouterStub } from 'ember-osf-web/tests/integration/helpers/osf-link-router-stub';

module('Integration | Component | preprint-doi', function(hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);

test('it renders', async function(assert) {
this.owner.unregister('service:router');
this.owner.register('service:router', OsfLinkRouterStub);
this.store = this.owner.lookup('service:store');
server.loadFixtures('preprint-providers');
const mirageProvider = server.schema.preprintProviders.find('osf') as ModelInstance<PreprintProviderModel>;
Expand Down Expand Up @@ -62,6 +65,9 @@ module('Integration | Component | preprint-doi', function(hooks) {
.hasText('Version 2 (Rejected)', 'Dropdown has passed in currentVersiom selected by default');
assert.dom('[data-test-preprint-version="2"]').exists('Version 2 is shown');

assert.dom('[data-test-view-version-link]').exists('View in OSF button exists');
assert.dom('[data-test-view-version-link]').hasText('View version 2', 'View version link has correct text');

// check version2 has DOI text
assert.dom('[data-test-no-doi-text]').doesNotExist('No DOI text does not exist');
assert.dom('[data-test-unlinked-doi-url]').exists('Preprint DOI URL exists');
Expand All @@ -86,6 +92,8 @@ module('Integration | Component | preprint-doi', function(hooks) {
});

test('it renders statuses', async function(assert) {
this.owner.unregister('service:router');
this.owner.register('service:router', OsfLinkRouterStub);
this.store = this.owner.lookup('service:store');
server.loadFixtures('preprint-providers');
const mirageProvider = server.schema.preprintProviders.find('osf') as ModelInstance<PreprintProviderModel>;
Expand Down
8 changes: 8 additions & 0 deletions app/preprints/-components/preprint-doi/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
<p>{{t 'preprints.detail.no_versions'}}</p>
{{/if}}
{{#if this.selectedVersion}}
<OsfLink
data-test-view-version-link
data-analytics-name='View version link'
@route='preprints.detail'
@model={{this.selectedVersion}}
>
{{t 'preprints.detail.view_version' number=this.selectedVersion.version}}
</OsfLink>
{{#if this.selectedVersion.preprintDoiUrl}}
{{#if this.selectedVersion.preprintDoiCreated}}
<OsfLink
Expand Down
1 change: 1 addition & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@ preprints:
orphan_preprint: 'The user has removed this file.'
preprint_doi: '{documentType} DOI'
version_doi_title: 'Version {number}'
view_version: 'View version {number}'
version_status:
pending: '(Pending)'
rejected: '(Rejected)'
Expand Down

0 comments on commit 5877c2f

Please sign in to comment.