vault/ui/app/components/transformation-edit.hbs
2025-08-01 10:04:25 -06:00

128 lines
3.9 KiB
Handlebars
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<PageHeader as |p|>
<p.top>
<KeyValueHeader
@baseKey={{this.model}}
@path="vault.cluster.secrets.backend.list"
@mode={{this.mode}}
@root={{this.root}}
@showCurrent={{true}}
/>
</p.top>
<p.levelLeft>
<h1 class="title is-3" data-test-secret-header="true">
{{#if (eq this.mode "create")}}
Create Transformation
{{else if (eq this.mode "edit")}}
Edit Transformation
{{else}}
Transformation
<code>{{this.model.id}}</code>
{{/if}}
</h1>
</p.levelLeft>
</PageHeader>
{{#if (eq this.mode "show")}}
<Toolbar>
<ToolbarActions>
{{#if this.model.updatePath.canDelete}}
{{#if (gt this.model.allowed_roles.length 0)}}
<ToolTip @verticalPosition="above" @horizontalPosition="center" as |T|>
<T.Trigger @tabindex="-1">
<Hds::Button
@text="Delete transformation"
@color="secondary"
class="toolbar-button"
aria-disabled="true"
disabled
/>
</T.Trigger>
<T.Content @defaultClass="tool-tip">
<div class="box">
This transformation is in use by a role and cant be deleted.
</div>
</T.Content>
</ToolTip>
{{else}}
<Hds::Button
@text="Delete transformation"
@color="secondary"
class="toolbar-button"
{{on "click" (action (mut this.isDeleteModalActive) true)}}
/>
{{/if}}
<div class="toolbar-separator"></div>
{{/if}}
{{#if this.model.updatePath.canUpdate}}
{{#if (gt this.model.allowed_roles.length 0)}}
<Hds::Button
@text="Edit transformation"
@color="secondary"
class="toolbar-button"
{{on "click" (fn (mut this.isEditModalActive) true)}}
data-test-edit-link
/>
{{else}}
<ToolbarSecretLink @secret={{this.model.id}} @mode="edit" data-test-edit-link={{true}} @replace={{true}}>
Edit transformation
</ToolbarSecretLink>
{{/if}}
{{/if}}
</ToolbarActions>
</Toolbar>
{{/if}}
{{#if (eq this.mode "edit")}}
<TransformEditForm @mode={{this.mode}} @model={{this.model}} />
{{else if (eq this.mode "create")}}
<TransformCreateForm @mode={{this.mode}} @model={{this.model}} />
{{else}}
<TransformShowTransformation @model={{this.model}} />
{{/if}}
<ConfirmationModal
@title="Delete transformation"
@onClose={{action (mut this.isDeleteModalActive) false}}
@isActive={{this.isDeleteModalActive}}
@confirmText={{this.model.name}}
@toConfirmMsg="deleting the transformation."
@onConfirm={{action "delete"}}
>
<p class="has-bottom-margin-m">
Deleting the
<strong>{{this.model.name}}</strong>
transformation means that the underlying keys are lost and the data encoded by the transformation are unrecoverable and
cannot be decoded.
</p>
<MessageError @model={{this.model}} @errorMessage={{this.error}} />
</ConfirmationModal>
{{#if this.isEditModalActive}}
<Hds::Modal id="transformation-edit-modal" @color="warning" @onClose={{fn (mut this.isEditModalActive) false}} as |M|>
<M.Header @icon="alert-triangle">
Edit transformation
</M.Header>
<M.Body>
<p>
Youre editing a transformation that is in use by at least one role. Editing it may mean that encode and decode
operations stop working. Are you sure?
</p>
</M.Body>
<M.Footer as |F|>
<Hds::ButtonSet>
<Hds::Button
@text="Confirm"
@route="vault.cluster.secrets.backend.edit"
@model={{this.model.id}}
data-test-edit-confirm-button
/>
<Hds::Button @color="secondary" @text="Cancel" {{on "click" F.close}} />
</Hds::ButtonSet>
</M.Footer>
</Hds::Modal>
{{/if}}