diff --git a/superset-frontend/src/components/ImportModal/ImportModal.test.tsx b/superset-frontend/src/components/ImportModal/ImportModal.test.tsx
index 1e922b4d128..718d4d63d70 100644
--- a/superset-frontend/src/components/ImportModal/ImportModal.test.tsx
+++ b/superset-frontend/src/components/ImportModal/ImportModal.test.tsx
@@ -22,6 +22,7 @@ import configureStore from 'redux-mock-store';
import { styledMount as mount } from 'spec/helpers/theming';
import { ReactWrapper } from 'enzyme';
+import { ImportResourceName } from 'src/views/CRUD/types';
import ImportModelsModal, { StyledIcon } from 'src/components/ImportModal';
import Modal from 'src/common/components/Modal';
@@ -29,8 +30,8 @@ const mockStore = configureStore([thunk]);
const store = mockStore({});
const requiredProps = {
- resourceName: 'model',
- resourceLabel: 'model',
+ resourceName: 'database' as ImportResourceName,
+ resourceLabel: 'database',
icon: ,
passwordsNeededMessage: 'Passwords are needed',
addDangerToast: () => {},
@@ -61,8 +62,8 @@ describe('ImportModelsModal', () => {
expect(wrapper.find(Modal)).toExist();
});
- it('renders "Import model" header', () => {
- expect(wrapper.find('h4').text()).toEqual('Import model');
+ it('renders "Import database" header', () => {
+ expect(wrapper.find('h4').text()).toEqual('Import database');
});
it('renders a label and a file input field', () => {
diff --git a/superset-frontend/src/components/ImportModal/index.tsx b/superset-frontend/src/components/ImportModal/index.tsx
index 1c26623f10c..5b2d1ac8cf7 100644
--- a/superset-frontend/src/components/ImportModal/index.tsx
+++ b/superset-frontend/src/components/ImportModal/index.tsx
@@ -22,6 +22,7 @@ import { styled, t } from '@superset-ui/core';
import Icon from 'src//components/Icon';
import Modal from 'src/common/components/Modal';
import { useImportResource } from 'src/views/CRUD/hooks';
+import { ImportResourceName } from 'src/views/CRUD/types';
export const StyledIcon = styled(Icon)`
margin: auto ${({ theme }) => theme.gridUnit * 2}px auto 0;
@@ -97,7 +98,7 @@ const StyledInputContainer = styled.div`
`;
export interface ImportModelsModalProps {
- resourceName: string;
+ resourceName: ImportResourceName;
resourceLabel: string;
icon: React.ReactNode;
passwordsNeededMessage: string;
@@ -145,7 +146,7 @@ const ImportModelsModal: FunctionComponent = ({
const {
state: { passwordsNeeded },
importResource,
- } = useImportResource(resourceName, resourceLabel, handleErrorMsg);
+ } = useImportResource(resourceName, resourceLabel, handleErrorMsg);
useEffect(() => {
setPasswordFields(passwordsNeeded);
diff --git a/superset-frontend/src/views/CRUD/hooks.ts b/superset-frontend/src/views/CRUD/hooks.ts
index dedcadd87af..794b2c4d0f1 100644
--- a/superset-frontend/src/views/CRUD/hooks.ts
+++ b/superset-frontend/src/views/CRUD/hooks.ts
@@ -26,7 +26,7 @@ import { FilterValue } from 'src/components/ListView/types';
import Chart, { Slice } from 'src/types/Chart';
import copyTextToClipboard from 'src/utils/copy';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
-import { FavoriteStatus } from './types';
+import { FavoriteStatus, ImportResourceName } from './types';
interface ListViewResourceState {
loading: boolean;
@@ -313,22 +313,22 @@ export function useSingleViewResource(
};
}
-interface ImportResourceState {
+interface ImportResourceState {
loading: boolean;
passwordsNeeded: string[];
}
-export function useImportResource(
- resourceName: string,
+export function useImportResource(
+ resourceName: ImportResourceName,
resourceLabel: string, // resourceLabel for translations
handleErrorMsg: (errorMsg: string) => void,
) {
- const [state, setState] = useState>({
+ const [state, setState] = useState({
loading: false,
passwordsNeeded: [],
});
- function updateState(update: Partial>) {
+ function updateState(update: Partial) {
setState(currentState => ({ ...currentState, ...update }));
}
diff --git a/superset-frontend/src/views/CRUD/types.ts b/superset-frontend/src/views/CRUD/types.ts
index c83e42ceba8..4a9a2c5c479 100644
--- a/superset-frontend/src/views/CRUD/types.ts
+++ b/superset-frontend/src/views/CRUD/types.ts
@@ -111,3 +111,5 @@ export enum QueryObjectColumns {
tmp_table_name = 'tmp_table_name',
tracking_url = 'tracking_url',
}
+
+export type ImportResourceName = 'chart' | 'dashboard' | 'database' | 'dataset';