vault/ui/app/components/generate-credentials-database.hbs
Vault Automation 1d0009efd1
UI: Part II: Consolidate error handling and update views to use Hds::ApplicationState (#12432) (#12467)
* render Hds::ApplicationState in Page::Error component

* fix initial test failures

* implement Page::Error component in remaining error templates

* replacing remaining errors with Page::Error

* update test coverage, clarify message logic

* fix status code for already parsed errors and revert to root url

* update tests to reflect more detailed error messages

* replace not found test coverage with more robust tests

* remove unnecessary error intervention

* round out test coverage, add typescript definitions for each error type

* remove manual db credentials error intervention

* var cleanup

* add titleTags to errors

* add changelog

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
2026-02-21 01:35:14 +00:00

65 lines
2.6 KiB
Handlebars

{{!
Copyright IBM Corp. 2016, 2025
SPDX-License-Identifier: BUSL-1.1
}}
<Page::Header @title={{@roleName}}>
<:breadcrumbs>
<Page::Breadcrumbs @breadcrumbs={{this.breadcrumbs}} />
</:breadcrumbs>
</Page::Header>
<div class={{if @roleType "box is-fullwidth is-sideless is-marginless"}}>
{{! If no role type, that means both static and dynamic requests returned an error }}
{{#unless @roleType}}
<Page::Error @error={{@model}} @titleTag="h2">
<:customFooter as |AppState|>
<AppState.Footer as |F|>
<F.LinkStandalone
@iconPosition="trailing"
@icon="docs-link"
@text="Database documentation"
@href={{doc-link "/vault/api-docs/secret/databases"}}
/>
</AppState.Footer>
</:customFooter>
</Page::Error>
{{/unless}}
{{#if (and (not @model.errors) (eq @roleType "dynamic"))}}
<Hds::Alert @type="inline" @color="warning" class="has-top-bottom-margin" data-test-credentials-warning as |A|>
<A.Title>Warning</A.Title>
<A.Description>
You will not be able to access these credentials later, so please copy them now.
</A.Description>
</Hds::Alert>
{{/if}}
{{! DYNAMIC ROLE }}
{{#if (and (eq @roleType "dynamic") @model.username)}}
<InfoTableRow @label="Username" @value={{@model.username}}>
<MaskedInput @value={{@model.username}} @name="Username" @displayOnly={{true}} @allowCopy={{true}} />
</InfoTableRow>
<InfoTableRow @label="Password" @value={{@model.password}}>
<MaskedInput @value={{@model.password}} @name="Password" @displayOnly={{true}} @allowCopy={{true}} />
</InfoTableRow>
<InfoTableRow @label="Lease ID" @value={{@model.leaseId}} />
<InfoTableRow @label="Lease Duration" @value={{format-duration @model.leaseDuration}} />
{{/if}}
{{! STATIC ROLE }}
{{#if (and (eq @roleType "static") @model.username)}}
<InfoTableRow
@label="Last Vault rotation"
@value={{date-format @model.lastVaultRotation "MMMM d yyyy, h:mm:ss a"}}
@tooltipText={{@model.lastVaultRotation}}
@addCopyButton={{true}}
/>
<InfoTableRow @label="Password" @value={{@model.password}}>
<MaskedInput @value={{@model.password}} @name="Password" @displayOnly={{true}} @allowCopy={{true}} />
</InfoTableRow>
<InfoTableRow @label="Username" @value={{@model.username}} />
<InfoTableRow @label="Rotation Period" @value={{format-duration @model.rotationPeriod}} />
<InfoTableRow @label="Time Remaining" @value={{format-duration @model.ttl}} />
{{/if}}
</div>
<div class="has-top-bottom-margin">
<Hds::Button @text="Back" {{on "click" (action "redirectPreviousPage")}} />
</div>