1 parent
b3abb658ab
commit
b79eebf73a
14 files changed
+538
-6
No files matched your search
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import Helper from '@ember/component/helper';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
/**
|
||||
* Takes a `Day` instance and returns in year format if there are no remainders,
|
||||
* * @example
|
||||
* {{format-day-year number}}
|
||||
*
|
||||
**/
|
||||
export default class extends Helper {
|
||||
// =services
|
||||
@service intl;
|
||||
|
||||
// =compute method
|
||||
|
||||
/**
|
||||
* @param {number} days
|
||||
* @return string
|
||||
*/
|
||||
|
||||
compute([days]) {
|
||||
const remainder = days % 365;
|
||||
if (remainder === 0) {
|
||||
const numberOfYears = days / 365;
|
||||
return this.intl.t('titles.year', { numberOfYears });
|
||||
} else {
|
||||
return this.intl.t('titles.days', { days });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
export { default } from 'core/helpers/format-day-year';
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import { setupIntl } from 'ember-intl/test-support';
|
||||
|
||||
module('Integration | Helper | format-day-year', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
setupIntl(hooks);
|
||||
|
||||
test('it renders correctly when it is 1 year', async function (assert) {
|
||||
this.set('inputValue', 365);
|
||||
await render(hbs`{{format-day-year this.inputValue}}`);
|
||||
assert.strictEqual(this.element.textContent.trim(), '1 year');
|
||||
});
|
||||
|
||||
test('it renders correctly when it is more than 1 year', async function (assert) {
|
||||
this.set('inputValue', 730);
|
||||
await render(hbs`{{format-day-year this.inputValue}}`);
|
||||
assert.strictEqual(this.element.textContent.trim(), '2 years');
|
||||
});
|
||||
|
||||
test('it renders correctly when it is not a whole year', async function (assert) {
|
||||
this.set('inputValue', 800);
|
||||
await render(hbs`{{format-day-year this.inputValue}}`);
|
||||
assert.strictEqual(this.element.textContent.trim(), '800 days');
|
||||
});
|
||||
test('it renders when null', async function (assert) {
|
||||
this.set('inputValue', null);
|
||||
await render(hbs`{{format-date-iso this.inputValue}}`);
|
||||
assert.strictEqual(this.element.textContent.trim(), '');
|
||||
});
|
||||
});
|
||||
@@ -38,6 +38,9 @@ titles:
|
||||
create-resources: Create Resources
|
||||
choose-an-option: Choose an option
|
||||
feature-edition: 'Edition: {edition}'
|
||||
unit: Unit
|
||||
year: '{numberOfYears, plural, =1 {# year} other {# years}}'
|
||||
days: '{days, plural, =1 {# day} other {# days}}'
|
||||
descriptions:
|
||||
empty-set: There are no items to display yet. You may be able to add items or try back later.
|
||||
cluster-url-initialization: To get started, please enter your cluster URL
|
||||
|
||||
@@ -920,3 +920,15 @@ policy:
|
||||
title_plural: Storage Policies
|
||||
titles:
|
||||
new: New Storage Policy
|
||||
policy_name: Policy name
|
||||
retain_for: Retain for
|
||||
delete_after: Delete After
|
||||
do_not_delete: Do not delete
|
||||
forever: Forever
|
||||
actions:
|
||||
delete: Delete Storage Policy
|
||||
messages:
|
||||
none:
|
||||
title: No storage policies yet
|
||||
description: Storage policies define how long to store recordings before they are automatically deleted. We recommend checking your data retention policies for compliance requirements.
|
||||
link: Create a new storage policy
|
||||
Reference in new issue
Block a user