-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1223 from eclipse-pass/russ-690-instructions-url
Externalize instructions Url to config.json
- Loading branch information
Showing
3 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
); | ||
}); | ||
}); |