add syntax highlighting for sql in query analysis (#819)

* Send headers as part of request headers too

* Disable helper functions from linting

* Update hasura-console-graphiql to filter mutations from analyze list

* Update hasura-console-graphiql to 0.0.6
This commit is contained in:
Karthik Venkateswaran 2018-10-19 14:47:41 +05:30 committed by Vamshi Surabhi
parent bcb3dadf27
commit 0e56c98959
7 changed files with 4869 additions and 9 deletions

View File

@ -6448,9 +6448,9 @@
} }
}, },
"hasura-console-graphiql": { "hasura-console-graphiql": {
"version": "0.0.5", "version": "0.0.6",
"resolved": "https://registry.npmjs.org/hasura-console-graphiql/-/hasura-console-graphiql-0.0.5.tgz", "resolved": "https://registry.npmjs.org/hasura-console-graphiql/-/hasura-console-graphiql-0.0.6.tgz",
"integrity": "sha512-pXc+PJ6mi8JzREt4y8xOkvN+QIO1N35dHbctZuvsPhXM+pRZRrpc9jNQgzmwH/Ucts4A7OaJouPJSp0Zgfd1Qg==", "integrity": "sha512-9gdwhtrsE3tkwfoWEy/3qOhvB3k16G8w7fF/ReLXNl+f2b3HhBZM5tXYYI9vN/v85vufx611E6uZO3AeU0IaOQ==",
"requires": { "requires": {
"codemirror": "^5.26.0", "codemirror": "^5.26.0",
"codemirror-graphql": "^0.7.1", "codemirror-graphql": "^0.7.1",

View File

@ -59,7 +59,7 @@
"deep-equal": "^1.0.1", "deep-equal": "^1.0.1",
"graphiql": "^0.11.11", "graphiql": "^0.11.11",
"graphql": "^0.13.2", "graphql": "^0.13.2",
"hasura-console-graphiql": "0.0.5", "hasura-console-graphiql": "0.0.6",
"history": "^3.0.0", "history": "^3.0.0",
"hoist-non-react-statics": "^1.0.3", "hoist-non-react-statics": "^1.0.3",
"invariant": "^2.2.0", "invariant": "^2.2.0",

View File

@ -1,5 +1,14 @@
import { SERVER_CONSOLE_MODE } from './constants'; import { SERVER_CONSOLE_MODE } from './constants';
/* helper tools to format explain json */
/* eslint-disable */
import sqlFormatter from './helpers/sql-formatter.min';
import hljs from './helpers/highlight.min';
/* eslint-enable */
/* */
const checkExtraSlashes = url => { const checkExtraSlashes = url => {
if (!url) { if (!url) {
return url; return url;
@ -42,6 +51,16 @@ if (!window.__env.isAccessKeySet) {
globals.isAccessKeySet = false; globals.isAccessKeySet = false;
} }
if (
window &&
typeof window === 'object' &&
!window.sqlFormatter &&
!window.hljs
) {
window.sqlFormatter = sqlFormatter;
window.hljs = hljs;
}
if (globals.consoleMode === SERVER_CONSOLE_MODE) { if (globals.consoleMode === SERVER_CONSOLE_MODE) {
if (globals.nodeEnv !== 'development') { if (globals.nodeEnv !== 'development') {
const windowUrl = window.location.protocol + '//' + window.location.host; const windowUrl = window.location.protocol + '//' + window.location.host;

View File

@ -25,11 +25,6 @@ export default class Html extends Component {
<html lang="en-us"> <html lang="en-us">
<head> <head>
<link rel="icon" type="image/png" href="/rstatic/favicon.png" /> <link rel="icon" type="image/png" href="/rstatic/favicon.png" />
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.13.1/build/styles/default.min.css"
/>
{Object.keys(assets.styles).map((style, key) => ( {Object.keys(assets.styles).map((style, key) => (
<link <link
href={assets.styles[style]} href={assets.styles[style]}
@ -98,8 +93,10 @@ export default class Html extends Component {
<div id="content" className="content" /> <div id="content" className="content" />
<script src={assets.javascript.main} charSet="UTF-8" /> <script src={assets.javascript.main} charSet="UTF-8" />
{/*
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.13.1/build/highlight.min.js" /> <script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.13.1/build/highlight.min.js" />
<script type="text/javascript" src="https://unpkg.com/sql-formatter@latest/dist/sql-formatter.min.js" /> <script type="text/javascript" src="https://unpkg.com/sql-formatter@latest/dist/sql-formatter.min.js" />
*/}
</body> </body>
</html> </html>
); );

1908
console/src/helpers/highlight.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2930
console/src/helpers/sql-formatter.min.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,12 @@
* Override Bootstrap styles that you can't modify via variables here. * Override Bootstrap styles that you can't modify via variables here.
* *
*/ */
/* Highlight js css */
.hljs{display:block;overflow-x:auto;padding:0.5em;background:#F0F0F0}.hljs,.hljs-subst{color:#444}.hljs-comment{color:#888888}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:#880000}.hljs-title,.hljs-section{color:#880000;font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-built_in,.hljs-bullet,.hljs-code,.hljs-addition{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold}
/* */
input[type="radio"], input[type="checkbox"] input[type="radio"], input[type="checkbox"]
{ {
margin: 0 5px 0px 0px; margin: 0 5px 0px 0px;