fix: Disable credential library request body in form
This commit is contained in:
3 files changed
+26
-26
No files matched your search
@@ -123,4 +123,4 @@ http_method:
|
||||
help: The HTTP method the library uses when requesting credentials from Vault.
|
||||
http_request_body:
|
||||
label: HTTP Request Body
|
||||
help: The body of the HTTP request the library sends to Vault when requesting credentials.
|
||||
help: The body of the HTTP request the library sends to Vault when requesting credentials. Only allowed when http_method is set to POST.
|
||||
@@ -31,7 +31,7 @@
|
||||
@label={{t 'form.description.label'}}
|
||||
@error={{@model.errors.description}}
|
||||
@helperText={{t 'form.description.help'}}
|
||||
disabled={{@model.isSaving}}
|
||||
@disabled={{@model.isSaving}}
|
||||
readonly={{false}}
|
||||
as |field|
|
||||
>
|
||||
@@ -74,27 +74,25 @@
|
||||
{{/each}}
|
||||
</form.radioGroup>
|
||||
|
||||
{{#if this.isHttpRequestBodyAllowed}}
|
||||
<form.textarea
|
||||
@name='http_request_body'
|
||||
@type='text'
|
||||
@value={{@model.attributes.http_request_body}}
|
||||
@label={{t 'form.http_request_body.label'}}
|
||||
@error={{@model.errors.description}}
|
||||
@helperText={{t 'form.http_request_body.help'}}
|
||||
disabled={{@model.isSaving}}
|
||||
readonly={{false}}
|
||||
as |field|
|
||||
>
|
||||
{{#if @model.errors.description}}
|
||||
<field.errors as |errors|>
|
||||
{{#each @model.errors.description as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</field.errors>
|
||||
{{/if}}
|
||||
</form.textarea>
|
||||
{{/if}}
|
||||
<form.textarea
|
||||
@name='http_request_body'
|
||||
@type='text'
|
||||
@value={{@model.attributes.http_request_body}}
|
||||
@label={{t 'form.http_request_body.label'}}
|
||||
@error={{@model.errors.description}}
|
||||
@helperText={{t 'form.http_request_body.help'}}
|
||||
@disabled={{this.cannotSaveHttpRequestBody}}
|
||||
readonly={{false}}
|
||||
as |field|
|
||||
>
|
||||
{{#if @model.errors.description}}
|
||||
<field.errors as |errors|>
|
||||
{{#each @model.errors.description as |error|}}
|
||||
<errors.message>{{error.message}}</errors.message>
|
||||
{{/each}}
|
||||
</field.errors>
|
||||
{{/if}}
|
||||
</form.textarea>
|
||||
|
||||
<form.actions
|
||||
@disabled={{if @model.cannotSave @model.cannotSave}}
|
||||
|
||||
@@ -13,8 +13,10 @@ export default class FormCredentialLibraryIndexComponent extends Component {
|
||||
* Only allow HTTP request body field if http_method is set to POST.
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('args.model.attributes.http_method')
|
||||
get isHttpRequestBodyAllowed() {
|
||||
return this.args.model.attributes.http_method?.match(/post/i);
|
||||
@computed('args.model.attributes.http_method', 'isSaving')
|
||||
get cannotSaveHttpRequestBody() {
|
||||
return (
|
||||
!this.args.model.attributes.http_method?.match(/post/i) || this.isSaving
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user