From 39ec6722f1999f355e441f7807cbafa16a59453d Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Fri, 8 Oct 2021 17:01:00 +0300 Subject: [PATCH] chore(Dashboard): Implement dedicated message for missing dataset (#16959) * Implement dedicated message * Clean up --- .../DatasetNotFoundErrorMessage.test.tsx | 45 +++++++++++++++++++ .../DatasetNotFoundErrorMessage.tsx | 44 ++++++++++++++++++ .../src/setup/setupErrorMessages.ts | 5 +++ 3 files changed, 94 insertions(+) create mode 100644 superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx create mode 100644 superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.tsx diff --git a/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx new file mode 100644 index 0000000000000..087b08fa8f865 --- /dev/null +++ b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.test.tsx @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import { render, screen } from 'spec/helpers/testing-library'; +import DatasetNotFoundErrorMessage from './DatasetNotFoundErrorMessage'; +import { ErrorLevel, ErrorSource, ErrorTypeEnum } from './types'; + +const mockedProps = { + error: { + error_type: ErrorTypeEnum.FAILED_FETCHING_DATASOURCE_INFO_ERROR, + level: 'error' as ErrorLevel, + message: 'The dataset associated with this chart no longer exists', + extra: {}, + }, + source: 'dashboard' as ErrorSource, +}; + +test('should render', () => { + const { container } = render( + , + ); + expect(container).toBeInTheDocument(); +}); + +test('should render the default title', () => { + render(); + expect(screen.getByText('Missing dataset')).toBeInTheDocument(); +}); diff --git a/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.tsx b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.tsx new file mode 100644 index 0000000000000..c1c7c37fee0ad --- /dev/null +++ b/superset-frontend/src/components/ErrorMessage/DatasetNotFoundErrorMessage.tsx @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; +import { t } from '@superset-ui/core'; + +import { ErrorMessageComponentProps } from './types'; +import ErrorAlert from './ErrorAlert'; + +function DatasetNotFoundErrorMessage({ + error, + source = 'dashboard', + subtitle, +}: ErrorMessageComponentProps) { + const { level, message } = error; + + return ( + + ); +} + +export default DatasetNotFoundErrorMessage; diff --git a/superset-frontend/src/setup/setupErrorMessages.ts b/superset-frontend/src/setup/setupErrorMessages.ts index a0626c171ce03..bebb22b20c13e 100644 --- a/superset-frontend/src/setup/setupErrorMessages.ts +++ b/superset-frontend/src/setup/setupErrorMessages.ts @@ -21,6 +21,7 @@ import { ErrorTypeEnum } from 'src/components/ErrorMessage/types'; import TimeoutErrorMessage from 'src/components/ErrorMessage/TimeoutErrorMessage'; import DatabaseErrorMessage from 'src/components/ErrorMessage/DatabaseErrorMessage'; import ParameterErrorMessage from 'src/components/ErrorMessage/ParameterErrorMessage'; +import DatasetNotFoundErrorMessage from 'src/components/ErrorMessage/DatasetNotFoundErrorMessage'; import setupErrorMessagesExtra from './setupErrorMessagesExtra'; @@ -139,5 +140,9 @@ export default function setupErrorMessages() { ErrorTypeEnum.CONNECTION_DATABASE_PERMISSIONS_ERROR, DatabaseErrorMessage, ); + errorMessageComponentRegistry.registerValue( + ErrorTypeEnum.FAILED_FETCHING_DATASOURCE_INFO_ERROR, + DatasetNotFoundErrorMessage, + ); setupErrorMessagesExtra(); }