diff --git a/lib/osf-components/addon/components/osf-navbar/preprint-links/component.ts b/lib/osf-components/addon/components/osf-navbar/preprint-links/component.ts new file mode 100644 index 00000000000..73f6b3e781f --- /dev/null +++ b/lib/osf-components/addon/components/osf-navbar/preprint-links/component.ts @@ -0,0 +1,14 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import CurrentUserService from 'ember-osf-web/services/current-user'; +import config from 'ember-osf-web/config/environment'; + +interface Args { + onLinkClicked: () => void; +} +export default class OsfNavbarPreprintLinks extends Component { + @service currentUser!: CurrentUserService; + + donateURL = `${config.OSF.donateUrl}`; + supportURL = `${config.support.faqPageUrl}`; +} diff --git a/lib/osf-components/addon/components/osf-navbar/preprint-links/template.hbs b/lib/osf-components/addon/components/osf-navbar/preprint-links/template.hbs new file mode 100644 index 00000000000..535fac00eb5 --- /dev/null +++ b/lib/osf-components/addon/components/osf-navbar/preprint-links/template.hbs @@ -0,0 +1,57 @@ +
  • + + {{t 'navbar.my_preprints'}} + +
  • +{{#if this.currentUser.user.canViewReviews}} +
  • + + {{t 'navbar.reviews'}} + +
  • +{{/if}} +
  • + + {{t 'navbar.add_a_preprint' preprintWord=(t 'documentType.preprint.singularCapitalized')}} + +
  • +
  • + + {{t 'navbar.search'}} + +
  • +
  • + + {{t 'navbar.support'}} + +
  • + diff --git a/lib/osf-components/addon/components/osf-navbar/template.hbs b/lib/osf-components/addon/components/osf-navbar/template.hbs index c1b721994df..04c2ad5b7a9 100644 --- a/lib/osf-components/addon/components/osf-navbar/template.hbs +++ b/lib/osf-components/addon/components/osf-navbar/template.hbs @@ -81,11 +81,18 @@ links=(component 'osf-navbar/x-links' onLinkClicked=(action 'onLinkClicked') ) + preprintLinks=(component 'osf-navbar/preprint-links' + onLinkClicked=(action 'onLinkClicked') + ) ) as |ctx|}} {{#if (has-block)}} {{yield ctx}} {{else}} - {{ctx.links}} + {{#if (eq this._activeService.name 'PREPRINTS')}} + {{ctx.preprintLinks}} + {{else}} + {{ctx.links}} + {{/if}} {{/if}} {{/let}} diff --git a/lib/osf-components/app/components/osf-navbar/preprint-links/component.js b/lib/osf-components/app/components/osf-navbar/preprint-links/component.js new file mode 100644 index 00000000000..113402c23bf --- /dev/null +++ b/lib/osf-components/app/components/osf-navbar/preprint-links/component.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/osf-navbar/preprint-links/component'; diff --git a/lib/osf-components/app/components/osf-navbar/preprint-links/template.js b/lib/osf-components/app/components/osf-navbar/preprint-links/template.js new file mode 100644 index 00000000000..abbee7e3ff2 --- /dev/null +++ b/lib/osf-components/app/components/osf-navbar/preprint-links/template.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/osf-navbar/preprint-links/template'; diff --git a/tests/integration/components/osf-navbar/component-test.ts b/tests/integration/components/osf-navbar/component-test.ts index 5252f06b820..3b10db17943 100644 --- a/tests/integration/components/osf-navbar/component-test.ts +++ b/tests/integration/components/osf-navbar/component-test.ts @@ -9,6 +9,7 @@ import { module, test } from 'qunit'; const routerStub = Service.extend({ currentURL: '/', + currentRouteName: 'dashboard', urlFor() { return '/FakeURL'; }, @@ -37,6 +38,10 @@ module('Integration | Component | osf-navbar', hooks => { await render(hbs``); assert.dom('.service-name').includesText('OSF'); assert.dom('.current-service').hasText('HOME'); + assert.dom('[data-test-nav-my-projects-link]').exists(); + assert.dom('[data-test-nav-search-link]').exists(); + assert.dom('[data-test-nav-support-link]').exists(); + assert.dom('[data-test-nav-donate-link]').exists(); }); test('service-dropdown: logged in', async function(assert) { @@ -72,4 +77,40 @@ module('Integration | Component | osf-navbar', hooks => { await click('[data-test-service-dropdown]'); await percySnapshot(assert); }); + + test('osf-navbar: preprints, no moderation', async function(assert) { + this.owner.lookup('service:session').set('isAuthenticated', true); + this.owner.lookup('service:router').set('currentRouteName', 'preprints.place'); + + await render(hbs``); + + assert.dom('.service-name').includesText('OSF'); + assert.dom('.current-service').hasText('PREPRINTS'); + assert.dom('[data-test-nav-my-preprints-link]').exists(); + assert.dom('[data-test-nav-submit-preprint-link]').exists(); + assert.dom('[data-test-nav-reviews-link]').doesNotExist(); + + assert.dom('[data-test-nav-search-link]').exists(); + assert.dom('[data-test-nav-donate-link]').hasClass('navbar-donate-button'); + + assert.dom('[data-test-nav-my-projects-link]').doesNotExist(); + }); + + test('osf-navbar: preprints with moderation', async function(assert) { + this.owner.lookup('service:session').set('isAuthenticated', true); + this.owner.lookup('service:router').set('currentRouteName', 'preprints.somewhere'); + // this.owner.register('service:current-user', currentUserStub); + this.owner.lookup('service:current-user').set('user', { canViewReviews: true }); + + await render(hbs``); + + assert.dom('.service-name').includesText('OSF'); + assert.dom('.current-service').hasText('PREPRINTS'); + assert.dom('[data-test-nav-my-preprints-link]').exists(); + assert.dom('[data-test-nav-submit-preprint-link]').exists(); + assert.dom('[data-test-nav-reviews-link]').exists(); + + assert.dom('[data-test-nav-my-projects-link]').doesNotExist(); + await percySnapshot(assert); + }); });