claire bontempo 3a9db72792
UI: improve control group UX (#28232)
* wip control group fix?

* dont rely on models for capabilities;

* Revert "wip control group fix?"

This reverts commit cf3e896ba05d2fdfe1f6287bba5c862df4e5d553.

* make explicit request for data

* remove dangerous triple curlies

* cleanup template logic and reuse each-in

* remove capability checks from model

* update tests to reflect new behavior

* add test coverage

* fix mirage factory, update details tests

* test control groups VAULT-29471

* finish patch test

* alphabetize!

* does await help?

* fix factory

* add conditionals for control group error
2024-09-03 10:49:41 -07:00

73 lines
2.5 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}
<KvPageHeader @breadcrumbs={{@breadcrumbs}} @pageTitle="Patch Secret to New Version" />
{{#if this.controlGroupError}}
<ControlGroupInlineError @error={{this.controlGroupError}} class="has-top-margin-s has-bottom-margin-s">
<:customMessage>
<strong>
You can re-submit the form once access is granted. Ask your authorizer when to attempt saving again.
</strong>
</:customMessage>
</ControlGroupInlineError>
{{/if}}
<MessageError @errorMessage={{this.errorMessage}} />
<div class="box is-sideless is-fullwidth is-bottomless">
<NamespaceReminder @mode="patch" @noun="secret" />
<Hds::Form::TextInput::Field name="secret path" @value={{@path}} disabled data-test-field="Path" as |F|>
<F.Label>Path for this secret</F.Label>
</Hds::Form::TextInput::Field>
<hr class="has-background-gray-200" />
<Hds::Text::Display @tag="h2" @size="300" class="has-bottom-padding-s">Patch secret data</Hds::Text::Display>
<Hds::Alert @type="compact" @icon="alert-triangle-fill" @color="warning" class="has-bottom-padding-m" as |A|>
<A.Description>
The
<code>PATCH</code>
action allows you to partially update or add a key-value pair to the current version of the secret. The values will
remain the same in the new version if no changes are made to them.
</A.Description>
</Hds::Alert>
<Hds::Form::Radio::Group @name="patch-method" class="has-bottom-margin-m" as |G|>
<G.Legend>Edit via</G.Legend>
<G.HelperText>
Choose how to patch the secret data.
<strong>Switching to another method will reset the form data.</strong>
</G.HelperText>
{{#each (array "JSON" "UI") as |method|}}
<G.RadioField
@value={{method}}
{{on "change" this.selectPatchMethod}}
checked={{eq this.patchMethod method}}
data-test-input={{method}}
as |F|
>
<F.Label>{{method}}</F.Label>
</G.RadioField>
{{/each}}
</Hds::Form::Radio::Group>
{{#if (eq this.patchMethod "UI")}}
<KvPatch::Editor::Form
@isSaving={{this.save.isRunning}}
@onCancel={{this.onCancel}}
@onSubmit={{perform this.save}}
@subkeys={{@subkeys}}
@submitError={{this.invalidFormAlert}}
/>
{{else}}
<KvPatch::JsonForm
@isSaving={{this.save.isRunning}}
@onCancel={{this.onCancel}}
@onSubmit={{perform this.save}}
@subkeys={{@subkeys}}
@submitError={{this.invalidFormAlert}}
/>
{{/if}}
</div>