-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport 1.16.x: UI fix k8 role filter (#27328)
* add changelog * initial changes for new component template only handle actions in parent * manual things * manual things
- Loading branch information
1 parent
a682542
commit 89b0b66
Showing
11 changed files
with
169 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:change | ||
ui/kubernetes: Update the roles filter-input to use explicit search. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{! | ||
Copyright (c) HashiCorp, Inc. | ||
SPDX-License-Identifier: BUSL-1.1 | ||
~}} | ||
|
||
<form {{on "submit" @handleSearch}}> | ||
<Hds::SegmentedGroup as |S|> | ||
<S.TextInput | ||
@value={{@query}} | ||
placeholder={{@placeholder}} | ||
aria-label="Search by path" | ||
size="32" | ||
{{on "input" @handleInput}} | ||
{{on "keydown" @handleKeyDown}} | ||
data-test-filter-input-explicit | ||
/> | ||
<S.Button @color="secondary" @text="Search" @icon="search" type="submit" data-test-filter-input-explicit-search /> | ||
</Hds::SegmentedGroup> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
export { default } from 'core/components/filter-input-explicit'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
ui/tests/integration/components/filter-input-explicit-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render, typeIn, click } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import { SELECTORS as GENERAL } from 'vault/tests/helpers/general-selectors'; | ||
import sinon from 'sinon'; | ||
|
||
const handler = (e) => { | ||
// required because filter-input-explicit passes handleSearch on form submit | ||
if (e && e.preventDefault) e.preventDefault(); | ||
return; | ||
}; | ||
|
||
module('Integration | Component | filter-input-explicit', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
hooks.beforeEach(function () { | ||
this.handleSearch = sinon.spy(handler); | ||
this.handleInput = sinon.spy(); | ||
this.handleKeyDown = sinon.spy(); | ||
this.query = ''; | ||
this.placeholder = 'Filter roles'; | ||
|
||
this.renderComponent = () => { | ||
return render( | ||
hbs`<FilterInputExplicit aria-label="test-component" @placeholder={{this.placeholder}} @query={{this.query}} @handleSearch={{this.handleSearch}} @handleInput={{this.handleInput}} @handleKeyDown={{this.handleKeyDown}} />` | ||
); | ||
}; | ||
}); | ||
|
||
test('it renders', async function (assert) { | ||
this.query = 'foo'; | ||
await this.renderComponent(); | ||
|
||
assert | ||
.dom(GENERAL.filterInputExplicit) | ||
.hasAttribute('placeholder', 'Filter roles', 'Placeholder passed to input element'); | ||
assert.dom(GENERAL.filterInputExplicit).hasValue('foo', 'Value passed to input element'); | ||
}); | ||
|
||
test('it should call handleSearch on submit', async function (assert) { | ||
await this.renderComponent(); | ||
await typeIn(GENERAL.filterInputExplicit, 'bar'); | ||
await click(GENERAL.filterInputExplicitSearch); | ||
assert.ok(this.handleSearch.calledOnce, 'handleSearch was called once'); | ||
}); | ||
|
||
test('it should send keydown event on keydown', async function (assert) { | ||
await this.renderComponent(); | ||
await typeIn(GENERAL.filterInputExplicit, 'a'); | ||
await typeIn(GENERAL.filterInputExplicit, 'b'); | ||
|
||
assert.ok(this.handleKeyDown.calledTwice, 'handle keydown was called twice'); | ||
assert.ok(this.handleSearch.notCalled, 'handleSearch was not called on a keydown event'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters