Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated code mirror component for consistency #11500

Merged
merged 4 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions changelog/11500.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Updated ivy code mirror component for consistency
```
4 changes: 4 additions & 0 deletions ui/app/components/json-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const JSON_EDITOR_DEFAULTS = {
};

export default Component.extend({
showToolbar: true,
title: null,
subTitle: null,
helpText: null,
value: null,
options: null,
valueUpdated: null,
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/console/log-json.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="console-ui-output has-copy-button">
<JsonEditor @value={{stringify content}} @options={{hash
<JsonEditor @showToolbar={{false}} @value={{stringify content}} @options={{hash
readOnly=true
lineNumbers=false
autoHeight=true
Expand Down
1 change: 1 addition & 0 deletions ui/app/templates/components/control-group-success.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<div class="has-copy-button">
<JsonEditor
data-test-json-viewer
@showToolbar={{false}}
@value={{ stringify unwrapData }}
@options={{hash
readOnly=true
Expand Down
25 changes: 24 additions & 1 deletion ui/app/templates/components/json-editor.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
{{#if showToolbar }}
<Toolbar>
<label class="is-label" data-test-component="json-editor-title">
{{title}}
{{#if subTitle }}
<span class="is-size-9 is-lowercase has-text-grey">({{ subTitle }})</span>
{{/if}}
</label>
<ToolbarActions>
{{yield}}
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{value}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
{{/if}}
{{ivy-codemirror
data-test-component="json-editor"
value=value
options=options
valueUpdated=(action "updateValue")
onFocusOut=(action "onFocus")
}}
}}
{{#if helpText }}
<div class="box is-shadowless is-fullwidth has-short-padding">
<p class="sub-text">{{ helpText }}</p>
</div>
{{/if}}
19 changes: 4 additions & 15 deletions ui/app/templates/components/secret-edit-display.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,12 @@

{{#if @showAdvancedMode}}
<div class="form-section">
<Toolbar>
<label class="is-label">
{{ if isV2 "Version Data" "Secret Data" }}
</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{@codemirrorString}}
@buttonType="button" @success={{action (set-flash-message 'Secret data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<JsonEditor
<JsonEditor
@title={{if isV2 "Version Data" "Secret Data"}}
@value={{@codemirrorString}}
@valueUpdated={{action @editActions.codemirrorUpdated}}
@onFocusOut={{action @editActions.formatJSON}}
/>
@onFocusOut={{action @editActions.formatJSON}}>
</JsonEditor>
</div>
{{else}}
<div class="form-section">
Expand Down
14 changes: 1 addition & 13 deletions ui/app/templates/components/transit-key-action/decrypt.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,12 @@
<p>You can decrypt ciphertext using <code>{{key.name}}</code> as the encryption key.</p>
</div>
<div class="field">
<Toolbar>
<label for="ciphertext" class="is-label">Ciphertext</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{ciphertext}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div id="ciphertext-control" class="control">
<JsonEditor
@title="Ciphertext"
@valueUpdated={{action (mut ciphertext)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}}
@data-test-transit-input="ciphertext" />
</div>
Expand Down
16 changes: 1 addition & 15 deletions ui/app/templates/components/transit-key-action/encrypt.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,12 @@
</div>
<KeyVersionSelect @key={{key}} @onVersionChange={{action (mut key_version)}} @key_version={{key_version}} />
<div class="field">
<Toolbar>
<label for="plaintext" class="is-label">
Plaintext
</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{plaintext}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div id="plaintext-control" class="control is-relative">
<JsonEditor
@title="Plaintext"
@value={{plaintext}} @valueUpdated={{action (mut plaintext)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}}
@data-test-transit-input="plaintext" />
</div>
Expand Down
14 changes: 1 addition & 13 deletions ui/app/templates/components/transit-key-action/hmac.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,12 @@
</div>
<KeyVersionSelect @key={{key}} @onVersionChange={{action (mut key_version)}} @key_version={{key_version}} />
<div class="field">
<Toolbar>
<label for="input" class="is-label">Input</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{input}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div id="input-control" class="control is-relative">
<JsonEditor
@title="Input"
@valueUpdated={{action (mut input)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}}
@data-test-transit-input="input" />
</div>
Expand Down
14 changes: 1 addition & 13 deletions ui/app/templates/components/transit-key-action/rewrap.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,12 @@
</div>
<KeyVersionSelect @key={{key}} @onVersionChange={{action (mut key_version)}} @key_version={{key_version}} />
<div class="field">
<Toolbar>
<label for="ciphertext" class="is-label">Ciphertext</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{ciphertext}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div class="control is-expanded">
<JsonEditor
@title="Ciphertext"
@valueUpdated={{action (mut ciphertext)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}}
/>
</div>
Expand Down
9 changes: 1 addition & 8 deletions ui/app/templates/components/transit-key-action/sign.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@
</div>
<KeyVersionSelect @key={{key}} @onVersionChange={{action (mut key_version)}} @key_version={{key_version}} />
<div class="field">
<Toolbar>
<label for="input" class="is-label">
Input
</label>
</Toolbar>
<div class="control is-relative">
<JsonEditor
@title="Input"
@value={{input}}
@valueUpdated={{action (mut input)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}}
@data-test-transit-input="input" />
</div>
Expand Down
58 changes: 4 additions & 54 deletions ui/app/templates/components/transit-key-action/verify.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,12 @@
<p>Check whether the provided signature is valid for the given data.</p>
</div>
<div class="field">
<Toolbar>
<label class="is-label">
Input
</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{input}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div class="control is-relative">
<JsonEditor
@title="Input"
@value={{input}} @valueUpdated={{action (mut input)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}}
@data-test-transit-input="input" />
</div>
Expand Down Expand Up @@ -127,50 +113,26 @@
<div class="column is-two-thirds is-flex-column">
{{#if (or (and verification (eq verification 'HMAC')) hmac)}}
<div class="field is-flex-column is-flex-1">
<Toolbar>
<label class="is-label">HMAC</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{hmac}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div class="control is-flex-column is-flex-1">
<JsonEditor
@title="HMAC"
@value={{hmac}}
@valueUpdated={{action (mut hmac)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}}
/>
</div>
</div>
{{else}}
<div class="field is-flex-column is-flex-1">
<Toolbar>
<label class="is-label">Signature</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{signature}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div class="control is-flex-column is-flex-1">
<JsonEditor
@title="Signature"
@value={{signature}}
@valueUpdated={{action (mut signature)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}} />
</div>
</div>
Expand All @@ -179,25 +141,13 @@
</div>
{{else}}
<div class="field">
<Toolbar>
<label class="is-label">HMAC</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{hmac}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div class="control">
<JsonEditor
@title="HMAC"
@value={{hmac}}
@valueUpdated={{action (mut hmac)}}
@options={{hash
lineNumbers=true
tabSize=2
mode='ruby'
theme='hashi'
}}
/>
</div>
Expand Down
15 changes: 2 additions & 13 deletions ui/app/templates/partials/secret-form-show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,8 @@
{{else}}
{{#if showAdvancedMode}}
<div class="has-top-margin-s">
<Toolbar>
<label class="is-label">
{{ if isV2 "Version Data" "Secret Data" }}
</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{modelForData.dataAsJSONString}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<JsonEditor
<JsonEditor
@title={{if isV2 "Version Data" "Secret Data"}}
@value={{modelForData.dataAsJSONString}}
@options={{hash
readOnly=true
Expand Down
12 changes: 1 addition & 11 deletions ui/app/templates/partials/tools/unwrap.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,8 @@
</nav>
{{#if (eq unwrapActiveTab "data")}}
<div class="field">
<Toolbar>
<label class="is-label">Unwrapped Data</label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{stringify unwrap_data}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div class="control">
<JsonEditor @value={{stringify unwrap_data}} @options={{hash
<JsonEditor @title="Unwrapped Data" @value={{stringify unwrap_data}} @options={{hash
readOnly=true
}} />
</div>
Expand Down
15 changes: 4 additions & 11 deletions ui/app/templates/partials/tools/wrap.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,11 @@
<NamespaceReminder @mode="perform" @noun={{selectedAction}} />
<MessageError @errors={{errors}} />
<div class="field">
<Toolbar>
<label for="data" class="is-label">Data to wrap <span class="is-size-9 is-lowercase has-text-grey">(json-formatted)</span></label>
<ToolbarActions>
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{data}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
<div class="control">
<JsonEditor @value={{data}} @valueUpdated={{action "codemirrorUpdated"}} />
<JsonEditor @title="Data to wrap"
@subTitle="json-formatted"
@value={{data}}
@valueUpdated={{action "codemirrorUpdated"}} />
</div>
</div>
<TtlPicker2
Expand Down
Loading