-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(SqlLab): Change Save Dataset Button to Split Save Query Button IV #20852
Changes from all commits
c7ee008
19f96c1
b370209
f66ce82
5c3c9c2
47b275d
4ed58bc
c415fe4
3fe3741
da90320
76375a8
a8ef2ea
548c804
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,7 +188,7 @@ export default class ResultSet extends React.PureComponent< | |
popSelectStar(tempSchema: string | null, tempTable: string) { | ||
const qe = { | ||
id: shortid.generate(), | ||
title: tempTable, | ||
name: tempTable, | ||
autorun: false, | ||
dbId: this.props.query.dbId, | ||
sql: `SELECT * FROM ${tempSchema ? `${tempSchema}.` : ''}${tempTable}`, | ||
|
@@ -281,11 +281,8 @@ export default class ResultSet extends React.PureComponent< | |
this.props.database?.allows_virtual_table_explore && ( | ||
<ExploreResultsButton | ||
database={this.props.database} | ||
onClick={() => this.setState({ showSaveDatasetModal: true })} | ||
onClick={this.createExploreResultsOnClick} | ||
/> | ||
// In order to use the new workflow for a query powered chart, replace the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add back these lines There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more of a broader question, when do we make this functionality the default behavior? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added back in |
||
// above function with: | ||
// onClick={this.createExploreResultsOnClick} | ||
)} | ||
{this.props.csv && ( | ||
<Button buttonSize="small" href={`/superset/csv/${query.id}`}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import { render, screen } from 'spec/helpers/testing-library'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { Menu } from 'src/components/Menu'; | ||
import SaveDatasetActionButton from 'src/SqlLab/components/SaveDatasetActionButton'; | ||
|
||
const overlayMenu = ( | ||
<Menu> | ||
<Menu.Item>Save dataset</Menu.Item> | ||
</Menu> | ||
); | ||
|
||
describe('SaveDatasetActionButton', () => { | ||
it('renders a split save button', () => { | ||
render( | ||
<SaveDatasetActionButton | ||
setShowSave={() => true} | ||
overlayMenu={overlayMenu} | ||
/>, | ||
); | ||
|
||
const saveBtn = screen.getByRole('button', { name: /save/i }); | ||
const caretBtn = screen.getByRole('button', { name: /caret-down/i }); | ||
|
||
expect(saveBtn).toBeVisible(); | ||
expect(caretBtn).toBeVisible(); | ||
}); | ||
|
||
it('renders a "save dataset" dropdown menu item when user clicks caret button', () => { | ||
render( | ||
<SaveDatasetActionButton | ||
setShowSave={() => true} | ||
overlayMenu={overlayMenu} | ||
/>, | ||
); | ||
|
||
const caretBtn = screen.getByRole('button', { name: /caret-down/i }); | ||
userEvent.click(caretBtn); | ||
|
||
const saveDatasetMenuItem = screen.getByText(/save dataset/i); | ||
|
||
expect(saveDatasetMenuItem).toBeInTheDocument(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import { t, useTheme, styled } from '@superset-ui/core'; | ||
import Icons from 'src/components/Icons'; | ||
import { DropdownButton } from 'src/components/DropdownButton'; | ||
import Button from 'src/components/Button'; | ||
import { DropdownButtonProps } from 'antd/lib/dropdown'; | ||
|
||
interface Props { | ||
setShowSave: (arg0: boolean) => void; | ||
overlayMenu: JSX.Element | null; | ||
} | ||
|
||
export default function SaveDatasetActionButton({ | ||
setShowSave, | ||
overlayMenu, | ||
}: Props) { | ||
const theme = useTheme(); | ||
|
||
const StyledDropdownButton = styled( | ||
DropdownButton as React.FC<DropdownButtonProps>, | ||
)` | ||
&.ant-dropdown-button button.ant-btn.ant-btn-default { | ||
&:first-of-type { | ||
width: ${theme.gridUnit * 16}px; | ||
} | ||
font-weight: ${theme.gridUnit * 150}; | ||
background-color: ${theme.colors.primary.light4}; | ||
color: ${theme.colors.primary.dark1}; | ||
&:nth-child(2) { | ||
&:before, | ||
&:hover:before { | ||
border-left: 2px solid ${theme.colors.primary.dark2}; | ||
} | ||
} | ||
} | ||
span[name='caret-down'] { | ||
margin-left: ${theme.gridUnit * 1}px; | ||
color: ${theme.colors.primary.dark2}; | ||
} | ||
`; | ||
|
||
return !overlayMenu ? ( | ||
<Button | ||
onClick={() => setShowSave(true)} | ||
buttonStyle="primary" | ||
css={{ width: theme.gridUnit * 25 }} | ||
> | ||
{t('Save')} | ||
</Button> | ||
) : ( | ||
<StyledDropdownButton | ||
onClick={() => setShowSave(true)} | ||
overlay={overlayMenu} | ||
icon={ | ||
<Icons.CaretDown | ||
iconColor={theme.colors.grayscale.light5} | ||
name="caret-down" | ||
/> | ||
} | ||
trigger={['click']} | ||
> | ||
{t('Save')} | ||
</StyledDropdownButton> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add back this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added back in
this commit
.