Files
threshold-ui/ui/admin/app/components/form/credential-library/vault-generic/index.hbs
T

258 lines
7.1 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<Rose::Form
@onSubmit={{@submit}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
@showEditToggle={{if @model.isNew false true}}
as |form|
>
<Hds::Form::TextInput::Field
name='name'
@value={{@model.name}}
@isInvalid={{@model.errors.name}}
@isOptional={{true}}
disabled={{form.disabled}}
{{on 'input' (set-from-event @model 'name')}}
as |F|
>
<F.Label>{{t 'form.name.label'}}</F.Label>
<F.HelperText>{{t 'form.name.help'}}</F.HelperText>
{{#if @model.errors.name}}
<F.Error as |E|>
{{#each @model.errors.name as |error|}}
<E.Message>
{{error.message}}
</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::Textarea::Field
name='description'
@value={{@model.description}}
@isInvalid={{@model.errors.description}}
@isOptional={{true}}
disabled={{form.disabled}}
as |F|
>
<F.Label>{{t 'form.description.label'}}</F.Label>
<F.HelperText>{{t 'form.description.help'}}</F.HelperText>
{{#if @model.errors.description}}
<F.Error as |E|>
{{#each @model.errors.description as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::Textarea::Field>
{{#if (and @model.isNew (feature-flag 'ssh-target'))}}
<Hds::Form::RadioCard::Group
@name={{t 'form.type.label'}}
@alignment='center'
as |G|
>
<G.Legend>{{t 'form.type.label'}}</G.Legend>
{{#each this.types as |type|}}
<G.RadioCard
@value={{type}}
@maxWidth='20rem'
@checked={{eq type @model.type}}
{{on 'input' (fn @changeType type)}}
as |R|
>
<R.Label>{{t
(concat 'resources.credential-library.types.' type)
}}</R.Label>
<R.Description>{{t
(concat 'resources.credential-library.help.' type)
}}</R.Description>
</G.RadioCard>
{{/each}}
</Hds::Form::RadioCard::Group>
{{else}}
<InfoField
@value={{t (concat 'resources.credential-library.types.' @model.type)}}
as |F|
>
<F.Label>{{t 'form.type.label'}}</F.Label>
<F.HelperText>
{{t (concat 'resources.credential-library.help.' @model.type)}}
</F.HelperText>
</InfoField>
{{/if}}
<Hds::Form::TextInput::Field
@isRequired={{true}}
@isOptional={{false}}
@value={{@model.path}}
@isInvalid={{@model.errors.path}}
@type='text'
name='vault_path'
disabled={{form.disabled}}
{{on 'input' (set-from-event @model 'path')}}
as |F|
>
<F.Label>{{t
'resources.credential-library.form.vault_path.label'
}}</F.Label>
<F.HelperText>{{t
'resources.credential-library.form.vault_path.help'
}}</F.HelperText>
{{#if @model.errors.path}}
<F.Error as |E|>
{{#each @model.errors.path as |error|}}
<E.Message
data-test-error-message-vault-path
>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::Select::Field
@isOptional={{true}}
@width='100%'
name='credential_type'
disabled={{or form.disabled (not @model.isNew)}}
{{on 'input' this.selectCredentialType}}
as |F|
>
<F.Label>
{{t 'resources.credential-library.form.credential_type.label'}}
</F.Label>
<F.HelperText>
{{t 'resources.credential-library.form.credential_type.help'}}
</F.HelperText>
<F.Options>
<option value='' />
{{#each this.credentialTypes as |type|}}
<option value={{type}} selected={{eq type @model.credential_type}}>
{{t (concat 'resources.credential-library.titles.' type)}}
</option>
{{/each}}
</F.Options>
{{#if @model.errors.credential_type}}
<F.Error as |E|>
{{#each @model.errors.credential_type as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::Select::Field>
{{#if @model.credential_type}}
<Form::Field::ListWrapper
@layout='horizontal'
@isOptional={{true}}
@disabled={{form.disabled}}
>
<:fieldset as |F|>
<F.Legend>
{{t
'resources.credential-library.form.credential_mapping_overrides.label'
}}
</F.Legend>
<F.HelperText>
{{t
'resources.credential-library.form.credential_mapping_overrides.help'
}}
</F.HelperText>
{{#if @model.errors.credential_mapping_overrides}}
<F.Error as |E|>
{{#each @model.errors.credential_mapping_overrides as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</:fieldset>
<:field as |F|>
<F.KeyValue
@name='credential_mapping_overrides'
@model={{@model}}
@disabled={{form.disabled}}
@width='100%'
@showNewRow={{this.showNewRow}}
>
<:newKey as |N|>
<N.select @selectOptions={{this.selectOptions}} />
</:newKey>
<:key as |K|>
<K.select @selectOptions={{this.mappingOverrides}} />
</:key>
<:value as |V|>
<V.text />
</:value>
</F.KeyValue>
</:field>
</Form::Field::ListWrapper>
{{/if}}
<Hds::Form::Radio::Group
disabled={{form.disabled}}
{{on 'input' (set-from-event @model 'http_method')}}
@isRequired={{true}}
@layout='horizontal'
@name='http_method'
as |G|
>
<G.Legend>
{{t 'resources.credential-library.form.http_method.label'}}
</G.Legend>
<G.HelperText>
{{t 'resources.credential-library.form.http_method.help'}}
</G.HelperText>
{{#each this.httpMethodOptions as |httpMethod|}}
<G.RadioField
checked={{eq @model.http_method httpMethod}}
@value={{httpMethod}}
as |F|
>
<F.Label>{{httpMethod}}</F.Label>
</G.RadioField>
{{/each}}
</Hds::Form::Radio::Group>
{{#if this.isHttpRequestBodyAllowed}}
<Hds::Form::Textarea::Field
@isRequired={{true}}
@isOptional={{false}}
@value={{@model.http_request_body}}
@isInvalid={{@model.errors.http_request_body}}
name='http_request_body'
disabled={{form.disabled}}
as |F|
>
<F.Label>{{t
'resources.credential-library.form.http_request_body.label'
}}</F.Label>
<F.HelperText>{{t
'resources.credential-library.form.http_request_body.help'
}}</F.HelperText>
{{#if @model.errors.http_request_body}}
<F.Error as |E|>
{{#each @model.errors.http_request_body as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::Textarea::Field>
{{/if}}
{{#if (can 'save model' @model)}}
<form.actions
@enableEditText={{t 'actions.edit-form'}}
@submitText={{t 'actions.save'}}
@cancelText={{t 'actions.cancel'}}
/>
{{/if}}
</Rose::Form>