chore: remove generic type (#12003)

* chore: remove generic type

* Make resourceName type stricter

* Fix type

* Fix type

* Fix lint
This commit is contained in:
Beto Dealmeida
2020-12-11 10:52:26 -08:00
committed by GitHub
parent 916f7e923a
commit 2769de3731
4 changed files with 16 additions and 12 deletions

View File

@@ -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: <StyledIcon name="database" />,
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', () => {

View File

@@ -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<ImportModelsModalProps> = ({
const {
state: { passwordsNeeded },
importResource,
} = useImportResource<any>(resourceName, resourceLabel, handleErrorMsg);
} = useImportResource(resourceName, resourceLabel, handleErrorMsg);
useEffect(() => {
setPasswordFields(passwordsNeeded);