[incubator-superset] branch master updated (6fde7f8 -> a10b185)
This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git. from 6fde7f8 style: add fade transition to bottom border on navbar menu items (#10402) add a10b185 chore: deactive flaky filter test (#10406) No new revisions were added by this update. Summary of changes: .../cypress-base/cypress/integration/dashboard/filter.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
[incubator-superset] branch master updated: style: add fade transition to bottom border on navbar menu items (#10402)
This is an automated email from the ASF dual-hosted git repository. rusackas pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new 6fde7f8 style: add fade transition to bottom border on navbar menu items (#10402) 6fde7f8 is described below commit 6fde7f8984e88e61949ef9f447616139742be1be Author: Moriah Kreeger AuthorDate: Thu Jul 23 12:49:28 2020 -0700 style: add fade transition to bottom border on navbar menu items (#10402) * Add fade transition to bottom border on navbar menu items * lint fix * use theme variables * fix spec --- .../spec/javascripts/components/Menu_spec.jsx | 6 +- superset-frontend/src/components/Menu/Menu.jsx | 22 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/superset-frontend/spec/javascripts/components/Menu_spec.jsx b/superset-frontend/spec/javascripts/components/Menu_spec.jsx index b0d9a98..103453d 100644 --- a/superset-frontend/spec/javascripts/components/Menu_spec.jsx +++ b/superset-frontend/spec/javascripts/components/Menu_spec.jsx @@ -19,6 +19,7 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; import { Nav } from 'react-bootstrap'; +import { supersetTheme, ThemeProvider } from '@superset-ui/style'; import Menu from 'src/components/Menu/Menu'; @@ -156,7 +157,10 @@ describe('Menu', () => { ...overrideProps, }; -const versionedWrapper = mount(); +const versionedWrapper = mount(, { + wrappingComponent: ThemeProvider, + wrappingComponentProps: { theme: supersetTheme }, +}); expect(versionedWrapper.find('.version-info div')).toHaveLength(2); }); diff --git a/superset-frontend/src/components/Menu/Menu.jsx b/superset-frontend/src/components/Menu/Menu.jsx index ccfd94a..0902c8d 100644 --- a/superset-frontend/src/components/Menu/Menu.jsx +++ b/superset-frontend/src/components/Menu/Menu.jsx @@ -59,6 +59,28 @@ const StyledHeader = styled.header` flex-direction: column; justify-content: center; } + + .navbar-nav > li > a { +&:after { + content: ''; + position: absolute; + bottom: -3px; + left: 0; + width: 100%; + height: 3px; + background-color: ${({ theme }) => theme.colors.primary.base}; + opacity: 0; + transition: opacity ${({ theme }) => theme.transitionTiming * 2}s; +} + +&:hover { + border-bottom: none; + + &:after { +opacity: 1; + } +} + } `; export default function Menu({
[incubator-superset] branch master updated: fix(api): fixes perf on charts and introduces sorting by database on datasets (#10392)
This is an automated email from the ASF dual-hosted git repository. tai pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new 2fd37b1 fix(api): fixes perf on charts and introduces sorting by database on datasets (#10392) 2fd37b1 is described below commit 2fd37b18e397c8ba700379485e9e9ddc7e6c78be Author: Daniel Vaz Gaspar AuthorDate: Thu Jul 23 19:19:05 2020 +0100 fix(api): fixes perf on charts and introduces sorting by database on datasets (#10392) --- superset-frontend/src/views/datasetList/DatasetList.tsx | 8 +--- superset/connectors/sqla/models.py | 4 superset/datasets/api.py| 5 +++-- superset/models/slice.py| 2 +- tests/datasets/api_tests.py | 3 +-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/superset-frontend/src/views/datasetList/DatasetList.tsx b/superset-frontend/src/views/datasetList/DatasetList.tsx index a5da58a..a0fcfd6 100644 --- a/superset-frontend/src/views/datasetList/DatasetList.tsx +++ b/superset-frontend/src/views/datasetList/DatasetList.tsx @@ -54,7 +54,10 @@ type Dataset = { changed_by_url: string; changed_by: string; changed_on_delta_humanized: string; - database_name: string; + database: { +id: string; +database_name: string; + }; explore_url: string; id: number; owners: Array; @@ -275,8 +278,7 @@ const DatasetList: FunctionComponent = ({ }, { Header: t('Source'), - accessor: 'database_name', - disableSortBy: true, + accessor: 'database.database_name', size: 'lg', }, { diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index f571cbc..2494096 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -493,10 +493,6 @@ class SqlaTable( # pylint: disable=too-many-public-methods,too-many-instance-at def datasource_name(self) -> str: return self.table_name -@property -def database_name(self) -> str: -return self.database.name - @classmethod def get_datasource_by_name( cls, diff --git a/superset/datasets/api.py b/superset/datasets/api.py index 34d08d5..eee5e33 100644 --- a/superset/datasets/api.py +++ b/superset/datasets/api.py @@ -72,8 +72,8 @@ class DatasetRestApi(BaseSupersetModelRestApi): } list_columns = [ "id", -"database_id", -"database_name", +"database.id", +"database.database_name", "changed_by_name", "changed_by_url", "changed_by.first_name", @@ -97,6 +97,7 @@ class DatasetRestApi(BaseSupersetModelRestApi): "schema", "changed_by.first_name", "changed_on_delta_humanized", +"database.database_name", ] show_columns = [ "database.database_name", diff --git a/superset/models/slice.py b/superset/models/slice.py index 30f56ca..b7f9e05 100644 --- a/superset/models/slice.py +++ b/superset/models/slice.py @@ -269,7 +269,7 @@ class Slice( @property def changed_by_url(self) -> str: -return f"/superset/profile/{self.created_by.username}" # type: ignore +return f"/superset/profile/{self.changed_by.username}" # type: ignore @property def icons(self) -> str: diff --git a/tests/datasets/api_tests.py b/tests/datasets/api_tests.py index d5bf9b0..0710b9d 100644 --- a/tests/datasets/api_tests.py +++ b/tests/datasets/api_tests.py @@ -92,8 +92,7 @@ class TestDatasetApi(SupersetTestCase): "changed_by_url", "changed_on_delta_humanized", "changed_on_utc", -"database_id", -"database_name", +"database", "default_endpoint", "explore_url", "id",
[incubator-superset] branch master updated: fix(charts): disable CSRF for chart data endpoint (#10397)
This is an automated email from the ASF dual-hosted git repository. dpgaspar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new e026406 fix(charts): disable CSRF for chart data endpoint (#10397) e026406 is described below commit e0264060c3eb58ad5c2a409f7c8961630a329601 Author: Daniel Vaz Gaspar AuthorDate: Thu Jul 23 10:44:25 2020 +0100 fix(charts): disable CSRF for chart data endpoint (#10397) --- superset/app.py| 4 ++-- superset/config.py | 2 +- superset/extensions.py | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/superset/app.py b/superset/app.py index 5dc0684..ad330f3 100644 --- a/superset/app.py +++ b/superset/app.py @@ -24,7 +24,6 @@ from flask import Flask, redirect from flask_appbuilder import expose, IndexView from flask_babel import gettext as __, lazy_gettext as _ from flask_compress import Compress -from flask_wtf import CSRFProtect from superset.connectors.connector_registry import ConnectorRegistry from superset.extensions import ( @@ -33,6 +32,7 @@ from superset.extensions import ( appbuilder, cache_manager, celery_app, +csrf, db, feature_flag_manager, jinja_context_manager, @@ -614,7 +614,7 @@ class SupersetAppInitializer: def configure_wtf(self) -> None: if self.config["WTF_CSRF_ENABLED"]: -csrf = CSRFProtect(self.flask_app) +csrf.init_app(self.flask_app) csrf_exempt_list = self.config["WTF_CSRF_EXEMPT_LIST"] for ex in csrf_exempt_list: csrf.exempt(ex) diff --git a/superset/config.py b/superset/config.py index d9ae516..d22fd80 100644 --- a/superset/config.py +++ b/superset/config.py @@ -171,7 +171,7 @@ QUERY_SEARCH_LIMIT = 1000 WTF_CSRF_ENABLED = True # Add endpoints that need to be exempt from CSRF protection -WTF_CSRF_EXEMPT_LIST = ["superset.views.core.log"] +WTF_CSRF_EXEMPT_LIST = ["superset.views.core.log", "superset.charts.api.data"] # Whether to run the web server in debug mode or not DEBUG = os.environ.get("FLASK_ENV") == "development" diff --git a/superset/extensions.py b/superset/extensions.py index a0dad81..7cafef6 100644 --- a/superset/extensions.py +++ b/superset/extensions.py @@ -29,6 +29,7 @@ from flask import Flask from flask_appbuilder import AppBuilder, SQLA from flask_migrate import Migrate from flask_talisman import Talisman +from flask_wtf.csrf import CSRFProtect from werkzeug.local import LocalProxy from superset.utils.cache_manager import CacheManager @@ -132,6 +133,7 @@ APP_DIR = os.path.dirname(__file__) appbuilder = AppBuilder(update_perms=False) cache_manager = CacheManager() celery_app = celery.Celery() +csrf = CSRFProtect() db = SQLA() _event_logger: Dict[str, Any] = {} event_logger = LocalProxy(lambda: _event_logger.get("event_logger"))
[incubator-superset] branch master updated: fix(api): fixes openapi spec errors and adds a test to validate all spec (#10393)
This is an automated email from the ASF dual-hosted git repository. dpgaspar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new 98a11e7 fix(api): fixes openapi spec errors and adds a test to validate all spec (#10393) 98a11e7 is described below commit 98a11e7cf216239df61b7da231c1c99cdbeaca23 Author: Daniel Vaz Gaspar AuthorDate: Thu Jul 23 10:43:41 2020 +0100 fix(api): fixes openapi spec errors and adds a test to validate all spec (#10393) --- requirements-dev.txt | 1 + superset/charts/api.py | 2 +- superset/charts/schemas.py | 3 +-- tests/base_api_tests.py| 16 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 399f9b7..c478ddd 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -21,6 +21,7 @@ flask-testing==0.8.0 ipdb==0.12 isort==4.3.21 mypy==0.770 +openapi-spec-validator==0.2.8 pytest==5.4.3 pytest-cov==2.10.0 parameterized==0.7.4 diff --git a/superset/charts/api.py b/superset/charts/api.py index 6c8635b..4901041 100644 --- a/superset/charts/api.py +++ b/superset/charts/api.py @@ -645,7 +645,7 @@ class ChartRestApi(BaseSupersetModelRestApi): responses: 200: description: Chart thumbnail image - /content: + content: image/*: schema: type: string diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py index 3856404..0449f65 100644 --- a/superset/charts/schemas.py +++ b/superset/charts/schemas.py @@ -31,13 +31,12 @@ get_delete_ids_schema = {"type": "array", "items": {"type": "integer"}} width_height_schema = { "type": "array", -"items": [{"type": "integer"}, {"type": "integer"}], +"items": {"type": "integer"}, } thumbnail_query_schema = { "type": "object", "properties": {"force": {"type": "boolean"}}, } - screenshot_query_schema = { "type": "object", "properties": { diff --git a/tests/base_api_tests.py b/tests/base_api_tests.py index ba7dde5..2be642c 100644 --- a/tests/base_api_tests.py +++ b/tests/base_api_tests.py @@ -48,6 +48,22 @@ class Model1Api(BaseSupersetModelRestApi): appbuilder.add_api(Model1Api) +class TestOpenApiSpec(SupersetTestCase): +def test_open_api_spec(self): +""" +API: Test validate OpenAPI spec +:return: +""" +from openapi_spec_validator import validate_spec + +self.login(username="admin") +uri = "api/v1/_openapi" +rv = self.client.get(uri) +self.assertEqual(rv.status_code, 200) +response = json.loads(rv.data.decode("utf-8")) +validate_spec(response) + + class TestBaseModelRestApi(SupersetTestCase): def test_default_missing_declaration_get(self): """
[incubator-superset] branch master updated: chore: wiring ControlLabel to a new FormLabel (#10388)
This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new b438ba9 chore: wiring ControlLabel to a new FormLabel (#10388) b438ba9 is described below commit b438ba9ed5a35c2bdef4333bdc251435dbcb7655 Author: Maxime Beauchemin AuthorDate: Thu Jul 23 00:27:22 2020 -0700 chore: wiring ControlLabel to a new FormLabel (#10388) * chore: wiring ControlLabel to a new FormLabel Creating new simple component and wiring all and react-bootstrap.ControlLabel towards it. FormLabel becomes a pivotal point that can be altered to point to AntD when we're ready. * lint * ViewportControl * addressing comments --- superset-frontend/src/CRUD/Field.jsx | 6 ++-- .../src/SqlLab/components/SaveQuery.jsx| 13 +++ .../src/SqlLab/components/ScheduleQueryButton.jsx | 13 +++ superset-frontend/src/components/DeleteModal.tsx | 5 +-- .../FormLabel.tsx} | 42 +++--- superset-frontend/src/components/TableSelector.jsx | 8 +++-- .../components/FilterIndicatorTooltip.jsx | 3 +- .../src/dashboard/components/PropertiesModal.jsx | 19 -- .../components/filterscope/FilterFieldItem.jsx | 5 +-- .../explore/components/AdhocMetricEditPopover.jsx | 19 -- .../src/explore/components/ControlHeader.jsx | 7 ++-- .../src/explore/components/EmbedCodeButton.jsx | 11 +++--- .../src/explore/components/PropertiesModal.tsx | 17 - .../components/controls/ViewportControl.jsx| 3 +- .../src/visualizations/FilterBox/FilterBox.jsx | 4 ++- superset-frontend/stylesheets/superset.less| 4 +++ 16 files changed, 89 insertions(+), 90 deletions(-) diff --git a/superset-frontend/src/CRUD/Field.jsx b/superset-frontend/src/CRUD/Field.jsx index 1425085..bfd528b 100644 --- a/superset-frontend/src/CRUD/Field.jsx +++ b/superset-frontend/src/CRUD/Field.jsx @@ -20,13 +20,13 @@ import React from 'react'; import PropTypes from 'prop-types'; import { FormGroup, - ControlLabel, HelpBlock, FormControl, OverlayTrigger, Tooltip, } from 'react-bootstrap'; +import FormLabel from 'src/components/FormLabel'; import './crud.less'; const propTypes = { @@ -61,7 +61,7 @@ export default class Field extends React.PureComponent { }); return ( - + {label || fieldKey} {compact && descr && ( )} - + {hookedControl} {!compact && descr && {descr}} diff --git a/superset-frontend/src/SqlLab/components/SaveQuery.jsx b/superset-frontend/src/SqlLab/components/SaveQuery.jsx index 025326a..b9eb2de 100644 --- a/superset-frontend/src/SqlLab/components/SaveQuery.jsx +++ b/superset-frontend/src/SqlLab/components/SaveQuery.jsx @@ -21,8 +21,9 @@ import PropTypes from 'prop-types'; import { FormControl, FormGroup, Row, Col } from 'react-bootstrap'; import { t } from '@superset-ui/translation'; -import Button from '../../components/Button'; -import ModalTrigger from '../../components/ModalTrigger'; +import Button from 'src/components/Button'; +import FormLabel from 'src/components/FormLabel'; +import ModalTrigger from 'src/components/ModalTrigger'; const propTypes = { query: PropTypes.object, @@ -91,9 +92,9 @@ class SaveQuery extends React.PureComponent { - + {t('Label')} - + - + {t('Description')} - + - + {t('Label')} - + - + {t('Description')} - + {description} -{t('type delete to confirm')} +{t('type "delete" to confirm')} ) => -setDisableChange(event.target.value !== 'DELETE') +setDisableChange(event.target.value.toUpperCase() !== 'DELETE') } /> diff --git a/superset-frontend/src/dashboard/components/filterscope/FilterFieldItem.jsx b/superset-frontend/src/components/FormLabel.tsx similarity index 56% copy from superset-frontend/src/dashboard/components/filterscope/FilterFieldItem.jsx copy to superset-frontend/src/components/FormLabel.tsx index fb3689d..e1979f57 100644 --- a/superset-frontend/src/dashboard/components/filterscope/FilterFieldItem.jsx +++ b/superset-frontend/src/components/FormLabel.tsx @@ -16,29 +16,31 @@ * specific language gove
[incubator-superset] branch master updated: feat: SIP-34 explore save modal (#10355)
This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new ea53916 feat: SIP-34 explore save modal (#10355) ea53916 is described below commit ea53916730e3671228083852ee0ee420c93532c2 Author: Maxime Beauchemin AuthorDate: Thu Jul 23 00:26:29 2020 -0700 feat: SIP-34 explore save modal (#10355) * feat: SIP-34 explore save modal * using a const for the session storage key * backend changes * minor tweaks * more tweaks * radio cosmetics * styles * fix tests * CreatableSelect\! * Fix cypress & lint * fix unit * lint --- .../cypress/integration/explore/link.test.js | 138 ++- superset-frontend/cypress-base/package-lock.json | 5 + superset-frontend/cypress-base/package.json| 5 +- .../explore/components/SaveModal_spec.jsx | 38 ++- .../src/explore/components/SaveModal.jsx | 254 + superset-frontend/src/explore/main.less| 4 - superset-frontend/stylesheets/superset.less| 32 +++ superset/views/core.py | 12 +- 8 files changed, 253 insertions(+), 235 deletions(-) diff --git a/superset-frontend/cypress-base/cypress/integration/explore/link.test.js b/superset-frontend/cypress-base/cypress/integration/explore/link.test.js index 1d0ce87..bbbdfaa 100644 --- a/superset-frontend/cypress-base/cypress/integration/explore/link.test.js +++ b/superset-frontend/cypress-base/cypress/integration/explore/link.test.js @@ -20,8 +20,14 @@ // Tests for links in the explore UI // *** +import rison from 'rison'; +import shortid from 'shortid'; import { HEALTH_POP_FORM_DATA_DEFAULTS } from './visualizations/shared.helper'; +const apiURL = (endpoint, queryObject) => { + return `${endpoint}?q=${rison.encode(queryObject)}`; +}; + describe('Test explore links', () => { beforeEach(() => { cy.login(); @@ -73,98 +79,120 @@ describe('Test explore links', () => { }); }); - xit('Test chart save as', () => { + it('Test chart save as AND overwrite', () => { const formData = { ...HEALTH_POP_FORM_DATA_DEFAULTS, viz_type: 'table', metrics: ['sum__SP_POP_TOTL'], groupby: ['country_name'], }; -const newChartName = 'Test chart'; +const newChartName = `Test chart [${shortid.generate()}]`; cy.visitChartByParams(JSON.stringify(formData)); cy.verifySliceSuccess({ waitAlias: '@postJson' }); cy.url().then(url => { cy.get('button[data-target="#save_modal"]').click(); cy.get('.modal-content').within(() => { +cy.get('#saveas-radio').check(); cy.get('input[name=new_slice_name]').type(newChartName); cy.get('button#btn_modal_save').click(); }); - cy.url().should('eq', url); - - cy.visitChartByName(newChartName); cy.verifySliceSuccess({ waitAlias: '@postJson' }); -}); - }); - - xit('Test chart save', () => { -const chartName = 'Test chart'; -cy.visitChartByName(chartName); -cy.verifySliceSuccess({ waitAlias: '@postJson' }); + cy.visitChartByName(newChartName); -cy.get('[data-test=groupby]').within(() => { - cy.get('.Select__clear-indicator').click(); -}); -cy.get('button[data-target="#save_modal"]').click(); -cy.get('.modal-content').within(() => { - cy.get('button#btn_modal_save').click(); + // Overwriting! + cy.get('button[data-target="#save_modal"]').click(); + cy.get('.modal-content').within(() => { +cy.get('#overwrite-radio').check(); +cy.get('button#btn_modal_save').click(); + }); + cy.verifySliceSuccess({ waitAlias: '@postJson' }); + const query = { +filters: [ + { +col: 'slice_name', +opr: 'eq', +value: newChartName, + }, +], + }; + cy.request(apiURL('/api/v1/chart/', query)).then(response => { +expect(response.body.count).equals(1); +cy.request('DELETE', `/api/v1/chart/${response.body.ids[0]}`); + }); }); -cy.verifySliceSuccess({ waitAlias: '@postJson' }); -cy.request(`/chart/api/read?_flt_3_slice_name=${chartName}`).then( - response => { -cy.request('DELETE', `/chart/api/delete/${response.body.pks[0]}`); - }, -); }); it('Test chart save as and add to new dashboard', () => { -cy.visitChartByName('Growth Rate'); +const chartName = 'Growth Rate'; +const newChartName = `${chartName} [${shortid.generate()}]`; +const dashboardTitle = `Test dashboard [${shortid.generate()}]`; + +cy.visitChartByName(chartName); cy.verifySliceSuccess({ waitAlias: '@postJson' });