Skip to content

Commit

Permalink
Merge pull request #1223 from eclipse-pass/russ-690-instructions-url
Browse files Browse the repository at this point in the history
Externalize instructions Url to config.json
  • Loading branch information
rpoet-jh authored Oct 10, 2023
2 parents 410d259 + ac7839b commit 8508c2a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
8 changes: 2 additions & 6 deletions app/components/notice-banner/index.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{{#if this.displayInfoBanner}}
<div class="info-banner p-1 text-center font-weight-bold">
Need help making a submission? Read our submission workflow
<a
href="https://github.com/eclipse-pass/main/blob/main/docs/user/README.md"
target="_blank"
rel="noopener noreferrer"
>
<a class="instructions-url" href={{this.instructionsUrl}} target="_blank" rel="noopener noreferrer">
instructions
</a>
{{#if this.contactUrl}}
or
<a href={{this.contactUrl}} target="_blank" rel="noopener noreferrer">
<a class="contact-us-url" href={{this.contactUrl}} target="_blank" rel="noopener noreferrer">
contact us
</a>
{{/if}}
Expand Down
18 changes: 17 additions & 1 deletion app/components/notice-banner/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
/* eslint-disable ember/no-computed-properties-in-native-classes */
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency-decorators';

export default class NoticeBanner extends Component {
@service router;
@service appStaticConfig;
@tracked contactUrl = null;
@tracked instructionsUrl = null;

constructor() {
super(...arguments);
this._setupAppStaticConfig.perform();
}

get displayInfoBanner() {
return true;
}

@task
_setupAppStaticConfig = function* () {
let config = yield this.appStaticConfig.getStaticConfig();
this.contactUrl = config.branding.pages.contactUrl;
this.instructionsUrl = config.branding.pages.instructionsUrl;
};
}
40 changes: 40 additions & 0 deletions tests/integration/components/notice-banner-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* eslint-disable ember/no-classic-classes */
import Service from '@ember/service';
import { setupRenderingTest } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import { module, test } from 'qunit';
import { render } from '@ember/test-helpers';

module('Integration | Component | notice-banner', (hooks) => {
setupRenderingTest(hooks);

test('it renders', async function (assert) {
const mockStaticConfig = Service.extend({
getStaticConfig: () =>
Promise.resolve({
branding: {
stylesheet: '',
pages: {
contactUrl: 'http://test-contact/',
instructionsUrl: 'http://test-instructions/',
},
},
}),
addCss: () => {},
});

this.owner.register('service:app-static-config', mockStaticConfig);

await render(hbs`<NoticeBanner />`);
assert.equal(
this.element.querySelector('.instructions-url').getAttribute('href'),
'http://test-instructions/',
'instruction url populated'
);
assert.equal(
this.element.querySelector('.contact-us-url').getAttribute('href'),
'http://test-contact/',
'contact us url populated'
);
});
});

0 comments on commit 8508c2a

Please sign in to comment.