Skip to content

Commit

Permalink
kasia feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Feb 24, 2022
1 parent 91c4a5e commit 01d1199
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 26 additions & 2 deletions superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ const TabTitleWrapper = styled.div`
align-items: center;
`;

const StyledTab = styled.span`
line-height: 24px;
`;

const TabTitle = styled.span`
margin-right: ${({ theme }) => theme.gridUnit * 2}px;
text-transform: none;
Expand Down Expand Up @@ -315,6 +319,7 @@ class TabbedSqlEditors extends React.PureComponent {
}

render() {
const noQueryEditors = this.props.queryEditors?.length === 0;
const editors = this.props.queryEditors.map(qe => {
let latestQuery;
if (qe.latestQueryId) {
Expand Down Expand Up @@ -403,10 +408,27 @@ class TabbedSqlEditors extends React.PureComponent {
});

const emptyTab = (
<StyledTab>
<TabTitle>{t('Add a new tab')}</TabTitle>
<Tooltip
id="add-tab"
placement="bottom"
title={
userOS === 'Windows'
? t('New tab (Ctrl + q)')
: t('New tab (Ctrl + t)')
}
>
<i data-test="add-tab-icon" className="fa fa-plus-circle" />
</Tooltip>
</StyledTab>
);

const emptyTabState = (
<EditableTabs.TabPane
key={0}
data-key={0}
tab={<TabTitle style={{ paddingTop: '6px' }}>Add a New Tab</TabTitle>}
tab={emptyTab}
closable={false}
>
<EmptyStateBig
Expand All @@ -425,7 +447,9 @@ class TabbedSqlEditors extends React.PureComponent {
onChange={this.handleSelect}
fullWidth={false}
hideAdd={this.props.offline}
onTabClick={() => noQueryEditors && this.newQueryEditor()}
onEdit={this.handleEdit}
type={noQueryEditors ? 'card' : 'editable-card'}
addIcon={
<Tooltip
id="add-tab"
Expand All @@ -441,7 +465,7 @@ class TabbedSqlEditors extends React.PureComponent {
}
>
{editors}
{this.props.queryEditors?.length === 0 && emptyTab}
{noQueryEditors && emptyTabState}
</EditableTabs>
);
}
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/reducers/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export default function sqlLabReducer(state = {}, action) {
[actions.SET_ACTIVE_QUERY_EDITOR]() {
const qeIds = state.queryEditors.map(qe => qe.id);
if (
qeIds.indexOf(action.queryEditor.id) > -1 &&
qeIds.indexOf(action.queryEditor?.id) > -1 &&
state.tabHistory[state.tabHistory.length - 1] !== action.queryEditor.id
) {
const tabHistory = state.tabHistory.slice();
Expand Down

0 comments on commit 01d1199

Please sign in to comment.