-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4541 from hashicorp/f-ui-new-json-viewer
UI: New JSON viewer
- Loading branch information
Showing
13 changed files
with
163 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,11 @@ | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import { run } from '@ember/runloop'; | ||
import { copy } from '@ember/object/internals'; | ||
import JSONFormatter from 'json-formatter-js'; | ||
|
||
export default Component.extend({ | ||
classNames: ['json-viewer'], | ||
|
||
json: null, | ||
expandDepth: Infinity, | ||
|
||
formatter: computed('json', 'expandDepth', function() { | ||
return new JSONFormatter(copy(this.get('json'), true), this.get('expandDepth'), { | ||
theme: 'nomad', | ||
}); | ||
jsonStr: computed('json', function() { | ||
return JSON.stringify(this.get('json'), null, 2); | ||
}), | ||
|
||
didReceiveAttrs() { | ||
const json = this.get('json'); | ||
if (!json) { | ||
return; | ||
} | ||
|
||
run.scheduleOnce('afterRender', this, embedViewer); | ||
}, | ||
}); | ||
|
||
function embedViewer() { | ||
this.$() | ||
.empty() | ||
.append(this.get('formatter').render()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
$dark-bright: lighten($dark, 15%); | ||
|
||
.CodeMirror { | ||
height: auto; | ||
} | ||
|
||
.cm-s-hashi, | ||
.cm-s-hashi-read-only { | ||
&.CodeMirror { | ||
background-color: $dark-3; | ||
color: $grey-blue; | ||
border: none; | ||
font-family: $family-monospace; | ||
-webkit-font-smoothing: auto; | ||
line-height: 1.4; | ||
} | ||
|
||
.CodeMirror-gutters { | ||
background-color: $dark-2; | ||
border: none; | ||
} | ||
|
||
.CodeMirror-cursor { | ||
border-left: solid thin $white-ter; | ||
} | ||
|
||
.CodeMirror-linenumber { | ||
color: $dark-bright; | ||
} | ||
|
||
&.CodeMirror-focused div.CodeMirror-selected { | ||
background: rgba(255, 255, 255, 0.1); | ||
} | ||
|
||
.CodeMirror-line::selection, | ||
.CodeMirror-line > span::selection, | ||
.CodeMirror-line > span > span::selection { | ||
background: rgba(255, 255, 255, 0.1); | ||
} | ||
|
||
span.cm-comment { | ||
color: $grey-light; | ||
} | ||
|
||
span.cm-string, | ||
span.cm-string-2 { | ||
color: $nomad-green; | ||
} | ||
|
||
span.cm-number { | ||
color: $serf-red; | ||
} | ||
|
||
span.cm-variable { | ||
color: $packer-blue; | ||
} | ||
|
||
span.cm-variable-2 { | ||
color: $packer-blue; | ||
} | ||
|
||
span.cm-def { | ||
color: $nomad-green; | ||
} | ||
|
||
span.cm-operator { | ||
color: $grey; | ||
} | ||
span.cm-keyword { | ||
color: $yellow; | ||
} | ||
|
||
span.cm-atom { | ||
color: $terraform-purple-bright; | ||
} | ||
|
||
span.cm-meta { | ||
color: $nomad-green; | ||
} | ||
|
||
span.cm-tag { | ||
color: $nomad-green; | ||
} | ||
|
||
span.cm-attribute { | ||
color: $consul-pink; | ||
} | ||
|
||
span.cm-qualifier { | ||
color: $consul-pink; | ||
} | ||
|
||
span.cm-property { | ||
color: $nomad-green; | ||
} | ||
|
||
span.cm-variable-3 { | ||
color: $consul-pink; | ||
} | ||
|
||
span.cm-builtin { | ||
color: $consul-pink; | ||
} | ||
|
||
.CodeMirror-activeline-background { | ||
background: $black-ter; | ||
} | ||
|
||
.CodeMirror-matchingbracket { | ||
text-decoration: underline; | ||
color: $white; | ||
} | ||
} | ||
|
||
.cm-s-auto-height.CodeMirror { | ||
height: auto; | ||
} | ||
|
||
.cm-s-hashi-read-only { | ||
&.CodeMirror { | ||
background-color: $dark-2; | ||
} | ||
|
||
.CodeMirror-gutters { | ||
background-color: $dark-2; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{ivy-codemirror | ||
value=jsonStr | ||
options=(hash | ||
mode="javascript" | ||
theme="hashi-read-only" | ||
tabSize=2 | ||
lineNumbers=true | ||
readOnly=true | ||
)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.