Skip to content

Commit

Permalink
Merge branch 'master' into fix/dataset-link-in-spa-for-chart-and-dash…
Browse files Browse the repository at this point in the history
…board
  • Loading branch information
EugeneTorap committed Aug 3, 2022
2 parents be78590 + bce32af commit f38a740
Show file tree
Hide file tree
Showing 58 changed files with 726 additions and 255 deletions.
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
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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ const propTypes = {
]),
aboveEditorSection: PropTypes.node,
readOnly: PropTypes.bool,
resize: PropTypes.oneOf([
null,
'block',
'both',
'horizontal',
'inline',
'none',
'vertical',
]),
textAreaStyles: PropTypes.object,
};

const defaultProps = {
Expand All @@ -55,6 +65,8 @@ const defaultProps = {
maxLines: 10,
offerEditInModal: true,
readOnly: false,
resize: null,
textAreaStyles: {},
};

class TextAreaControl extends React.Component {
Expand All @@ -72,18 +84,23 @@ class TextAreaControl extends React.Component {
if (this.props.language) {
const style = {
border: `1px solid ${this.props.theme.colors.grayscale.light1}`,
minHeight: `${minLines}em`,
width: 'auto',
...this.props.textAreaStyles,
};
if (this.props.resize) {
style.resize = this.props.resize;
}
if (this.props.readOnly) {
style.backgroundColor = '#f2f2f2';
}

return (
<TextAreaEditor
mode={this.props.language}
style={style}
minLines={minLines}
maxLines={inModal ? 1000 : this.props.maxLines}
width="100%"
height={`${minLines}em`}
editorProps={{ $blockScrolling: true }}
defaultValue={this.props.initialValue}
readOnly={this.props.readOnly}
Expand All @@ -106,10 +123,10 @@ class TextAreaControl extends React.Component {

renderModalBody() {
return (
<div>
<>
<div>{this.props.aboveEditorSection}</div>
{this.renderEditor(true)}
</div>
</>
);
}

Expand Down
1 change: 0 additions & 1 deletion superset/databases/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def run(self) -> Model:
security_manager.add_permission_view_menu(
"schema_access", security_manager.get_schema_perm(database, schema)
)
security_manager.add_permission_view_menu("database_access", database.perm)
db.session.commit()
except DAOCreateFailedError as ex:
db.session.rollback()
Expand Down
Loading

0 comments on commit f38a740

Please sign in to comment.