Skip to content

Commit b3c7c3e

Browse files
committed
Delete unused code
1 parent 16eed5b commit b3c7c3e

File tree

5 files changed

+173
-976
lines changed

5 files changed

+173
-976
lines changed

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
3737
"@types/jest": "29.5.5",
3838
"@types/lodash": "4.14.199",
3939
"@types/node": "20.8.2",
40+
"@types/ol-ext": "npm:@siedlerchr/types-ol-ext@3.2.0",
4041
"@types/pluralize": "0.0.30",
4142
"@types/prismjs": "1.26.0",
4243
"@types/react": "18.2.15",
4344
"@types/react-beautiful-dnd": "13.1.4",
4445
"@types/react-dom": "18.2.7",
4546
"@types/react-highlight-words": "0.16.5",
4647
"@types/react-redux": "7.1.25",
48+
"@types/react-window": "1.8.7",
4749
"@types/semver": "7.5.0",
4850
"@types/slate": "0.47.11",
4951
"@types/slate-plain-serializer": "0.7.2",
@@ -90,12 +92,12 @@
9092
"dependencies": {
9193
"@emotion/css": "11.11.2",
9294
"@grafana/aws-sdk": "0.1.3",
93-
"@grafana/data": "10.2.0-nightly.6184bf21",
95+
"@grafana/data": "10.2.0-nightly.e365200c",
9496
"@grafana/experimental": "1.7.3",
9597
"@grafana/faro-web-sdk": "1.2.1",
96-
"@grafana/runtime": "10.2.0-nightly.6184bf21",
97-
"@grafana/schema": "10.2.0-nightly.6184bf21",
98-
"@grafana/ui": "10.2.0-nightly.6184bf21",
98+
"@grafana/runtime": "10.2.0-nightly.e365200c",
99+
"@grafana/schema": "10.2.0-nightly.e365200c",
100+
"@grafana/ui": "10.2.0-nightly.e365200c",
99101
"@leeoniya/ufuzzy": "1.0.8",
100102
"@lezer/common": "1.1.0",
101103
"@lezer/highlight": "1.1.3",

src/components/PromQueryField.tsx

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
import { cx } from '@emotion/css';
22
import { isDataFrame, QueryEditorProps, QueryHint, TimeRange, toLegacyResponseData } from '@grafana/data';
33
import { reportInteraction } from '@grafana/runtime';
4-
import {
5-
BracesPlugin,
6-
clearButtonStyles,
7-
DOMUtil,
8-
Icon,
9-
SlatePrism,
10-
SuggestionsState,
11-
Themeable2,
12-
TypeaheadInput,
13-
TypeaheadOutput,
14-
withTheme2,
15-
} from '@grafana/ui';
16-
import { LanguageMap, languages as prismLanguages } from 'prismjs';
4+
import { clearButtonStyles, Icon, Themeable2, withTheme2 } from '@grafana/ui';
175
import React, { ReactNode } from 'react';
18-
import { Plugin } from 'slate';
19-
import { Editor } from 'slate-react';
206

217
import { PrometheusDatasource } from '../datasource';
228
import { LocalStorageValueProvider } from '../gcopypaste/app/core/components/LocalStorageValueProvider';
@@ -31,7 +17,6 @@ import { PromOptions, PromQuery } from '../types';
3117
import { PrometheusMetricsBrowser } from './PrometheusMetricsBrowser';
3218
import { MonacoQueryFieldWrapper } from './monaco-query-field/MonacoQueryFieldWrapper';
3319

34-
export const RECORDING_RULES_GROUP = '__recording_rules__';
3520
const LAST_USED_LABELS_KEY = 'grafana.datasources.prometheus.browser.labels';
3621

3722
function getChooserText(metricsLookupDisabled: boolean, hasSyntax: boolean, hasMetrics: boolean) {
@@ -50,33 +35,6 @@ function getChooserText(metricsLookupDisabled: boolean, hasSyntax: boolean, hasM
5035
return 'Metrics browser';
5136
}
5237

53-
export function willApplySuggestion(suggestion: string, { typeaheadContext, typeaheadText }: SuggestionsState): string {
54-
// Modify suggestion based on context
55-
switch (typeaheadContext) {
56-
case 'context-labels': {
57-
const nextChar = DOMUtil.getNextCharacter();
58-
if (!nextChar || nextChar === '}' || nextChar === ',') {
59-
suggestion += '=';
60-
}
61-
break;
62-
}
63-
64-
case 'context-label-values': {
65-
// Always add quotes and remove existing ones instead
66-
if (!typeaheadText.match(/^(!?=~?"|")/)) {
67-
suggestion = `"${suggestion}`;
68-
}
69-
if (DOMUtil.getNextCharacter() !== '"') {
70-
suggestion = `${suggestion}"`;
71-
}
72-
break;
73-
}
74-
75-
default:
76-
}
77-
return suggestion;
78-
}
79-
8038
interface PromQueryFieldProps extends QueryEditorProps<PrometheusDatasource, PromQuery, PromOptions>, Themeable2 {
8139
ExtraFieldElement?: ReactNode;
8240
'data-testid'?: string;
@@ -89,23 +47,11 @@ interface PromQueryFieldState {
8947
}
9048

9149
class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryFieldState> {
92-
plugins: Array<Plugin<Editor>>;
9350
declare languageProviderInitializationPromise: CancelablePromise<any>;
9451

9552
constructor(props: PromQueryFieldProps, context: React.Context<any>) {
9653
super(props, context);
9754

98-
this.plugins = [
99-
BracesPlugin(),
100-
SlatePrism(
101-
{
102-
onlyIn: (node: any) => node.type === 'code_block',
103-
getSyntax: (node: any) => 'promql',
104-
},
105-
{ ...(prismLanguages as LanguageMap), promql: this.props.datasource.languageProvider.syntax }
106-
),
107-
];
108-
10955
this.state = {
11056
labelBrowserVisible: false,
11157
syntaxLoaded: false,
@@ -254,26 +200,6 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
254200
this.setState({ syntaxLoaded: true });
255201
};
256202

257-
onTypeahead = async (typeahead: TypeaheadInput): Promise<TypeaheadOutput> => {
258-
const {
259-
datasource: { languageProvider },
260-
} = this.props;
261-
262-
if (!languageProvider) {
263-
return { suggestions: [] };
264-
}
265-
266-
const { history } = this.props;
267-
const { prefix, text, value, wrapperClasses, labelKey } = typeahead;
268-
269-
const result = await languageProvider.provideCompletionItems(
270-
{ text, value, prefix, wrapperClasses, labelKey },
271-
{ history }
272-
);
273-
274-
return result;
275-
};
276-
277203
render() {
278204
const {
279205
datasource,

0 commit comments

Comments
 (0)