Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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) {
codemirrorUpdated(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
24 changes: 4 additions & 20 deletions ui/app/components/policy-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
</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 +42,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 +56,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 +66,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);
codemirrorUpdated(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) {
codemirrorUpdated(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
20 changes: 9 additions & 11 deletions ui/app/components/secret-create-or-update.js
Original file line number Diff line number Diff line change
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;
}
codemirrorUpdated(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;
}

@action
createOrUpdateKey(type, event) {
event.preventDefault();
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);
codemirrorUpdated(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) {
codemirrorUpdated(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
195 changes: 0 additions & 195 deletions ui/app/styles/components/codemirror.scss

This file was deleted.

Loading
Loading