forked from hashicorp/vault
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport 1.13.x: UI: fixes pki role editing changing to default key p…
…arameter values (hashicorp#20921)
- Loading branch information
1 parent
9f18485
commit 2881445
Showing
8 changed files
with
122 additions
and
3 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:bug | ||
ui: fixes key_bits and signature_bits reverting to default values when editing a pki role | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { helper } from '@ember/component/helper'; | ||
|
||
/* | ||
* use sparingly * | ||
ex: logic for an HTML element's selected boolean because <select> values are strings | ||
strict equal (===) will fail if the API param is a number | ||
<option selected={{loose-equal model.someAttr someOption)}} value={{someOption}}> | ||
*/ | ||
export function looseEqual([a, b]) { | ||
// loose equal 0 == '' returns true, we don't want that | ||
if ((a === 0 && b === '') || (a === '' && b === 0)) { | ||
return false; | ||
} | ||
return a == b; | ||
} | ||
|
||
export default helper(looseEqual); |
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 @@ | ||
export { default } from 'core/helpers/loose-equal'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'vault/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { looseEqual } from 'core/helpers/loose-equal'; | ||
|
||
module('Integration | Helper | loose-equal', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
this.inputValue = 1234; | ||
await render(hbs`{{if (loose-equal "1234" 1234) "true" "false"}}`); | ||
assert.dom(this.element).hasText('true'); | ||
|
||
this.inputValue = '4567'; | ||
await render(hbs`{{if (loose-equal "1234" "4567") "true" "false"}}`); | ||
assert.dom(this.element).hasText('false'); | ||
}); | ||
|
||
test('it compares values as expected', async function (assert) { | ||
assert.true(looseEqual([0, '0'])); | ||
assert.true(looseEqual([0, 0])); | ||
assert.true(looseEqual(['0', '0'])); | ||
assert.true(looseEqual(['1234', 1234])); | ||
assert.true(looseEqual(['1234', '1234'])); | ||
assert.true(looseEqual([1234, 1234])); | ||
assert.true(looseEqual(['abc', 'abc'])); | ||
assert.true(looseEqual(['', ''])); | ||
|
||
// == normally returns true for this comparison, we intercept and return false | ||
assert.false(looseEqual(['', 0])); | ||
assert.false(looseEqual([0, ''])); | ||
}); | ||
}); |