From cfd8fae69aa6c57964d1ef91689fd41291593e0c Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Mon, 5 Oct 2020 17:20:04 -0400 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20apply=20doc-url=20he?= =?UTF-8?q?lper=20to=20footer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and refactor to use company-name and company-copyright helpers, rather than translations --- ui/core/.template-lintrc.js | 4 ++-- ui/core/app/helpers/company-copyright.js | 7 +++++++ ui/core/app/helpers/company-name.js | 6 ++++++ ui/core/app/helpers/doc-url.js | 2 +- ui/core/app/templates/application.hbs | 10 ++++++---- ui/core/config/environment.js | 1 + .../tests/integration/helpers/app-name-test.js | 1 + .../integration/helpers/company-copyright-test.js | 15 +++++++++++++++ .../integration/helpers/company-name-test.js | 14 ++++++++++++++ ui/core/translations/en-us.yaml | 8 +------- 10 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 ui/core/app/helpers/company-copyright.js create mode 100644 ui/core/app/helpers/company-name.js create mode 100644 ui/core/tests/integration/helpers/company-copyright-test.js create mode 100644 ui/core/tests/integration/helpers/company-name-test.js diff --git a/ui/core/.template-lintrc.js b/ui/core/.template-lintrc.js index 61df6a727..4db5af2b0 100644 --- a/ui/core/.template-lintrc.js +++ b/ui/core/.template-lintrc.js @@ -4,7 +4,7 @@ module.exports = { extends: 'octane', rules: { 'no-bare-strings': true, - 'no-curly-component-invocation': { allow: ['app-name'] }, - 'no-implicit-this': { allow: ['app-name'] } + 'no-curly-component-invocation': { allow: ['app-name', 'company-name', 'company-copyright'] }, + 'no-implicit-this': { allow: ['app-name', 'company-name', 'company-copyright', 'doc-url'] } } }; diff --git a/ui/core/app/helpers/company-copyright.js b/ui/core/app/helpers/company-copyright.js new file mode 100644 index 000000000..f4e799954 --- /dev/null +++ b/ui/core/app/helpers/company-copyright.js @@ -0,0 +1,7 @@ +import { helper } from '@ember/component/helper'; +import config from '../config/environment'; + +export default helper(function companyCopyright() { + const currentYear = new Date().getFullYear(); + return `© ${currentYear} ${config.companyName}`; +}); diff --git a/ui/core/app/helpers/company-name.js b/ui/core/app/helpers/company-name.js new file mode 100644 index 000000000..78d99f2e7 --- /dev/null +++ b/ui/core/app/helpers/company-name.js @@ -0,0 +1,6 @@ +import { helper } from '@ember/component/helper'; +import config from '../config/environment'; + +export default helper(function companyName() { + return config.companyName; +}); diff --git a/ui/core/app/helpers/doc-url.js b/ui/core/app/helpers/doc-url.js index ae10962ce..e31e4932a 100644 --- a/ui/core/app/helpers/doc-url.js +++ b/ui/core/app/helpers/doc-url.js @@ -5,7 +5,7 @@ import config from '../config/environment'; export default helper(function docUrl(params/*, hash*/) { const baseURL = config.documentation.baseURL; - const docKey = params[0]; + const docKey = params[0] || ''; const configuredPath = get(config.documentation, docKey); if (docKey) { assert(` diff --git a/ui/core/app/templates/application.hbs b/ui/core/app/templates/application.hbs index fa96053b4..ac4f0eac3 100644 --- a/ui/core/app/templates/application.hbs +++ b/ui/core/app/templates/application.hbs @@ -59,11 +59,13 @@ - - {{t "hashicorp.copyright"}} - {{t "hashicorp.product"}} + + {{company-copyright}} + {{app-name}} - {{t "hashicorp.documentation.title"}} + + {{t "titles.documentation"}} + diff --git a/ui/core/config/environment.js b/ui/core/config/environment.js index 93bb0495c..0eb7294af 100644 --- a/ui/core/config/environment.js +++ b/ui/core/config/environment.js @@ -32,6 +32,7 @@ module.exports = function (environment) { }, appName: APP_NAME, + companyName: 'HashiCorp', notifyTimeout: 4000, sessionPollingTimeoutSeconds: 2.5, diff --git a/ui/core/tests/integration/helpers/app-name-test.js b/ui/core/tests/integration/helpers/app-name-test.js index 0dc7fbb09..cd86480cf 100644 --- a/ui/core/tests/integration/helpers/app-name-test.js +++ b/ui/core/tests/integration/helpers/app-name-test.js @@ -7,6 +7,7 @@ module('Integration | Helper | app-name', function (hooks) { setupRenderingTest(hooks); test('it renders', async function (assert) { + assert.expect(1); await render(hbs`{{app-name}}`); assert.equal(this.element.textContent.trim(), 'Boundary'); }); diff --git a/ui/core/tests/integration/helpers/company-copyright-test.js b/ui/core/tests/integration/helpers/company-copyright-test.js new file mode 100644 index 000000000..87b468e2f --- /dev/null +++ b/ui/core/tests/integration/helpers/company-copyright-test.js @@ -0,0 +1,15 @@ +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 | company-copyright', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + assert.expect(1); + const currentYear = new Date().getFullYear(); + await render(hbs`{{company-copyright}}`); + assert.equal(this.element.textContent.trim(), `© ${currentYear} HashiCorp`); + }); +}); diff --git a/ui/core/tests/integration/helpers/company-name-test.js b/ui/core/tests/integration/helpers/company-name-test.js new file mode 100644 index 000000000..0599a936e --- /dev/null +++ b/ui/core/tests/integration/helpers/company-name-test.js @@ -0,0 +1,14 @@ +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 | company-name', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + assert.expect(1); + await render(hbs`{{company-name}}`); + assert.equal(this.element.textContent.trim(), 'HashiCorp'); + }); +}); diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 84b842579..4441f333c 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -16,15 +16,9 @@ titles: empty-set: No Items Yet global: Global actions: Actions + documentation: Documentation descriptions: empty-set: There are no items to display yet. You may be able to add items or try back later. questions: delete-confirm: Are you sure you want to delete this resource? remove-confirm: Are you sure you want to remove this association? -hashicorp: - title: HashiCorp - copyright: © 2020 HashiCorp - product: Boundary v0.1 - documentation: - title: Documentation - link: https://boundaryproject.io