Skip to content

Commit

Permalink
Change template to use state and derived class
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Dec 6, 2019
1 parent f081b7d commit a8c571e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 13 additions & 0 deletions ui/app/components/client-node-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Component from '@ember/component';
import { lazyClick } from '../helpers/lazy-click';
import { watchRelationship } from 'nomad-ui/utils/properties/watch';
import WithVisibilityDetection from 'nomad-ui/mixins/with-component-visibility-detection';
import { computed } from '@ember/object';

export default Component.extend(WithVisibilityDetection, {
store: service(),
Expand Down Expand Up @@ -45,4 +46,16 @@ export default Component.extend(WithVisibilityDetection, {
},

watch: watchRelationship('allocations'),

stateClass: computed('node.state', function() {
let state = this.get('node.state');

if (state === 'draining') {
return 'status-text is-info';
} else if (state === 'ineligible') {
return 'status-text is-warning';
} else {
return '';
}
}),
});
8 changes: 1 addition & 7 deletions ui/app/templates/components/client-node-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
<td data-test-client-name class="is-200px is-truncatable" title="{{node.name}}">{{node.name}}</td>
<td data-test-client-state>
<span class="tooltip" aria-label="{{node.status}} / {{if node.isDraining "draining" "not draining"}} / {{if node.isEligible "eligible" "not eligible"}}">
{{#if node.isDraining}}
<span class="status-text is-info">draining</span>
{{else if (not node.isEligible)}}
<span class="status-text is-warning">ineligible</span>
{{else}}
{{node.status}}
{{/if}}
<span class="{{stateClass}}">{{node.state}}</span>
</span>
</td>
<td data-test-client-address>{{node.httpAddr}}</td>
Expand Down

0 comments on commit a8c571e

Please sign in to comment.