-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathgenerate-credentials.hbs
142 lines (140 loc) · 4.93 KB
/
generate-credentials.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<PageHeader as |p|>
<p.top>
<Hds::Breadcrumb>
<Hds::Breadcrumb::Item
@text={{@backendPath}}
@route="vault.cluster.secrets.backend"
@model={{@backendPath}}
data-test-link="role-list"
/>
<Hds::Breadcrumb::Item @text="Credentials" @route="vault.cluster.secrets.backend" @model={{@backendPath}} />
<Hds::Breadcrumb::Item @text={{@roleName}} @route="vault.cluster.secrets.backend.show" @model={{@roleName}} />
<Hds::Breadcrumb::Item @text={{this.options.title}} @current={{true}} />
</Hds::Breadcrumb>
</p.top>
<p.levelLeft>
<h1 data-test-title class="title is-3">
{{this.options.title}}
</h1>
</p.levelLeft>
</PageHeader>
{{#if this.hasGenerated}}
<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
<MessageError @model={{this.model}} />
{{#unless this.model.isError}}
<Hds::Alert @type="inline" @color="warning" class="has-top-bottom-margin" data-test-warning as |A|>
<A.Title>Warning</A.Title>
<A.Description>
You will not be able to access this information later, so please copy the information below.
</A.Description>
</Hds::Alert>
{{/unless}}
{{#each this.displayFields as |key|}}
{{#let (get this.model.allByKey key) as |attr|}}
{{#if (eq attr.type "object")}}
<InfoTableRow
@label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
@value={{stringify (get this.model attr.name)}}
/>
{{else}}
{{#if attr.options.masked}}
{{#if (get this.model attr.name)}}
<InfoTableRow
@label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
@value={{get this.model attr.name}}
>
<MaskedInput
@value={{get this.model attr.name}}
@name={{attr.name}}
@displayOnly={{true}}
@allowCopy={{true}}
/>
</InfoTableRow>
{{/if}}
{{else if (and (get this.model attr.name) (or (eq attr.name "issueDate") (eq attr.name "expiryDate")))}}
<InfoTableRow
data-test-table-row
@label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
@value={{date-format (get this.model attr.name) "MMM dd, yyyy hh:mm:ss a"}}
/>
{{else}}
<InfoTableRow
@label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
@value={{get this.model attr.name}}
/>
{{/if}}
{{/if}}
{{/let}}
{{/each}}
</div>
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<Hds::Copy::Button
@text="Copy credentials"
@textToCopy={{this.model.toCreds}}
@onError={{(fn (set-flash-message "Clipboard copy failed. The Clipboard API requires a secure context." "danger"))}}
class="primary"
/>
</div>
{{#if this.model.leaseId}}
<div class="control">
<Hds::Copy::Button
@text="Copy Lease ID"
@textToCopy={{this.model.leaseId}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. The Clipboard API requires a secure context." "danger")
)}}
class="secondary"
/>
</div>
{{/if}}
<div class="control">
{{#if this.options.backIsListLink}}
<Hds::Button
@text="Back"
@color="secondary"
@route="vault.cluster.secrets.backend.list-root"
@model={{@backendPath}}
data-test-back-button
/>
{{else}}
<Hds::Button @text="Back" @color="secondary" {{on "click" this.reset}} data-test-back-button />
{{/if}}
</div>
</div>
{{else}}
<form {{on "submit" this.create}} data-test-secret-generate-form>
<div class="box is-sideless no-padding-top is-fullwidth is-marginless">
<NamespaceReminder @mode="generate" @noun="credential" />
<MessageError @model={{this.model}} />
{{#if this.helpText}}
<p class="is-hint">{{this.helpText}}</p>
{{/if}}
{{#each this.formFields as |key|}}
<FormField data-test-field @attr={{get this.model.allByKey key}} @model={{this.model}} />
{{/each}}
</div>
<div class="field is-grouped box is-fullwidth is-bottomless">
<Hds::ButtonSet>
<Hds::Button
@text="Generate"
@icon={{if this.loading "loading"}}
type="submit"
disabled={{this.loading}}
data-test-save
/>
<Hds::Button
@text="Cancel"
@route="vault.cluster.secrets.backend.list-root"
@color="secondary"
@model={{@backendPath}}
data-test-cancel
/>
</Hds::ButtonSet>
</div>
</form>
{{/if}}