[SIP-9] Introduce TypeScript (#6120)

* [SIP-9] Introduce TypeScript

- Introduce TypeScript and co to both source and tests
- Define alias for src directory in both webpack config and jest config so we can avoid using long relative paths like ../../src in both source and tests
- Type check feature flags system to prevent typos of flag names
- Change the feature flags system and the flags on window instead of populating them through the state tree. When introducing the first SCOPED_FILTER feature flag, it became too difficult to pipe the flags through the state initializers and layers of components and containers (the resulting code is hard to read and has a handful of methods taking an additional feature flag map parameter). Given that feature flags don't change throughout the life time of the app, it is better to leave them on window for easy access than piping them through the global state tree, which is meant to store the state of the app which changes frequently.
- Add a barebone filter panel that only shows when the SCOPED_FILTER feature flag is on

* Remove unnecessary dev-dependency on gl

* - Adding linting for TypeScript files via tslint.
- Fixing linting for Javascript files importing Typscript files
- Also fix linting for Javascript files that now leverage the webpack alias for the src directory

- up Typescript and type def versions

* Rename src directory's webpack alias from @ to src to be more explicit.
This commit is contained in:
Christine Chambers
2018-10-23 22:33:51 -07:00
committed by Maxime Beauchemin
parent 9e6b171ee9
commit 5f1eaa49f2
31 changed files with 1129 additions and 1131 deletions

View File

@@ -1,11 +1,9 @@
import React from 'react';
import { shallow } from 'enzyme';
import { getFormDataFromControls, defaultControls }
from '../../../../src/explore/store';
import {
ControlPanelsContainer,
} from '../../../../src/explore/components/ControlPanelsContainer';
import ControlPanelSection from '../../../../src/explore/components/ControlPanelSection';
import { getFormDataFromControls, defaultControls } from 'src/explore/store';
import { ControlPanelsContainer } from 'src/explore/components/ControlPanelsContainer';
import ControlPanelSection from 'src/explore/components/ControlPanelSection';
import * as featureFlags from 'src/featureFlags';
const defaultProps = {
datasource_type: 'table',
@@ -18,12 +16,22 @@ const defaultProps = {
describe('ControlPanelsContainer', () => {
let wrapper;
let scopedFilterOn = false;
const isFeatureEnabledMock = jest.spyOn(featureFlags, 'isFeatureEnabled')
.mockImplementation(() => scopedFilterOn);
beforeEach(() => {
wrapper = shallow(<ControlPanelsContainer {...defaultProps} />);
afterAll(() => {
isFeatureEnabledMock.mockRestore();
});
it('renders ControlPanelSections', () => {
wrapper = shallow(<ControlPanelsContainer {...defaultProps} />);
expect(wrapper.find(ControlPanelSection)).toHaveLength(6);
});
it('renders filter panel when SCOPED_FILTER flag is on', () => {
scopedFilterOn = true;
wrapper = shallow(<ControlPanelsContainer {...defaultProps} />);
expect(wrapper.find(ControlPanelSection)).toHaveLength(7);
});
});