From 2679c42e5616ddea635e7ba10ca4cd5e622669ee Mon Sep 17 00:00:00 2001 From: Cristiano Rastelli Date: Wed, 19 Mar 2025 20:06:16 +0000 Subject: [PATCH] [VAULT-34704] UI: update `FilterInput` component to use `Hds::Form::TextInput` (#29946) * [UI] replaced internal implementation of `FilterInput` with equivalent `Hds::Form::TextInput::Base` (#34704) * [UI] updated `FilterInput` instances to use correct `Hds::Form::TextInput::Base` arguments/API (#34704) * [UI] updated `FilterInput` integration tests (#34704) --- ui/lib/core/addon/components/filter-input.hbs | 14 ++++++----- ui/lib/core/addon/components/filter-input.ts | 11 +-------- .../addon/components/kv-suggestion-input.hbs | 5 ++-- .../ldap/addon/components/page/libraries.hbs | 2 +- ui/lib/ldap/addon/components/page/roles.hbs | 3 +-- .../components/secrets/page/destinations.hbs | 5 ++-- .../page/destinations/destination/sync.hbs | 4 ++-- .../components/filter-input-test.js | 23 +------------------ 8 files changed, 18 insertions(+), 49 deletions(-) diff --git a/ui/lib/core/addon/components/filter-input.hbs b/ui/lib/core/addon/components/filter-input.hbs index 172b822109..9782e10120 100644 --- a/ui/lib/core/addon/components/filter-input.hbs +++ b/ui/lib/core/addon/components/filter-input.hbs @@ -3,9 +3,11 @@ SPDX-License-Identifier: BUSL-1.1 }} -
- - {{#unless @hideIcon}} - - {{/unless}} -
\ No newline at end of file + \ No newline at end of file diff --git a/ui/lib/core/addon/components/filter-input.ts b/ui/lib/core/addon/components/filter-input.ts index 00ba0bf585..3cbddda1ef 100644 --- a/ui/lib/core/addon/components/filter-input.ts +++ b/ui/lib/core/addon/components/filter-input.ts @@ -5,25 +5,16 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; -import { debounce, next } from '@ember/runloop'; +import { debounce } from '@ember/runloop'; import type { HTMLElementEvent } from 'vault/forms'; interface Args { wait?: number; // defaults to 500 - autofocus?: boolean; // initially focus the input on did-insert - hideIcon?: boolean; // hide the search icon in the input onInput(value: string): void; // invoked with input value after debounce timer expires } export default class FilterInputComponent extends Component { - @action - focus(elem: HTMLElement) { - if (this.args.autofocus) { - next(() => elem.focus()); - } - } - @action onInput(event: HTMLElementEvent) { const wait = this.args.wait || 500; diff --git a/ui/lib/core/addon/components/kv-suggestion-input.hbs b/ui/lib/core/addon/components/kv-suggestion-input.hbs index 83b67c8a1d..37e66737e2 100644 --- a/ui/lib/core/addon/components/kv-suggestion-input.hbs +++ b/ui/lib/core/addon/components/kv-suggestion-input.hbs @@ -7,11 +7,10 @@ {{/if}} diff --git a/ui/lib/ldap/addon/components/page/roles.hbs b/ui/lib/ldap/addon/components/page/roles.hbs index 4b5c65f7a9..80047da5ff 100644 --- a/ui/lib/ldap/addon/components/page/roles.hbs +++ b/ui/lib/ldap/addon/components/page/roles.hbs @@ -9,8 +9,7 @@ {{/if}} diff --git a/ui/lib/sync/addon/components/secrets/page/destinations.hbs b/ui/lib/sync/addon/components/secrets/page/destinations.hbs index 94352d973f..d5c5214f4d 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations.hbs @@ -32,12 +32,11 @@ />
diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.hbs index 53a608a226..521faffa4a 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.hbs @@ -59,9 +59,9 @@ {{else}} diff --git a/ui/tests/integration/components/filter-input-test.js b/ui/tests/integration/components/filter-input-test.js index 1760e9c8ba..879e87ace2 100644 --- a/ui/tests/integration/components/filter-input-test.js +++ b/ui/tests/integration/components/filter-input-test.js @@ -17,7 +17,7 @@ module('Integration | Component | filter-input', function (hooks) { this.onClick = () => assert.ok(true, 'on click modifier passed to input element'); await render( - hbs`` + hbs`` ); await click('[data-test-filter-input]'); assert @@ -26,11 +26,6 @@ module('Integration | Component | filter-input', function (hooks) { assert.dom('[data-test-filter-input]').hasValue('foo', 'Value passed to input element'); }); - test('it should focus input on insert', async function (assert) { - await render(hbs``); - assert.dom('[data-test-filter-input]').isFocused('Input is focussed'); - }); - test('it should send input event', async function (assert) { assert.expect(1); @@ -41,20 +36,4 @@ module('Integration | Component | filter-input', function (hooks) { await render(hbs``); await fillIn('[data-test-filter-input]', 'foo'); }); - - test('it should render icon', async function (assert) { - await render(hbs``); - assert - .dom('[data-test-filter-input-container]') - .hasClass('has-icons-left', 'Icon class exists on container'); - assert.dom('[data-test-filter-input-icon]').exists('Icon renders'); - }); - - test('it should hide icon', async function (assert) { - await render(hbs``); - assert - .dom('[data-test-filter-input-container]') - .doesNotHaveClass('has-icons-left', 'Icon class does not exist on container'); - assert.dom('[data-test-filter-input-icon]').doesNotExist('Icon is hidden'); - }); });