ui: Create a helper to show the last 8 characters of token Accessor ID (#7327)

* Create substr helper
* Create a test for the new substr helper
* Display the last 8 characters of token Accessor ID in the Token lists page
This commit is contained in:
Kenia 2020-02-20 13:53:37 -05:00 committed by John Cowen
parent bc1c3d71bf
commit b0b76e6f0c
3 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,5 @@
import { helper } from '@ember/component/helper';
export default helper(function substr([str = '', start = 0, length], hash) {
return str.substr(start, length);
});

View File

@ -45,7 +45,7 @@
</BlockSlot>
<BlockSlot @name="row">
<td data-test-token="{{item.AccessorID}}" class={{if (eq item.AccessorID token.AccessorID) 'me' }}>
<a href={{href-to 'dc.acls.tokens.edit' item.AccessorID}}>{{truncate item.AccessorID 8 false}}</a>
<a href={{href-to 'dc.acls.tokens.edit' item.AccessorID}}>{{substr item.AccessorID -8}}</a>
</td>
<td>
{{if item.Local 'local' 'global' }}

View File

@ -0,0 +1,17 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
module('helper:substr', function(hooks) {
setupRenderingTest(hooks);
// Replace this with your real tests.
test('it returns last 2 characters of string', async function(assert) {
this.set('inputValue', 'd9a54409-648b-4327-974f-62a45c8c65f1');
await render(hbs`{{substr inputValue -4}}`);
assert.dom('*').hasText('65f1');
});
});