Skip to content

Commit

Permalink
fix sqllab <Loading /> css, fix double AddSliceCard margin and drag b…
Browse files Browse the repository at this point in the history
…order (apache#5293)

* fix sqllab <Loading /> css, fix double AddSliceCard margin and drag border

* [dashboard v2] improve cached visual indicator, add last fetched messaging

* [dashboard v2] fix ctrl + cmd + z + UndoRedoKeylisteners

(cherry picked from commit 05a39b3)
  • Loading branch information
williaster authored and mistercrunch committed Aug 4, 2018
1 parent 845167a commit aee0b20
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 54 deletions.
19 changes: 0 additions & 19 deletions superset/assets/src/SqlLab/TODO.md

This file was deleted.

6 changes: 4 additions & 2 deletions superset/assets/src/SqlLab/components/ResultSet.jsx
Expand Up @@ -31,6 +31,8 @@ const defaultProps = {

const SEARCH_HEIGHT = 46;

const LOADING_STYLES = { position: 'relative', height: 50 };

export default class ResultSet extends React.PureComponent {
constructor(props) {
super(props);
Expand Down Expand Up @@ -238,9 +240,9 @@ export default class ResultSet extends React.PureComponent {
);
}
return (
<div>
<Loading />
<div style={LOADING_STYLES}>
<QueryStateLabel query={query} />
{!progressBar && <Loading />}
{progressBar}
<div>
{trackingUrl}
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/src/SqlLab/components/SouthPane.jsx
Expand Up @@ -86,7 +86,7 @@ class SouthPane extends React.PureComponent {
title={t('Query History')}
eventKey="History"
>
<div style={{ height: `${innerTabHeight}px`, overflow: 'scroll' }}>
<div style={{ height: `${innerTabHeight}px`, overflow: 'auto' }}>
<QueryHistory queries={props.editorQueries} actions={props.actions} />
</div>
</Tab>
Expand Down
4 changes: 2 additions & 2 deletions superset/assets/src/SqlLab/main.less
Expand Up @@ -45,7 +45,7 @@ body {
left: 0px;
right: 0px;
bottom: 0px;
overflow: scroll;
overflow: auto;
margin-right: 0px;
margin-bottom: 0px;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ a.Link {
margin-top: 10px;
position: absolute;
width: 100%;
overflow: scroll;
overflow: auto;
}
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
Expand Down
Expand Up @@ -87,11 +87,9 @@ class BuilderComponentPane extends React.PureComponent {

<i className="fa fa-arrow-right trigger" />
</div>

<NewTabs />
<NewRow />
<NewColumn />

<NewHeader />
<NewMarkdown />
<NewDivider />
Expand Down
4 changes: 4 additions & 0 deletions superset/assets/src/dashboard/components/SliceHeader.jsx
Expand Up @@ -12,6 +12,7 @@ const propTypes = {
isExpanded: PropTypes.bool,
isCached: PropTypes.bool,
cachedDttm: PropTypes.string,
updatedDttm: PropTypes.number,
updateSliceName: PropTypes.func,
toggleExpandSlice: PropTypes.func,
forceRefresh: PropTypes.func,
Expand All @@ -37,6 +38,7 @@ const defaultProps = {
annotationQuery: {},
annotationError: {},
cachedDttm: null,
updatedDttm: null,
isCached: false,
isExpanded: false,
sliceName: '',
Expand All @@ -51,6 +53,7 @@ class SliceHeader extends React.PureComponent {
isExpanded,
isCached,
cachedDttm,
updatedDttm,
toggleExpandSlice,
forceRefresh,
exploreChart,
Expand Down Expand Up @@ -102,6 +105,7 @@ class SliceHeader extends React.PureComponent {
isCached={isCached}
isExpanded={isExpanded}
cachedDttm={cachedDttm}
updatedDttm={updatedDttm}
toggleExpandSlice={toggleExpandSlice}
forceRefresh={forceRefresh}
exploreChart={exploreChart}
Expand Down
27 changes: 13 additions & 14 deletions superset/assets/src/dashboard/components/SliceHeaderControls.jsx
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import moment from 'moment';
import { Dropdown, MenuItem } from 'react-bootstrap';
import {
Expand All @@ -17,6 +16,7 @@ const propTypes = {
isCached: PropTypes.bool,
isExpanded: PropTypes.bool,
cachedDttm: PropTypes.string,
updatedDttm: PropTypes.number,
supersetCanExplore: PropTypes.bool,
sliceCanEdit: PropTypes.bool,
toggleExpandSlice: PropTypes.func,
Expand All @@ -31,6 +31,7 @@ const defaultProps = {
exploreChart: () => ({}),
exportCSV: () => ({}),
cachedDttm: null,
updatedDttm: null,
isCached: false,
isExpanded: false,
supersetCanExplore: false,
Expand Down Expand Up @@ -101,31 +102,29 @@ class SliceHeaderControls extends React.PureComponent {
}

render() {
const slice = this.props.slice;
const isCached = this.props.isCached;
const cachedWhen = moment.utc(this.props.cachedDttm).fromNow();
const refreshTooltip = isCached ? t('Cached %s', cachedWhen) : '';

// @TODO account for
// dashboard.dashboard.superset_can_explore
// dashboard.dashboard.slice_can_edit
const { slice, isCached, cachedDttm, updatedDttm } = this.props;
const cachedWhen = moment.utc(cachedDttm).fromNow();
const updatedWhen = updatedDttm ? moment.utc(updatedDttm).fromNow() : '';
const refreshTooltip = isCached
? t('Cached %s', cachedWhen)
: (updatedWhen && t('Fetched %s', updatedWhen)) || '';

return (
<Dropdown
id={`slice_${slice.slice_id}-controls`}
className={cx(isCached && 'is-cached')}
pullRight
// react-bootstrap handles visibility, but call toggle to force a re-render
// and update the fetched/cached timestamps
onToggle={this.toggleControls}
>
<Dropdown.Toggle className="slice-header-controls-trigger" noCaret>
<VerticalDotsTrigger />
</Dropdown.Toggle>

<Dropdown.Menu>
<MenuItem onClick={this.refreshChart}>
{isCached && <span className="dot" />}
{t('Force refresh')}
{isCached && (
<div className="refresh-tooltip">{refreshTooltip}</div>
)}
<div className="refresh-tooltip">{refreshTooltip}</div>
</MenuItem>

<MenuItem divider />
Expand Down
Expand Up @@ -21,13 +21,12 @@ class UndoRedoKeylisteners extends React.PureComponent {
}

handleKeydown(event) {
const controlOrCommand = event.keyCode === 90 || event.metaKey;
const controlOrCommand = event.ctrlKey || event.metaKey;
if (controlOrCommand) {
const isZChar = event.key === 'z' || event.keyCode === 90;
const isYChar = event.key === 'y' || event.keyCode === 89;
const isEditingMarkdown = document.querySelector(
'.dashboard-markdown--editing',
);
const isEditingMarkdown =
document && document.querySelector('.dashboard-markdown--editing');

if (!isEditingMarkdown && (isZChar || isYChar)) {
event.preventDefault();
Expand Down
Expand Up @@ -11,7 +11,6 @@ import {

const staticCardStyles = {
position: 'fixed',
background: 'rgba(255, 255, 255, 0.7)',
pointerEvents: 'none',
top: 0,
left: 0,
Expand Down
Expand Up @@ -160,7 +160,7 @@ class Chart extends React.Component {
if (!chart || !slice) return null;

const { width } = this.state;
const { queryResponse } = chart;
const { queryResponse, chartUpdateEndTime } = chart;
const isCached = queryResponse && queryResponse.is_cached;
const cachedDttm = queryResponse && queryResponse.cached_dttm;
const isOverflowable = OVERFLOWABLE_VIZ_TYPES.has(slice && slice.viz_type);
Expand All @@ -173,6 +173,7 @@ class Chart extends React.Component {
isExpanded={!!isExpanded}
isCached={isCached}
cachedDttm={cachedDttm}
updatedDttm={chartUpdateEndTime}
toggleExpandSlice={toggleExpandSlice}
forceRefresh={this.forceRefresh}
editMode={editMode}
Expand Down
4 changes: 3 additions & 1 deletion superset/assets/src/dashboard/containers/Chart.jsx
Expand Up @@ -28,7 +28,9 @@ function mapStateToProps(

return {
chart,
datasource: (chart && datasources[chart.form_data.datasource]) || {},
datasource:
(chart && chart.form_data && datasources[chart.form_data.datasource]) ||
{},
slice: sliceEntities.slices[id],
timeout: dashboardInfo.common.conf.SUPERSET_WEBSERVER_TIMEOUT,
filters: filters[id] || EMPTY_FILTERS,
Expand Down
Expand Up @@ -29,7 +29,6 @@
.viewport {
position: absolute;
transform: none !important;
background: white;
overflow: hidden;
width: @builder-pane-width;
height: 100%;
Expand Down Expand Up @@ -77,9 +76,10 @@
border: 1px solid @gray-light;
font-weight: 200;
padding: 16px;
margin: 16px;
margin: 0 16px 16px 16px;
position: relative;
cursor: move;
background: rgba(255, 255, 255, 0.4);

&:hover {
background: @gray-bg;
Expand Down
Expand Up @@ -83,11 +83,6 @@
margin: 2px 0;
display: inline-block;

.is-cached & {
background-color: @pink;
box-shadow: 0 0 5px 1.5px rgba(255, 0, 0, 0.3);
}

.vertical-dots-container & {
display: block;
}
Expand Down

0 comments on commit aee0b20

Please sign in to comment.