Skip to content

Commit

Permalink
fix(chart-crud): make to rebase master
Browse files Browse the repository at this point in the history
  • Loading branch information
prosdev0107 committed Mar 17, 2022
2 parents 85b768e + cfb967f commit f3b6cbf
Show file tree
Hide file tree
Showing 158 changed files with 4,225 additions and 889 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.
#

# Python version installed; we need 3.7-3.9
PYTHON=`command -v python3.9 || command -v python3.8 || command -v python3.7`
# Python version installed; we need 3.8-3.9
PYTHON=`command -v python3.9 || command -v python3.8`

.PHONY: install superset venv pre-commit

Expand Down Expand Up @@ -70,7 +70,7 @@ update-js:

venv:
# Create a virtual environment and activate it (recommended)
if ! [ -x "${PYTHON}" ]; then echo "You need Python 3.7, 3.8 or 3.9 installed"; exit 1; fi
if ! [ -x "${PYTHON}" ]; then echo "You need Python 3.8 or 3.9 installed"; exit 1; fi
test -d venv || ${PYTHON} -m venv venv # setup a python3 virtualenv
. venv/bin/activate

Expand Down
4 changes: 3 additions & 1 deletion UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ assists people when migrating to a new version.
- [17539](https://github.com/apache/superset/pull/17539): all Superset CLI commands (init, load_examples and etc) require setting the FLASK_APP environment variable (which is set by default when `.flaskenv` is loaded)
- [18970](https://github.com/apache/superset/pull/18970): Changes feature
flag for the legacy datasource editor (DISABLE_LEGACY_DATASOURCE_EDITOR) in config.py to True, thus disabling the feature from being shown in the client.
- [19017](https://github.com/apache/superset/pull/19017): Removes Python 3.7 support.

### Potential Downtime

Expand All @@ -48,11 +49,12 @@ flag for the legacy datasource editor (DISABLE_LEGACY_DATASOURCE_EDITOR) in conf

### Deprecations

- [19078](https://github.com/apache/superset/pull/19078): Creation of old shorturl links has been deprecated in favor of a new permalink feature that solves the long url problem (old shorturls will still work, though!). By default, new permalinks use UUID4 as the key. However, to use serial ids similar to the old shorturls, add the following to your `superset_config.py`: `PERMALINK_KEY_TYPE = "id"`.
- [18960](https://github.com/apache/superset/pull/18960): Persisting URL params in chart metadata is no longer supported. To set a default value for URL params in Jinja code, use the optional second argument: `url_param("my-param", "my-default-value")`.

### Other

- [17589](https://github.com/apache/incubator-superset/pull/17589): It is now possible to limit access to users' recent activity data by setting the `ENABLE_BROAD_ACTIVITY_ACCESS` config flag to false, or customizing the `raise_for_user_activity_access` method in the security manager.
- [17589](https://github.com/apache/superset/pull/17589): It is now possible to limit access to users' recent activity data by setting the `ENABLE_BROAD_ACTIVITY_ACCESS` config flag to false, or customizing the `raise_for_user_activity_access` method in the security manager.
- [17536](https://github.com/apache/superset/pull/17536): introduced a key-value endpoint to store dashboard filter state. This endpoint is backed by Flask-Caching and the default configuration assumes that the values will be stored in the file system. If you are already using another cache backend like Redis or Memchached, you'll probably want to change this setting in `superset_config.py`. The key is `FILTER_STATE_CACHE_CONFIG` and the available settings can be found in Flask-Caching [docs](https://flask-caching.readthedocs.io/en/latest/).
- [17882](https://github.com/apache/superset/pull/17882): introduced a key-value endpoint to store Explore form data. This endpoint is backed by Flask-Caching and the default configuration assumes that the values will be stored in the file system. If you are already using another cache backend like Redis or Memchached, you'll probably want to change this setting in `superset_config.py`. The key is `EXPLORE_FORM_DATA_CACHE_CONFIG` and the available settings can be found in Flask-Caching [docs](https://flask-caching.readthedocs.io/en/latest/).

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/contributing/local-backend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version: 1
Make sure your machine meets the [OS dependencies](https://superset.apache.org/docs/installation/installing-superset-from-scratch#os-dependencies) before following these steps.
You also need to install MySQL or [MariaDB](https://mariadb.com/downloads).

Ensure that you are using Python version 3.7 or 3.8, then proceed with:
Ensure that you are using Python version 3.8 or 3.9, then proceed with:

````bash
# Create a virtual environment and activate it (recommended)
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,12 @@ def get_git_sha() -> str:
"vertica": ["sqlalchemy-vertica-python>=0.5.9, < 0.6"],
"netezza": ["nzalchemy>=11.0.2"],
},
python_requires="~=3.7",
python_requires="~=3.8",
author="Apache Software Foundation",
author_email="dev@superset.apache.org",
url="https://superset.apache.org/",
download_url="https://www.apache.org/dist/superset/" + version_string,
classifiers=[
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/cypress-base/cypress.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"baseUrl": "http://localhost:8088",
"chromeWebSecurity": false,
"defaultCommandTimeout": 5000,
"defaultCommandTimeout": 8000,
"numTestsKeptInMemory": 0,
"experimentalFetchPolyfill": true,
"requestTimeout": 10000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,29 @@ interface QueryString {
native_filters_key: string;
}

describe('nativefiler url param key', () => {
xdescribe('nativefiler url param key', () => {
// const urlParams = { param1: '123', param2: 'abc' };
before(() => {
cy.login();
cy.visit(WORLD_HEALTH_DASHBOARD);
WORLD_HEALTH_CHARTS.forEach(waitForChartLoad);
cy.wait(1000); // wait for key to be published (debounced)
});

let initialFilterKey: string;
it('should have cachekey in nativefilter param', () => {
// things in `before` will not retry and the `waitForChartLoad` check is
// especically flaky and may need more retries
cy.visit(WORLD_HEALTH_DASHBOARD);
WORLD_HEALTH_CHARTS.forEach(waitForChartLoad);
cy.wait(1000); // wait for key to be published (debounced)
cy.location().then(loc => {
const queryParams = qs.parse(loc.search) as QueryString;
expect(typeof queryParams.native_filters_key).eq('string');
});
});

it('should have different key when page reloads', () => {
cy.visit(WORLD_HEALTH_DASHBOARD);
WORLD_HEALTH_CHARTS.forEach(waitForChartLoad);
cy.wait(1000); // wait for key to be published (debounced)
cy.location().then(loc => {
const queryParams = qs.parse(loc.search) as QueryString;
expect(queryParams.native_filters_key).not.equal(initialFilterKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,42 @@ describe('Nativefilters Sanity test', () => {
.contains('year')
.should('be.visible');
});
it('User can create a value filter', () => {
cy.get(nativeFilters.filterFromDashboardView.expand).click({ force: true });
cy.get(nativeFilters.filterFromDashboardView.createFilterButton)
.should('be.visible')
.click();
cy.get(nativeFilters.modal.container).should('be.visible');
cy.get('body').type('{home}');

cy.get(nativeFilters.filtersPanel.filterTypeInput)
.click({ scrollBehavior: false })
.type('{home}Value{enter}', { scrollBehavior: false });
cy.get(nativeFilters.filtersPanel.filterTypeInput)
.find(nativeFilters.filtersPanel.filterTypeItem)
.should('have.text', 'Value');
cy.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.filterName)
.click({ scrollBehavior: false })
.clear()
.type('country_name', { scrollBehavior: false });

cy.get(nativeFilters.silentLoading).should('not.exist');
cy.get(nativeFilters.filtersPanel.filterInfoInput)
.last()
.should('be.visible')
.click({ force: true });
cy.get(nativeFilters.filtersPanel.filterInfoInput)
.last()
.type('country_name {enter}');
cy.get(nativeFilters.modal.footer)
.find(nativeFilters.modal.saveButton)
.should('be.visible')
.click({ force: true });
cy.get(nativeFilters.filterFromDashboardView.filterName)
.should('be.visible', { timeout: 40000 })
.contains('country_name');
});
});

xdescribe('Nativefilters', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ export interface ChartMetadataConfig {
exampleGallery?: ExampleImage[];
tags?: string[];
category?: string | null;
label?: {
name?: ChartLabel;
description?: string;
} | null;
// deprecated: true hides a chart from all viz picker interactions.
deprecated?: boolean;
// label: ChartLabel.DEPRECATED which will display a "deprecated" label on the chart.
label?: ChartLabel | null;
labelExplanation?: string | null;
}

export default class ChartMetadata {
Expand Down Expand Up @@ -80,10 +81,11 @@ export default class ChartMetadata {

category: string | null;

label?: {
name?: ChartLabel;
description?: string;
} | null;
deprecated?: boolean;

label?: ChartLabel | null;

labelExplanation?: string | null;

constructor(config: ChartMetadataConfig) {
const {
Expand All @@ -101,7 +103,9 @@ export default class ChartMetadata {
exampleGallery = [],
tags = [],
category = null,
deprecated = false,
label = null,
labelExplanation = null,
} = config;

this.name = name;
Expand All @@ -127,7 +131,9 @@ export default class ChartMetadata {
this.exampleGallery = exampleGallery;
this.tags = tags;
this.category = category;
this.deprecated = deprecated;
this.label = label;
this.labelExplanation = labelExplanation;
}

canBeAnnotationType(type: string): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ export interface PlainObject {
}

export enum ChartLabel {
VERIFIED = 'VERIFIED',
DEPRECATED = 'DEPRECATED',
FEATURED = 'FEATURED',
}

export const ChartLabelWeight = {
export const chartLabelExplanations: Record<ChartLabel, string> = {
[ChartLabel.DEPRECATED]:
'This chart uses features or modules which are no longer actively maintained. It will eventually be replaced or removed.',
[ChartLabel.FEATURED]:
'This chart was tested and verified, so the overall experience should be stable.',
};

export const chartLabelWeight: Record<ChartLabel, { weight: number }> = {
[ChartLabel.DEPRECATED]: {
weight: -0.1,
},
[ChartLabel.VERIFIED]: {
weight: 0.2,
},
[ChartLabel.FEATURED]: {
weight: 0.1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,20 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
meta: 'schema',
}));
const columns = {};
const tables = props.extendedTables || props.tables || [];

const tables = props.tables || [];
const extendedTables = props.extendedTables || [];

const tableWords = tables.map(t => {
const tableName = t.name;
const cols = t.columns || [];
const tableName = t.value;
const extendedTable = extendedTables.find(et => et.name === tableName);
const cols = (extendedTable && extendedTable.columns) || [];
cols.forEach(col => {
columns[col.name] = null; // using an object as a unique set
});

return {
name: tableName,
name: t.label,
value: tableName,
score: TABLE_AUTOCOMPLETE_SCORE,
meta: 'table',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
* under the License.
*/
import React from 'react';
import { render } from 'spec/helpers/testing-library';
import { ThemeProvider, supersetTheme } from '@superset-ui/core';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import thunk from 'redux-thunk';
import configureStore from 'redux-mock-store';
import QueryAutoRefresh from 'src/SqlLab/components/QueryAutoRefresh';
import { initialState, runningQuery } from 'src/SqlLab/fixtures';
import fetchMock from 'fetch-mock';
import * as actions from 'src/SqlLab/actions/sqlLab';

describe('QueryAutoRefresh', () => {
const middlewares = [thunk];
Expand All @@ -40,29 +38,31 @@ describe('QueryAutoRefresh', () => {
sqlLab,
};
const store = mockStore(state);
const setup = (overrides = {}) => (
<ThemeProvider theme={supersetTheme}>
<QueryAutoRefresh store={store} {...overrides} />
</ThemeProvider>
);

const mockFetch = fetchMock.get('glob:*/superset/queries/*', {});
const getWrapper = () =>
shallow(<QueryAutoRefresh store={store} />)
.dive()
.dive();
let wrapper;

it('shouldCheckForQueries', () => {
render(setup(), {
useRedux: true,
});

expect(mockFetch.called()).toBe(true);
wrapper = getWrapper();
expect(wrapper.instance().shouldCheckForQueries()).toBe(true);
});

it('setUserOffline', () => {
const spy = jest.spyOn(actions, 'setUserOffline');
wrapper = getWrapper();
const spy = sinon.spy(wrapper.instance().props.actions, 'setUserOffline');

render(setup(), {
useRedux: true,
// state not changed
wrapper.setState({
offline: false,
});
expect(spy.called).toBe(false);

expect(spy).toHaveBeenCalled();
// state is changed
wrapper.setState({
offline: true,
});
expect(spy.callCount).toBe(1);
});
});
Loading

0 comments on commit f3b6cbf

Please sign in to comment.