Skip to content

Commit

Permalink
Merge branch 'master' into test_bq
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Aug 3, 2022
2 parents 6fed238 + e4fc556 commit 58b44ed
Show file tree
Hide file tree
Showing 74 changed files with 979 additions and 265 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
# Notify Helm Chart maintainers about changes in it

/helm/superset/ @craig-rueda @dpgaspar @villebro

# Notify E2E test maintainers of changes
/superset-frontend/cypress-base/ @jinghua-qa
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ We don't recommend using the system installed Python. Instead, first install the
brew install readline pkg-config libffi openssl mysql postgres
```

You should install a recent version of Python (the official docker image uses 3.8.12). We'd recommend using a Python version manager like [pyenv](https://github.com/pyenv/pyenv) (and also [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv)).
You should install a recent version of Python (the official docker image uses 3.8.13). We'd recommend using a Python version manager like [pyenv](https://github.com/pyenv/pyenv) (and also [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv)).

Let's also make sure we have the latest version of `pip` and `setuptools`:

Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ def get_git_sha() -> str:
"shillelagh": [
"shillelagh[datasetteapi,gsheetsapi,socrata,weatherapi]>=1.0.3, <2"
],
"snowflake": [
"snowflake-sqlalchemy==1.2.4"
], # PINNED! 1.2.5 introduced breaking changes requiring sqlalchemy>=1.4.0
"snowflake": ["snowflake-sqlalchemy>=1.2.4, <2"],
"spark": ["pyhive[hive]>=0.6.5", "tableschema", "thrift>=0.11.0, <1.0.0"],
"teradata": ["teradatasql>=16.20.0.23"],
"thumbnails": ["Pillow>=9.1.1, <10.0.0"],
Expand Down
3 changes: 2 additions & 1 deletion superset-embedded-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ export async function embedDashboard({
iframe.sandbox.add("allow-scripts"); // obviously the iframe needs scripts
iframe.sandbox.add("allow-presentation"); // for fullscreen charts
iframe.sandbox.add("allow-downloads"); // for downloading charts as image
iframe.sandbox.add("allow-forms"); // for forms to submit
iframe.sandbox.add("allow-popups"); // for exporting charts as csv
// add these ones if it turns out we need them:
// iframe.sandbox.add("allow-top-navigation");
// iframe.sandbox.add("allow-forms");

// add the event listener before setting src, to be 100% sure that we capture the load event
iframe.addEventListener('load', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ export default function transformProps(
if (compareIndex < sortedData.length) {
const compareValue = sortedData[compareIndex][1];
// compare values must both be non-nulls
if (bigNumber !== null && compareValue !== null && compareValue !== 0) {
percentChange = (bigNumber - compareValue) / Math.abs(compareValue);
if (bigNumber !== null && compareValue !== null) {
percentChange = compareValue
? (bigNumber - compareValue) / Math.abs(compareValue)
: 0;
formattedSubheader = `${formatPercentChange(
percentChange,
)} ${compareSuffix}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,35 @@ const config: ControlPanelConfig = {
row_limit: {
default: rowLimit,
},
limit: {
rerender: ['timeseries_limit_metric', 'order_desc'],
},
timeseries_limit_metric: {
label: t('Series Limit Sort By'),
description: t(
'Metric used to order the limit if a series limit is present. ' +
'If undefined reverts to the first metric (where appropriate).',
),
visibility: ({ controls }) => Boolean(controls?.limit.value),
mapStateToProps: (state, controlState) => {
const timeserieslimitProps =
sharedControls.timeseries_limit_metric.mapStateToProps?.(
state,
controlState,
) || {};
timeserieslimitProps.value = state.controls?.limit?.value
? controlState.value
: [];
return timeserieslimitProps;
},
},
order_desc: {
label: t('Series Limit Sort Descending'),
default: false,
description: t(
'Whether to sort descending or ascending if a series limit is present',
),
},
},
formDataOverrides: formData => ({
...formData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
EchartsTimeseriesSeriesType,
TimeseriesChartTransformedProps,
OrientationType,
AxisType,
} from './types';
import { DEFAULT_FORM_DATA } from './constants';
import { ForecastSeriesEnum, ForecastValue } from '../types';
Expand Down Expand Up @@ -337,13 +338,23 @@ export default function transformProps(
rotate: xAxisLabelRotation,
},
minInterval:
xAxisType === 'time' && timeGrainSqla
xAxisType === AxisType.time && timeGrainSqla
? TIMEGRAIN_TO_TIMESTAMP[timeGrainSqla]
: 0,
};

if (xAxisType === AxisType.time) {
/**
* Overriding default behavior (false) for time axis regardless of the granilarity.
* Not including this in the initial declaration above so if echarts changes the default
* behavior for other axist types we won't unintentionally override it
*/
xAxis.axisLabel.showMaxLabel = null;
}

let yAxis: any = {
...defaultYAxis,
type: logAxis ? 'log' : 'value',
type: logAxis ? AxisType.log : AxisType.value,
min,
max,
minorTick: { show: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ export interface EchartsTimeseriesChartProps

export type TimeseriesChartTransformedProps =
EChartTransformedProps<EchartsTimeseriesFormData>;

export enum AxisType {
category = 'category',
value = 'value',
time = 'time',
log = 'log',
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
export const NULL_STRING = '<NULL>';

export const TIMESERIES_CONSTANTS = {
gridOffsetRight: 40,
gridOffsetRight: 20,
gridOffsetLeft: 20,
gridOffsetTop: 20,
gridOffsetBottom: 20,
Expand Down
17 changes: 8 additions & 9 deletions superset-frontend/src/SqlLab/components/ResultSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ interface ResultSetState {
alertIsOpen: boolean;
}

const Styles = styled.div`
const ResultlessStyles = styled.div`
position: relative;
minheight: 100px;
[role='alert'] {
margin-top: ${({ theme }) => theme.gridUnit * 2}px;
}
.sql-result-track-job {
margin-top: ${({ theme }) => theme.gridUnit * 2}px;
}
Expand Down Expand Up @@ -113,10 +116,6 @@ const ResultSetButtons = styled.div`
padding-right: ${({ theme }) => 2 * theme.gridUnit}px;
`;

const ResultSetErrorMessage = styled.div`
padding-top: ${({ theme }) => 4 * theme.gridUnit}px;
`;

export default class ResultSet extends React.PureComponent<
ResultSetProps,
ResultSetState
Expand Down Expand Up @@ -445,7 +444,7 @@ export default class ResultSet extends React.PureComponent<
}
if (query.state === 'failed') {
return (
<ResultSetErrorMessage>
<ResultlessStyles>
<ErrorMessageWithStackTrace
title={t('Database error')}
error={query?.errors?.[0]}
Expand All @@ -455,7 +454,7 @@ export default class ResultSet extends React.PureComponent<
source="sqllab"
/>
{trackingUrl}
</ResultSetErrorMessage>
</ResultlessStyles>
);
}
if (query.state === 'success' && query.ctas) {
Expand Down Expand Up @@ -586,7 +585,7 @@ export default class ResultSet extends React.PureComponent<
: null;

return (
<Styles>
<ResultlessStyles>
<div>{!progressBar && <Loading position="normal" />}</div>
{/* show loading bar whenever progress bar is completed but needs time to render */}
<div>{query.progress === 100 && <Loading position="normal" />}</div>
Expand All @@ -596,7 +595,7 @@ export default class ResultSet extends React.PureComponent<
</div>
<div>{query.progress !== 100 && progressBar}</div>
{trackingUrl && <div>{trackingUrl}</div>}
</Styles>
</ResultlessStyles>
);
}
}
18 changes: 17 additions & 1 deletion superset-frontend/src/components/Datasource/CollectionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ interface CRUDCollectionProps {
expandFieldset?: ReactNode;
extraButtons?: ReactNode;
itemGenerator?: () => any;
itemCellProps?: ((
val: unknown,
label: string,
record: any,
) => React.DetailedHTMLProps<
React.TdHTMLAttributes<HTMLTableCellElement>,
HTMLTableCellElement
>)[];
itemRenderers?: ((
val: unknown,
onChange: () => void,
Expand Down Expand Up @@ -335,6 +343,12 @@ export default class CRUDCollection extends React.PureComponent<
);
}

getCellProps(record: any, col: any) {
const cellPropsFn = this.props.itemCellProps?.[col];
const val = record[col];
return cellPropsFn ? cellPropsFn(val, this.getLabel(col), record) : {};
}

renderCell(record: any, col: any) {
const renderer = this.props.itemRenderers && this.props.itemRenderers[col];
const val = record[col];
Expand Down Expand Up @@ -366,7 +380,9 @@ export default class CRUDCollection extends React.PureComponent<
}
tds = tds.concat(
tableColumns.map(col => (
<td key={col}>{this.renderCell(record, col)}</td>
<td {...this.getCellProps(record, col)} key={col}>
{this.renderCell(record, col)}
</td>
)),
);
if (allowAddItem) {
Expand Down
18 changes: 17 additions & 1 deletion superset-frontend/src/components/Datasource/DatasourceEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ function ColumnCollectionTable({
<TextAreaControl
language="markdown"
offerEditInModal={false}
resize="vertical"
/>
}
/>
Expand Down Expand Up @@ -848,7 +849,11 @@ class DatasourceEditor extends React.PureComponent {
fieldKey="description"
label={t('Description')}
control={
<TextAreaControl language="markdown" offerEditInModal={false} />
<TextAreaControl
language="markdown"
offerEditInModal={false}
resize="vertical"
/>
}
/>
<Field
Expand Down Expand Up @@ -882,6 +887,7 @@ class DatasourceEditor extends React.PureComponent {
language="sql"
controlId="fetch_values_predicate"
minLines={5}
resize="vertical"
/>
}
/>
Expand All @@ -901,6 +907,7 @@ class DatasourceEditor extends React.PureComponent {
controlId="extra"
language="json"
offerEditInModal={false}
resize="vertical"
/>
}
/>
Expand Down Expand Up @@ -1081,6 +1088,7 @@ class DatasourceEditor extends React.PureComponent {
minLines={20}
maxLines={20}
readOnly={!this.state.isEditMode}
resize="both"
/>
}
/>
Expand Down Expand Up @@ -1233,6 +1241,7 @@ class DatasourceEditor extends React.PureComponent {
controlId="warning_markdown"
language="markdown"
offerEditInModal={false}
resize="vertical"
/>
}
/>
Expand All @@ -1247,6 +1256,11 @@ class DatasourceEditor extends React.PureComponent {
verbose_name: '',
expression: '',
})}
itemCellProps={{
expression: () => ({
width: '240px',
}),
}}
itemRenderers={{
metric_name: (v, onChange, _, record) => (
<FlexRowContainer>
Expand Down Expand Up @@ -1276,6 +1290,8 @@ class DatasourceEditor extends React.PureComponent {
language="sql"
offerEditInModal={false}
minLines={5}
textAreaStyles={{ minWidth: '200px', maxWidth: '450px' }}
resize="both"
/>
),
description: (v, onChange, label) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { t, isFeatureEnabled, FeatureFlag, css } from '@superset-ui/core';
import ImageLoader from 'src/components/ListViewCard/ImageLoader';
import { usePluginContext } from 'src/components/DynamicPlugins';
import { Tooltip } from 'src/components/Tooltip';
import { GenericLink } from 'src/components/GenericLink/GenericLink';
import { Theme } from '@emotion/react';

const FALLBACK_THUMBNAIL_URL = '/static/assets/images/chart-card-fallback.svg';
Expand Down Expand Up @@ -264,7 +265,15 @@ const AddSliceCard: React.FC<{
<MetadataItem label={t('Viz type')} value={vizName} />
<MetadataItem
label={t('Dataset')}
value={<a href={datasourceUrl}>{datasourceName}</a>}
value={
datasourceUrl ? (
<GenericLink to={datasourceUrl}>
{datasourceName}
</GenericLink>
) : (
datasourceName
)
}
/>
<MetadataItem label={t('Modified')} value={lastModified} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import AsyncEsmComponent from 'src/components/AsyncEsmComponent';
import { getChartKey } from 'src/explore/exploreUtils';
import { runAnnotationQuery } from 'src/components/Chart/chartAction';
import CustomListItem from 'src/explore/components/controls/CustomListItem';
import ControlPopover from '../ControlPopover/ControlPopover';
import ControlPopover, {
getSectionContainerElement,
} from '../ControlPopover/ControlPopover';

const AnnotationLayer = AsyncEsmComponent(
() => import('./AnnotationLayer'),
Expand Down Expand Up @@ -114,6 +116,11 @@ class AnnotationLayerControl extends React.PureComponent {

removeAnnotationLayer(annotation) {
const annotations = this.props.value.filter(anno => anno !== annotation);
// So scrollbar doesnt get stuck on hidden
const element = getSectionContainerElement();
if (element) {
element.style.setProperty('overflow-y', 'auto', 'important');
}
this.props.onChange(annotations);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Popover, {
} from 'src/components/Popover';

const sectionContainerId = 'controlSections';
const getSectionContainerElement = () =>
export const getSectionContainerElement = () =>
document.getElementById(sectionContainerId)?.lastElementChild as HTMLElement;

const getElementYVisibilityRatioOnContainer = (node: HTMLElement) => {
Expand Down
Loading

0 comments on commit 58b44ed

Please sign in to comment.