From 11d52cb4e15af95a5e562b82d0646416f0140c07 Mon Sep 17 00:00:00 2001 From: John Bodley <4567245+john-bodley@users.noreply.github.com> Date: Tue, 12 Oct 2021 15:14:40 -0700 Subject: [PATCH 1/2] Update druid.py (#17079) --- superset/db_engine_specs/druid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/db_engine_specs/druid.py b/superset/db_engine_specs/druid.py index a0765d4e7b878..76de48083d115 100644 --- a/superset/db_engine_specs/druid.py +++ b/superset/db_engine_specs/druid.py @@ -54,7 +54,7 @@ class DruidEngineSpec(BaseEngineSpec): "P1D": "TIME_FLOOR({col}, 'P1D')", "P1W": "TIME_FLOOR({col}, 'P1W')", "P1M": "TIME_FLOOR({col}, 'P1M')", - "P0.25Y": "TIME_FLOOR({col}, 'P0.25Y')", + "P0.25Y": "TIME_FLOOR({col}, 'P3M')", "P1Y": "TIME_FLOOR({col}, 'P1Y')", "P1W/1970-01-03T00:00:00Z": ( "TIME_SHIFT(TIME_FLOOR(TIME_SHIFT({col}, 'P1D', 1), 'P1W'), 'P1D', 5)" From 959fd763a8b22367e7de5d3438e457f3448c6ceb Mon Sep 17 00:00:00 2001 From: "Hugh A. Miles II" Date: Tue, 12 Oct 2021 17:27:56 -0700 Subject: [PATCH 2/2] fix: Owners selection in dataset edit UX (#17063) * boilerplate * update owner select component * this is working * update onchange * refactorig * you need to useMemo or things break * update test * prettier * move logic into bootstrap data endpoint * address concerns * oops * oops * fix test --- .../spec/fixtures/mockDatasource.js | 1 + .../components/FiltersBadge_spec.tsx | 1 - .../src/datasource/DatasourceEditor.jsx | 60 ++++++++++++------- .../src/datasource/DatasourceModal.tsx | 4 +- .../DatasourceControl.test.tsx | 1 + .../views/CRUD/data/dataset/DatasetList.tsx | 3 +- superset/connectors/base/models.py | 12 ++++ superset/views/core.py | 3 + 8 files changed, 61 insertions(+), 24 deletions(-) diff --git a/superset-frontend/spec/fixtures/mockDatasource.js b/superset-frontend/spec/fixtures/mockDatasource.js index 55d95ebde222c..ca60a712b2088 100644 --- a/superset-frontend/spec/fixtures/mockDatasource.js +++ b/superset-frontend/spec/fixtures/mockDatasource.js @@ -168,6 +168,7 @@ export default { id, granularity_sqla: [['ds', 'ds']], name: 'birth_names', + owners: [{ first_name: 'joe', last_name: 'man', id: 1 }], database: { allow_multi_schema_metadata_fetch: null, name: 'main', diff --git a/superset-frontend/spec/javascripts/dashboard/components/FiltersBadge_spec.tsx b/superset-frontend/spec/javascripts/dashboard/components/FiltersBadge_spec.tsx index f24b973199dee..539aa67a69913 100644 --- a/superset-frontend/spec/javascripts/dashboard/components/FiltersBadge_spec.tsx +++ b/superset-frontend/spec/javascripts/dashboard/components/FiltersBadge_spec.tsx @@ -139,7 +139,6 @@ describe('FiltersBadge', () => { wrapper.find('[data-test="incompatible-filter-count"]'), ).toHaveText('1'); // to look at the shape of the wrapper use: - // console.log(wrapper.debug()) expect(wrapper.find(Icons.AlertSolid)).toExist(); }); }); diff --git a/superset-frontend/src/datasource/DatasourceEditor.jsx b/superset-frontend/src/datasource/DatasourceEditor.jsx index e502a3e2b22a4..e725cdc238900 100644 --- a/superset-frontend/src/datasource/DatasourceEditor.jsx +++ b/superset-frontend/src/datasource/DatasourceEditor.jsx @@ -17,7 +17,7 @@ * under the License. */ import rison from 'rison'; -import React from 'react'; +import React, { useCallback } from 'react'; import PropTypes from 'prop-types'; import { Row, Col } from 'src/common/components'; import { Radio } from 'src/components/Radio'; @@ -26,6 +26,8 @@ import Alert from 'src/components/Alert'; import Badge from 'src/components/Badge'; import shortid from 'shortid'; import { styled, SupersetClient, t, supersetTheme } from '@superset-ui/core'; +import { Select } from 'src/components'; +import { FormLabel } from 'src/components/Form'; import Button from 'src/components/Button'; import Tabs from 'src/components/Tabs'; import CertifiedIcon from 'src/components/CertifiedIcon'; @@ -40,9 +42,7 @@ import { getClientErrorObject } from 'src/utils/getClientErrorObject'; import CheckboxControl from 'src/explore/components/controls/CheckboxControl'; import TextControl from 'src/explore/components/controls/TextControl'; -import { Select } from 'src/components'; import TextAreaControl from 'src/explore/components/controls/TextAreaControl'; -import SelectAsyncControl from 'src/explore/components/controls/SelectAsyncControl'; import SpatialControl from 'src/explore/components/controls/SpatialControl'; import CollectionTable from 'src/CRUD/CollectionTable'; @@ -374,12 +374,44 @@ const defaultProps = { onChange: () => {}, }; +function OwnersSelector({ datasource, onChange }) { + const loadOptions = useCallback((search = '', page, pageSize) => { + const query = rison.encode({ filter: search, page, page_size: pageSize }); + return SupersetClient.get({ + endpoint: `/api/v1/dataset/related/owners?q=${query}`, + }).then(response => ({ + data: response.json.result.map(item => ({ + value: item.value, + label: item.text, + })), + totalCount: response.json.count, + })); + }, []); + + return ( +