-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: refactor KMIP role model (#28418)
* update kmip/role model and adapter * New KMIP role form component * cleanup on kmip role adapter/model * fix role details view * update tests to check for kmip role form and details validity * cleanup * Add kmip-role-fields test * add headers, remove old component * Address PR comments
- Loading branch information
Showing
16 changed files
with
360 additions
and
257 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
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,27 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import { removeManyFromArray } from 'vault/helpers/remove-from-array'; | ||
|
||
export const operationFields = (fieldNames) => { | ||
if (!Array.isArray(fieldNames)) { | ||
throw new Error('fieldNames must be an array'); | ||
} | ||
return fieldNames.filter((key) => key.startsWith('operation')); | ||
}; | ||
|
||
export const operationFieldsWithoutSpecial = (fieldNames) => { | ||
const opFields = operationFields(fieldNames); | ||
return removeManyFromArray(opFields, ['operationAll', 'operationNone']); | ||
}; | ||
|
||
export const nonOperationFields = (fieldNames) => { | ||
const opFields = operationFields(fieldNames); | ||
return removeManyFromArray(fieldNames, opFields); | ||
}; | ||
|
||
export const tlsFields = () => { | ||
return ['tlsClientKeyBits', 'tlsClientKeyType', 'tlsClientTtl']; | ||
}; |
This file was deleted.
Oops, something went wrong.
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,82 @@ | ||
{{! | ||
Copyright (c) HashiCorp, Inc. | ||
SPDX-License-Identifier: BUSL-1.1 | ||
~}} | ||
|
||
<form {{on "submit" (perform this.save)}}> | ||
<MessageError @model={{@model}} data-test-edit-form-error /> | ||
<div class="box is-sideless is-fullwidth is-marginless"> | ||
<NamespaceReminder @mode="save" /> | ||
{{#if @model.isNew}} | ||
{{! Show role name only in create mode }} | ||
<FormField data-test-field @attr={{hash name="role" type="string" options=(hash label="Name")}} @model={{@model}} /> | ||
{{/if}} | ||
<div class="control is-flex box is-shadowless is-fullwidth is-marginless"> | ||
<input | ||
data-test-input="operationNone" | ||
id="operationNone" | ||
type="checkbox" | ||
class="toggle is-success is-small" | ||
checked={{not @model.operationNone}} | ||
{{on "change" this.toggleOperationSpecial}} | ||
/> | ||
<label for="operationNone" class="has-text-weight-bold is-size-8"> | ||
Allow this role to perform KMIP operations | ||
</label> | ||
</div> | ||
{{#unless @model.operationNone}} | ||
<Toolbar> | ||
<h3 class="title is-6 has-left-padding-s" data-test-kmip-section="Allowed Operations"> | ||
Allowed Operations | ||
</h3> | ||
</Toolbar> | ||
<div class="box"> | ||
<FormField | ||
@attr={{hash name="operationAll" type="boolean" options=(hash label="Allow this role to perform all operations")}} | ||
@model={{@model}} | ||
/> | ||
<hr /> | ||
<div class="kmip-role-operations"> | ||
{{#each this.operationFormGroups as |group|}} | ||
<div class="kmip-role-allowed-operations"> | ||
<h4 class="title is-7" data-test-kmip-operations={{group.name}}>{{group.name}}</h4> | ||
{{#each group.fields as |attr|}} | ||
<FormField | ||
data-test-field | ||
@disabled={{or @model.operationNone @model.operationAll}} | ||
@attr={{attr}} | ||
@model={{this.placeholderOrModel @model attr.name}} | ||
@showHelpText={{false}} | ||
/> | ||
{{/each}} | ||
</div> | ||
{{/each}} | ||
</div> | ||
</div> | ||
{{/unless}} | ||
<div class="box is-fullwidth is-shadowless"> | ||
<h3 class="title is-3" data-test-kmip-section="TLS"> | ||
TLS | ||
</h3> | ||
{{#each this.tlsFormFields as |attr|}} | ||
<FormField data-test-field @attr={{attr}} @model={{@model}} /> | ||
{{/each}} | ||
</div> | ||
{{#each @model.fields as |attr|}} | ||
<FormField data-test-field @attr={{attr}} @model={{@model}} /> | ||
{{/each}} | ||
</div> | ||
|
||
<div class="field is-grouped is-grouped-split is-fullwidth box is-bottomless"> | ||
<Hds::ButtonSet> | ||
<Hds::Button | ||
@text="Save" | ||
@icon={{if this.save.isRunning "loading"}} | ||
type="submit" | ||
disabled={{this.save.isRunning}} | ||
data-test-save | ||
/> | ||
<Hds::Button @text="Cancel" @color="secondary" {{on "click" @onCancel}} data-test-cancel /> | ||
</Hds::ButtonSet> | ||
</div> | ||
</form> |
Oops, something went wrong.