From 96b066bb2a845b7c03a601735543fa3d6bb45d3c Mon Sep 17 00:00:00 2001 From: Damien de Lemeny Date: Mon, 29 Jan 2024 09:28:11 -0500 Subject: [PATCH] Configure path aliases (webpack, jest, ts) --- .config/jest.config.js | 1 + .config/tsconfig.json | 5 ++++- .config/webpack/webpack.config.ts | 3 +++ src/components/QueryEditor/AnnotationQueryEditor.tsx | 2 +- .../BucketAggregationEditor.tsx | 6 +++--- .../SettingsEditor/DateHistogramSettingsEditor.tsx | 6 +++--- .../SettingsEditor/FiltersSettingsEditor/index.tsx | 6 +++--- .../FiltersSettingsEditor/state/actions.ts | 2 +- .../FiltersSettingsEditor/state/reducer.test.ts | 2 +- .../FiltersSettingsEditor/state/reducer.ts | 2 +- .../SettingsEditor/FiltersSettingsEditor/utils.ts | 2 +- .../SettingsEditor/TermsSettingsEditor.test.tsx | 2 +- .../SettingsEditor/TermsSettingsEditor.tsx | 12 ++++++------ .../SettingsEditor/index.tsx | 6 +++--- .../SettingsEditor/useDescription.ts | 4 ++-- .../BucketAggregationsEditor/aggregations.ts | 2 +- .../QueryEditor/BucketAggregationsEditor/index.tsx | 6 +++--- .../BucketAggregationsEditor/state/actions.ts | 2 +- .../BucketAggregationsEditor/state/reducer.test.ts | 2 +- .../BucketAggregationsEditor/state/reducer.ts | 6 +++--- .../QueryEditor/BucketAggregationsEditor/utils.ts | 2 +- .../QueryEditor/ElasticsearchQueryContext.test.tsx | 4 ++-- .../QueryEditor/ElasticsearchQueryContext.tsx | 6 +++--- .../MetricAggregationsEditor/MetricEditor.test.tsx | 7 +++---- .../MetricAggregationsEditor/MetricEditor.tsx | 6 +++--- .../BucketScriptSettingsEditor/index.tsx | 8 ++++---- .../BucketScriptSettingsEditor/state/reducer.test.ts | 2 +- .../BucketScriptSettingsEditor/state/reducer.ts | 2 +- .../BucketScriptSettingsEditor/utils.ts | 2 +- .../SettingsEditor/MovingAverageSettingsEditor.tsx | 6 +++--- .../SettingsEditor/SettingField.tsx | 6 +++--- .../SettingsEditor/TopMetricsSettingsEditor.tsx | 8 ++++---- .../SettingsEditor/index.test.tsx | 4 ++-- .../SettingsEditor/index.tsx | 6 +++--- .../SettingsEditor/useDescription.ts | 2 +- .../MetricAggregationsEditor/aggregations.ts | 2 +- .../QueryEditor/MetricAggregationsEditor/index.tsx | 4 ++-- .../MetricAggregationsEditor/state/actions.ts | 2 +- .../MetricAggregationsEditor/state/reducer.test.ts | 4 ++-- .../MetricAggregationsEditor/state/reducer.ts | 6 +++--- .../QueryEditor/MetricAggregationsEditor/utils.ts | 2 +- .../QueryEditor/QueryEditorSpecialMetricRow.tsx | 2 +- src/components/QueryEditor/QueryTypeSelector.tsx | 4 ++-- src/components/QueryEditor/index.test.tsx | 4 ++-- src/components/QueryEditor/index.tsx | 8 ++++---- src/components/QueryEditor/state.test.ts | 2 +- src/components/QueryEditor/state.ts | 2 +- 47 files changed, 99 insertions(+), 93 deletions(-) diff --git a/.config/jest.config.js b/.config/jest.config.js index 3cb011e..fddcbd2 100644 --- a/.config/jest.config.js +++ b/.config/jest.config.js @@ -10,6 +10,7 @@ const { grafanaESModules, nodeModulesToTransform } = require('./jest/utils'); module.exports = { moduleNameMapper: { + "^@/(.*)$": "/src/$1", '\\.(css|scss|sass)$': 'identity-obj-proxy', 'react-inlinesvg': path.resolve(__dirname, 'jest', 'mocks', 'react-inlinesvg.tsx'), }, diff --git a/.config/tsconfig.json b/.config/tsconfig.json index 64b3769..97766bc 100644 --- a/.config/tsconfig.json +++ b/.config/tsconfig.json @@ -11,7 +11,10 @@ "rootDir": "../src", "baseUrl": "../src", "typeRoots": ["../node_modules/@types"], - "resolveJsonModule": true + "resolveJsonModule": true, + "paths": { + "@/*": ["../src/*"] + } }, "ts-node": { "compilerOptions": { diff --git a/.config/webpack/webpack.config.ts b/.config/webpack/webpack.config.ts index 59e1963..3b21b72 100644 --- a/.config/webpack/webpack.config.ts +++ b/.config/webpack/webpack.config.ts @@ -198,6 +198,9 @@ const config = async (env): Promise => { ], resolve: { + alias: { + '@': path.resolve(process.cwd(), 'src'), + }, extensions: ['.js', '.jsx', '.ts', '.tsx'], // handle resolving "rootDir" paths modules: [path.resolve(process.cwd(), 'src'), 'node_modules'], diff --git a/src/components/QueryEditor/AnnotationQueryEditor.tsx b/src/components/QueryEditor/AnnotationQueryEditor.tsx index 413decf..b687b7e 100644 --- a/src/components/QueryEditor/AnnotationQueryEditor.tsx +++ b/src/components/QueryEditor/AnnotationQueryEditor.tsx @@ -4,7 +4,7 @@ import { AnnotationQuery } from '@grafana/data'; import { EditorField, EditorRow } from '@grafana/experimental'; import { Input } from '@grafana/ui'; -import { ElasticsearchQuery } from '../../types'; +import { ElasticsearchQuery } from '@/types'; import { ElasticQueryEditorProps, ElasticSearchQueryField } from './index'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/BucketAggregationEditor.tsx b/src/components/QueryEditor/BucketAggregationsEditor/BucketAggregationEditor.tsx index c9332d1..aefa868 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/BucketAggregationEditor.tsx +++ b/src/components/QueryEditor/BucketAggregationsEditor/BucketAggregationEditor.tsx @@ -3,11 +3,11 @@ import React from 'react'; import { SelectableValue } from '@grafana/data'; import { InlineSegmentGroup, Segment, SegmentAsync } from '@grafana/ui'; -import { useFields } from '../../../hooks/useFields'; -import { useDispatch } from '../../../hooks/useStatelessReducer'; +import { useFields } from '@/hooks/useFields'; +import { useDispatch } from '@/hooks/useStatelessReducer'; import { segmentStyles } from '../styles'; -import { BucketAggregation, BucketAggregationType } from './../../../types'; +import { BucketAggregation, BucketAggregationType } from '@/types'; import { SettingsEditor } from './SettingsEditor'; import { isBucketAggregationWithField } from './aggregations'; import { changeBucketAggregationField, changeBucketAggregationType } from './state/actions'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/DateHistogramSettingsEditor.tsx b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/DateHistogramSettingsEditor.tsx index 5b5f1c5..54e2f03 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/DateHistogramSettingsEditor.tsx +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/DateHistogramSettingsEditor.tsx @@ -5,9 +5,9 @@ import { GroupBase, OptionsOrGroups } from 'react-select'; import { InternalTimeZones, SelectableValue } from '@grafana/data'; import { InlineField, Input, Select, TimeZonePicker } from '@grafana/ui'; -import { useDispatch } from '../../../../hooks/useStatelessReducer'; -import { DateHistogram } from '../../../../types'; -import { useCreatableSelectPersistedBehaviour } from '../../../hooks/useCreatableSelectPersistedBehaviour'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { DateHistogram } from '@/types'; +import { useCreatableSelectPersistedBehaviour } from '@/components/hooks/useCreatableSelectPersistedBehaviour'; import { changeBucketAggregationSetting } from '../state/actions'; import { bucketAggregationConfig } from '../utils'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/index.tsx b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/index.tsx index 79c6e74..0090400 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/index.tsx +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/index.tsx @@ -4,9 +4,9 @@ import React, { useEffect, useRef } from 'react'; import { InlineField, Input, QueryField } from '@grafana/ui'; -import { useDispatch, useStatelessReducer } from '../../../../../hooks/useStatelessReducer'; -import { Filters } from '../../../../../types'; -import { AddRemove } from '../../../../AddRemove'; +import { useDispatch, useStatelessReducer } from '@/hooks/useStatelessReducer'; +import { Filters } from '@/types'; +import { AddRemove } from '@/components/AddRemove'; import { changeBucketAggregationSetting } from '../../state/actions'; import { addFilter, changeFilter, removeFilter } from './state/actions'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/actions.ts b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/actions.ts index 30edf04..e4bc04a 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/actions.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/actions.ts @@ -1,6 +1,6 @@ import { createAction } from '@reduxjs/toolkit'; -import { Filter } from '../../../../../../types'; +import { Filter } from '@/types'; export const addFilter = createAction('@bucketAggregations/filter/add'); export const removeFilter = createAction('@bucketAggregations/filter/remove'); diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.test.ts b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.test.ts index e1080c3..5f41813 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.test.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.test.ts @@ -1,5 +1,5 @@ import { reducerTester } from 'dependencies/reducerTester'; -import { Filter } from '../../../../../../types'; +import { Filter } from '@/types'; import { addFilter, changeFilter, removeFilter } from './actions'; import { reducer } from './reducer'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.ts b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.ts index ab607b9..7247948 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/state/reducer.ts @@ -1,6 +1,6 @@ import { Action } from 'redux'; -import { Filter } from '../../../../../../types'; +import { Filter } from '@/types'; import { defaultFilter } from '../utils'; import { addFilter, changeFilter, removeFilter } from './actions'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/utils.ts b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/utils.ts index a216fcf..4d4270e 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/utils.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/FiltersSettingsEditor/utils.ts @@ -1,3 +1,3 @@ -import { Filter } from '../../../../../types'; +import { Filter } from '@/types'; export const defaultFilter = (): Filter => ({ label: '', query: '*' }); diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.test.tsx b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.test.tsx index dc7462c..f61857b 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.test.tsx +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.test.tsx @@ -2,7 +2,7 @@ import { screen } from '@testing-library/react'; import React from 'react'; import selectEvent from 'react-select-event'; -import { ElasticsearchQuery, Terms, Average, Derivative, TopMetrics } from '../../../../types'; +import { ElasticsearchQuery, Terms, Average, Derivative, TopMetrics } from '@/types'; import { TermsSettingsEditor } from './TermsSettingsEditor'; import { describeMetric } from 'utils'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.tsx b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.tsx index 5829a54..9fcb0a2 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.tsx +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.tsx @@ -4,12 +4,12 @@ import React, { useRef } from 'react'; import { SelectableValue } from '@grafana/data'; import { InlineField, Select, Input } from '@grafana/ui'; -import { useDispatch } from '../../../../hooks/useStatelessReducer'; -import { MetricAggregation, Percentiles, ExtendedStatMetaType, ExtendedStats, Terms } from '../../../../types'; -import { describeMetric } from '../../../../utils'; -import { useCreatableSelectPersistedBehaviour } from '../../../hooks/useCreatableSelectPersistedBehaviour'; -import { useQuery } from '../../ElasticsearchQueryContext'; -import { isPipelineAggregation } from '../../MetricAggregationsEditor/aggregations'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { MetricAggregation, Percentiles, ExtendedStatMetaType, ExtendedStats, Terms } from '@/types'; +import { describeMetric } from '@/utils'; +import { useCreatableSelectPersistedBehaviour } from '@/components/hooks/useCreatableSelectPersistedBehaviour'; +import { useQuery } from '@/components/QueryEditor/ElasticsearchQueryContext'; +import { isPipelineAggregation } from '@/components/QueryEditor/MetricAggregationsEditor/aggregations'; import { changeBucketAggregationSetting } from '../state/actions'; import { bucketAggregationConfig, orderByOptions, orderOptions, sizeOptions } from '../utils'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/index.tsx b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/index.tsx index 5edfeb7..ae0fdee 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/index.tsx +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/index.tsx @@ -3,9 +3,9 @@ import React, { ComponentProps, useRef } from 'react'; import { InlineField, Input } from '@grafana/ui'; -import { useDispatch } from '../../../../hooks/useStatelessReducer'; -import { BucketAggregation } from '../../../../types'; -import { SettingsEditorContainer } from '../../SettingsEditorContainer'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { BucketAggregation } from '@/types'; +import { SettingsEditorContainer } from '@/components/QueryEditor/SettingsEditorContainer'; import { changeBucketAggregationSetting } from '../state/actions'; import { bucketAggregationConfig } from '../utils'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/useDescription.ts b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/useDescription.ts index b2ea572..4625986 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/useDescription.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/useDescription.ts @@ -1,5 +1,5 @@ -import { BucketAggregation } from '../../../../types'; -import { describeMetric, convertOrderByToMetricId } from '../../../../utils'; +import { BucketAggregation } from '@/types'; +import { describeMetric, convertOrderByToMetricId } from '@/utils'; import { useQuery } from '../../ElasticsearchQueryContext'; import { bucketAggregationConfig, orderByOptions, orderOptions } from '../utils'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/aggregations.ts b/src/components/QueryEditor/BucketAggregationsEditor/aggregations.ts index 6a60679..857451b 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/aggregations.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/aggregations.ts @@ -1,4 +1,4 @@ -import { BucketAggregationType, BucketAggregationWithField, BucketAggregation } from '../../../types'; +import { BucketAggregationType, BucketAggregationWithField, BucketAggregation } from '@/types'; import { bucketAggregationConfig } from './utils'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/index.tsx b/src/components/QueryEditor/BucketAggregationsEditor/index.tsx index 01ae496..a61abc3 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/index.tsx +++ b/src/components/QueryEditor/BucketAggregationsEditor/index.tsx @@ -1,11 +1,11 @@ import React from 'react'; -import { useDispatch } from '../../../hooks/useStatelessReducer'; -import { IconButton } from '../../IconButton'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { IconButton } from '@/components/IconButton'; import { useQuery } from '../ElasticsearchQueryContext'; import { QueryEditorRow } from '../QueryEditorRow'; -import { BucketAggregation } from './../../../types'; +import { BucketAggregation } from '@/types'; import { BucketAggregationEditor } from './BucketAggregationEditor'; import { addBucketAggregation, removeBucketAggregation } from './state/actions'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/state/actions.ts b/src/components/QueryEditor/BucketAggregationsEditor/state/actions.ts index 2b20065..a94b0cd 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/state/actions.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/state/actions.ts @@ -1,6 +1,6 @@ import { createAction } from '@reduxjs/toolkit'; -import { BucketAggregation, BucketAggregationType, BucketAggregationWithField } from '../../../../types'; +import { BucketAggregation, BucketAggregationType, BucketAggregationWithField } from '@/types'; export const addBucketAggregation = createAction('@bucketAggs/add'); export const removeBucketAggregation = createAction('@bucketAggs/remove'); diff --git a/src/components/QueryEditor/BucketAggregationsEditor/state/reducer.test.ts b/src/components/QueryEditor/BucketAggregationsEditor/state/reducer.test.ts index 3e7a011..f02d1bc 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/state/reducer.test.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/state/reducer.test.ts @@ -1,5 +1,5 @@ import { reducerTester } from 'dependencies/reducerTester'; -import { BucketAggregation, DateHistogram, ElasticsearchQuery } from '../../../../types'; +import { BucketAggregation, DateHistogram, ElasticsearchQuery } from '@/types'; import { changeMetricType } from '../../MetricAggregationsEditor/state/actions'; import { initQuery } from '../../state'; import { bucketAggregationConfig } from '../utils'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/state/reducer.ts b/src/components/QueryEditor/BucketAggregationsEditor/state/reducer.ts index ec3aba5..fd449a2 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/state/reducer.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/state/reducer.ts @@ -1,8 +1,8 @@ import { Action } from '@reduxjs/toolkit'; -import { defaultBucketAgg } from '../../../../queryDef'; -import { ElasticsearchQuery, Terms, BucketAggregation } from '../../../../types'; -import { removeEmpty } from '../../../../utils'; +import { defaultBucketAgg } from '@/queryDef'; +import { ElasticsearchQuery, Terms, BucketAggregation } from '@/types'; +import { removeEmpty } from '@/utils'; import { changeMetricType } from '../../MetricAggregationsEditor/state/actions'; import { metricAggregationConfig } from '../../MetricAggregationsEditor/utils'; import { initExploreQuery, initQuery } from '../../state'; diff --git a/src/components/QueryEditor/BucketAggregationsEditor/utils.ts b/src/components/QueryEditor/BucketAggregationsEditor/utils.ts index 60ecba4..3e094c9 100644 --- a/src/components/QueryEditor/BucketAggregationsEditor/utils.ts +++ b/src/components/QueryEditor/BucketAggregationsEditor/utils.ts @@ -1,6 +1,6 @@ import { InternalTimeZones, SelectableValue } from '@grafana/data'; -import { BucketsConfiguration } from '../../../types'; +import { BucketsConfiguration } from '@/types'; import { defaultFilter } from './SettingsEditor/FiltersSettingsEditor/utils'; diff --git a/src/components/QueryEditor/ElasticsearchQueryContext.test.tsx b/src/components/QueryEditor/ElasticsearchQueryContext.test.tsx index 25c08ac..4a940b4 100644 --- a/src/components/QueryEditor/ElasticsearchQueryContext.test.tsx +++ b/src/components/QueryEditor/ElasticsearchQueryContext.test.tsx @@ -4,8 +4,8 @@ import React, { PropsWithChildren } from 'react'; import { getDefaultTimeRange } from '@grafana/data'; -import { ElasticDatasource } from '../../datasource'; -import { ElasticsearchQuery } from '../../types'; +import { ElasticDatasource } from '@/datasource'; +import { ElasticsearchQuery } from '@/types'; import { ElasticsearchProvider, useQuery } from './ElasticsearchQueryContext'; diff --git a/src/components/QueryEditor/ElasticsearchQueryContext.tsx b/src/components/QueryEditor/ElasticsearchQueryContext.tsx index db8af06..e598c2e 100644 --- a/src/components/QueryEditor/ElasticsearchQueryContext.tsx +++ b/src/components/QueryEditor/ElasticsearchQueryContext.tsx @@ -2,9 +2,9 @@ import React, { Context, createContext, PropsWithChildren, useCallback, useConte import { CoreApp, TimeRange } from '@grafana/data'; -import { ElasticDatasource } from '../../datasource'; -import { combineReducers, useStatelessReducer, DispatchContext } from '../../hooks/useStatelessReducer'; -import { ElasticsearchQuery } from '../../types'; +import { ElasticDatasource } from '@/datasource'; +import { combineReducers, useStatelessReducer, DispatchContext } from '@/hooks/useStatelessReducer'; +import { ElasticsearchQuery } from '@/types'; import { createReducer as createBucketAggsReducer } from './BucketAggregationsEditor/state/reducer'; import { reducer as metricsReducer } from './MetricAggregationsEditor/state/reducer'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx index 20455cf..e8142c0 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.test.tsx @@ -5,12 +5,11 @@ import { from } from 'rxjs'; import { CoreApp, getDefaultTimeRange } from '@grafana/data'; -import { ElasticDatasource } from '../../../datasource'; -import { defaultBucketAgg } from '../../../queryDef'; -import { ElasticsearchQuery } from '../../../types'; +import { ElasticDatasource } from '@/datasource'; +import { defaultBucketAgg } from '@/queryDef'; +import { ElasticsearchQuery, Count, UniqueCount } from '@/types'; import { ElasticsearchProvider } from '../ElasticsearchQueryContext'; -import { Count, UniqueCount } from './../../../types'; import { MetricEditor } from './MetricEditor'; describe('Metric Editor', () => { diff --git a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx index b63f319..faede80 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx @@ -5,9 +5,9 @@ import React, { useCallback } from 'react'; import { SelectableValue } from '@grafana/data'; import { InlineSegmentGroup, SegmentAsync, useTheme2 } from '@grafana/ui'; -import { useFields } from '../../../hooks/useFields'; -import { useDispatch } from '../../../hooks/useStatelessReducer'; -import { MetricAggregation, MetricAggregationType } from '../../../types'; +import { useFields } from '@/hooks/useFields'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { MetricAggregation, MetricAggregationType } from '@/types'; import { MetricPicker } from '../../MetricPicker'; import { useQuery } from '../ElasticsearchQueryContext'; import { segmentStyles } from '../styles'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/index.tsx b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/index.tsx index 4f8a9eb..53c40bd 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/index.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/index.tsx @@ -4,10 +4,10 @@ import React, { Fragment, useEffect } from 'react'; import { Input, InlineLabel } from '@grafana/ui'; -import { useStatelessReducer, useDispatch } from '../../../../../hooks/useStatelessReducer'; -import { BucketScript, MetricAggregation } from '../../../../../types'; -import { AddRemove } from '../../../../AddRemove'; -import { MetricPicker } from '../../../../MetricPicker'; +import { useStatelessReducer, useDispatch } from '@/hooks/useStatelessReducer'; +import { BucketScript, MetricAggregation } from '@/types'; +import { AddRemove } from '@/components/AddRemove'; +import { MetricPicker } from '@/components/MetricPicker'; import { changeMetricAttribute } from '../../state/actions'; import { SettingField } from '../SettingField'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.test.ts b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.test.ts index b557f9d..7da3166 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.test.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.test.ts @@ -1,5 +1,5 @@ import { reducerTester } from 'dependencies/reducerTester'; -import { PipelineVariable } from '../../../../../../types'; +import { PipelineVariable } from '@/types'; import { addPipelineVariable, diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.ts b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.ts index 455037e..41bee05 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/state/reducer.ts @@ -1,6 +1,6 @@ import { Action } from '@reduxjs/toolkit'; -import { PipelineVariable } from '../../../../../../types'; +import { PipelineVariable } from '@/types'; import { defaultPipelineVariable, generatePipelineVariableName } from '../utils'; import { diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/utils.ts b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/utils.ts index fdade3f..acfa7ab 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/utils.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/BucketScriptSettingsEditor/utils.ts @@ -1,4 +1,4 @@ -import { PipelineVariable } from '../../../../../types'; +import { PipelineVariable } from '@/types'; export const defaultPipelineVariable = (name: string): PipelineVariable => ({ name, pipelineAgg: '' }); diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/MovingAverageSettingsEditor.tsx b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/MovingAverageSettingsEditor.tsx index b8f5a94..fa0340e 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/MovingAverageSettingsEditor.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/MovingAverageSettingsEditor.tsx @@ -3,9 +3,9 @@ import React, { useRef } from 'react'; import { Input, InlineField, Select, InlineSwitch } from '@grafana/ui'; -import { useDispatch } from '../../../../hooks/useStatelessReducer'; -import { movingAvgModelOptions } from '../../../../queryDef'; -import { MovingAverage } from '../../../../types'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { movingAvgModelOptions } from '@/queryDef'; +import { MovingAverage } from '@/types'; import { isEWMAMovingAverage, isHoltMovingAverage, isHoltWintersMovingAverage } from '../aggregations'; import { changeMetricSetting } from '../state/actions'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/SettingField.tsx b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/SettingField.tsx index c530c34..97f7568 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/SettingField.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/SettingField.tsx @@ -3,9 +3,9 @@ import React, { ComponentProps, useState } from 'react'; import { InlineField, Input } from '@grafana/ui'; -import { useDispatch } from '../../../../hooks/useStatelessReducer'; -import { MetricAggregationWithSettings } from '../../../../types'; -import { SettingKeyOf } from '../../../types'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { MetricAggregationWithSettings } from '@/types'; +import { SettingKeyOf } from '@/components/types'; import { changeMetricSetting } from '../state/actions'; interface Props> { diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/TopMetricsSettingsEditor.tsx b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/TopMetricsSettingsEditor.tsx index 3c5bdba..990c27d 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/TopMetricsSettingsEditor.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/TopMetricsSettingsEditor.tsx @@ -4,10 +4,10 @@ import React from 'react'; import { SelectableValue } from '@grafana/data'; import { AsyncMultiSelect, InlineField, SegmentAsync, Select } from '@grafana/ui'; -import { useFields } from '../../../../hooks/useFields'; -import { useDispatch } from '../../../../hooks/useStatelessReducer'; -import { TopMetrics } from '../../../../types'; -import { orderOptions } from '../../BucketAggregationsEditor/utils'; +import { useFields } from '@/hooks/useFields'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { TopMetrics } from '@/types'; +import { orderOptions } from '@/components/QueryEditor/BucketAggregationsEditor/utils'; import { changeMetricSetting } from '../state/actions'; interface Props { diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.test.tsx b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.test.tsx index b089a55..5032c52 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.test.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.test.tsx @@ -3,8 +3,8 @@ import React from 'react'; import { CoreApp, getDefaultTimeRange } from '@grafana/data'; -import { ElasticDatasource } from '../../../../datasource'; -import { ElasticsearchQuery } from '../../../../types'; +import { ElasticDatasource } from '@/datasource'; +import { ElasticsearchQuery } from '@/types'; import { ElasticsearchProvider } from '../../ElasticsearchQueryContext'; import { SettingsEditor } from '.'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx index e7317da..3d56d04 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx @@ -2,9 +2,9 @@ import { uniqueId } from 'lodash'; import React, { ComponentProps, useRef, useState } from 'react'; import { InlineField, Input, InlineSwitch, Select } from '@grafana/ui'; -import { useDispatch } from '../../../../hooks/useStatelessReducer'; -import { extendedStats } from '../../../../queryDef'; -import { MetricAggregation, ExtendedStat } from '../../../../types'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { extendedStats } from '@/queryDef'; +import { MetricAggregation, ExtendedStat } from '@/types'; import { useQuery } from '../../ElasticsearchQueryContext'; import { SettingsEditorContainer } from '../../SettingsEditorContainer'; import { isMetricAggregationWithMissingSupport } from '../aggregations'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/useDescription.ts b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/useDescription.ts index e6e10c8..b143c59 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/useDescription.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/useDescription.ts @@ -1,5 +1,5 @@ import { extendedStats } from 'queryDef'; -import { MetricAggregation } from '../../../../types'; +import { MetricAggregation } from '@/types'; const hasValue = (value: string) => (object: { value: string }) => object.value === value; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/aggregations.ts b/src/components/QueryEditor/MetricAggregationsEditor/aggregations.ts index 24e423b..db112da 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/aggregations.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/aggregations.ts @@ -8,7 +8,7 @@ import { MetricAggregationWithMissingSupport, PipelineMetricAggregation, MetricAggregationWithSettings, -} from '../../../types'; +} from '@/types'; import { metricAggregationConfig } from './utils'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/index.tsx b/src/components/QueryEditor/MetricAggregationsEditor/index.tsx index fd798c2..3296612 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/index.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/index.tsx @@ -1,11 +1,11 @@ import React from 'react'; -import { useDispatch } from '../../../hooks/useStatelessReducer'; +import { useDispatch } from '@/hooks/useStatelessReducer'; import { IconButton } from '../../IconButton'; import { useQuery } from '../ElasticsearchQueryContext'; import { QueryEditorRow } from '../QueryEditorRow'; -import { MetricAggregation } from './../../../types'; +import { MetricAggregation } from '@/types'; import { MetricEditor } from './MetricEditor'; import { addMetric, removeMetric, toggleMetricVisibility } from './state/actions'; import { metricAggregationConfig } from './utils'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/state/actions.ts b/src/components/QueryEditor/MetricAggregationsEditor/state/actions.ts index 9c3fe19..69047a1 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/state/actions.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/state/actions.ts @@ -1,6 +1,6 @@ import { createAction } from '@reduxjs/toolkit'; -import { MetricAggregationWithMeta, MetricAggregation, MetricAggregationWithSettings } from '../../../../types'; +import { MetricAggregationWithMeta, MetricAggregation, MetricAggregationWithSettings } from '@/types'; export const addMetric = createAction('@metrics/add'); export const removeMetric = createAction('@metrics/remove'); diff --git a/src/components/QueryEditor/MetricAggregationsEditor/state/reducer.test.ts b/src/components/QueryEditor/MetricAggregationsEditor/state/reducer.test.ts index dea9145..4e96531 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/state/reducer.test.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/state/reducer.test.ts @@ -1,6 +1,6 @@ import { reducerTester } from 'dependencies/reducerTester'; -import { defaultMetricAgg } from '../../../../queryDef'; -import { Derivative, ElasticsearchQuery, ExtendedStats, MetricAggregation } from '../../../../types'; +import { defaultMetricAgg } from '@/queryDef'; +import { Derivative, ElasticsearchQuery, ExtendedStats, MetricAggregation } from '@/types'; import { initQuery } from '../../state'; import { metricAggregationConfig } from '../utils'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/state/reducer.ts b/src/components/QueryEditor/MetricAggregationsEditor/state/reducer.ts index 493086f..10f096b 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/state/reducer.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/state/reducer.ts @@ -1,7 +1,7 @@ import { Action } from '@reduxjs/toolkit'; -import { defaultLogsAgg, defaultMetricAgg } from '../../../../queryDef'; -import { ElasticsearchQuery, MetricAggregation } from '../../../../types'; -import { removeEmpty } from '../../../../utils'; +import { defaultLogsAgg, defaultMetricAgg } from '@/queryDef'; +import { ElasticsearchQuery, MetricAggregation } from '@/types'; +import { removeEmpty } from '@/utils'; import { initExploreQuery, initQuery } from '../../state'; import { isMetricAggregationWithMeta, isMetricAggregationWithSettings, isPipelineAggregation } from '../aggregations'; import { getChildren, metricAggregationConfig } from '../utils'; diff --git a/src/components/QueryEditor/MetricAggregationsEditor/utils.ts b/src/components/QueryEditor/MetricAggregationsEditor/utils.ts index d9aa246..bab53bf 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/utils.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/utils.ts @@ -1,4 +1,4 @@ -import { MetricsConfiguration, MetricAggregation, PipelineMetricAggregationType } from '../../../types'; +import { MetricsConfiguration, MetricAggregation, PipelineMetricAggregationType } from '@/types'; import { defaultPipelineVariable, diff --git a/src/components/QueryEditor/QueryEditorSpecialMetricRow.tsx b/src/components/QueryEditor/QueryEditorSpecialMetricRow.tsx index 6820e01..ab34c00 100644 --- a/src/components/QueryEditor/QueryEditorSpecialMetricRow.tsx +++ b/src/components/QueryEditor/QueryEditorSpecialMetricRow.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { InlineFieldRow, InlineLabel, InlineSegmentGroup } from '@grafana/ui'; -import { MetricAggregation } from '../../types'; +import { MetricAggregation } from '@/types'; import { SettingsEditor } from './MetricAggregationsEditor/SettingsEditor'; diff --git a/src/components/QueryEditor/QueryTypeSelector.tsx b/src/components/QueryEditor/QueryTypeSelector.tsx index aacc394..e164ef3 100644 --- a/src/components/QueryEditor/QueryTypeSelector.tsx +++ b/src/components/QueryEditor/QueryTypeSelector.tsx @@ -3,8 +3,8 @@ import React from 'react'; import { SelectableValue } from '@grafana/data'; import { RadioButtonGroup } from '@grafana/ui'; -import { useDispatch } from '../../hooks/useStatelessReducer'; -import { MetricAggregation, QueryType } from '../../types'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { MetricAggregation, QueryType } from '@/types'; import { useQuery } from './ElasticsearchQueryContext'; import { changeMetricType } from './MetricAggregationsEditor/state/actions'; diff --git a/src/components/QueryEditor/index.test.tsx b/src/components/QueryEditor/index.test.tsx index 37e3a51..f51cf03 100644 --- a/src/components/QueryEditor/index.test.tsx +++ b/src/components/QueryEditor/index.test.tsx @@ -1,8 +1,8 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; -import { ElasticDatasource } from '../../datasource'; -import { ElasticsearchQuery } from '../../types'; +import { ElasticDatasource } from '@/datasource'; +import { ElasticsearchQuery } from '@/types'; import { QueryEditor } from '.'; import { noop } from 'lodash'; diff --git a/src/components/QueryEditor/index.tsx b/src/components/QueryEditor/index.tsx index 67ec64b..94204f5 100644 --- a/src/components/QueryEditor/index.tsx +++ b/src/components/QueryEditor/index.tsx @@ -5,10 +5,10 @@ import React from 'react'; import { getDefaultTimeRange, GrafanaTheme2, QueryEditorProps } from '@grafana/data'; import { InlineLabel, QueryField, useStyles2 } from '@grafana/ui'; -import { ElasticDatasource } from '../../datasource'; -import { useNextId } from '../../hooks/useNextId'; -import { useDispatch } from '../../hooks/useStatelessReducer'; -import { ElasticsearchQuery } from '../../types'; +import { ElasticDatasource } from '@/datasource'; +import { useNextId } from '@/hooks/useNextId'; +import { useDispatch } from '@/hooks/useStatelessReducer'; +import { ElasticsearchQuery } from '@/types'; import { BucketAggregationsEditor } from './BucketAggregationsEditor'; import { ElasticsearchProvider } from './ElasticsearchQueryContext'; diff --git a/src/components/QueryEditor/state.test.ts b/src/components/QueryEditor/state.test.ts index 8addc34..8abab39 100644 --- a/src/components/QueryEditor/state.test.ts +++ b/src/components/QueryEditor/state.test.ts @@ -1,5 +1,5 @@ import { reducerTester } from 'dependencies/reducerTester'; -import { ElasticsearchQuery } from '../../types'; +import { ElasticsearchQuery } from '@/types'; import { aliasPatternReducer, changeAliasPattern, changeQuery, initQuery, queryReducer } from './state'; diff --git a/src/components/QueryEditor/state.ts b/src/components/QueryEditor/state.ts index 712557b..67cc43b 100644 --- a/src/components/QueryEditor/state.ts +++ b/src/components/QueryEditor/state.ts @@ -1,6 +1,6 @@ import { Action, createAction } from '@reduxjs/toolkit'; -import { ElasticsearchQuery } from '../../types'; +import { ElasticsearchQuery } from '@/types'; /** * When the `initQuery` Action is dispatched, the query gets populated with default values where values are not present.