Skip to content

Commit

Permalink
ui: display server version in index table
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Oct 21, 2021
1 parent 65bf47f commit 178af69
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ui/app/models/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ export default class Agent extends Model {
get isLeader() {
return this.get('system.leader.rpcAddr') === this.rpcAddr;
}

@computed('tags.[]')
get version() {
return this.tags?.build || '';
}
}
3 changes: 2 additions & 1 deletion ui/app/templates/components/server-agent-row.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<td data-test-server-name><LinkTo @route="servers.server" @model={{this.agent.id}} class="is-primary">{{this.agent.name}}</LinkTo></td>
<td data-test-server-status>{{this.agent.status}}</td>
<td data-test-server-is-leader>{{if this.agent.isLeader "True" "False"}}</td>
<td data-test-server-address>{{this.agent.address}}</td>
<td data-test-server-address class="is-200px is-truncatable">{{this.agent.address}}</td>
<td data-test-server-port>{{this.agent.serfPort}}</td>
<td data-test-server-datacenter>{{this.agent.datacenter}}</td>
<td data-test-server-version>{{this.agent.version}}</td>
3 changes: 2 additions & 1 deletion ui/app/templates/servers/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
<t.sort-by @prop="name">Name</t.sort-by>
<t.sort-by @prop="status">Status</t.sort-by>
<t.sort-by @prop="isLeader">Leader</t.sort-by>
<t.sort-by @prop="address">Address</t.sort-by>
<t.sort-by @class="is-200px is-truncatable" @prop="address">Address</t.sort-by>
<t.sort-by @prop="serfPort">port</t.sort-by>
<t.sort-by @prop="datacenter">Datacenter</t.sort-by>
<t.sort-by @prop="version">Version</t.sort-by>
</t.head>
<t.body as |row|>
<ServerAgentRow data-test-server-agent-row @agent={{row.model}} />
Expand Down
6 changes: 6 additions & 0 deletions ui/mirage/factories/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DATACENTERS } from '../common';

const UUIDS = provide(100, faker.random.uuid.bind(faker.random));
const AGENT_STATUSES = ['alive', 'leaving', 'left', 'failed'];
const AGENT_BUILDS = ['1.1.0-beta', '1.0.2-alpha+ent', ...provide(5, faker.system.semver)];

export default Factory.extend({
id: i => (i / 100 >= 1 ? `${UUIDS[i]}-${i}` : UUIDS[i]),
Expand All @@ -29,6 +30,10 @@ export default Factory.extend({
Tags: generateTags(serfPort),
};
},

version() {
return this.member.Tags?.build || '';
},
});

function generateName() {
Expand All @@ -44,5 +49,6 @@ function generateTags(serfPort) {
return {
port: rpcPortCandidate === serfPort ? rpcPortCandidate + 1 : rpcPortCandidate,
dc: faker.helpers.randomize(DATACENTERS),
build: faker.helpers.randomize(AGENT_BUILDS),
};
}
1 change: 1 addition & 0 deletions ui/tests/acceptance/servers-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module('Acceptance | servers list', function(hooks) {
assert.equal(agentRow.address, agent.member.Address, 'Address');
assert.equal(agentRow.serfPort, agent.member.Port, 'Serf Port');
assert.equal(agentRow.datacenter, agent.member.Tags.dc, 'Datacenter');
assert.equal(agentRow.version, agent.version, 'Version');
});

test('each server should link to the server detail page', async function(assert) {
Expand Down
1 change: 1 addition & 0 deletions ui/tests/pages/servers/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default create({
address: text('[data-test-server-address]'),
serfPort: text('[data-test-server-port]'),
datacenter: text('[data-test-server-datacenter]'),
version: text('[data-test-server-version]'),

clickRow: clickable(),
clickName: clickable('[data-test-server-name] a'),
Expand Down

0 comments on commit 178af69

Please sign in to comment.