-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6be041
commit 7fa427f
Showing
4 changed files
with
98 additions
and
64 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
ui/app/components/secret-engine/configurable-secret-engine-details.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{{! | ||
Copyright (c) HashiCorp, Inc. | ||
SPDX-License-Identifier: BUSL-1.1 | ||
~}} | ||
|
||
{{#if this.configError}} | ||
<EmptyState data-test-config-error={{@model.id}} @title="Something went wrong" @message={{this.configError}} /> | ||
{{else if this.configModel}} | ||
{{#each this.configModel.attrs as |attr|}} | ||
{{#if attr.options.sensitive}} | ||
<InfoTableRow | ||
alwaysRender={{(not (is-empty-value (get @model attr.name)))}} | ||
@label={{or attr.options.label (to-label attr.name)}} | ||
@value={{get this.configModel (or attr.options.fieldValue attr.name)}} | ||
> | ||
<MaskedInput @value={{get @model attr.name}} @name={{attr.name}} @displayOnly={{true}} @allowCopy={{true}} /> | ||
</InfoTableRow> | ||
{{else}} | ||
<InfoTableRow | ||
@alwaysRender={{(not (is-empty-value (get @model attr.name)))}} | ||
@label={{or attr.options.label (to-label attr.name)}} | ||
@value={{get this.configModel (or attr.options.fieldValue attr.name)}} | ||
/> | ||
{{/if}} | ||
{{/each}} | ||
{{else}} | ||
<EmptyState | ||
data-test-config-cta | ||
@title="{{this.typeDisplay}} not configured" | ||
@message="Get started by setting up the connection with your existing {{this.typeDisplay}} account." | ||
> | ||
<Hds::Link::Standalone | ||
@icon="chevron-right" | ||
@iconPosition="trailing" | ||
@text="Configure {{this.typeDisplay}}" | ||
@route="vault.cluster.settings.configure-secret-backend" | ||
@model={{@model.id}} | ||
/> | ||
</EmptyState> | ||
{{/if}} |
57 changes: 57 additions & 0 deletions
57
ui/app/components/secret-engine/configurable-secret-engine-details.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import errorMessage from 'vault/utils/error-message'; | ||
import { tracked } from '@glimmer/tracking'; | ||
// ARG TODO add documentation | ||
export default class ConfigurableSecretEngineDetails extends Component { | ||
@service store; | ||
@tracked configModel = null; | ||
@tracked configError = null; | ||
|
||
constructor() { | ||
super(...arguments); | ||
const { model } = this.args; | ||
// Currently two secret engines that return configuration data and that can be configured by the user on the ui: aws, and ssh. | ||
if (model.type === 'aws') { | ||
this.fetchAwsRootConfig(model.id); | ||
} | ||
if (model.type === 'ssh') { | ||
this.fetchSshCaConfig(model.id); | ||
} | ||
} | ||
|
||
async fetchAwsRootConfig(backend) { | ||
try { | ||
this.configModel = await this.store.queryRecord('aws/root-config', { backend }); | ||
} catch (e) { | ||
this.configError = errorMessage(e); | ||
} | ||
} | ||
|
||
async fetchSshCaConfig(backend) { | ||
try { | ||
this.configModel = await this.store.queryRecord('ssh/ca-config', { backend }); | ||
} catch (e) { | ||
this.configError = errorMessage(e); | ||
} | ||
} | ||
|
||
get typeDisplay() { | ||
// TODO will eventually handle GCP and Azure. | ||
// Did not use capitalize helper because some are all caps and some only title case. | ||
const { type } = this.args.model; | ||
switch (type) { | ||
case 'aws': | ||
return 'AWS'; | ||
case 'ssh': | ||
return 'SSH'; | ||
default: | ||
return type; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters