Skip to content

Show API Token expiry in token list #6647

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

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions app/components/settings/api-tokens.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@
<div title={{token.created_at}} local-class="created-at" data-test-created-at>
Created {{date-format-distance-to-now token.created_at addSuffix=true}}
</div>

{{#if token.expired_at}}
<div title={{token.expired_at}} local-class="expired-at" data-test-expired-at>
Expires {{date-format-distance-to-now token.expired_at addSuffix=true}}
</div>
{{/if}}
</div>

{{#if token.token}}
Expand Down
2 changes: 2 additions & 0 deletions app/models/api-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export default class ApiToken extends Model {
@attr crate_scopes;
/** @type string[] | null */
@attr endpoint_scopes;
/** @type string | null */
@attr('date') expired_at;
}
3 changes: 3 additions & 0 deletions tests/acceptance/api-token-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module('Acceptance | api-tokens', function (hooks) {
name: 'BAR',
createdAt: '2017-11-19T17:59:22',
lastUsedAt: null,
expiredAt: '2017-12-19T17:59:22',
});

context.authenticateAs(user);
Expand All @@ -47,6 +48,7 @@ module('Acceptance | api-tokens', function (hooks) {
assert.dom('[data-test-name]', row1).hasText('BAR');
assert.dom('[data-test-created-at]', row1).hasText('Created about 18 hours ago');
assert.dom('[data-test-last-used-at]', row1).hasText('Never used');
assert.dom('[data-test-expired-at]', row1).hasText('Expires in 29 days');
assert.dom('[data-test-save-token-button]', row1).doesNotExist();
assert.dom('[data-test-revoke-token-button]', row1).exists();
assert.dom('[data-test-saving-spinner]', row1).doesNotExist();
Expand All @@ -56,6 +58,7 @@ module('Acceptance | api-tokens', function (hooks) {
assert.dom('[data-test-name]', row2).hasText('foo');
assert.dom('[data-test-created-at]', row2).hasText('Created 4 months ago');
assert.dom('[data-test-last-used-at]', row2).hasText('Last used 18 days ago');
assert.dom('[data-test-expired-at]', row2).doesNotExist();
assert.dom('[data-test-save-token-button]', row2).doesNotExist();
assert.dom('[data-test-revoke-token-button]', row2).exists();
assert.dom('[data-test-saving-spinner]', row2).doesNotExist();
Expand Down