From 56a9a9ed49e48b98119885ed1ac89a986695f2fa Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Mon, 18 May 2020 17:59:32 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20add=20app-name=20helper?= =?UTF-8?q?=20for=20env-var=20configured=20app=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/.template-lintrc.js | 4 +++- ui/core/README.md | 14 +++++++++++--- ui/core/app/helpers/.gitkeep | 0 ui/core/app/helpers/app-name.js | 6 ++++++ ui/core/app/templates/application.hbs | 2 +- ui/core/app/templates/index.hbs | 2 +- ui/core/config/environment.js | 4 ++++ ui/core/tests/integration/helpers/app-name-test.js | 13 +++++++++++++ 8 files changed, 39 insertions(+), 6 deletions(-) delete mode 100644 ui/core/app/helpers/.gitkeep create mode 100644 ui/core/app/helpers/app-name.js create mode 100644 ui/core/tests/integration/helpers/app-name-test.js diff --git a/ui/core/.template-lintrc.js b/ui/core/.template-lintrc.js index 99ddf1bd6..61df6a727 100644 --- a/ui/core/.template-lintrc.js +++ b/ui/core/.template-lintrc.js @@ -3,6 +3,8 @@ module.exports = { extends: 'octane', rules: { - 'no-bare-strings': true + 'no-bare-strings': true, + 'no-curly-component-invocation': { allow: ['app-name'] }, + 'no-implicit-this': { allow: ['app-name'] } } }; diff --git a/ui/core/README.md b/ui/core/README.md index 144a0b034..84d20145c 100644 --- a/ui/core/README.md +++ b/ui/core/README.md @@ -8,11 +8,11 @@ The core UI for Project Watchtower. - [Prerequisites](#prerequisites) - [Installation](#installation) +- [Yarn Commands](#yarn-commands) - [Running / Development](#running--development) - - [Code Generators](#code-generators) - - [Running Tests](#running-tests) - - [Linting](#linting) - [Building](#building) + - [Environment Variables](#environment-variables) + - [Running Tests](#running-tests) - [Deploying](#deploying) - [Further Reading / Useful Links](#further-reading--useful-links) @@ -65,6 +65,14 @@ To build the project, without running it, execute one of the following commands: * `yarn run build` (development) * `yarn run build:production` (production) +#### Environment Variables + +These environment variables may be used to customized the build. + +| Variable | Default Value | Description | +| -------- | ------------- | ----------- | +| `APP_NAME` | Application Name | The user-facing name of the application, appearing in titles, etc. | + ### Running Tests * `npm test` runs full tests in random order with coverage diff --git a/ui/core/app/helpers/.gitkeep b/ui/core/app/helpers/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/ui/core/app/helpers/app-name.js b/ui/core/app/helpers/app-name.js new file mode 100644 index 000000000..ed1e479bb --- /dev/null +++ b/ui/core/app/helpers/app-name.js @@ -0,0 +1,6 @@ +import { helper } from '@ember/component/helper'; +import config from '../config/environment'; + +export default helper(function appName() { + return config.appName; +}); diff --git a/ui/core/app/templates/application.hbs b/ui/core/app/templates/application.hbs index 9dffbf57c..71796d43c 100644 --- a/ui/core/app/templates/application.hbs +++ b/ui/core/app/templates/application.hbs @@ -1,5 +1,5 @@ -{{title (t 'app.name')}} +{{title (app-name)}} {{outlet}} diff --git a/ui/core/app/templates/index.hbs b/ui/core/app/templates/index.hbs index bda6cb7ea..0ec72cc33 100644 --- a/ui/core/app/templates/index.hbs +++ b/ui/core/app/templates/index.hbs @@ -1 +1 @@ -

{{t 'app.name'}}

+

{{app-name}}

diff --git a/ui/core/config/environment.js b/ui/core/config/environment.js index 5cb032af1..fd1d4fdbd 100644 --- a/ui/core/config/environment.js +++ b/ui/core/config/environment.js @@ -1,5 +1,7 @@ 'use strict'; +const APP_NAME = process.env.APP_NAME || 'Application Name'; + module.exports = function (environment) { let ENV = { modulePrefix: 'core', @@ -23,6 +25,8 @@ module.exports = function (environment) { // when it is created }, + appName: APP_NAME, + contentSecurityPolicyHeader: 'Content-Security-Policy', contentSecurityPolicyMeta: true, contentSecurityPolicy: { diff --git a/ui/core/tests/integration/helpers/app-name-test.js b/ui/core/tests/integration/helpers/app-name-test.js new file mode 100644 index 000000000..cf2aac82f --- /dev/null +++ b/ui/core/tests/integration/helpers/app-name-test.js @@ -0,0 +1,13 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Helper | app-name', function(hooks) { + setupRenderingTest(hooks); + + test('it renders', async function(assert) { + await render(hbs`{{app-name}}`); + assert.equal(this.element.textContent.trim(), 'Application Name'); + }); +});