Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI - fix perf standby feature display #5971

Merged
merged 5 commits into from
Dec 18, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions ui/app/components/license-info.js
Original file line number Diff line number Diff line change
@@ -7,18 +7,25 @@ export default Component.extend({
startTime: '',
licenseId: '',
features: null,
model: null,
text: '',
showForm: false,
isTemporary: computed('licenseId', function() {
return this.licenseId === 'temporary';
}),
featuresInfo: computed('features', function() {
let info = [];
allFeatures().forEach(feature => {
let active = this.features.includes(feature) ? true : false;
info.push({ name: feature, active: active });
featuresInfo: computed('model', 'features', function() {
return allFeatures().map(feature => {
let active = this.features.includes(feature);
if (active && feature === 'Performance Standby') {
let count = this.model.performanceStandbyCount;
return {
name: feature,
active: count ? active : false,
count,
};
}
return { name: feature, active };
});
return info;
}),
saveModel() {},
actions: {
1 change: 1 addition & 0 deletions ui/app/models/license.js
Original file line number Diff line number Diff line change
@@ -26,4 +26,5 @@ export default DS.Model.extend({
licenseId: attr('string'),
startTime: attr('string'),
text: attr('string'),
performanceStandbyCount: attr('number'),
});
3 changes: 2 additions & 1 deletion ui/app/templates/components/license-info.hbs
Original file line number Diff line number Diff line change
@@ -71,7 +71,8 @@
{{#each featuresInfo as |info|}}
{{#info-table-row label=info.name value=(if info.active "Active" "Not Active") data-test-feature-row="data-test-feature-row"}}
{{#if info.active}}
<ICon @size=28 @glyph="true" /> <span data-test-feature-status>Active</span>
<ICon @size=28 @glyph="true" /> <span data-test-feature-status>Active {{#if info.count}}&mdash;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💅 &mdash; fanciness

count: {{info.count}}{{/if}}</span>
{{else}}
<ICon @size=28 @glyph="false" /> <span data-test-feature-status>Not Active</span>
{{/if}}
Original file line number Diff line number Diff line change
@@ -15,14 +15,6 @@ const component = create(license);
module('Integration | Component | license info', function(hooks) {
setupRenderingTest(hooks);

hooks.beforeEach(function() {
component.setContext(this);
});

hooks.afterEach(function() {
component.removeContext();
});

const LICENSE_WARNING_TEXT = `Warning Your temporary license expires in 30 minutes and your vault will seal. Please enter a valid license below.`;

test('it renders properly for temporary license', async function(assert) {
@@ -114,4 +106,36 @@ module('Integration | Component | license info', function(hooks) {
await component.saveButton();
assert.ok(this.get('saveModel').calledOnce);
});

test('it renders Performance Standby as inactive if count is 0', async function(assert) {
const now = Date.now();
this.set('licenseId', 'temporary');
this.set('expirationTime', addMinutes(now, 30));
this.set('startTime', now);
this.set('model', { performanceStandbyCount: 0 });
this.set('features', ['Performance Standby', 'Namespaces']);

await render(
hbs`<LicenseInfo @licenseId={{this.licenseId}} @expirationTime={{this.expirationTime}} @startTime={{this.startTime}} @features={{this.features}} @model={{this.model}}/>`
);

let row = component.featureRows.filterBy('featureName', 'Performance Standby')[0];
assert.equal(row.featureStatus, 'Not Active', 'renders feature as inactive because when count is 0');
});

test('it renders Performance Standby as active and shows count', async function(assert) {
const now = Date.now();
this.set('licenseId', 'temporary');
this.set('expirationTime', addMinutes(now, 30));
this.set('startTime', now);
this.set('model', { performanceStandbyCount: 4 });
this.set('features', ['Performance Standby', 'Namespaces']);

await render(
hbs`<LicenseInfo @licenseId={{this.licenseId}} @expirationTime={{this.expirationTime}} @startTime={{this.startTime}} @features={{this.features}} @model={{this.model}}/>`
);

let row = component.featureRows.filterBy('featureName', 'Performance Standby')[0];
assert.equal(row.featureStatus, 'Active — count: 4', 'renders active and displays count');
});
});