Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: blankstate metrics columns #20755

Merged
merged 106 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
6fc435d
add POC ExploreMixin
hughhhh Jun 6, 2022
632ce21
Working POC
hughhhh Jun 6, 2022
6f22618
Created/tested query dataset dropdown
lyndsiWilliams Jun 7, 2022
236c489
Add isValidDatasourceType to @superset-ui/core and hide query dropdown
lyndsiWilliams Jun 8, 2022
24261d1
fix merge conflicts
hughhhh Jun 8, 2022
bd3b6a9
Visual updates to explore datasource panel
lyndsiWilliams Jun 8, 2022
64f4181
Temporarily make Query icon visible
lyndsiWilliams Jun 8, 2022
7c07534
Remove Query icon visibility
lyndsiWilliams Jun 8, 2022
6fab57f
Removed isValidDatasourceType check
lyndsiWilliams Jun 8, 2022
3a46152
Added Query preview Modal from DatasourceControl if the data source t…
eric-briscoe Jun 8, 2022
613d78a
> fix integration point with frontend
hughhhh Jun 8, 2022
e076f13
Merge branch 'master' of https://github.com/preset-io/superset into c…
hughhhh Jun 13, 2022
31dfdd2
Adjusts conditional logic approach to be extensible for additional ty…
eric-briscoe Jun 13, 2022
bbb91e0
Merge branch 'chart-power-query' into lyndsi/dataset-panel-updates
eric-briscoe Jun 13, 2022
8513cc5
Merge branch 'lyndsi/dataset-panel-updates' into ericbriscoe/sc-41493…
eric-briscoe Jun 13, 2022
cd54603
refactor
hughhhh Jun 14, 2022
a173cfa
Merge branch 'master' of https://github.com/preset-io/superset into c…
hughhhh Jun 15, 2022
0295818
Merge pull request #218 from preset-io/ericbriscoe/sc-41493/query-pre…
eric-briscoe Jun 15, 2022
de20276
set field for sql
hughhhh Jun 15, 2022
bd7db0d
Fixes issue where Missing query parameters error was showing in datas…
eric-briscoe Jun 16, 2022
e344197
add query_language
hughhhh Jun 16, 2022
9c5bc48
fix ds main_dttm
hughhhh Jun 17, 2022
b6fbc33
Fixes issue where menu.tsx was blocking access to redux debugging for…
eric-briscoe Jun 17, 2022
6af2961
Fixes issue where database id was not available to save query as data…
eric-briscoe Jun 17, 2022
12546f5
Merge branch 'master' into chart-power-query
eric-briscoe Jun 17, 2022
ff59846
Merge branch 'master' into chart-power-query
hughhhh Jun 21, 2022
bdbf2d1
oops
hughhhh Jun 21, 2022
559e1a2
fix pre-commit to 50 errors now
hughhhh Jun 21, 2022
890be43
fix circuliar dep
hughhhh Jun 21, 2022
4b833be
Disables showing Metrics section in DatasourcePanel when Query is the…
eric-briscoe Jun 21, 2022
4254b7e
adds condition to use query.columns if query.results is not present e…
eric-briscoe Jun 22, 2022
4710b3d
down to 26 now
hughhhh Jun 22, 2022
017bde6
patch for pre-commit
hughhhh Jun 24, 2022
075c5d8
one more pre-commit
hughhhh Jun 24, 2022
d73504c
added explore_json error
AAfghahi Jun 24, 2022
74ae38c
added error messages
AAfghahi Jun 24, 2022
ea49535
add for metrics
pkdotson Jun 27, 2022
3f5bea4
add text for columns
pkdotson Jun 27, 2022
07ee508
add model open/close method
pkdotson Jun 27, 2022
3ab4526
add propogation and methods
pkdotson Jun 28, 2022
d5d8aaa
change link to span
pkdotson Jun 28, 2022
91cd5c4
lint fix
pkdotson Jun 28, 2022
97ee4eb
Fixes frontend lint and TypeScript errors unit test fixes will be nex…
eric-briscoe Jun 28, 2022
276bc28
Aditional TypeScript error fix
eric-briscoe Jun 28, 2022
a8ff273
Fixes unit test failure
eric-briscoe Jun 28, 2022
ddf2c8d
fix some types
pkdotson Jun 28, 2022
044945b
added frontend piece
AAfghahi Jun 28, 2022
a9fb857
fix type
pkdotson Jun 28, 2022
8d8a868
Merge branch master
eric-briscoe Jun 28, 2022
7ace7a4
Fixes bad import caused by merge from master and removes duplicate sh…
eric-briscoe Jun 28, 2022
e436582
Fixes for DartasourceControl Test Suite
eric-briscoe Jun 28, 2022
76c3505
Fix lint error
eric-briscoe Jun 28, 2022
3370439
Fixes unit test issues due to array instead of a component being pass…
eric-briscoe Jun 29, 2022
d1866e8
merged main branch
AAfghahi Jun 29, 2022
18b6fa1
Merge pull request #223 from preset-io/arash/error_messages
AAfghahi Jun 29, 2022
a7ded35
Fixes unit test failure for DatasourceControl and simplifies getDatas…
eric-briscoe Jun 30, 2022
c65c225
Merge branch 'master' into chart-power-query
eric-briscoe Jun 30, 2022
54e4023
fix ts
pkdotson Jun 30, 2022
232d6dc
pylint
AAfghahi Jun 29, 2022
aa2756e
core_test fix
AAfghahi Jul 5, 2022
ebdfcf0
Merge pull request #225 from preset-io/arash/pylint_errors
hughhhh Jul 5, 2022
a52acd9
Merge branch 'master' into chart-power-query
eric-briscoe Jul 5, 2022
3653e40
Fixes line error post merge from master
eric-briscoe Jul 5, 2022
c0ab26b
merge master
hughhhh Jul 6, 2022
655fddf
fixed from master
hughhhh Jul 6, 2022
f752655
fixed from master
hughhhh Jul 6, 2022
c478add
Merge branch 'chart-power-query' of ssh://github.com/preset-io/supers…
eric-briscoe Jul 6, 2022
5e32c24
Fixes issue where Overwrite dataset does not work due to userid error
eric-briscoe Jul 6, 2022
6707808
Resolves TypeScript errors with changes made for SPA merging in and c…
eric-briscoe Jul 6, 2022
b28d79c
fix: top right panel view query functionality
hughhhh Jul 7, 2022
c619618
Merge branch 'master' of https://github.com/preset-io/superset into c…
hughhhh Jul 7, 2022
fa85488
remove unneeded code from core.py
hughhhh Jul 7, 2022
a09d781
working samples endpoint for query
hughhhh Jul 7, 2022
076e4fd
add owner check
hughhhh Jul 8, 2022
c5ca22d
update FE for it
hughhhh Jul 8, 2022
a35038d
handle columns are dict vs object
hughhhh Jul 8, 2022
661bb9e
fix exceptions
hughhhh Jul 8, 2022
b476b70
fix fe lint
hughhhh Jul 8, 2022
56fcdc9
fix test
hughhhh Jul 8, 2022
551ddc8
Merge pull request #233 from preset-io/chart-power-query-samples
hughhhh Jul 8, 2022
6e5443a
add tab_name to payload
hughhhh Jul 8, 2022
97ac731
Enables use of tab name from Query
eric-briscoe Jul 8, 2022
664773a
fix merge conflicts
hughhhh Jul 11, 2022
a073313
fix cypress test
hughhhh Jul 11, 2022
f717e18
save columns on execution
hughhhh Jul 11, 2022
16ea687
fix frontend build test
hughhhh Jul 11, 2022
3f6fa0a
remove parathesis around columns
hughhhh Jul 11, 2022
88a51b4
changing column types
AAfghahi Jul 11, 2022
a105ca6
fixing samples that has literal_columns
AAfghahi Jul 11, 2022
9e09af2
address comments
hughhhh Jul 11, 2022
69777d3
add changes
pkdotson Jul 12, 2022
6334e21
Merge branch 'chart-power-query' of https://github.com/preset-io/supe…
pkdotson Jul 12, 2022
8394881
fix path
pkdotson Jul 14, 2022
996f8d3
Merge branch 'master' of https://github.com/preset-io/superset into f…
pkdotson Jul 18, 2022
e9aaa1f
fix merge
pkdotson Jul 18, 2022
3db3d10
fix types
pkdotson Jul 19, 2022
0cf7000
remove console
pkdotson Jul 19, 2022
85177aa
add type
pkdotson Jul 21, 2022
79836f0
fix linting
hughhhh Jul 24, 2022
6073777
update to enum
hughhhh Jul 24, 2022
dc74d2b
Merge branch 'master' of https://github.com/preset-io/superset into f…
hughhhh Jul 25, 2022
bee3795
fix test
hughhhh Jul 25, 2022
b626843
remove explore from buttons
hughhhh Jul 26, 2022
9aac370
fix logic
hughhhh Jul 26, 2022
c0853cf
fix logic
hughhhh Jul 26, 2022
69009be
oops
hughhhh Jul 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,23 @@
*/
/* eslint-disable camelcase */
import React, {
Dispatch,
SetStateAction,
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import { AdhocColumn, isAdhocColumn, t, styled, css } from '@superset-ui/core';
import { useSelector } from 'react-redux';
import {
AdhocColumn,
isAdhocColumn,
t,
styled,
css,
DatasourceType,
} from '@superset-ui/core';
import { ColumnMeta, isSavedExpression } from '@superset-ui/chart-controls';
import Tabs from 'src/components/Tabs';
import Button from 'src/components/Button';
Expand All @@ -38,6 +48,7 @@ import {
POPOVER_INITIAL_HEIGHT,
UNRESIZABLE_POPOVER_WIDTH,
} from 'src/explore/constants';
import { ExplorePageState } from 'src/explore/types';

const StyledSelect = styled(Select)`
.metric-option {
Expand All @@ -60,6 +71,7 @@ interface ColumnSelectPopoverProps {
getCurrentTab: (tab: string) => void;
label: string;
isTemporal?: boolean;
setDatasetModal?: Dispatch<SetStateAction<boolean>>;
}

const getInitialColumnValues = (
Expand All @@ -82,11 +94,16 @@ const ColumnSelectPopover = ({
editedColumn,
onChange,
onClose,
setDatasetModal,
setLabel,
getCurrentTab,
label,
isTemporal,
}: ColumnSelectPopoverProps) => {
const datasourceType = useSelector<ExplorePageState, string | undefined>(
state => state.explore.datasource.type,
);
console.log('datasource', datasourceType);
const [initialLabel] = useState(label);
const [initialAdhocColumn, initialCalculatedColumn, initialSimpleColumn] =
getInitialColumnValues(editedColumn);
Expand Down Expand Up @@ -214,6 +231,11 @@ const ColumnSelectPopover = ({
sqlEditorRef.current?.editor.resize();
}, []);

const setDatasetAndClose = () => {
if (setDatasetModal) setDatasetModal(true);
onClose();
};

const stateIsValid =
adhocColumn || selectedCalculatedColumn || selectedSimpleColumn;
const hasUnsavedChanges =
Expand All @@ -226,6 +248,8 @@ const ColumnSelectPopover = ({
const savedExpressionsLabel = t('Saved expressions');
const simpleColumnsLabel = t('Column');

console.log(calculatedColumns.length > 0);
console.log(datasourceType === DatasourceType.Query);
return (
<Form layout="vertical" id="metrics-edit-popover">
<Tabs
Expand Down Expand Up @@ -261,7 +285,7 @@ const ColumnSelectPopover = ({
}))}
/>
</FormItem>
) : (
) : datasourceType === DatasourceType.Table ? (
<EmptyStateSmall
image="empty.svg"
title={
Expand All @@ -279,16 +303,63 @@ const ColumnSelectPopover = ({
)
}
/>
) : (
<EmptyStateSmall
image="empty.svg"
title={
isTemporal
? t('No temporal columns found')
: t('No saved expressions found')
}
description={
isTemporal ? (
<>
<span
role="button"
tabIndex={0}
onClick={setDatasetAndClose}
>
{t('Create a dataset')}
</span>{' '}
{t(' to mark a column as a time column')}
</>
) : (
<>
<span
role="button"
tabIndex={0}
onClick={setDatasetAndClose}
>
{t('Create a dataset')}
</span>{' '}
{t(' to add calculated columns')}
</>
)
}
/>
)}
</Tabs.TabPane>
<Tabs.TabPane key="simple" tab={t('Simple')}>
{isTemporal && simpleColumns.length === 0 ? (
<EmptyStateSmall
image="empty.svg"
title={t('No temporal columns found')}
description={t(
'Mark a column as temporal in "Edit datasource" modal',
)}
description={
datasourceType === DatasourceType.Table ? (
t('Mark a column as temporal in "Edit datasource" modal')
) : (
<>
<span
role="button"
tabIndex={0}
onClick={setDatasetAndClose}
>
{t('Create a dataset')}
</span>{' '}
{t(' to mark a column as a time column')}
</>
)
}
/>
) : (
<FormItem label={simpleColumnsLabel}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* under the License.
*/
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useSelector } from 'react-redux';
import { AdhocColumn, t, isAdhocColumn } from '@superset-ui/core';
import { ColumnMeta, isColumnMeta } from '@superset-ui/chart-controls';
import { ExplorePopoverContent } from 'src/explore/components/ExploreContentPopover';
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
import ColumnSelectPopover from './ColumnSelectPopover';
import { DndColumnSelectPopoverTitle } from './DndColumnSelectPopoverTitle';
import ControlPopover from '../ControlPopover/ControlPopover';
Expand Down Expand Up @@ -48,10 +50,13 @@ const ColumnSelectPopoverTrigger = ({
isTemporal,
...props
}: ColumnSelectPopoverTriggerProps) => {
// @ts-ignore
const datasource = useSelector(state => state.explore.datasource);
const [popoverLabel, setPopoverLabel] = useState(defaultPopoverLabel);
const [popoverVisible, setPopoverVisible] = useState(false);
const [isTitleEditDisabled, setIsTitleEditDisabled] = useState(true);
const [hasCustomLabel, setHasCustomLabel] = useState(false);
const [showDatasetModal, setDatasetModal] = useState(false);

let initialPopoverLabel = defaultPopoverLabel;
if (editedColumn && isColumnMeta(editedColumn)) {
Expand Down Expand Up @@ -95,6 +100,7 @@ const ColumnSelectPopoverTrigger = ({
<ColumnSelectPopover
editedColumn={editedColumn}
columns={columns}
setDatasetModal={setDatasetModal}
onClose={handleClosePopover}
onChange={onColumnEdit}
label={popoverLabel}
Expand Down Expand Up @@ -133,17 +139,31 @@ const ColumnSelectPopoverTrigger = ({
);

return (
<ControlPopover
trigger="click"
content={overlayContent}
defaultVisible={visible}
visible={visible}
onVisibleChange={handleTogglePopover}
title={popoverTitle}
destroyTooltipOnHide
>
{children}
</ControlPopover>
<>
{showDatasetModal && (
<SaveDatasetModal
visible={showDatasetModal}
onHide={() => setDatasetModal(false)}
buttonTextOnSave={t('Save')}
buttonTextOnOverwrite={t('Overwrite')}
modalDescription={t(
'Save this query as a virtual dataset to continue exploring',
)}
datasource={datasource}
/>
)}
<ControlPopover
trigger="click"
content={overlayContent}
defaultVisible={visible}
visible={visible}
onVisibleChange={handleTogglePopover}
title={popoverTitle}
destroyTooltipOnHide
>
{children}
</ControlPopover>
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ const defaultProps: DndColumnSelectProps = {
};

test('renders with default props', () => {
render(<DndColumnSelect {...defaultProps} />, { useDnd: true });
render(<DndColumnSelect {...defaultProps} />, {
useDnd: true,
useRedux: true,
});
expect(screen.getByText('Drop columns here')).toBeInTheDocument();
});

test('renders with value', () => {
render(<DndColumnSelect {...defaultProps} value="string" />, {
useDnd: true,
useRedux: true,
});
expect(screen.getByText('Column A')).toBeInTheDocument();
});
Expand All @@ -55,7 +59,7 @@ test('renders adhoc column', () => {
expressionType: 'SQL',
}}
/>,
{ useDnd: true },
{ useDnd: true, useRedux: true },
);
expect(screen.getByText('adhoc column')).toBeVisible();
expect(screen.getByLabelText('calculator')).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* eslint-disable camelcase */
import React from 'react';
import PropTypes from 'prop-types';
import { t, styled, ensureIsArray } from '@superset-ui/core';
import { t, styled, ensureIsArray, DatasourceType } from '@superset-ui/core';
import Tabs from 'src/components/Tabs';
import Button from 'src/components/Button';
import { Select } from 'src/components';
Expand Down Expand Up @@ -370,14 +370,34 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
{...savedSelectProps}
/>
</FormItem>
) : (
) : datasource.type === DatasourceType.Table ? (
<EmptyStateSmall
image="empty.svg"
title={t('No saved metrics found')}
description={t(
'Add metrics to dataset in "Edit datasource" modal',
)}
/>
) : (
<EmptyStateSmall
image="empty.svg"
title={t('No saved metrics found')}
description={
<>
<span
tabIndex={0}
role="button"
onClick={() => {
this.props.handleDatasetModal(true);
this.props.onClose();
}}
>
{t('Create a dataset')}{' '}
</span>
{t('to add metrics')}
</>
}
/>
)}
</Tabs.TabPane>
<Tabs.TabPane
Expand Down
Loading