Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Minor improvements to SQL Lab UI (apache#5662)
Browse files Browse the repository at this point in the history
* Remove "for"

* add space

* Separate control to select table from database and schema.

* Adjust schema displays

* Fix caret and arrow position in Select and Tab

* Reduce space after caret in tab header

* Use translator

* Align icons in the pop-up menu in Sql Lab

* Add new table in front of the list (so it will appear on top)

* shorten message

* reduce line
  • Loading branch information
kristw authored and williaster committed Aug 20, 2018
1 parent 4c5142d commit cdd348a
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 20 deletions.
7 changes: 5 additions & 2 deletions superset/assets/src/SqlLab/components/CopyQueryTabUrl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ export default class CopyQueryTabUrl extends React.PureComponent {
inMenu
copyNode={(
<div>
<i className="fa fa-clipboard" /> <span>{t('share query')}</span>
<div className="icon-container">
<i className="fa fa-clipboard" />
</div>
<span>{t('Share query')}</span>
</div>
)}
tooltipText={t('copy URL to clipboard')}
tooltipText={t('Copy URL to clipboard')}
shouldShowText={false}
getText={this.getUrl.bind(this)}
/>
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/src/SqlLab/components/SouthPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SouthPane extends React.PureComponent {
}
const dataPreviewTabs = props.dataPreviewQueries.map(query => (
<Tab
title={t('Preview for %s', query.tableName)}
title={t('Preview: `%s`', query.tableName)}
eventKey={query.id}
key={query.id}
>
Expand Down
16 changes: 14 additions & 2 deletions superset/assets/src/SqlLab/components/SqlEditorLeftBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint no-undef: 2 */
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from 'react-bootstrap';
import { ControlLabel, Button } from 'react-bootstrap';
import Select from 'react-virtualized-select';
import createFilterOptions from 'react-select-fast-filter-options';

Expand Down Expand Up @@ -189,13 +189,25 @@ class SqlEditorLeftBar extends React.PureComponent {
onChange={this.changeSchema.bind(this)}
/>
</div>
<hr />
<div className="m-t-5">
<ControlLabel>
{t('See table schema')}
&nbsp;
<small>
({this.state.tableOptions.length}
&nbsp;{t('in')}&nbsp;
<i>
{this.props.queryEditor.schema}
</i>)
</small>
</ControlLabel>
{this.props.queryEditor.schema &&
<Select
name="select-table"
ref="selectTable"
isLoading={this.state.tableLoading}
placeholder={t('Add a table (%s)', this.state.tableOptions.length)}
placeholder={t('Select table or type table name')}
autosize={false}
onChange={this.changeTable.bind(this)}
filterOptions={this.state.filterOptions}
Expand Down
24 changes: 18 additions & 6 deletions superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,30 @@ class TabbedSqlEditors extends React.PureComponent {
<div>
<TabStatusIcon onClose={this.removeQueryEditor.bind(this, qe)} tabState={state} />{' '}
{qe.title}{' '}
<DropdownButton bsSize="small" id={'ddbtn-tab-' + i} title="">
<DropdownButton
bsSize="small"
id={'ddbtn-tab-' + i}
className="ddbtn-tab"
title=""
>
<MenuItem eventKey="1" onClick={this.removeQueryEditor.bind(this, qe)}>
<i className="fa fa-close" /> {t('close tab')}
<div className="icon-container">
<i className="fa fa-close" />
</div>
{t('Close tab')}
</MenuItem>
<MenuItem eventKey="2" onClick={this.renameTab.bind(this, qe)}>
<i className="fa fa-i-cursor" /> {t('rename tab')}
<div className="icon-container">
<i className="fa fa-i-cursor" />
</div>
{t('Rename tab')}
</MenuItem>
{qe && <CopyQueryTabUrl queryEditor={qe} />}
<MenuItem eventKey="4" onClick={this.toggleLeftBar.bind(this)}>
<i className="fa fa-cogs" />
&nbsp;
{this.state.hideLeftBar ? t('expand tool bar') : t('hide tool bar')}
<div className="icon-container">
<i className="fa fa-cogs" />
</div>
{this.state.hideLeftBar ? t('Expand tool bar') : t('Hide tool bar')}
</MenuItem>
</DropdownButton>
</div>
Expand Down
9 changes: 4 additions & 5 deletions superset/assets/src/SqlLab/components/TableElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ class TableElement extends React.PureComponent {
className="table-name"
onClick={(e) => { this.toggleTable(e); }}
>
<strong>{table.name}</strong>
<small className="m-l-5">
<small className="m-r-5">
<i className={`fa fa-${table.expanded ? 'minus' : 'plus'}-square-o`} />
</small>
<strong>`{table.name}`</strong>
</a>
</div>
<div className="pull-right">
Expand Down Expand Up @@ -197,11 +197,10 @@ class TableElement extends React.PureComponent {
>
<div>
{this.renderWell()}
<div className="table-columns">
<div className="table-columns m-t-5">
{cols && cols.map(col => (
<ColumnElement column={col} key={col.name} />
))}
<hr />
</div>
</div>
</Collapse>
Expand All @@ -217,7 +216,7 @@ class TableElement extends React.PureComponent {
transitionAppear
onExited={this.removeFromStore.bind(this)}
>
<div className="TableElement">
<div className="TableElement m-b-10">
{this.renderHeader()}
<div>
{this.renderBody()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class TemplateParamsEditor extends React.Component {
(example: <code>{'{"my_table": "foo"}'}</code>),
and they become available
in your SQL (example: <code>SELECT * FROM {'{{ my_table }}'} </code>)
by using
by using&nbsp;
<a
href="http://superset.apache.org/sqllab.html#templating-with-jinja"
target="_blank"
Expand Down
23 changes: 23 additions & 0 deletions superset/assets/src/SqlLab/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ div.tablePopover:hover {
min-width: 100%;
width: inherit;
}
.Select-clear {
margin-top: -2px;
}
.Select-arrow {
margin-top: 5px;
}

.ace_content {
background-color: #f4f4f4;
}
Expand All @@ -266,6 +273,10 @@ div.tablePopover:hover {
padding: 5px 10px;
}

.TableElement .ws-el-controls {
margin-right: -.3em;
}

.QueryTable .label {
display: inline-block;
}
Expand Down Expand Up @@ -309,6 +320,18 @@ a.Link {
.nav-tabs > li.active > a:focus {
padding-bottom: 8px;
}
.nav-tabs .dropdown-toggle.btn .caret {
margin-top: -12px;
}
.nav-tabs .ddbtn-tab {
margin-left: 5px;
padding-right: 0;
}
.icon-container {
display: inline-block;
width: 30px;
text-align: center;
}
.search-date-filter-container {
display: flex;

Expand Down
2 changes: 1 addition & 1 deletion superset/assets/src/SqlLab/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const sqlLabReducer = function (state = {}, action) {
at.id = shortid.generate();
// for new table, associate Id of query for data preview
at.dataPreviewQueryId = null;
let newState = addToArr(state, 'tables', at);
let newState = addToArr(state, 'tables', at, true);
if (action.query) {
newState = alterInArr(newState, 'tables', at, { dataPreviewQueryId: action.query.id });
}
Expand Down
8 changes: 6 additions & 2 deletions superset/assets/src/reduxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ export function getFromArr(arr, id) {
return obj;
}

export function addToArr(state, arrKey, obj) {
export function addToArr(state, arrKey, obj, prepend = false) {
const newObj = Object.assign({}, obj);
if (!newObj.id) {
newObj.id = shortid.generate();
}
const newState = {};
newState[arrKey] = [...state[arrKey], newObj];
if (prepend) {
newState[arrKey] = [newObj, ...state[arrKey]];
} else {
newState[arrKey] = [...state[arrKey], newObj];
}
return Object.assign({}, state, newState);
}

Expand Down

0 comments on commit cdd348a

Please sign in to comment.