Skip to content

Commit

Permalink
Merge pull request #9173 from hashicorp/f-ui/show-version
Browse files Browse the repository at this point in the history
UI: Show the nomad agent version of the agent the UI is served from
  • Loading branch information
DingoEatingFuzz committed Oct 26, 2020
2 parents 824633c + 8d8f9aa commit 50372a1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
14 changes: 14 additions & 0 deletions ui/app/services/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ export default class SystemService extends Service {
});
}

@computed
get agent() {
const token = this.token;
return PromiseObject.create({
promise: token
.authorizedRawRequest(`/${namespace}/agent/self`)
.then(jsonWithDefault({}))
.then(agent => {
agent.version = agent.member?.Tags?.build || 'Unknown';
return agent;
}),
});
}

@computed
get defaultRegion() {
const token = this.token;
Expand Down
9 changes: 9 additions & 0 deletions ui/app/styles/components/gutter.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.gutter {
display: flex;
flex-direction: column;
height: 100%;
border-right: 1px solid $grey-blue;
overflow: hidden;
Expand Down Expand Up @@ -56,6 +58,13 @@
.menu {
z-index: $z-gutter;
}

.gutter-footer {
text-align: center;
border-top: 1px solid lighten($grey-blue, 10%);
padding: 0.5em 0;
margin-top: auto;
}
}

// Treated as an element of the gutter component despite not being nested within
Expand Down
3 changes: 3 additions & 0 deletions ui/app/templates/components/gutter-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<li><LinkTo @route="topology" @activeClass="is-active" data-test-gutter-link="topology">Topology</LinkTo></li>
</ul>
</aside>
<footer class="gutter-footer">
<span class="is-faded">v{{this.system.agent.version}}</span>
</footer>
</div>
</div>
<div data-test-page-content class="page-column is-right">
Expand Down
6 changes: 6 additions & 0 deletions ui/mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ export default function() {
};
});

this.get('/agent/self', function({ agents }) {
return {
member: this.serialize(agents.first()),
};
});

this.get('/agent/monitor', function({ agents, nodes }, { queryParams }) {
const serverId = queryParams.server_id;
const clientId = queryParams.client_id;
Expand Down
8 changes: 6 additions & 2 deletions ui/tests/acceptance/regions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module('Acceptance | regions (many)', function(hooks) {
);
});

test('when the region is not the default region, all api requests include the region query param', async function(assert) {
test('when the region is not the default region, all api requests other than the agent/self request include the region query param', async function(assert) {
window.localStorage.removeItem('nomadTokenSecret');
const region = server.db.regions[1].id;

Expand All @@ -178,7 +178,11 @@ module('Acceptance | regions (many)', function(hooks) {
);

appRequests.forEach(req => {
assert.ok(req.url.includes(`region=${region}`), req.url);
if (req.url === '/v1/agent/self') {
assert.notOk(req.url.includes('region='), `(no region) ${req.url}`);
} else {
assert.ok(req.url.includes(`region=${region}`), req.url);
}
});
});
});

0 comments on commit 50372a1

Please sign in to comment.