mirror of
https://github.com/apache/superset.git
synced 2026-05-07 17:04:58 +00:00
refactor: Move fetchTimeRange to core package (#27852)
This commit is contained in:
committed by
GitHub
parent
30bc8f06dc
commit
a498d6d10f
@@ -19,9 +19,8 @@
|
||||
|
||||
import React from 'react';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import { supersetTheme } from '@superset-ui/core';
|
||||
import { ErrorLevel, supersetTheme } from '@superset-ui/core';
|
||||
import BasicErrorAlert from './BasicErrorAlert';
|
||||
import { ErrorLevel } from './types';
|
||||
|
||||
jest.mock(
|
||||
'src/components/Icons/Icon',
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { styled, useTheme } from '@superset-ui/core';
|
||||
import { ErrorLevel, styled, useTheme } from '@superset-ui/core';
|
||||
import Icons from 'src/components/Icons';
|
||||
import { ErrorLevel } from './types';
|
||||
|
||||
const StyledContainer = styled.div<{ level: ErrorLevel }>`
|
||||
display: flex;
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import DatabaseErrorMessage from './DatabaseErrorMessage';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from './types';
|
||||
|
||||
jest.mock(
|
||||
'src/components/Icons/Icon',
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import DatasetNotFoundErrorMessage from './DatasetNotFoundErrorMessage';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from './types';
|
||||
|
||||
jest.mock(
|
||||
'src/components/Icons/Icon',
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
import React from 'react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import { supersetTheme } from '@superset-ui/core';
|
||||
import { ErrorLevel, ErrorSource, supersetTheme } from '@superset-ui/core';
|
||||
import { isCurrentUserBot } from 'src/utils/isBot';
|
||||
import ErrorAlert from './ErrorAlert';
|
||||
import { ErrorLevel, ErrorSource } from './types';
|
||||
|
||||
jest.mock(
|
||||
'src/components/Icons/Icon',
|
||||
|
||||
@@ -17,14 +17,19 @@
|
||||
* under the License.
|
||||
*/
|
||||
import React, { useState, ReactNode } from 'react';
|
||||
import { styled, useTheme, t } from '@superset-ui/core';
|
||||
import {
|
||||
ErrorLevel,
|
||||
ErrorSource,
|
||||
styled,
|
||||
useTheme,
|
||||
t,
|
||||
} from '@superset-ui/core';
|
||||
import { noOp } from 'src/utils/common';
|
||||
import Modal from 'src/components/Modal';
|
||||
import Button from 'src/components/Button';
|
||||
import { isCurrentUserBot } from 'src/utils/isBot';
|
||||
|
||||
import Icons from 'src/components/Icons';
|
||||
import { ErrorLevel, ErrorSource } from './types';
|
||||
import CopyToClipboard from '../CopyToClipboard';
|
||||
|
||||
const ErrorAlertDiv = styled.div<{ level: ErrorLevel }>`
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import ErrorMessageWithStackTrace from './ErrorMessageWithStackTrace';
|
||||
import BasicErrorAlert from './BasicErrorAlert';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from './types';
|
||||
|
||||
jest.mock(
|
||||
'src/components/Icons/Icon',
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { t } from '@superset-ui/core';
|
||||
import { ErrorSource, t, SupersetError } from '@superset-ui/core';
|
||||
import getErrorMessageComponentRegistry from './getErrorMessageComponentRegistry';
|
||||
import { SupersetError, ErrorSource } from './types';
|
||||
import ErrorAlert from './ErrorAlert';
|
||||
|
||||
const DEFAULT_TITLE = t('Unexpected error');
|
||||
|
||||
@@ -20,8 +20,12 @@
|
||||
import React from 'react';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import { ThemeProvider, supersetTheme } from '@superset-ui/core';
|
||||
import { ErrorLevel, ErrorTypeEnum } from 'src/components/ErrorMessage/types';
|
||||
import {
|
||||
ErrorLevel,
|
||||
ErrorTypeEnum,
|
||||
ThemeProvider,
|
||||
supersetTheme,
|
||||
} from '@superset-ui/core';
|
||||
import MarshmallowErrorMessage from './MarshmallowErrorMessage';
|
||||
|
||||
describe('MarshmallowErrorMessage', () => {
|
||||
|
||||
@@ -23,13 +23,14 @@ import { Provider } from 'react-redux';
|
||||
import { createStore } from 'redux';
|
||||
import { render, fireEvent, waitFor } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
import { ThemeProvider, supersetTheme } from '@superset-ui/core';
|
||||
import OAuth2RedirectMessage from 'src/components/ErrorMessage/OAuth2RedirectMessage';
|
||||
import {
|
||||
ErrorLevel,
|
||||
ErrorSource,
|
||||
ErrorTypeEnum,
|
||||
} from 'src/components/ErrorMessage/types';
|
||||
ThemeProvider,
|
||||
supersetTheme,
|
||||
} from '@superset-ui/core';
|
||||
import OAuth2RedirectMessage from 'src/components/ErrorMessage/OAuth2RedirectMessage';
|
||||
import { reRunQuery } from 'src/SqlLab/actions/sqlLab';
|
||||
import { triggerQuery } from 'src/components/Chart/chartAction';
|
||||
import { onRefresh } from 'src/dashboard/actions/dashboardState';
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from '@superset-ui/core';
|
||||
import React from 'react';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import ParameterErrorMessage from './ParameterErrorMessage';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from './types';
|
||||
|
||||
jest.mock(
|
||||
'src/components/Icons/Icon',
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { ErrorSource, ErrorTypeEnum, ErrorLevel } from '@superset-ui/core';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import TimeoutErrorMessage from './TimeoutErrorMessage';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from './types';
|
||||
|
||||
jest.mock(
|
||||
'src/components/Icons/Icon',
|
||||
|
||||
@@ -17,95 +17,14 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// Keep in sync with superset/views/errors.py
|
||||
export const ErrorTypeEnum = {
|
||||
// Frontend errors
|
||||
FRONTEND_CSRF_ERROR: 'FRONTEND_CSRF_ERROR',
|
||||
FRONTEND_NETWORK_ERROR: 'FRONTEND_NETWORK_ERROR',
|
||||
FRONTEND_TIMEOUT_ERROR: 'FRONTEND_TIMEOUT_ERROR',
|
||||
|
||||
// DB Engine errors
|
||||
GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR',
|
||||
COLUMN_DOES_NOT_EXIST_ERROR: 'COLUMN_DOES_NOT_EXIST_ERROR',
|
||||
TABLE_DOES_NOT_EXIST_ERROR: 'TABLE_DOES_NOT_EXIST_ERROR',
|
||||
SCHEMA_DOES_NOT_EXIST_ERROR: 'SCHEMA_DOES_NOT_EXIST_ERROR',
|
||||
CONNECTION_INVALID_USERNAME_ERROR: 'CONNECTION_INVALID_USERNAME_ERROR',
|
||||
CONNECTION_INVALID_PASSWORD_ERROR: 'CONNECTION_INVALID_PASSWORD_ERROR',
|
||||
CONNECTION_INVALID_HOSTNAME_ERROR: 'CONNECTION_INVALID_HOSTNAME_ERROR',
|
||||
CONNECTION_PORT_CLOSED_ERROR: 'CONNECTION_PORT_CLOSED_ERROR',
|
||||
CONNECTION_INVALID_PORT_ERROR: 'CONNECTION_INVALID_PORT_ERROR',
|
||||
CONNECTION_HOST_DOWN_ERROR: 'CONNECTION_HOST_DOWN_ERROR',
|
||||
CONNECTION_ACCESS_DENIED_ERROR: 'CONNECTION_ACCESS_DENIED_ERROR',
|
||||
CONNECTION_UNKNOWN_DATABASE_ERROR: 'CONNECTION_UNKNOWN_DATABASE_ERROR',
|
||||
CONNECTION_DATABASE_PERMISSIONS_ERROR:
|
||||
'CONNECTION_DATABASE_PERMISSIONS_ERROR',
|
||||
CONNECTION_MISSING_PARAMETERS_ERRORS: 'CONNECTION_MISSING_PARAMETERS_ERRORS',
|
||||
OBJECT_DOES_NOT_EXIST_ERROR: 'OBJECT_DOES_NOT_EXIST_ERROR',
|
||||
SYNTAX_ERROR: 'SYNTAX_ERROR',
|
||||
|
||||
// Viz errors
|
||||
VIZ_GET_DF_ERROR: 'VIZ_GET_DF_ERROR',
|
||||
UNKNOWN_DATASOURCE_TYPE_ERROR: 'UNKNOWN_DATASOURCE_TYPE_ERROR',
|
||||
FAILED_FETCHING_DATASOURCE_INFO_ERROR:
|
||||
'FAILED_FETCHING_DATASOURCE_INFO_ERROR',
|
||||
|
||||
// Security access errors
|
||||
TABLE_SECURITY_ACCESS_ERROR: 'TABLE_SECURITY_ACCESS_ERROR',
|
||||
DATASOURCE_SECURITY_ACCESS_ERROR: 'DATASOURCE_SECURITY_ACCESS_ERROR',
|
||||
DATABASE_SECURITY_ACCESS_ERROR: 'DATABASE_SECURITY_ACCESS_ERROR',
|
||||
QUERY_SECURITY_ACCESS_ERROR: 'QUERY_SECURITY_ACCESS_ERROR',
|
||||
MISSING_OWNERSHIP_ERROR: 'MISSING_OWNERSHIP_ERROR',
|
||||
DASHBOARD_SECURITY_ACCESS_ERROR: 'DASHBOARD_SECURITY_ACCESS_ERROR',
|
||||
OAUTH2_REDIRECT: 'OAUTH2_REDIRECT',
|
||||
OAUTH2_REDIRECT_ERROR: 'OAUTH2_REDIRECT_ERROR',
|
||||
|
||||
// Other errors
|
||||
BACKEND_TIMEOUT_ERROR: 'BACKEND_TIMEOUT_ERROR',
|
||||
DATABASE_NOT_FOUND_ERROR: 'DATABASE_NOT_FOUND_ERROR',
|
||||
|
||||
// Sqllab error
|
||||
MISSING_TEMPLATE_PARAMS_ERROR: 'MISSING_TEMPLATE_PARAMS_ERROR',
|
||||
INVALID_TEMPLATE_PARAMS_ERROR: 'INVALID_TEMPLATE_PARAMS_ERROR',
|
||||
RESULTS_BACKEND_NOT_CONFIGURED_ERROR: 'RESULTS_BACKEND_NOT_CONFIGURED_ERROR',
|
||||
DML_NOT_ALLOWED_ERROR: 'DML_NOT_ALLOWED_ERROR',
|
||||
INVALID_CTAS_QUERY_ERROR: 'INVALID_CTAS_QUERY_ERROR',
|
||||
INVALID_CVAS_QUERY_ERROR: 'INVALID_CVAS_QUERY_ERROR',
|
||||
SQLLAB_TIMEOUT_ERROR: 'SQLLAB_TIMEOUT_ERROR',
|
||||
RESULTS_BACKEND_ERROR: 'RESULTS_BACKEND_ERROR',
|
||||
ASYNC_WORKERS_ERROR: 'ASYNC_WORKERS_ERROR',
|
||||
|
||||
// Generic errors
|
||||
GENERIC_COMMAND_ERROR: 'GENERIC_COMMAND_ERROR',
|
||||
GENERIC_BACKEND_ERROR: 'GENERIC_BACKEND_ERROR',
|
||||
|
||||
// API errors
|
||||
INVALID_PAYLOAD_FORMAT_ERROR: 'INVALID_PAYLOAD_FORMAT_ERROR',
|
||||
INVALID_PAYLOAD_SCHEMA_ERROR: 'INVALID_PAYLOAD_SCHEMA_ERROR',
|
||||
MARSHMALLOW_ERROR: 'MARSHMALLOW_ERROR',
|
||||
} as const;
|
||||
|
||||
type ValueOf<T> = T[keyof T];
|
||||
|
||||
export type ErrorType = ValueOf<typeof ErrorTypeEnum>;
|
||||
|
||||
// Keep in sync with superset/views/errors.py
|
||||
export type ErrorLevel = 'info' | 'warning' | 'error';
|
||||
|
||||
export type ErrorSource = 'dashboard' | 'explore' | 'sqllab' | 'crud';
|
||||
|
||||
export type SupersetError<ExtraType = Record<string, any> | null> = {
|
||||
error_type: ErrorType;
|
||||
extra: ExtraType;
|
||||
level: ErrorLevel;
|
||||
message: string;
|
||||
};
|
||||
import { ReactNode, ComponentType } from 'react';
|
||||
import { ErrorSource, SupersetError } from '@superset-ui/core';
|
||||
|
||||
export type ErrorMessageComponentProps<ExtraType = Record<string, any> | null> =
|
||||
{
|
||||
error: SupersetError<ExtraType>;
|
||||
source?: ErrorSource;
|
||||
subtitle?: React.ReactNode;
|
||||
subtitle?: ReactNode;
|
||||
};
|
||||
|
||||
export type ErrorMessageComponent =
|
||||
React.ComponentType<ErrorMessageComponentProps>;
|
||||
export type ErrorMessageComponent = ComponentType<ErrorMessageComponentProps>;
|
||||
|
||||
Reference in New Issue
Block a user