-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
index.hbs
109 lines (107 loc) · 5.52 KB
/
index.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
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<DataSource @src={{uri '/${partition}/${nspace}/${dc}/policy/00000000-0000-0000-0000-000000000002'
(hash dc=@dc partition=@partition nspace=@nspace) }} as |globalReadonlyPolicy|>
<Hds::Modal id="link-to-hcp-modal" class="link-to-hcp-modal" data-test-link-to-hcp-modal
@onClose={{fn this.deactivateModal}} as |M|>
<M.Header>
Link to HCP Consul Central
</M.Header>
<M.Body>
{{#if (not (can "read acls"))}}
<Hds::Alert class="link-to-hcp-modal__no-acls-alert" @type="inline" @color="critical" data-test-link-to-hcp-modal-no-acls-alert as |A|>
<A.Title>ACLs are disabled on this cluster.</A.Title>
<A.Description>The cluster can only be linked with read/write access.</A.Description>
</Hds::Alert>
{{/if}}
<Hds::Form::Radio::Group data-test-link-to-hcp-modal-access-level-options @layout="vertical" @name="accessMode" as
|G|>
<G.Legend>Select cluster access mode before linking</G.Legend>
<G.HelperText>Control the level of access that HCP Consul Central has to your linked cluster.
<Hds::Link::Inline @href="https://developer.hashicorp.com/consul/docs/security/acl" @isHrefExternal={{true}}
@color="secondary">Learn more
</Hds::Link::Inline>
</G.HelperText>
<G.Radio::Field @id="accessMode-management" checked @value={{this.AccessLevel.GLOBALREADWRITE}} {{on "change"
this.onAccessModeChanged}}
as |F|>
<F.Label>Read/write</F.Label>
<F.HelperText>HCP Consul Central can perform write operations on your cluster (i.e. cluster peering).
</F.HelperText>
</G.Radio::Field>
<G.Radio::Field @id="accessMode-readonly" @value={{this.AccessLevel.GLOBALREADONLY}} {{on "change"
this.onAccessModeChanged}}
as |F|>
<F.Label>Read-only</F.Label>
<F.HelperText>HCP Consul Central can only read information from your cluster. Read-only requires an ACL token
with the “builtin/global-read-only” policy in the next step.
</F.HelperText>
</G.Radio::Field>
{{#if (and this.isReadOnlyAccessLevelSelected (not (can "read acls")))}}
<G.Error data-test-link-to-hcp-modal-access-level-options-error>ACLs are disabled on this cluster and are required for read-only access.</G.Error>
{{/if}}
</Hds::Form::Radio::Group>
{{#if (and this.isReadOnlyAccessLevelSelected (can "read acls") (can "create tokens"))}}
<div class="link-to-hcp-modal__generate-token">
{{#if globalReadonlyPolicy.data}}
<p class="hds-typography-display-100 hds-font-weight-medium font-family-sans-display">
Generate a read-only ACL token now (preferred) or copy an existing token’s secret ID
</p>
{{#if this.isTokenGenerated}}
<Hds::Card::Container data-test-link-to-hcp-modal-generate-token-card
class="link-to-hcp-modal__generate-token__copy-card"
@level="mid"
@hasBorder={{true}}>
<div>
<p class="hds-font-weight-semibold">Token secret ID</p>
<p class="hds-typography-code-200 link-to-hcp-modal__generate-token__copy-card__token"
data-test-link-to-hcp-modal-generate-token-card-value
id="tokenSecretId">
{{this.token}}
</p>
</div>
<Hds::Copy::Button
@text="Copy"
data-test-link-to-hcp-modal-generate-token-card-copy-button
@isIconOnly={{true}}
@targetToCopy="#tokenSecretId" />
</Hds::Card::Container>
{{else}}
<div>
<Hds::Button
data-test-link-to-hcp-modal-generate-token-button
@color="tertiary"
@text={{if this.isGeneratingToken "Generating token" "Generate a read-only ACL token"}}
@icon={{if this.isGeneratingToken "loading" "token"}}
@disabled={{this.isGeneratingToken}}
{{on "click" (fn this.onGenerateTokenClicked globalReadonlyPolicy)}}
/>
</div>
{{/if}}
{{else}}
<Hds::Alert @type="compact" data-test-link-to-hcp-modal-missed-policy-alert as |A|>
<A.Description>Could not generate token.</A.Description>
</Hds::Alert>
{{/if}}
</div>
{{/if}}
</M.Body>
<M.Footer as |F|>
<Hds::ButtonSet>
<Hds::Button type="button"
@text="Next: Authenticate into HCP"
@icon="external-link"
@iconPosition="trailing"
data-test-link-to-hcp-modal-next-button
@href={{hcp-authentication-link this.hcpLinkModal.resourceId this.accessLevel}}
/>
<Hds::Button type="button" @text="Cancel" @color="secondary"
data-test-link-to-hcp-modal-cancel-button
{{on "click" F.close}}
/>
</Hds::ButtonSet>
</M.Footer>
</Hds::Modal>
</DataSource>