Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a9552e5
Completed initial replacement of editor
zamoore Mar 17, 2025
f035745
fixing ts issues
zamoore Apr 4, 2025
fd8810c
removing codemirror modifier and deps
zamoore Apr 4, 2025
90c6b94
working on replacing the code editor
zamoore Apr 14, 2025
a55a785
addressing linting concerns
zamoore Apr 14, 2025
058a6da
cleaning up policy-form editor
zamoore Apr 15, 2025
710db1f
fixing linting issues
zamoore Apr 15, 2025
788351d
fixing linting issues
zamoore Apr 15, 2025
ab41216
fixing tests
zamoore Apr 16, 2025
970a50b
fixing tests
zamoore Apr 16, 2025
d824721
fixing tests
zamoore Apr 17, 2025
6eb0e95
fixing tests
zamoore Apr 18, 2025
aa06fa5
fixing failing tests
zamoore Apr 18, 2025
a55494a
cleaning up PR
zamoore Apr 21, 2025
a37e420
fixing tests
zamoore Apr 21, 2025
6fe902e
remove outdated message for navigating editor
lane-wetmore Jul 3, 2025
f64f4d9
fix linting in tests
lane-wetmore Jul 3, 2025
0489e7b
add changelog
lane-wetmore Jul 3, 2025
c013ff1
fix tests
lane-wetmore Jul 7, 2025
ff7d6f7
update naming
lane-wetmore Jul 9, 2025
28fc510
remove unused lint param + name changes
lane-wetmore Jul 9, 2025
5040569
Merge branch 'main' into zamoore/hds-4340/code-editor
lane-wetmore Jul 10, 2025
7f05692
update test selector usage
lane-wetmore Jul 11, 2025
85d27cf
update test selector usage
lane-wetmore Jul 11, 2025
6418171
update test selector usage
lane-wetmore Jul 11, 2025
320fd17
Merge branch 'main' into zamoore/hds-4340/code-editor
lane-wetmore Jul 11, 2025
06ba13c
lint fixes
lane-wetmore Jul 14, 2025
52bbfc2
replace page object selectors
lane-wetmore Jul 16, 2025
c68aea3
Merge branch 'main' into zamoore/hds-4340/code-editor
lane-wetmore Jul 16, 2025
24edd33
lint fix
lane-wetmore Jul 16, 2025
cae9da3
fix lint
lane-wetmore Jul 16, 2025
70f4b40
Merge branch 'main' into zamoore/hds-4340/code-editor
lane-wetmore Jul 21, 2025
3e60df5
fix lint after merge
lane-wetmore Jul 21, 2025
66082b3
update tests
lane-wetmore Jul 22, 2025
6a96601
remove import
lane-wetmore Jul 22, 2025
2dd22cd
remove await settled
lane-wetmore Jul 23, 2025
55f8629
lint
lane-wetmore Jul 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/30188.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Use the Helios Design System Code Block component for all readonly code editors and use its Code Editor component for all other code editors
```
10 changes: 5 additions & 5 deletions ui/app/components/generate-credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ export default class GenerateCredentials extends Component {
}

@action
codemirrorUpdated(attr, val, codemirror) {
codemirror.performLint();
const hasErrors = codemirror.state.lint.marked.length > 0;

if (!hasErrors) {
editorUpdated(attr, val) {
// wont set invalid JSON to the model
try {
this.model[attr] = JSON.parse(val);
} catch {
// linting is handled by the component
}
}

Expand Down
29 changes: 4 additions & 25 deletions ui/app/components/policy-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
</div>
{{/if}}
<div class="field">
{{#unless this.showFileUpload}}
<span class="is-size-9 has-text-grey has-bottom-margin-l has-top-margin-xs" data-test-alt-tab-message>
You can use Alt+Tab (Option+Tab on MacOS) in the code editor to skip to the next field.
</span>
{{/unless}}
<Toolbar aria-label="toolbar for managing {{or @model.name 'new'}} policy">
<label class="has-text-weight-bold has-right-margin-4">Policy</label>
{{#if @renderPolicyExampleModal}}
{{! only true in policy create and edit routes }}
<ToolbarFilters aria-label="help tools for managing {{or @model.name 'new'}} policy">
Expand All @@ -43,9 +37,8 @@
/>
</ToolbarFilters>
{{/if}}
<ToolbarActions aria-label="actions for managing {{or @model.name 'new'}} policy">
<div class="toolbar-separator"></div>
{{#if @model.isNew}}
{{#if @model.isNew}}
<ToolbarActions aria-label="actions for managing {{or @model.name 'new'}} policy">
<div class="control is-flex">
<Input
id="fileUploadToggle"
Expand All @@ -58,20 +51,8 @@
/>
<label for="fileUploadToggle" class="has-text-weight-bold is-size-8">Upload file</label>
</div>
{{else}}
{{! EDITING - no file upload toggle}}
<Hds::Copy::Button
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{@model.policy}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. The Clipboard API requires a secure context." "danger")
)}}
class="transparent"
data-test-copy-button
/>
{{/if}}
</ToolbarActions>
</ToolbarActions>
{{/if}}
</Toolbar>
{{#if this.showFileUpload}}
<div class="has-top-margin-xs">
Expand All @@ -80,15 +61,13 @@
{{else}}
<JsonEditor
@title="Policy"
@showToolbar={{false}}
@value={{@model.policy}}
@valueUpdated={{action (mut @model.policy)}}
@mode="ruby"
@extraKeys={{hash Shift-Enter=(perform this.save)}}
data-test-policy-editor
/>
{{/if}}

</div>
{{#each @model.additionalAttrs as |attr|}}
<FormField data-test-field={{true}} @attr={{attr}} @model={{@model}} />
Expand Down
12 changes: 6 additions & 6 deletions ui/app/components/role-aws-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export default RoleEdit.extend({
});
},

codemirrorUpdated(attr, val, codemirror) {
codemirror.performLint();
const hasErrors = codemirror.state.lint.marked.length > 0;

if (!hasErrors) {
set(this.model, attr, val);
editorUpdated(attr, val) {
// wont set invalid JSON to the model
try {
set(this.model, attr, JSON.parse(val));
} catch {
// linting is handled by the component
}
},
},
Expand Down
10 changes: 5 additions & 5 deletions ui/app/components/role-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ export default Component.extend(FocusOnInsertMixin, {
});
},

codemirrorUpdated(attr, val, codemirror) {
codemirror.performLint();
const hasErrors = codemirror.state.lint.marked.length > 0;

if (!hasErrors) {
editorUpdated(attr, val) {
// wont set invalid JSON to the model
try {
set(this.model, attr, JSON.parse(val));
} catch {
// linting is handled by the component
}
},
},
Expand Down
34 changes: 18 additions & 16 deletions ui/app/components/secret-create-or-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const LIST_ROOT_ROUTE = 'vault.cluster.secrets.backend.list-root';
const SHOW_ROUTE = 'vault.cluster.secrets.backend.show';

export default class SecretCreateOrUpdate extends Component {
@tracked codemirrorString = null;
@tracked editorString = null;
@tracked error = null;
@tracked secretPaths = null;
@tracked pathWhiteSpaceWarning = false;
Expand All @@ -58,7 +58,7 @@ export default class SecretCreateOrUpdate extends Component {

@action
setup(elem, [secretData, mode]) {
this.codemirrorString = secretData.toJSONString();
this.editorString = secretData.toJSONString();
this.validationMessages = {
path: '',
};
Expand Down Expand Up @@ -160,21 +160,19 @@ export default class SecretCreateOrUpdate extends Component {
}
this.checkRows();
}

@action
codemirrorUpdated(val, codemirror) {
this.error = null;
codemirror.performLint();
const noErrors = codemirror.state.lint.marked.length === 0;
if (noErrors) {
try {
this.args.secretData.fromJSONString(val);
set(this.args.modelForData, 'secretData', this.args.secretData.toJSON());
} catch (e) {
this.error = e.message;
}
editorUpdated(val) {
try {
this.args.secretData.fromJSONString(val);
set(this.args.modelForData, 'secretData', this.args.secretData.toJSON());
} catch (e) {
this.error = e.message;
}
this.codemirrorString = val;

this.editorString = val;
}

@action
createOrUpdateKey(type, event) {
event.preventDefault();
Expand Down Expand Up @@ -204,21 +202,25 @@ export default class SecretCreateOrUpdate extends Component {
this.checkRows();
this.handleChange();
}

@action
formatJSON() {
this.codemirrorString = this.args.secretData.toJSONString(true);
this.editorString = this.args.secretData.toJSONString(true);
}

@action
handleMaskedInputChange(secret, index, value) {
const row = { ...secret, value };
set(this.args.secretData, index, row);
this.handleChange();
}

@action
handleChange() {
this.codemirrorString = this.args.secretData.toJSONString(true);
this.editorString = this.args.secretData.toJSONString(true);
set(this.args.modelForData, 'secretData', this.args.secretData.toJSON());
}

@action
updateValidationErrorCount(errorCount) {
this.validationErrorCount = errorCount;
Expand Down
4 changes: 2 additions & 2 deletions ui/app/components/secret-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export default class SecretEdit extends Component {
@service store;

@tracked secretData = null;
@tracked codemirrorString = null;
@tracked editorString = null;

// fired on did-insert from render modifier
@action
createKvData(elem, [model]) {
this.secretData = KVObject.create({ content: [] }).fromJSON(model.secretData);
this.codemirrorString = this.secretData.toJSONString();
this.editorString = this.secretData.toJSONString();
}
// TODO move this to the secret model
@maybeQueryRecord(
Expand Down
2 changes: 1 addition & 1 deletion ui/app/components/tools/wrap.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
@title="Data to wrap"
@subTitle="json-formatted"
@value={{this.stringifiedWrapData}}
@valueUpdated={{this.codemirrorUpdated}}
@valueUpdated={{this.editorUpdated}}
/>
{{else}}
<KvObjectEditor
Expand Down
13 changes: 8 additions & 5 deletions ui/app/components/tools/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type ApiService from 'vault/services/api';
import type FlashMessageService from 'vault/services/flash-messages';
import type { TtlEvent } from 'vault/app-types';
import type { HTMLElementEvent } from 'vault/forms';
import type { Editor } from 'codemirror';

/**
* @module ToolsWrap
Expand Down Expand Up @@ -68,10 +67,14 @@ export default class ToolsWrap extends Component {
}

@action
codemirrorUpdated(val: string, codemirror: Editor) {
codemirror.performLint();
this.hasLintingErrors = codemirror?.state.lint.marked?.length > 0;
if (!this.hasLintingErrors) this.wrapData = JSON.parse(val);
editorUpdated(val: string) {
this.hasLintingErrors = false;

try {
this.wrapData = JSON.parse(val);
} catch {
this.hasLintingErrors = true;
}
}

@action
Expand Down
10 changes: 5 additions & 5 deletions ui/app/controllers/vault/cluster/secrets/backend/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export default Controller.extend({
});
},

codemirrorUpdated(attr, val, codemirror) {
codemirror.performLint();
const hasErrors = codemirror.state.lint.marked.length > 0;

if (!hasErrors) {
editorUpdated(attr, val) {
// wont set invalid JSON to the model
try {
set(this.model, attr, JSON.parse(val));
} catch {
// linting is handled by the component
}
},

Expand Down
Loading
Loading