Skip to content

Commit

Permalink
Merge branch 'master' into return-rows
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Feb 18, 2021
2 parents 4a35213 + 1e17ef3 commit bb3413a
Show file tree
Hide file tree
Showing 87 changed files with 1,519 additions and 677 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ignore:
- "superset/migrations/versions/*.py"
coverage:
status:
project:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/docs/Connecting to Databases/athena.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ You can also use [PyAthena library](https://pypi.org/project/PyAthena/) (no Java
following connection string:

```
awsathena+rest://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com/{
awsathena+rest://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com/{schema_name}?s3_staging_dir={s3_staging_dir}&...
```
2 changes: 1 addition & 1 deletion helm/superset/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ RESULTS_BACKEND = RedisCache(
# Overrides
{{- range $key, $value := .Values.configOverrides }}
# {{ $key }}
{{ $value }}
{{ tpl $value $ }}
{{- end }}
{{- end }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Test explore links', () => {
});
});

it('Visit short link', () => {
it('Test if short link is generated', () => {
cy.intercept('POST', 'r/shortner/').as('getShortUrl');

cy.visitChartByName('Growth Rate');
Expand All @@ -58,13 +58,6 @@ describe('Test explore links', () => {

// explicitly wait for the url response
cy.wait('@getShortUrl');

cy.get('#shorturl-popover [data-test="short-url"]')
.invoke('text')
.then(text => {
cy.visit(text);
});
cy.verifySliceSuccess({ waitAlias: '@chartData' });
});

it('Test iframe link', () => {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prettier": "npm run format",
"check-translation": "prettier --check ../superset/translations/**/LC_MESSAGES/*.json",
"clean-translation": "prettier --write ../superset/translations/**/LC_MESSAGES/*.json",
"storybook": "NODE_ENV=development BABEL_ENV=development start-storybook -p 6006",
"storybook": "NODE_ENV=development BABEL_ENV=development start-storybook -s ./images -p 6006",
"build-storybook": "build-storybook"
},
"repository": {
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/spec/fixtures/mockNativeFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { NativeFiltersState } from 'src/dashboard/reducers/types';

export const nativeFilters: NativeFiltersState = {
filterSets: {},
filters: {
'NATIVE_FILTER-e7Q8zKixx': {
id: 'NATIVE_FILTER-e7Q8zKixx',
Expand Down Expand Up @@ -92,6 +93,7 @@ export const nativeFilters: NativeFiltersState = {
'NATIVE_FILTER-x9QPw0so1': {
id: 'NATIVE_FILTER-x9QPw0so1',
extraFormData: {},
currentState: {},
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getChartControlPanelRegistry } from '@superset-ui/core';

import AlteredSliceTag from 'src/components/AlteredSliceTag';
import ModalTrigger from 'src/components/ModalTrigger';
import TooltipWrapper from 'src/components/TooltipWrapper';
import { Tooltip } from 'src/common/components/Tooltip';
import TableCollection from 'src/components/dataViewCommon/TableCollection';
import TableView from 'src/components/TableView';

Expand Down Expand Up @@ -97,11 +97,11 @@ describe('AlteredSliceTag', () => {
});

describe('renderTriggerNode', () => {
it('renders a TooltipWrapper', () => {
it('renders a Tooltip', () => {
const triggerNode = mount(
<div>{wrapper.instance().renderTriggerNode()}</div>,
);
expect(triggerNode.find(TooltipWrapper)).toHaveLength(1);
expect(triggerNode.find(Tooltip)).toHaveLength(1);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import React from 'react';
import { shallow } from 'enzyme';
import { Menu, NoAnimationDropdown } from 'src/common/components';
import RefreshIntervalModal from 'src/dashboard/components/RefreshIntervalModal';
import URLShortLinkModal from 'src/components/URLShortLinkModal';
import HeaderActionsDropdown from 'src/dashboard/components/HeaderActionsDropdown';
import SaveModal from 'src/dashboard/components/SaveModal';
import CssEditor from 'src/dashboard/components/CssEditor';
import fetchMock from 'fetch-mock';
import ShareMenuItems from 'src/dashboard/components/menu/ShareMenuItems';

fetchMock.get('glob:*/csstemplateasyncmodelview/api/read', {});

Expand Down Expand Up @@ -79,19 +79,19 @@ describe('HeaderActionsDropdown', () => {
expect(menu.find(SaveModal)).not.toExist();
});

it('should render five Menu items', () => {
it('should render available Menu items', () => {
const { menu } = setup(overrideProps);
expect(menu.find(Menu.Item)).toHaveLength(5);
expect(menu.find(Menu.Item)).toHaveLength(4);
});

it('should render the RefreshIntervalModal', () => {
const { menu } = setup(overrideProps);
expect(menu.find(RefreshIntervalModal)).toExist();
});

it('should render the URLShortLinkModal', () => {
it('should render the ShareMenuItems', () => {
const { menu } = setup(overrideProps);
expect(menu.find(URLShortLinkModal)).toExist();
expect(menu.find(ShareMenuItems)).toExist();
});

it('should not render the CssEditor', () => {
Expand All @@ -113,19 +113,19 @@ describe('HeaderActionsDropdown', () => {
expect(menu.find(SaveModal)).toExist();
});

it('should render six Menu items', () => {
it('should render available Menu items', () => {
const { menu } = setup(overrideProps);
expect(menu.find(Menu.Item)).toHaveLength(6);
expect(menu.find(Menu.Item)).toHaveLength(5);
});

it('should render the RefreshIntervalModal', () => {
const { menu } = setup(overrideProps);
expect(menu.find(RefreshIntervalModal)).toExist();
});

it('should render the URLShortLinkModal', () => {
it('should render the ShareMenuItems', () => {
const { menu } = setup(overrideProps);
expect(menu.find(URLShortLinkModal)).toExist();
expect(menu.find(ShareMenuItems)).toExist();
});

it('should not render the CssEditor', () => {
Expand All @@ -147,19 +147,19 @@ describe('HeaderActionsDropdown', () => {
expect(menu.find(SaveModal)).toExist();
});

it('should render seven MenuItems', () => {
it('should render available MenuItems', () => {
const { menu } = setup(overrideProps);
expect(menu.find(Menu.Item)).toHaveLength(7);
expect(menu.find(Menu.Item)).toHaveLength(6);
});

it('should render the RefreshIntervalModal', () => {
const { menu } = setup(overrideProps);
expect(menu.find(RefreshIntervalModal)).toExist();
});

it('should render the URLShortLinkModal', () => {
it('should render the ShareMenuItems', () => {
const { menu } = setup(overrideProps);
expect(menu.find(URLShortLinkModal)).toExist();
expect(menu.find(ShareMenuItems)).toExist();
});

it('should render the CssEditor', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe('Chart', () => {
changeFilter() {},
setFocusedFilterField() {},
unsetFocusedFilterField() {},
addSuccessToast() {},
addDangerToast() {},
componentId: 'test',
dashboardId: 111,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('getFormDataWithExtraFilters', () => {
},
sliceId: chartId,
nativeFilters: {
filterSets: {},
filters: {
[filterId]: ({
id: filterId,
Expand All @@ -64,6 +65,7 @@ describe('getFormDataWithExtraFilters', () => {
[filterId]: {
id: filterId,
extraFormData: {},
currentState: {},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ describe('EmbedCodeButton', () => {
const stub = sinon
.stub(exploreUtils, 'getURIDirectory')
.callsFake(() => 'endpoint_url');
const wrapper = mount(<EmbedCodeButton {...defaultProps} />);
wrapper.setState({
const wrapper = mount(
<ThemeProvider theme={supersetTheme}>
<EmbedCodeButton {...defaultProps} />
</ThemeProvider>,
);
wrapper.find(EmbedCodeButton).setState({
height: '1000',
width: '2000',
shortUrlId: 100,
Expand All @@ -104,7 +108,9 @@ describe('EmbedCodeButton', () => {
}${DashboardStandaloneMode.HIDE_NAV}&height=1000"\n` +
`>\n` +
`</iframe>`;
expect(wrapper.instance().generateEmbedHTML()).toBe(embedHTML);
expect(wrapper.find(EmbedCodeButton).instance().generateEmbedHTML()).toBe(
embedHTML,
);
stub.restore();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { mockStore } from 'spec/fixtures/mockStore';
import ExploreActionButtons from 'src/explore/components/ExploreActionButtons';

describe('ExploreActionButtons', () => {
Expand All @@ -35,8 +36,10 @@ describe('ExploreActionButtons', () => {
).toBe(true);
});

it('should render 5 children/buttons', () => {
const wrapper = shallow(<ExploreActionButtons {...defaultProps} />);
expect(wrapper.children()).toHaveLength(5);
it('should render 6 children/buttons', () => {
const wrapper = shallow(
<ExploreActionButtons {...defaultProps} store={mockStore} />,
);
expect(wrapper.dive().children()).toHaveLength(6);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React from 'react';
import { shallow } from 'enzyme';

import Label from 'src/components/Label';
import TooltipWrapper from 'src/components/TooltipWrapper';
import { Tooltip } from 'src/common/components/Tooltip';
import RowCountLabel from 'src/explore/components/RowCountLabel';

describe('RowCountLabel', () => {
Expand All @@ -34,10 +34,10 @@ describe('RowCountLabel', () => {
true,
);
});
it('renders a Label and a TooltipWrapper', () => {
it('renders a Label and a Tooltip', () => {
const wrapper = shallow(<RowCountLabel {...defaultProps} />);
expect(wrapper.find(Label)).toExist();
expect(wrapper.find(TooltipWrapper)).toExist();
expect(wrapper.find(Tooltip)).toExist();
});
it('renders a danger when limit is reached', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,23 @@ fetchMock.put(alertsEndpoint, { ...mockalerts[0], active: false });
fetchMock.delete(alertEndpoint, {});
fetchMock.delete(alertsEndpoint, {});

describe('AlertList', () => {
const wrapper = mount(
async function mountAndWait(props = {}) {
const mounted = mount(
<Provider store={store}>
<AlertList store={store} user={mockUser} />
<AlertList store={store} user={mockUser} {...props} />
</Provider>,
);

await waitForComponentToPaint(mounted);

return mounted;
}

describe('AlertList', () => {
let wrapper;

beforeAll(async () => {
await waitForComponentToPaint(wrapper);
wrapper = await mountAndWait();
});

it('renders', async () => {
Expand Down Expand Up @@ -147,4 +155,30 @@ describe('AlertList', () => {
mockalerts.length + 1, // 1 for each row and 1 for select all
);
});

it('hides bulk actions when switch between alert and report list', async () => {
expect(wrapper.find(IndeterminateCheckbox)).toHaveLength(
mockalerts.length + 1,
);
expect(wrapper.find('[data-test="alert-list"]').hasClass('active')).toBe(
true,
);
expect(wrapper.find('[data-test="report-list"]').hasClass('active')).toBe(
false,
);

const reportWrapper = await mountAndWait({ isReportEnabled: true });

expect(fetchMock.calls(/report\/\?q/)[2][0]).toMatchInlineSnapshot(
`"http://localhost/api/v1/report/?q=(filters:!((col:type,opr:eq,value:Report)),order_column:name,order_direction:desc,page:0,page_size:25)"`,
);

expect(
reportWrapper.find('[data-test="report-list"]').hasClass('active'),
).toBe(true);
expect(
reportWrapper.find('[data-test="alert-list"]').hasClass('active'),
).toBe(false);
expect(reportWrapper.find(IndeterminateCheckbox)).toHaveLength(0);
});
});
25 changes: 15 additions & 10 deletions superset-frontend/src/SqlLab/components/ResultSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ export default class ResultSet extends React.PureComponent<
this.handleExploreBtnClick = this.handleExploreBtnClick.bind(this);
}

componentDidMount() {
async componentDidMount() {
// only do this the first time the component is rendered/mounted
this.reRunQueryIfSessionTimeoutErrorOnMount();
const userDatasetsOwned = await this.getUserDatasets();
this.setState({ userDatasetOptions: userDatasetsOwned });
}

UNSAFE_componentWillReceiveProps(nextProps: ResultSetProps) {
Expand Down Expand Up @@ -296,7 +298,7 @@ export default class ResultSet extends React.PureComponent<
});
};

handleSaveDatasetModalSearch = async (searchText: string) => {
getUserDatasets = async (searchText = '') => {
// Making sure that autocomplete input has a value before rendering the dropdown
// Transforming the userDatasetsOwned data for SaveModalComponent)
const appContainer = document.getElementById('app');
Expand Down Expand Up @@ -327,15 +329,18 @@ export default class ResultSet extends React.PureComponent<
endpoint: '/api/v1/dataset',
})(`q=${queryParams}`);

const userDatasetsOwned = response.result.map(
(r: { table_name: string; id: number }) => ({
value: r.table_name,
datasetId: r.id,
}),
);

this.setState({ userDatasetOptions: userDatasetsOwned });
return response.result.map((r: { table_name: string; id: number }) => ({
value: r.table_name,
datasetId: r.id,
}));
}

return null;
};

handleSaveDatasetModalSearch = async (searchText: string) => {
const userDatasetsOwned = await this.getUserDatasets(searchText);
this.setState({ userDatasetOptions: userDatasetsOwned });
};

handleFilterAutocompleteOption = (
Expand Down
8 changes: 6 additions & 2 deletions superset-frontend/src/chart/ChartRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ class ChartRenderer extends React.Component {
setControlValue: this.handleSetControlValue,
onFilterMenuOpen: this.props.onFilterMenuOpen,
onFilterMenuClose: this.props.onFilterMenuClose,
setExtraFormData: extraFormData =>
this.props.actions?.setExtraFormData(this.props.chartId, extraFormData),
setExtraFormData: ({ extraFormData, currentState }) =>
this.props.actions?.setExtraFormData(
this.props.chartId,
extraFormData,
currentState,
),
};
}

Expand Down
Loading

0 comments on commit bb3413a

Please sign in to comment.