mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 02:52:27 +08:00
Chore: Remove unnecessary type assertions (#78009)
* Chore: Remove unnecessary type assertions * betterer
This commit is contained in:
@ -1748,12 +1748,6 @@ exports[`better eslint`] = {
|
||||
"public/app/features/alerting/components/OptionElement.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/alerting/getAlertingValidationMessage.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
],
|
||||
"public/app/features/alerting/state/ThresholdMapper.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
@ -2182,9 +2176,8 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "4"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "5"]
|
||||
[0, 0, 0, "Styles should be written using objects.", "3"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "4"]
|
||||
],
|
||||
"public/app/features/alerting/unified/components/receivers/form/TestContactPointModal.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"],
|
||||
@ -2199,12 +2192,10 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "6"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"]
|
||||
[0, 0, 0, "Styles should be written using objects.", "4"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
|
||||
],
|
||||
"public/app/features/alerting/unified/components/receivers/form/fields/StringArrayInput.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"],
|
||||
@ -2732,8 +2723,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"]
|
||||
],
|
||||
"public/app/features/annotations/components/StandardAnnotationQueryEditor.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"]
|
||||
@ -3280,9 +3270,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"]
|
||||
],
|
||||
"public/app/features/dashboard/dashgrid/DashboardGrid.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
@ -4327,9 +4314,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"]
|
||||
],
|
||||
"public/app/features/live/index.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/logs/components/LogDetailsRow.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "1"],
|
||||
@ -4683,9 +4667,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Styles should be written using objects.", "1"]
|
||||
],
|
||||
"public/app/features/plugins/sql/components/visual-query-builder/AwesomeQueryBuilder.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/plugins/sql/components/visual-query-builder/SQLWhereRow.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
@ -4835,9 +4817,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Styles should be written using objects.", "2"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "3"]
|
||||
],
|
||||
"public/app/features/search/hooks/useSearchKeyboardSelection.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/search/page/components/ActionRow.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "1"]
|
||||
@ -5179,9 +5158,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Styles should be written using objects.", "1"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "2"]
|
||||
],
|
||||
"public/app/features/users/state/reducers.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/variables/adapters.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@ -5202,9 +5178,6 @@ exports[`better eslint`] = {
|
||||
"public/app/features/variables/datasource/actions.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/variables/datasource/reducer.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/variables/editor/LegacyVariableQueryEditor.tsx:5381": [
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
||||
],
|
||||
@ -5286,9 +5259,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"]
|
||||
],
|
||||
"public/app/features/variables/interval/reducer.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/variables/pickers/OptionsPicker/actions.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
@ -5370,9 +5340,8 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/features/variables/query/reducer.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/features/variables/query/variableQueryObserver.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -5585,22 +5554,22 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "11"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "12"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "18"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "20"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
|
||||
@ -5613,9 +5582,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "30"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "31"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "32"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "33"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "34"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "35"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "33"]
|
||||
],
|
||||
"public/app/plugins/datasource/elasticsearch/LanguageProvider.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -5726,12 +5693,11 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Styles should be written using objects.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/elasticsearch/datasource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"public/app/plugins/datasource/elasticsearch/hooks/useStatelessReducer.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
@ -5757,9 +5723,8 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationQueryEditor.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -6147,9 +6112,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Styles should be written using objects.", "10"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "11"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "12"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "13"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "14"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "15"]
|
||||
[0, 0, 0, "Styles should be written using objects.", "13"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/components/LokiOptionFields.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"],
|
||||
@ -6411,20 +6374,12 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"public/app/plugins/datasource/prometheus/language_utils.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "7"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "8"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "9"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/prometheus/metric_find_query.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -6610,9 +6565,8 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/plugins/datasource/tempo/ServiceGraphSection.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "2"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "3"]
|
||||
[0, 0, 0, "Styles should be written using objects.", "1"],
|
||||
[0, 0, 0, "Styles should be written using objects.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/tempo/configuration/ConfigEditor.tsx:5381": [
|
||||
[0, 0, 0, "Styles should be written using objects.", "0"]
|
||||
@ -6652,10 +6606,9 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "6"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "7"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "8"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"]
|
||||
],
|
||||
"public/app/plugins/datasource/tempo/language_provider.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
|
@ -4,8 +4,8 @@ import { DataSourceSrv } from '@grafana/runtime';
|
||||
export const getDefaultCondition = () => ({
|
||||
type: 'query',
|
||||
query: { params: ['A', '5m', 'now'] },
|
||||
reducer: { type: 'avg', params: [] as any[] },
|
||||
evaluator: { type: 'gt', params: [null] as any[] },
|
||||
reducer: { type: 'avg', params: [] },
|
||||
evaluator: { type: 'gt', params: [null] },
|
||||
operator: { type: 'and' },
|
||||
});
|
||||
|
||||
|
@ -177,7 +177,7 @@ export function ReceiverForm<R extends ChannelValues>({
|
||||
type="button"
|
||||
icon="plus"
|
||||
variant="secondary"
|
||||
onClick={() => append({ ...defaultItem, __id: String(Math.random()) } as R)}
|
||||
onClick={() => append({ ...defaultItem, __id: String(Math.random()) })}
|
||||
>
|
||||
Add contact point integration
|
||||
</Button>
|
||||
|
@ -41,7 +41,7 @@ export const OptionField: FC<Props> = ({
|
||||
readOnly={readOnly}
|
||||
defaultValue={defaultValue}
|
||||
option={option}
|
||||
errors={error as DeepMap<any, FieldError> | undefined}
|
||||
errors={error}
|
||||
pathPrefix={optionPath}
|
||||
/>
|
||||
);
|
||||
|
@ -171,8 +171,7 @@ export function getFirstActiveAt(promRule?: AlertingRule) {
|
||||
return null;
|
||||
}
|
||||
return promRule.alerts.reduce<Date | null>((prev, alert) => {
|
||||
const isNotNormal =
|
||||
mapStateWithReasonToBaseState(alert.state as GrafanaAlertStateWithReason) !== GrafanaAlertState.Normal;
|
||||
const isNotNormal = mapStateWithReasonToBaseState(alert.state) !== GrafanaAlertState.Normal;
|
||||
if (alert.activeAt && isNotNormal) {
|
||||
const activeAt = new Date(alert.activeAt);
|
||||
if (prev === null || prev.getTime() > activeAt.getTime()) {
|
||||
|
@ -71,11 +71,8 @@ export class DashboardGrid extends PureComponent<Props, State> {
|
||||
if (e.payload.variable?.id === PANEL_FILTER_VARIABLE) {
|
||||
if ('current' in e.payload.variable) {
|
||||
let variable = e.payload.variable.current;
|
||||
if ('value' in variable) {
|
||||
let value = variable.value;
|
||||
if (typeof value === 'string') {
|
||||
this.setPanelFilter(value as string);
|
||||
}
|
||||
if ('value' in variable && typeof variable.value === 'string') {
|
||||
this.setPanelFilter(variable.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { config, getBackendSrv, getGrafanaLiveSrv, setGrafanaLiveSrv } from '@grafana/runtime';
|
||||
import { GrafanaLiveSrv, config, getBackendSrv, getGrafanaLiveSrv, setGrafanaLiveSrv } from '@grafana/runtime';
|
||||
import { liveTimer } from 'app/features/dashboard/dashgrid/liveTimer';
|
||||
|
||||
import { contextSrv } from '../../core/services/context_srv';
|
||||
@ -30,6 +30,6 @@ export function initGrafanaLive() {
|
||||
);
|
||||
}
|
||||
|
||||
export function getGrafanaLiveCentrifugeSrv() {
|
||||
return getGrafanaLiveSrv() as GrafanaLiveService;
|
||||
export function getGrafanaLiveCentrifugeSrv(): GrafanaLiveSrv {
|
||||
return getGrafanaLiveSrv();
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ const enum Op {
|
||||
MACROS = 'macros',
|
||||
}
|
||||
// eslint-ignore
|
||||
const customOperators = getCustomOperators(BasicConfig) as typeof BasicConfig.operators;
|
||||
const customOperators = getCustomOperators(BasicConfig);
|
||||
const textWidget = BasicConfig.types.text.widgets.text;
|
||||
const opers = [...(textWidget.operators || []), Op.IN, Op.NOT_IN];
|
||||
const customTextWidget = {
|
||||
@ -216,7 +216,7 @@ export const raqbConfig: Config = {
|
||||
...BasicConfig,
|
||||
widgets,
|
||||
settings,
|
||||
operators: customOperators as typeof BasicConfig.operators,
|
||||
operators: customOperators,
|
||||
types: customTypes,
|
||||
};
|
||||
|
||||
|
@ -85,8 +85,8 @@ export function useSearchKeyboardNavigation(
|
||||
setHighlightIndex({ ...highlightIndexRef.current });
|
||||
break;
|
||||
}
|
||||
const url = urlsRef.current.values?.[idx] as string;
|
||||
if (url) {
|
||||
const url: unknown = urlsRef.current.values?.[idx];
|
||||
if (typeof url === 'string') {
|
||||
locationService.push(locationUtil.stripBaseFromUrl(url));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import config from 'app/core/config';
|
||||
import { OrgUser, UsersState } from 'app/types';
|
||||
|
||||
export const initialState: UsersState = {
|
||||
users: [] as OrgUser[],
|
||||
users: [],
|
||||
searchQuery: '',
|
||||
page: 0,
|
||||
perPage: 30,
|
||||
|
@ -10,7 +10,7 @@ import { DataSourceVariableModel, initialVariableModelState, VariableOption, Var
|
||||
export const initialDataSourceVariableModelState: DataSourceVariableModel = {
|
||||
...initialVariableModelState,
|
||||
type: 'datasource',
|
||||
current: {} as VariableOption,
|
||||
current: {},
|
||||
regex: '',
|
||||
options: [],
|
||||
query: '',
|
||||
|
@ -14,7 +14,7 @@ export const initialIntervalVariableModelState: IntervalVariableModel = {
|
||||
auto: false,
|
||||
query: '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d',
|
||||
refresh: VariableRefresh.onTimeRangeChanged,
|
||||
current: {} as VariableOption,
|
||||
current: {},
|
||||
};
|
||||
|
||||
export const intervalVariableSlice = createSlice({
|
||||
|
@ -25,7 +25,7 @@ export const initialQueryVariableModelState: QueryVariableModel = {
|
||||
includeAll: false,
|
||||
allValue: null,
|
||||
options: [],
|
||||
current: {} as VariableOption,
|
||||
current: {},
|
||||
definition: '',
|
||||
};
|
||||
|
||||
|
@ -84,7 +84,7 @@ export class ElasticResponse {
|
||||
}
|
||||
case 'extended_stats': {
|
||||
for (const statName in metric.meta) {
|
||||
if (!metric.meta[statName as ExtendedStatMetaType]) {
|
||||
if (!metric.meta[statName]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ export class ElasticResponse {
|
||||
}
|
||||
case 'extended_stats': {
|
||||
for (const statName in metric.meta) {
|
||||
if (!metric.meta[statName as ExtendedStatMetaType]) {
|
||||
if (!metric.meta[statName]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ export class ElasticDatasource
|
||||
this.url = instanceSettings.url!;
|
||||
this.name = instanceSettings.name;
|
||||
this.isProxyAccess = instanceSettings.access === 'proxy';
|
||||
const settingsData = instanceSettings.jsonData || ({} as ElasticsearchOptions);
|
||||
const settingsData = instanceSettings.jsonData || {};
|
||||
|
||||
this.index = settingsData.index ?? instanceSettings.database ?? '';
|
||||
this.timeField = settingsData.timeField;
|
||||
|
@ -25,7 +25,7 @@ interface SimInfo {
|
||||
|
||||
export const SimulationQueryEditor = ({ onChange, query, ds }: EditorProps) => {
|
||||
const simQuery = query.sim ?? ({} as SimulationQuery);
|
||||
const simKey = simQuery.key ?? ({} as typeof simQuery.key);
|
||||
const simKey = simQuery.key ?? {};
|
||||
// keep track of updated config state to pass down to form
|
||||
const [cfgValue, setCfgValue] = useState<Record<string, any>>({});
|
||||
|
||||
|
@ -188,7 +188,7 @@ const getStyles = (theme: GrafanaTheme2) => ({
|
||||
|
||||
export class UnthemedLokiLabelBrowser extends React.Component<BrowserProps, BrowserState> {
|
||||
state: BrowserState = {
|
||||
labels: [] as SelectableLabel[],
|
||||
labels: [],
|
||||
searchTerm: '',
|
||||
status: 'Ready',
|
||||
error: '',
|
||||
@ -497,7 +497,7 @@ export class UnthemedLokiLabelBrowser extends React.Component<BrowserProps, Brow
|
||||
height={200}
|
||||
itemCount={label.values?.length || 0}
|
||||
itemSize={28}
|
||||
itemKey={(i) => (label.values as FacettableValue[])[i].name}
|
||||
itemKey={(i) => label.values?.[i].name ?? i}
|
||||
width={200}
|
||||
className={styles.valueList}
|
||||
>
|
||||
|
@ -348,9 +348,10 @@ export default class PromQlLanguageProvider extends LanguageProvider {
|
||||
|
||||
function getNameLabelValue(promQuery: string, tokens: any): string {
|
||||
let nameLabelValue = '';
|
||||
for (let prop in tokens) {
|
||||
if (typeof tokens[prop] === 'string') {
|
||||
nameLabelValue = tokens[prop] as string;
|
||||
|
||||
for (const token of tokens) {
|
||||
if (typeof token === 'string') {
|
||||
nameLabelValue = token;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -287,6 +287,7 @@ const FromPromLikeMap: Record<string, AbstractLabelOperator> = {
|
||||
'=~': AbstractLabelOperator.EqualRegEx,
|
||||
'!~': AbstractLabelOperator.NotEqualRegEx,
|
||||
};
|
||||
|
||||
const ToPromLikeMap: Record<AbstractLabelOperator, string> = invert(FromPromLikeMap) as Record<
|
||||
AbstractLabelOperator,
|
||||
string
|
||||
@ -321,38 +322,49 @@ export interface PromLikeQuery extends DataQuery {
|
||||
range: boolean;
|
||||
}
|
||||
|
||||
function getMaybeTokenStringContent(token: Token): string {
|
||||
if (typeof token.content === 'string') {
|
||||
return token.content;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
export function extractLabelMatchers(tokens: Array<string | Token>): AbstractLabelMatcher[] {
|
||||
const labelMatchers: AbstractLabelMatcher[] = [];
|
||||
|
||||
for (let prop in tokens) {
|
||||
if (tokens[prop] instanceof Token) {
|
||||
let token: Token = tokens[prop] as Token;
|
||||
if (token.type === 'context-labels') {
|
||||
let labelKey = '';
|
||||
let labelValue = '';
|
||||
let labelOperator = '';
|
||||
let contentTokens: any[] = token.content as any[];
|
||||
for (let currentToken in contentTokens) {
|
||||
if (typeof contentTokens[currentToken] === 'string') {
|
||||
let currentStr: string;
|
||||
currentStr = contentTokens[currentToken] as string;
|
||||
if (currentStr === '=' || currentStr === '!=' || currentStr === '=~' || currentStr === '!~') {
|
||||
labelOperator = currentStr;
|
||||
}
|
||||
} else if (contentTokens[currentToken] instanceof Token) {
|
||||
switch (contentTokens[currentToken].type) {
|
||||
case 'label-key':
|
||||
labelKey = contentTokens[currentToken].content as string;
|
||||
break;
|
||||
case 'label-value':
|
||||
labelValue = contentTokens[currentToken].content as string;
|
||||
labelValue = labelValue.substring(1, labelValue.length - 1);
|
||||
const labelComparator = FromPromLikeMap[labelOperator];
|
||||
if (labelComparator) {
|
||||
labelMatchers.push({ name: labelKey, operator: labelComparator, value: labelValue });
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (const token of tokens) {
|
||||
if (!(token instanceof Token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (token.type === 'context-labels') {
|
||||
let labelKey = '';
|
||||
let labelValue = '';
|
||||
let labelOperator = '';
|
||||
|
||||
const contentTokens = Array.isArray(token.content) ? token.content : [token.content];
|
||||
|
||||
for (let currentToken of contentTokens) {
|
||||
if (typeof currentToken === 'string') {
|
||||
let currentStr: string;
|
||||
currentStr = currentToken;
|
||||
if (currentStr === '=' || currentStr === '!=' || currentStr === '=~' || currentStr === '!~') {
|
||||
labelOperator = currentStr;
|
||||
}
|
||||
} else if (currentToken instanceof Token) {
|
||||
switch (currentToken.type) {
|
||||
case 'label-key':
|
||||
labelKey = getMaybeTokenStringContent(currentToken);
|
||||
break;
|
||||
case 'label-value':
|
||||
labelValue = getMaybeTokenStringContent(currentToken);
|
||||
labelValue = labelValue.substring(1, labelValue.length - 1);
|
||||
const labelComparator = FromPromLikeMap[labelOperator];
|
||||
if (labelComparator) {
|
||||
labelMatchers.push({ name: labelKey, operator: labelComparator, value: labelValue });
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ export function ServiceGraphSection({
|
||||
return null;
|
||||
}
|
||||
|
||||
const ds = dsState.value as PrometheusDatasource;
|
||||
const ds = dsState.value;
|
||||
|
||||
if (!graphDatasourceUid) {
|
||||
return getWarning(
|
||||
|
@ -986,7 +986,7 @@ function makePromLink(title: string, expr: string, datasourceUid: string, instan
|
||||
range: !instant,
|
||||
exemplar: !instant,
|
||||
instant: instant,
|
||||
} as PromQuery,
|
||||
},
|
||||
datasourceUid,
|
||||
datasourceName: getDatasourceSrv().getDataSourceSettingsByUid(datasourceUid)?.name ?? '',
|
||||
},
|
||||
|
Reference in New Issue
Block a user