diff --git a/ui-v2/app/helpers/substr.js b/ui-v2/app/helpers/substr.js new file mode 100644 index 000000000..926ecbcfb --- /dev/null +++ b/ui-v2/app/helpers/substr.js @@ -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); +}); diff --git a/ui-v2/app/templates/dc/acls/tokens/index.hbs b/ui-v2/app/templates/dc/acls/tokens/index.hbs index 9127160ea..0a0700312 100644 --- a/ui-v2/app/templates/dc/acls/tokens/index.hbs +++ b/ui-v2/app/templates/dc/acls/tokens/index.hbs @@ -45,7 +45,7 @@ - {{truncate item.AccessorID 8 false}} + {{substr item.AccessorID -8}} {{if item.Local 'local' 'global' }} diff --git a/ui-v2/tests/integration/helpers/substr-test.js b/ui-v2/tests/integration/helpers/substr-test.js new file mode 100644 index 000000000..467d94da7 --- /dev/null +++ b/ui-v2/tests/integration/helpers/substr-test.js @@ -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'); + }); +});