mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-17 02:00:49 +01:00
fix: fix env info popup issues in graphql query editor
This commit is contained in:
parent
095d7c6bcb
commit
dd4fecfd1c
@ -40,7 +40,10 @@ export default class QueryEditor extends React.Component {
|
|||||||
value: this.props.value || '',
|
value: this.props.value || '',
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
mode: 'graphql',
|
mode: 'brunovariables',
|
||||||
|
brunoVarInfo: {
|
||||||
|
variables: getEnvironmentVariables(this.props.collection),
|
||||||
|
},
|
||||||
theme: this.props.editorTheme || 'graphiql',
|
theme: this.props.editorTheme || 'graphiql',
|
||||||
theme: this.props.theme === 'dark' ? 'monokai' : 'default',
|
theme: this.props.theme === 'dark' ? 'monokai' : 'default',
|
||||||
keyMap: 'sublime',
|
keyMap: 'sublime',
|
||||||
@ -159,6 +162,8 @@ export default class QueryEditor extends React.Component {
|
|||||||
this.ignoreChangeEvent = false;
|
this.ignoreChangeEvent = false;
|
||||||
let variables = getEnvironmentVariables(this.props.collection);
|
let variables = getEnvironmentVariables(this.props.collection);
|
||||||
if (!isEqual(variables, this.variables)) {
|
if (!isEqual(variables, this.variables)) {
|
||||||
|
this.editor.options.brunoVarInfo.variables = variables;
|
||||||
|
console.log(variables);
|
||||||
this.addOverlay();
|
this.addOverlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,7 +182,7 @@ export default class QueryEditor extends React.Component {
|
|||||||
this.variables = variables;
|
this.variables = variables;
|
||||||
console.log(variables);
|
console.log(variables);
|
||||||
|
|
||||||
defineCodeMirrorBrunoVariablesMode(variables, "text/plain");
|
defineCodeMirrorBrunoVariablesMode(variables, 'graphql');
|
||||||
this.editor.setOption('mode', 'brunovariables');
|
this.editor.setOption('mode', 'brunovariables');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,12 +14,13 @@ if (!SERVER_RENDERED) {
|
|||||||
|
|
||||||
const renderVarInfo = (token, options, cm, pos) => {
|
const renderVarInfo = (token, options, cm, pos) => {
|
||||||
const str = token.string || '';
|
const str = token.string || '';
|
||||||
|
if(!str || !str.length || typeof str !== 'string') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// str is of format {{variableName}}, extract variableName
|
// str is of format {{variableName}}, extract variableName
|
||||||
const variableName = str.substring(2, str.length - 2);
|
// we are seeing that from the gql query editor, the token string is of format variableName
|
||||||
|
const variableName = str.replace('{{', '').replace('}}', '').trim();
|
||||||
// get the value of the variable
|
const variableValue = options.variables[variableName];
|
||||||
const variableValue = options.variables[variableName] || '';
|
|
||||||
|
|
||||||
const into = document.createElement('div');
|
const into = document.createElement('div');
|
||||||
const descriptionDiv = document.createElement('div');
|
const descriptionDiv = document.createElement('div');
|
||||||
|
Loading…
Reference in New Issue
Block a user