mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: reverted back to import * as module
instead of using namespaces (#23069)
* Removed namespace declaration to prevent issues with external plugins. * fixed imports and tests.
This commit is contained in:
parent
c4693378dd
commit
f75387bd14
@ -1,7 +1,7 @@
|
|||||||
import sinon, { SinonFakeTimers } from 'sinon';
|
import sinon, { SinonFakeTimers } from 'sinon';
|
||||||
import each from 'lodash/each';
|
import each from 'lodash/each';
|
||||||
|
|
||||||
import { dateMath } from './datemath';
|
import * as dateMath from './datemath';
|
||||||
import { dateTime, DurationUnit, DateTime } from './moment_wrapper';
|
import { dateTime, DurationUnit, DateTime } from './moment_wrapper';
|
||||||
|
|
||||||
describe('DateMath', () => {
|
describe('DateMath', () => {
|
||||||
|
@ -5,8 +5,6 @@ import { TimeZone } from '../types/index';
|
|||||||
|
|
||||||
const units: DurationUnit[] = ['y', 'M', 'w', 'd', 'h', 'm', 's'];
|
const units: DurationUnit[] = ['y', 'M', 'w', 'd', 'h', 'm', 's'];
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
export namespace dateMath {
|
|
||||||
export function isMathString(text: string | DateTime | Date): boolean {
|
export function isMathString(text: string | DateTime | Date): boolean {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return false;
|
return false;
|
||||||
@ -162,4 +160,3 @@ export namespace dateMath {
|
|||||||
}
|
}
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Names are too general to export globally
|
// Names are too general to export globally
|
||||||
export { dateMath } from './datemath';
|
import * as dateMath from './datemath';
|
||||||
export { rangeUtil } from './rangeutil';
|
import * as rangeUtil from './rangeutil';
|
||||||
export * from './moment_wrapper';
|
export * from './moment_wrapper';
|
||||||
export * from './timezones';
|
export * from './timezones';
|
||||||
export * from './formats';
|
export * from './formats';
|
||||||
|
export { dateMath, rangeUtil };
|
||||||
|
@ -3,11 +3,9 @@ import groupBy from 'lodash/groupBy';
|
|||||||
|
|
||||||
import { RawTimeRange } from '../types/time';
|
import { RawTimeRange } from '../types/time';
|
||||||
|
|
||||||
import { dateMath } from './datemath';
|
import * as dateMath from './datemath';
|
||||||
import { isDateTime, DateTime } from './moment_wrapper';
|
import { isDateTime, DateTime } from './moment_wrapper';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
export namespace rangeUtil {
|
|
||||||
const spans: { [key: string]: { display: string; section?: number } } = {
|
const spans: { [key: string]: { display: string; section?: number } } = {
|
||||||
s: { display: 'second' },
|
s: { display: 'second' },
|
||||||
m: { display: 'minute' },
|
m: { display: 'minute' },
|
||||||
@ -182,4 +180,3 @@ export namespace rangeUtil {
|
|||||||
const info = describeTextRange(value);
|
const info = describeTextRange(value);
|
||||||
return info.invalid !== true;
|
return info.invalid !== true;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
@ -5,11 +5,8 @@ export interface AppEvent<T> {
|
|||||||
payload?: T;
|
payload?: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
export namespace AppEvents {
|
|
||||||
export type AlertPayload = [string, string?];
|
export type AlertPayload = [string, string?];
|
||||||
|
|
||||||
export const alertSuccess = eventFactory<AlertPayload>('alert-success');
|
export const alertSuccess = eventFactory<AlertPayload>('alert-success');
|
||||||
export const alertWarning = eventFactory<AlertPayload>('alert-warning');
|
export const alertWarning = eventFactory<AlertPayload>('alert-warning');
|
||||||
export const alertError = eventFactory<AlertPayload>('alert-error');
|
export const alertError = eventFactory<AlertPayload>('alert-error');
|
||||||
}
|
|
||||||
|
@ -24,5 +24,9 @@ export * from './theme';
|
|||||||
export * from './orgs';
|
export * from './orgs';
|
||||||
export * from './flot';
|
export * from './flot';
|
||||||
|
|
||||||
export { AppEvent, AppEvents } from './appEvents';
|
import * as AppEvents from './appEvents';
|
||||||
export { PanelEvents } from './panelEvents';
|
import { AppEvent } from './appEvents';
|
||||||
|
export { AppEvent, AppEvents };
|
||||||
|
|
||||||
|
import * as PanelEvents from './panelEvents';
|
||||||
|
export { PanelEvents };
|
||||||
|
@ -2,8 +2,6 @@ import { eventFactory } from './utils';
|
|||||||
import { DataQueryError, DataQueryResponseData } from './datasource';
|
import { DataQueryError, DataQueryResponseData } from './datasource';
|
||||||
import { AngularPanelMenuItem } from './panel';
|
import { AngularPanelMenuItem } from './panel';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
export namespace PanelEvents {
|
|
||||||
/** Payloads */
|
/** Payloads */
|
||||||
export interface PanelChangeViewPayload {
|
export interface PanelChangeViewPayload {
|
||||||
fullscreen?: boolean;
|
fullscreen?: boolean;
|
||||||
@ -26,4 +24,3 @@ export namespace PanelEvents {
|
|||||||
export const panelTeardown = eventFactory('panel-teardown');
|
export const panelTeardown = eventFactory('panel-teardown');
|
||||||
export const render = eventFactory<any>('render');
|
export const render = eventFactory<any>('render');
|
||||||
export const viewModeChanged = eventFactory('view-mode-changed');
|
export const viewModeChanged = eventFactory('view-mode-changed');
|
||||||
}
|
|
||||||
|
@ -2,7 +2,7 @@ import React, { ChangeEvent } from 'react';
|
|||||||
import { HorizontalGroup } from '../Layout/Layout';
|
import { HorizontalGroup } from '../Layout/Layout';
|
||||||
import Forms from '../Forms';
|
import Forms from '../Forms';
|
||||||
import { MappingType, RangeMap, ValueMap, ValueMapping } from '@grafana/data';
|
import { MappingType, RangeMap, ValueMap, ValueMapping } from '@grafana/data';
|
||||||
import { styleMixins } from '../../themes/mixins';
|
import * as styleMixins from '../../themes/mixins';
|
||||||
import { useTheme } from '../../themes';
|
import { useTheme } from '../../themes';
|
||||||
import { FieldConfigItemHeaderTitle } from '../FieldConfigs/FieldConfigItemHeaderTitle';
|
import { FieldConfigItemHeaderTitle } from '../FieldConfigs/FieldConfigItemHeaderTitle';
|
||||||
|
|
||||||
|
@ -3,4 +3,6 @@ import { getTheme, mockTheme } from './getTheme';
|
|||||||
import { selectThemeVariant } from './selectThemeVariant';
|
import { selectThemeVariant } from './selectThemeVariant';
|
||||||
export { stylesFactory } from './stylesFactory';
|
export { stylesFactory } from './stylesFactory';
|
||||||
export { ThemeContext, withTheme, mockTheme, getTheme, selectThemeVariant, useTheme, mockThemeContext };
|
export { ThemeContext, withTheme, mockTheme, getTheme, selectThemeVariant, useTheme, mockThemeContext };
|
||||||
export { styleMixins } from './mixins';
|
|
||||||
|
import * as styleMixins from './mixins';
|
||||||
|
export { styleMixins };
|
||||||
|
@ -3,8 +3,6 @@ import { selectThemeVariant } from './selectThemeVariant';
|
|||||||
import { css } from 'emotion';
|
import { css } from 'emotion';
|
||||||
import { stylesFactory } from './stylesFactory';
|
import { stylesFactory } from './stylesFactory';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
export namespace styleMixins {
|
|
||||||
export function cardChrome(theme: GrafanaTheme): string {
|
export function cardChrome(theme: GrafanaTheme): string {
|
||||||
if (theme.isDark) {
|
if (theme.isDark) {
|
||||||
return `
|
return `
|
||||||
@ -98,4 +96,3 @@ export namespace styleMixins {
|
|||||||
`,
|
`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
export namespace DOMUtil {
|
|
||||||
// Node.closest() polyfill
|
// Node.closest() polyfill
|
||||||
if ('Element' in window && !Element.prototype.closest) {
|
if ('Element' in window && !Element.prototype.closest) {
|
||||||
Element.prototype.closest = function(this: any, s: string) {
|
Element.prototype.closest = function(this: any, s: string) {
|
||||||
@ -41,4 +39,3 @@ export namespace DOMUtil {
|
|||||||
const offset = range.startOffset;
|
const offset = range.startOffset;
|
||||||
return text!.substr(offset, 1);
|
return text!.substr(offset, 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -6,5 +6,5 @@ export * from './tags';
|
|||||||
export * from './measureText';
|
export * from './measureText';
|
||||||
export { default as ansicolor } from './ansicolor';
|
export { default as ansicolor } from './ansicolor';
|
||||||
|
|
||||||
// Export with a namespace
|
import * as DOMUtil from './dom'; // includes Element.closest polyfil
|
||||||
export { DOMUtil } from './dom'; // includes Element.closest polyfil
|
export { DOMUtil };
|
||||||
|
Loading…
Reference in New Issue
Block a user