mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(loki-monaco-editor): escape autocompleted label values (#56890)
This commit is contained in:
@@ -24,7 +24,7 @@ const history = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const labelNames = ['place', 'source'];
|
const labelNames = ['place', 'source'];
|
||||||
const labelValues = ['moon', 'luna'];
|
const labelValues = ['moon', 'luna', 'server\\1'];
|
||||||
const extractedLabelKeys = ['extracted', 'label'];
|
const extractedLabelKeys = ['extracted', 'label'];
|
||||||
const otherLabels: Label[] = [
|
const otherLabels: Label[] = [
|
||||||
{
|
{
|
||||||
@@ -244,6 +244,11 @@ describe('getCompletions', () => {
|
|||||||
label: 'luna',
|
label: 'luna',
|
||||||
type: 'LABEL_VALUE',
|
type: 'LABEL_VALUE',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
insertText: '"server\\\\1"',
|
||||||
|
label: 'server\\1',
|
||||||
|
type: 'LABEL_VALUE',
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
completions = await getCompletions({ ...situation, betweenQuotes: true }, completionProvider);
|
completions = await getCompletions({ ...situation, betweenQuotes: true }, completionProvider);
|
||||||
@@ -259,6 +264,11 @@ describe('getCompletions', () => {
|
|||||||
label: 'luna',
|
label: 'luna',
|
||||||
type: 'LABEL_VALUE',
|
type: 'LABEL_VALUE',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
insertText: 'server\\\\1',
|
||||||
|
label: 'server\\1',
|
||||||
|
type: 'LABEL_VALUE',
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { escapeLabelValueInExactSelector } from '../../../languageUtils';
|
||||||
import { AGGREGATION_OPERATORS, RANGE_VEC_FUNCTIONS } from '../../../syntax';
|
import { AGGREGATION_OPERATORS, RANGE_VEC_FUNCTIONS } from '../../../syntax';
|
||||||
|
|
||||||
import { CompletionDataProvider } from './CompletionDataProvider';
|
import { CompletionDataProvider } from './CompletionDataProvider';
|
||||||
@@ -197,7 +198,7 @@ async function getLabelValuesForMetricCompletions(
|
|||||||
return values.map((text) => ({
|
return values.map((text) => ({
|
||||||
type: 'LABEL_VALUE',
|
type: 'LABEL_VALUE',
|
||||||
label: text,
|
label: text,
|
||||||
insertText: betweenQuotes ? text : `"${text}"`,
|
insertText: betweenQuotes ? escapeLabelValueInExactSelector(text) : `"${escapeLabelValueInExactSelector(text)}"`,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user