Skip to content

Commit 2772e65

Browse files
typing error fix and modifications (#101)
* typing error fix and modifications * react-use module installed * Fix type error and adhoc filter alignment * Fix one more type error --------- Co-authored-by: Spikatrix <[email protected]>
1 parent 9fcd69d commit 2772e65

File tree

70 files changed

+522
-2201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+522
-2201
lines changed

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@
147147
"@types/papaparse": "5.3.7",
148148
"@types/pluralize": "^0.0.29",
149149
"@types/prismjs": "1.26.0",
150-
"@types/react": "18.2.15",
150+
"@types/react": "18.2.28",
151151
"@types/react-beautiful-dnd": "13.1.3",
152+
"@types/react-datepicker": "^4.19.0",
152153
"@types/react-dom": "18.2.7",
153154
"@types/react-grid-layout": "1.3.2",
154155
"@types/react-highlight-words": "0.16.4",
@@ -275,7 +276,7 @@
275276
"@grafana/ui": "workspace:*",
276277
"@kusto/monaco-kusto": "^7.4.0",
277278
"@leeoniya/ufuzzy": "1.0.8",
278-
"@lezer/common": "1.0.2",
279+
"@lezer/common": "^1.1.0",
279280
"@lezer/highlight": "1.1.3",
280281
"@lezer/lr": "1.3.3",
281282
"@locker/near-membrane-dom": "^0.12.15",
@@ -287,7 +288,7 @@
287288
"@opentelemetry/exporter-collector": "0.25.0",
288289
"@opentelemetry/semantic-conventions": "1.15.0",
289290
"@popperjs/core": "2.11.6",
290-
"@prometheus-io/lezer-promql": "^0.37.0-rc.1",
291+
"@prometheus-io/lezer-promql": "0.37.0-rc.1",
291292
"@pyroscope/flamegraph": "^0.35.5",
292293
"@react-aria/button": "3.8.0",
293294
"@react-aria/dialog": "3.5.3",
@@ -410,7 +411,7 @@
410411
"react-split-pane": "0.1.92",
411412
"react-table": "7.8.0",
412413
"react-transition-group": "4.4.5",
413-
"react-use": "17.4.0",
414+
"react-use": "^17.4.0",
414415
"react-virtual": "2.10.4",
415416
"react-virtualized-auto-sizer": "1.0.7",
416417
"react-window": "1.8.8",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { QueryResultMeta } from '../types';
2+
import { Field, FieldType, DataFrame, TIME_SERIES_VALUE_FIELD_NAME } from '../types/dataFrame';
3+
4+
import { guessFieldTypeForField } from './processDataFrame';
5+
6+
/**
7+
* The ArrayDataFrame takes an array of objects and presents it as a DataFrame
8+
*
9+
* @deprecated use arrayToDataFrame
10+
*/
11+
export class ArrayDataFrame<T = any> implements DataFrame {
12+
fields: Field[] = [];
13+
length = 0;
14+
name?: string;
15+
refId?: string;
16+
meta?: QueryResultMeta;
17+
18+
constructor(source: T[], names?: string[]) {
19+
return arrayToDataFrame(source, names) as ArrayDataFrame<T>; // returns a standard DataFrame
20+
}
21+
}
22+
23+
/**
24+
* arrayToDataFrame will convert any array into a DataFrame
25+
*
26+
* @public
27+
*/
28+
export function arrayToDataFrame(source: any[], names?: string[]): DataFrame {
29+
const df: DataFrame = {
30+
fields: [],
31+
length: source.length,
32+
};
33+
if (!source?.length) {
34+
return df;
35+
}
36+
37+
if (names) {
38+
for (const name of names) {
39+
df.fields.push(
40+
makeFieldFromValues(
41+
name,
42+
source.map((v) => v[name])
43+
)
44+
);
45+
}
46+
return df;
47+
}
48+
49+
const first = source.find((v) => v != null); // first not null|undefined
50+
if (first != null) {
51+
if (typeof first === 'object') {
52+
df.fields = Object.keys(first).map((name) => {
53+
return makeFieldFromValues(
54+
name,
55+
source.map((v) => v[name])
56+
);
57+
});
58+
} else {
59+
df.fields.push(makeFieldFromValues(TIME_SERIES_VALUE_FIELD_NAME, source));
60+
}
61+
}
62+
return df;
63+
}
64+
65+
function makeFieldFromValues(name: string, values: unknown[]): Field {
66+
const f = { name, config: {}, values, type: FieldType.other };
67+
f.type = guessFieldTypeForField(f) ?? FieldType.other;
68+
return f;
69+
}

packages/grafana-data/src/themes/fnCreateColors.ts

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class FnDarkColors implements ThemeColorsBase<Partial<ThemeRichColor>> {
7575
disabledText: this.text.disabled,
7676
disabledBackground: `rgba(${this.whiteBase}, 0.04)`,
7777
disabledOpacity: 0.38,
78+
selectedBorder: palette.orangeDarkMain,
7879
};
7980

8081
gradients = {
@@ -155,6 +156,7 @@ class FnLightColors implements ThemeColorsBase<Partial<ThemeRichColor>> {
155156
disabledBackground: `rgba(${this.blackBase}, 0.04)`,
156157
disabledText: this.text.disabled,
157158
disabledOpacity: 0.38,
159+
selectedBorder: palette.orangeLightMain,
158160
};
159161

160162
gradients = {

packages/grafana-data/src/types/featureToggles.gen.ts

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface FeatureToggles {
5757
accessTokenExpirationCheck?: boolean;
5858
emptyDashboardPage?: boolean;
5959
disablePrometheusExemplarSampling?: boolean;
60+
datasourceOnboarding?: boolean;
6061
alertingBacktesting?: boolean;
6162
editPanelCSVDragAndDrop?: boolean;
6263
alertingNoNormalState?: boolean;
@@ -72,6 +73,7 @@ export interface FeatureToggles {
7273
clientTokenRotation?: boolean;
7374
prometheusDataplane?: boolean;
7475
lokiMetricDataplane?: boolean;
76+
newTraceView?: boolean;
7577
lokiLogsDataplane?: boolean;
7678
dataplaneFrontendFallback?: boolean;
7779
disableSSEDataplane?: boolean;

packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import CustomScrollbar from '../../CustomScrollbar/CustomScrollbar';
1414
import { Field } from '../../Forms/Field';
1515
import { Icon } from '../../Icon/Icon';
1616
import { getInputStyles, Input } from '../../Input/Input';
17-
import { Portal } from '../../Portal/Portal';
1817
import { Tooltip } from '../../Tooltip/Tooltip';
1918
import { TimePickerTitle } from '../TimeRangePicker/TimePickerTitle';
2019
import { TimeRangeList } from '../TimeRangePicker/TimeRangeList';

packages/grafana-ui/src/components/Dropdown/Dropdown.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const Dropdown = React.memo(({ children, overlay, placement, offset, onVi
5151

5252
return (
5353
<>
54+
{/* @ts-ignore */}
5455
{React.cloneElement(typeof children === 'function' ? children(visible) : children, {
5556
ref: setTriggerRef,
5657
})}
@@ -71,6 +72,7 @@ export const Dropdown = React.memo(({ children, overlay, placement, offset, onVi
7172
timeout={{ appear: animationDuration, exit: 0, enter: 0 }}
7273
classNames={animationStyles}
7374
>
75+
{/* @ts-ignore */}
7476
<div ref={transitionRef}>{ReactUtils.renderOrCallToRender(overlay, {})}</div>
7577
</CSSTransition>
7678
</div>

packages/grafana-ui/src/components/Icon/Icon.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ const getIconStyles = (theme: GrafanaTheme2) => {
3737
};
3838

3939
export const Icon = React.forwardRef<HTMLDivElement, IconProps>(
40-
({ size = 'md', type = 'default', name, className, style, title = '', ...divElementProps }, ref) => {
40+
({ size = 'md', type = 'default', name, className, style, title = '', ...divElementProps }, ref): JSX.Element => {
4141
const styles = useStyles2(getIconStyles);
4242

4343
/* Temporary solution to display also font awesome icons */
4444
if (name?.startsWith('fa fa-')) {
45+
/* @ts-ignore */
4546
return <i className={getFontAwesomeIconStyles(name, className)} {...divElementProps} style={style} />;
4647
}
4748

@@ -65,6 +66,7 @@ export const Icon = React.forwardRef<HTMLDivElement, IconProps>(
6566

6667
return (
6768
<div className={styles.container} {...divElementProps} ref={ref}>
69+
{/* @ts-ignore */}
6870
<SVG
6971
src={svgPath}
7072
width={svgWid}

packages/grafana-ui/src/components/Menu/MenuItem.tsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,30 @@ export const MenuItem = React.memo(
160160
{...disabledProps}
161161
>
162162
<>
163+
{/* @ts-ignore */}
163164
{icon && <Icon name={icon} className={styles.icon} aria-hidden />}
164165
{label}
165166

166167
<div className={cx(styles.rightWrapper, { [styles.withShortcut]: hasShortcut })}>
167168
{hasShortcut && (
168169
<div className={styles.shortcut}>
170+
{/* @ts-ignore */}
169171
<Icon name="keyboard" aria-hidden />
170172
{shortcut}
171173
</div>
172174
)}
173175
{hasSubMenu && (
174-
<SubMenu
175-
items={childItems}
176-
isOpen={isSubMenuOpen}
177-
openedWithArrow={openedWithArrow}
178-
setOpenedWithArrow={setOpenedWithArrow}
179-
close={closeSubMenu}
180-
customStyle={customSubMenuContainerStyles}
181-
/>
176+
<>
177+
{/* @ts-ignore */}
178+
<SubMenu
179+
items={childItems}
180+
isOpen={isSubMenuOpen}
181+
openedWithArrow={openedWithArrow}
182+
setOpenedWithArrow={setOpenedWithArrow}
183+
close={closeSubMenu}
184+
customStyle={customSubMenuContainerStyles}
185+
/>
186+
</>
182187
)}
183188
</div>
184189
</>

packages/grafana-ui/src/components/Menu/SubMenu.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const SubMenu = React.memo(
5050
return (
5151
<>
5252
<div className={styles.iconWrapper} aria-label={selectors.components.Menu.SubMenu.icon}>
53+
{/* @ts-ignore */}
5354
<Icon name="angle-right" className={styles.icon} aria-hidden />
5455
</div>
5556
{isOpen && (
@@ -60,6 +61,7 @@ export const SubMenu = React.memo(
6061
style={customStyle}
6162
>
6263
<div tabIndex={-1} className={styles.itemsWrapper} role="menu" onKeyDown={handleKeys}>
64+
{/* @ts-ignore */}
6365
{items}
6466
</div>
6567
</div>

packages/grafana-ui/src/components/Select/SelectBase.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function SelectBase<T, Rest = {}>({
125125
menuPlacement = 'auto',
126126
menuPosition,
127127
menuShouldPortal = true,
128-
noOptionsMessage = t('grafana-ui.select.no-options-label', 'No options found'),
128+
noOptionsMessage = t('grafana-ui.select.no-options-label', 'No options found') as string,
129129
onBlur,
130130
onChange,
131131
onCloseMenu,
@@ -138,7 +138,7 @@ export function SelectBase<T, Rest = {}>({
138138
onFocus,
139139
openMenuOnFocus = false,
140140
options = [],
141-
placeholder = t('grafana-ui.select.placeholder', 'Choose'),
141+
placeholder = t('grafana-ui.select.placeholder', 'Choose') as string,
142142
prefix,
143143
renderControl,
144144
showAllSelectedWhenOpen = true,

packages/grafana-ui/src/components/ToolbarButton/ToolbarButton.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { cx, css } from '@emotion/css';
2-
import { isString } from 'lodash';
32
import React, { forwardRef, ButtonHTMLAttributes, ReactNode } from 'react';
43

54
import { GrafanaTheme2, IconName, isIconName } from '@grafana/data';

packages/grafana-ui/src/themes/ThemeContext.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const withTheme = <P extends Themeable, S extends {} = {}>(Component: Rea
4040
};
4141

4242
WithTheme.displayName = `WithTheme(${Component.displayName})`;
43+
// @ts-ignore
4344
hoistNonReactStatics(WithTheme, Component);
4445
type Hoisted = typeof WithTheme & S;
4546
return WithTheme as Hoisted;
@@ -60,6 +61,7 @@ export const withTheme2 = <P extends Themeable2, S extends {} = {}>(Component: R
6061
};
6162

6263
WithTheme.displayName = `WithTheme(${Component.displayName})`;
64+
// @ts-ignore
6365
hoistNonReactStatics(WithTheme, Component);
6466
type Hoisted = typeof WithTheme & S;
6567
return WithTheme as Hoisted;

packages/grafana-ui/src/themes/mixins.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ export function mediaUp(breakpoint: string) {
4040
return `only screen and (min-width: ${breakpoint})`;
4141
}
4242

43-
const isGrafanaTheme2 = (theme: GrafanaTheme | GrafanaTheme2): theme is GrafanaTheme2 => theme.hasOwnProperty('v1');
43+
// const isGrafanaTheme2 = (theme: GrafanaTheme | GrafanaTheme2): theme is GrafanaTheme2 => theme.hasOwnProperty('v1');
4444
export const focusCss = (theme: GrafanaTheme | GrafanaTheme2) => {
45-
const isTheme2 = isGrafanaTheme2(theme);
45+
/* const isTheme2 = isGrafanaTheme2(theme);
4646
const firstColor = isTheme2 ? theme.colors.background.canvas : theme.colors.bodyBg;
4747
const secondColor = isTheme2 ? theme.colors.primary.main : theme.colors.formFocusOutline;
48+
box-shadow: 0 0 0 2px ${firstColor}, 0 0 0px 4px ${secondColor}; */
4849

4950
return `
5051
outline: 2px dotted transparent;
5152
outline-offset: 2px;
52-
box-shadow: 0 0 0 2px ${firstColor}, 0 0 0px 4px ${secondColor};
5353
transition-property: outline, outline-offset, box-shadow;
5454
transition-duration: 0.2s;
5555
transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1);`;

public/app/core/components/Page/SectionNavItem.test.tsx

-25
This file was deleted.

public/app/core/components/TraceToMetrics/TraceToMetricsSettings.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function TraceToMetricsSettings({ options, onOptionsChange }: Props) {
8282
<InlineFieldRow>
8383
<IntervalInput
8484
label={getTimeShiftLabel('start')}
85-
tooltip={getTimeShiftTooltip('start')}
85+
tooltip={getTimeShiftTooltip('start', '')}
8686
value={options.jsonData.tracesToMetrics?.spanStartTimeShift || ''}
8787
onChange={(val) => {
8888
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'tracesToMetrics', {
@@ -97,7 +97,7 @@ export function TraceToMetricsSettings({ options, onOptionsChange }: Props) {
9797
<InlineFieldRow>
9898
<IntervalInput
9999
label={getTimeShiftLabel('end')}
100-
tooltip={getTimeShiftTooltip('end')}
100+
tooltip={getTimeShiftTooltip('end', '')}
101101
value={options.jsonData.tracesToMetrics?.spanEndTimeShift || ''}
102102
onChange={(val) => {
103103
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'tracesToMetrics', {

public/app/core/navigation/GrafanaRoute.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { GrafanaRoute, Props } from './GrafanaRoute';
1212
import { GrafanaRouteComponentProps } from './types';
1313

1414
function setup(overrides: Partial<Props>) {
15-
const store = configureStore();
1615
const props: Props = {
1716
location: { search: '?query=hello&test=asd' } as Location,
1817
history: {} as History,

public/app/core/utils/ConfigProvider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ export const ThemeProvider = ({ children, value }: { children: React.ReactNode;
3636

3737
export const provideTheme = (component: React.ComponentType<any>, theme: GrafanaTheme2) => {
3838
return function ThemeProviderWrapper(props: any) {
39-
return <ThemeProvider value={theme} children={React.createElement(component, { ...props })} />;
39+
return <ThemeProvider value={theme}>{React.createElement(component, { ...props })}</ThemeProvider>;
4040
};
4141
};

public/app/features/alerting/AlertRuleList.test.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { render, screen } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
33
import React from 'react';
4-
import { Provider } from 'react-redux';
54
import { openMenu } from 'react-select-event';
65
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
76
import { TestProvider } from 'test/helpers/TestProvider';
@@ -10,7 +9,6 @@ import { locationService } from '@grafana/runtime';
109
import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps';
1110

1211
import appEvents from '../../core/app_events';
13-
import { configureStore } from '../../store/configureStore';
1412
import { ShowModalReactEvent } from '../../types/events';
1513

1614
import { AlertHowToModal } from './AlertHowToModal';
@@ -32,7 +30,6 @@ const defaultProps: Props = {
3230
};
3331

3432
const setup = (propOverrides?: object) => {
35-
const store = configureStore();
3633
const props: Props = {
3734
...defaultProps,
3835
...propOverrides,

public/app/features/alerting/unified/components/rule-editor/GrafanaEvaluationBehavior.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ function FolderGroupAndEvaluationInterval({
156156
function ForInput({ evaluateEvery }: { evaluateEvery: string }) {
157157
const styles = useStyles2(getStyles);
158158
const {
159-
watch,
160159
register,
161160
formState: { errors },
162161
} = useFormContext<RuleFormValues>();

0 commit comments

Comments
 (0)