Skip to content

Commit 7ed09e6

Browse files
committed
replaced instances of code-mirror modifier with hds-code-editor modifier
1 parent 4963a6e commit 7ed09e6

13 files changed

+75
-104
lines changed

ui/app/components/namespace-editor.hbs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@
2525
class="namespace-editor-wrapper boxed-section-body is-full-bleed
2626
{{if this.JSONError 'error'}}"
2727
>
28+
{{!-- TODO: Needs to support extraKeys=(hash Cmd-Enter=this.save) --}}
2829
<div
2930
class="namespace-editor"
3031
data-test-namespace-editor
31-
{{code-mirror
32-
screenReaderLabel="Namespace definition"
33-
theme="hashi"
34-
mode="javascript"
35-
content=this.definitionString
36-
onUpdate=this.updateNamespaceDefinition
37-
autofocus=false
38-
extraKeys=(hash Cmd-Enter=this.save)
32+
{{hds-code-editor
33+
ariaLabel="Namespace definition"
34+
language="javascript"
35+
value=this.definitionString
36+
onInput=this.updateNamespaceDefinition
3937
}}
4038
/>
4139
{{#if this.JSONError}}

ui/app/components/namespace-editor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ export default class NamespaceEditorComponent extends Component {
4141
}
4242

4343
@action async save(e) {
44-
if (e instanceof Event) {
45-
e.preventDefault(); // code-mirror "command+enter" submits the form, but doesnt have a preventDefault()
46-
}
44+
e?.preventDefault(); // code-mirror "command+enter" submits the form, but doesnt have a preventDefault()
45+
4746
try {
4847
this.deserializeDefinitionJson(JSON.parse(this.definitionString));
4948

ui/app/components/policy-editor.hbs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@
2222
</div>
2323
<div class="boxed-section-body is-full-bleed">
2424

25+
{{!-- TODO: extraKeys=(hash Cmd-Enter=this.save) --}}
2526
<div
2627
class="policy-editor"
2728
data-test-policy-editor
28-
{{code-mirror
29-
screenReaderLabel="Policy definition"
30-
theme="hashi"
31-
mode="ruby"
32-
content=@policy.rules
33-
onUpdate=this.updatePolicyRules
34-
autofocus=false
35-
extraKeys=(hash Cmd-Enter=this.save)
36-
}} />
29+
{{hds-code-editor
30+
ariaLabel="Policy definition"
31+
language="ruby"
32+
value=@policy.rules
33+
onInput=this.updatePolicyRules
34+
}}
35+
/>
3736
</div>
3837
</div>
3938

ui/app/components/policy-editor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ export default class PolicyEditorComponent extends Component {
2525
}
2626

2727
@action async save(e) {
28-
if (e instanceof Event) {
29-
e.preventDefault(); // code-mirror "command+enter" submits the form, but doesnt have a preventDefault()
30-
}
28+
e?.preventDefault(); // code-mirror "command+enter" submits the form, but doesnt have a preventDefault()
29+
3130
try {
3231
const nameRegex = '^[a-zA-Z0-9-]{1,128}$';
3332
if (!this.policy.name?.match(nameRegex)) {

ui/app/components/role-editor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ export default class RoleEditorComponent extends Component {
4141
}
4242

4343
@action async save(e) {
44-
if (e instanceof Event) {
45-
e.preventDefault(); // code-mirror "command+enter" submits the form, but doesnt have a preventDefault()
46-
}
44+
e?.preventDefault(); // code-mirror "command+enter" submits the form, but doesnt have a preventDefault()
45+
4746
try {
4847
const nameRegex = '^[a-zA-Z0-9-]{1,128}$';
4948
if (!this.role.name?.match(nameRegex)) {

ui/app/components/sentinel-policy-editor.hbs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@
2121
Policy Definition
2222
</div>
2323
<div class="boxed-section-body is-full-bleed">
24+
{{!-- TODO: extraKeys=(hash Cmd-Enter=this.save) --}}
2425
<div
2526
class="policy-editor"
2627
data-test-policy-editor
27-
{{code-mirror
28-
screenReaderLabel="Policy definition"
29-
theme="hashi"
30-
mode="ruby"
31-
content=@policy.policy
32-
onUpdate=this.updatePolicy
33-
autofocus=false
34-
extraKeys=(hash Cmd-Enter=this.save)
35-
}} />
28+
{{hds-code-editor
29+
ariaLabel="Policy definition"
30+
language="ruby"
31+
value=@policy.policy
32+
onInput=this.updatePolicy
33+
}}
34+
/>
3635
</div>
3736
</div>
3837

ui/app/components/sentinel-policy-editor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ export default class SentinelPolicyEditorComponent extends Component {
3131
}
3232

3333
@action async save(e) {
34-
if (e instanceof Event) {
35-
e.preventDefault(); // code-mirror "command+enter" submits the form, but doesnt have a preventDefault()
36-
}
34+
e?.preventDefault(); // code-mirror "command+enter" submits the form, but doesnt have a preventDefault()
35+
3736
try {
3837
const nameRegex = '^[a-zA-Z0-9-]{1,128}$';
3938
if (!this.policy.name?.match(nameRegex)) {

ui/app/components/variable-form.hbs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@
117117
class="editor-wrapper boxed-section-body is-full-bleed
118118
{{if this.JSONError 'error'}}"
119119
>
120+
{{!-- TODO: extraKeys=(hash Cmd-Enter=(action "save")) --}}
120121
<div
121122
data-test-json-editor
122-
{{code-mirror
123-
content=this.JSONItems
124-
onUpdate=this.updateCode
125-
extraKeys=(hash Cmd-Enter=(action "save"))
123+
{{hds-code-editor
124+
value=this.JSONItems
125+
onInput=this.updateCode
126126
}}
127-
></div>
127+
/>
128128
{{#if this.JSONError}}
129129
<p class="help is-danger">
130130
{{this.JSONError}}

ui/app/components/variable-form/job-template-editor.hbs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@
2525
</span>
2626
<div
2727
data-test-template-json
28-
{{code-mirror
29-
theme="hashi"
30-
mode="ruby"
31-
autofocus=false
32-
content=this.template
33-
onUpdate=(action this.updateTemplate)
28+
{{hds-code-editor
29+
language="ruby"
30+
value=this.template
31+
onInput=this.updateTemplate
3432
}}
3533
></div>
3634
</label>

ui/app/templates/components/job-dispatch.hbs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@
5555
<div class="boxed-section-body is-full-bleed">
5656
<div
5757
data-test-payload-editor
58-
{{code-mirror
59-
theme="hashi"
60-
onUpdate=(action (mut this.payload))
61-
mode="javascript"
62-
screenReaderLabel="Payload definition"
58+
{{hds-code-editor
59+
language="javascript"
60+
ariaLabel="Payload definition"
61+
onInput=(fn (mut this.payload))
6362
}}
6463
/>
6564
</div>

ui/app/templates/components/job-editor/edit.hbs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,12 @@
125125
<div class="boxed-section-body is-full-bleed">
126126
<div
127127
data-test-editor
128-
{{code-mirror
129-
screenReaderLabel="Job definition"
130-
content=@data.job._newDefinition
131-
theme="hashi"
132-
onUpdate=@fns.onUpdate
133-
mode=(if (eq @data.format "json") "javascript" "ruby")
134-
lineWrapping=@data.shouldWrap
128+
{{hds-code-editor
129+
ariaLabel="Job definition"
130+
value=@data.job._newDefinition
131+
onInput=@fns.onUpdate
132+
language=(if (eq @data.format "json") "javascript" "ruby")
133+
hasLineWrapping=@data.shouldWrap
135134
}}
136135
></div>
137136
</div>
@@ -148,15 +147,12 @@
148147
<div
149148
class="json-viewer is-variable-editor"
150149
data-test-variable-editor
151-
{{code-mirror
152-
autofocus=false
153-
screenReaderLabel="HLC Variables for Job Spec"
154-
content=@data.job._newDefinitionVariables
155-
theme="hashi"
156-
onUpdate=@fns.onUpdate
157-
type="hclVariables"
158-
mode="ruby"
159-
lineWrapping=@data.shouldWrap
150+
{{hds-code-editor
151+
ariaLabel="HLC Variables for Job Spec"
152+
value=@data.job._newDefinitionVariables
153+
language="ruby"
154+
hasLineWrapping=@data.shouldWrap
155+
onInput=@fns.onUpdate
160156
}}
161157
></div>
162158
</div>

ui/app/templates/components/job-editor/read.hbs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,20 @@
5050
</div>
5151
<div class="boxed-section-body is-full-bleed">
5252
{{#if (eq @data.view "job-spec")}}
53-
<div
53+
<Hds::CodeBlock
5454
data-test-job-spec-view
55-
{{code-mirror
56-
content=@data.definition
57-
mode=(if (eq @data.format "json") "javascript" "ruby")
58-
readOnly=true
59-
screenReaderLabel="Job specification"
60-
theme="hashi-read-only"
61-
lineWrapping=@data.shouldWrap
62-
}}
55+
aria-label="Job specification"
56+
@value={{@data.Definition}}
57+
@language={{if (eq @data.format "json") "javascript" "ruby"}}
58+
@hasLineWrapping={{@data.shouldWrap}}
6359
/>
6460
{{else}}
65-
<div
61+
<Hds::CodeBlock
6662
data-test-json-viewer
67-
{{code-mirror
68-
content=@data.definition
69-
theme="hashi-read-only"
70-
readOnly=true
71-
screenReaderLabel="JSON Viewer"
72-
lineWrapping=@data.shouldWrap
73-
}}
63+
aria-label="JSON Viewer"
64+
@value={{@data.Definition}}
65+
@language="json"
66+
@hasLineWrapping={{@data.shouldWrap}}
7467
/>
7568
{{/if}}
7669
</div>
@@ -80,17 +73,13 @@
8073
HCL Variable Values
8174
</div>
8275
<div class="boxed-section-body is-full-bleed">
83-
<div
76+
<Hds::CodeBlock
8477
class="json-viewer is-variable-editor"
8578
data-test-variable-editor
86-
{{code-mirror
87-
screenReaderLabel="HLC Variables for Job Spec"
88-
content=@data.job._newDefinitionVariables
89-
mode="ruby"
90-
theme="hashi-read-only"
91-
readOnly=true
92-
lineWrapping=@data.shouldWrap
93-
}}
79+
aria-label="HLC Variables for Job Spec"
80+
@value={{@data.job._newDefinitionVariables}}
81+
@language="ruby"
82+
@hasLineWrapping={{@data.shouldWrap}}
9483
/>
9584
</div>
9685
</div>

ui/app/templates/components/json-viewer.hbs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
SPDX-License-Identifier: BUSL-1.1
44
~}}
55

6-
<div
6+
<Hds::CodeBlock
77
data-test-json-viewer
8-
{{code-mirror
9-
content=(stringify-object @json)
10-
theme="hashi-read-only"
11-
readOnly=true
12-
screenReaderLabel="JSON Viewer"
13-
}}
14-
/>
8+
aria-label="JSON Viewer"
9+
@language="json"
10+
@value={{stringify-object @json}}
11+
/>

0 commit comments

Comments
 (0)