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