Skip to content
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

Merged
merged 13 commits into from
Aug 1, 2022

Conversation

lyndsiWilliams
Copy link
Member

@lyndsiWilliams lyndsiWilliams commented Jul 25, 2022

SUMMARY

This changes the current save query button into a split save button if the database has "Allow this database to be explored" enabled. When the user clicks the caret section of the button, they can now save the query as a dataset.

Bonus: In order to create this button, I conveniently needed to fix the styling on the "Run" query split button. The split line now goes all the way through the button and the caret is centered.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE:

saveButtonBefore
runButtonBefore

AFTER:

splitSaveButtonAfter
saveButtonAfter
runButtonAfter

TESTING INSTRUCTIONS

  • From SqlLab, open a query for a database that has "Allow this database to be explored" enabled.
    • Observe the new split save button
      • Click the "Save" section of the button to see the save query modal
      • Click the caret v section of the button, then click "Save dataset" to see the save dataset modal
      • Both of these modals should be fully functional
  • From SqlLab, open a query for a database that does NOT have "Allow this database to be explored" enabled.
    • Observe that the save button is a normal button, not split
      • Clicking this button should show the save query modal

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@@ -275,11 +250,19 @@ export default class ResultSet extends React.PureComponent<
this.props.database?.allows_virtual_table_explore && (
<ExploreResultsButton
database={this.props.database}
onClick={() => this.setState({ showSaveDatasetModal: true })}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add back this line

Copy link
Member Author

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.

/>
// In order to use the new workflow for a query powered chart, replace the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add back these lines

Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Member Author

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.

Comment on lines 253 to 264
onClick={() => {
// There is currently redux / state issue where sometimes a query will have serverId
// and other times it will not. We need this attribute consistently for this to work
// const qid = this.props?.query?.results?.query_id;
// if (qid) {
// // This will open explore using the query as datasource
// window.location.href = `/explore/?dataset_type=query&dataset_id=${qid}`;
// } else {
// this.setState({ showSaveDatasetModal: true });
// }
this.setState({ showSaveDatasetModal: true });
}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these lines

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in this commit.

describe('SaveDatasetModal RTL', () => {
it('renders a "Save as new" field', () => {
render(<SaveDatasetModal {...mockedProps} />, { useRedux: true });
const testDatasetList = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we put this in a separate fixture file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, once I'm done fixing this test file I'll be cleaning it up.

</ErrorBoundary>
{showSaveDatasetModal && (
<SaveDatasetModal
key={Math.random()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we doing a Math.random() here for the key? couldn't we just set it as specific value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the SaveDatasetModal can be deleted from this, we ended up invoking it in another portion of the code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed in this commit.

/>
// In order to use the new workflow for a query powered chart, replace the
Copy link
Member

Choose a reason for hiding this comment

The 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?

const toggleSave = () => {
setShowSave(!showSave);
};
const toggleSave = () => setShowSave(!showSave);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think that this would be better taking in a boolean value that we set. Sometimes when connections are slower, the action doesn't immediately render and users click multiple times, causing it to reverse back to original value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I cleaned this up in this commit.

@@ -29,19 +29,14 @@ import {
SaveDatasetModal,
} from 'src/SqlLab/components/SaveDatasetModal';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
import { EXPLORE_CHART_DEFAULT } from 'src/SqlLab/types';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was lost in a rebase potentially? Please revert this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there seems to be some weird rebase stuff on this PR, thanks for catching all these! Re-added in this commit.

@@ -218,26 +213,6 @@ export default class ResultSet extends React.PureComponent<
}
}

createExploreResultsOnClick = async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-added in this commit.

@@ -25,6 +25,7 @@ import { PLACEHOLDER_DATASOURCE } from 'src/dashboard/constants';
import Loading from 'src/components/Loading';
import { EmptyStateBig } from 'src/components/EmptyState';
import ErrorBoundary from 'src/components/ErrorBoundary';
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this is part of an older rebase, and is no longer in this portion of the code base.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in this commit.

@@ -122,8 +123,10 @@ const MonospaceDiv = styled.div`
class Chart extends React.PureComponent {
constructor(props) {
super(props);
this.state = { showSaveDatasetModal: false };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in this commit.

</ErrorBoundary>
{showSaveDatasetModal && (
<SaveDatasetModal
key={Math.random()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the SaveDatasetModal can be deleted from this, we ended up invoking it in another portion of the code.

@@ -136,6 +139,12 @@ class Chart extends React.PureComponent {
}
}

toggleSaveDatasetModal = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in this commit.

@@ -253,6 +262,7 @@ class Chart extends React.PureComponent {
width,
} = this.props;

const { showSaveDatasetModal } = this.state;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in this commit.

@@ -42,6 +42,5 @@ export const ChartErrorMessage: React.FC<Props> = ({
...error,
extra: { ...error.extra, owners },
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add this space back?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird rebase stuff haha! Added back in this commit.

Copy link
Member

@AAfghahi AAfghahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link

codecov bot commented Jul 25, 2022

Codecov Report

Merging #20852 (548c804) into master (3a11856) will increase coverage by 0.05%.
The diff coverage is 77.14%.

@@            Coverage Diff             @@
##           master   #20852      +/-   ##
==========================================
+ Coverage   66.30%   66.36%   +0.05%     
==========================================
  Files        1759     1760       +1     
  Lines       67088    67096       +8     
  Branches     7127     7129       +2     
==========================================
+ Hits        44486    44528      +42     
+ Misses      20770    20744      -26     
+ Partials     1832     1824       -8     
Flag Coverage Δ
javascript 52.12% <77.14%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...frontend/src/SqlLab/components/ResultSet/index.tsx 51.03% <ø> (+0.34%) ⬆️
...frontend/src/SqlLab/components/SqlEditor/index.jsx 51.36% <0.00%> (ø)
...d/src/SqlLab/components/TabbedSqlEditors/index.jsx 56.11% <ø> (ø)
...et-frontend/src/SqlLab/reducers/getInitialState.js 46.42% <ø> (ø)
superset-frontend/src/SqlLab/reducers/sqlLab.js 33.33% <ø> (ø)
superset-frontend/src/SqlLab/types.ts 57.14% <ø> (ø)
superset-frontend/src/components/Chart/Chart.jsx 52.54% <ø> (ø)
superset-frontend/src/utils/datasourceUtils.js 100.00% <ø> (ø)
...d/src/SqlLab/components/SaveDatasetModal/index.tsx 50.00% <40.00%> (+15.11%) ⬆️
superset-frontend/src/SqlLab/actions/sqlLab.js 60.44% <66.66%> (ø)
... and 10 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@lyndsiWilliams
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

@lyndsiWilliams Ephemeral environment spinning up at http://52.25.149.118:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@lyndsiWilliams
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

@lyndsiWilliams Ephemeral environment spinning up at http://54.202.3.230:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@lyndsiWilliams
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

@lyndsiWilliams Ephemeral environment spinning up at http://54.185.46.90:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@lyndsiWilliams
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

@lyndsiWilliams Ephemeral environment spinning up at http://35.165.194.84:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@lyndsiWilliams lyndsiWilliams merged commit 8a04536 into apache:master Aug 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2022

Ephemeral environment shutdown and build artifacts deleted.

@lyndsiWilliams lyndsiWilliams deleted the lyndsi/split-save-btn branch August 1, 2022 19:37
@AAfghahi AAfghahi added the logging Creates a UI or API endpoint that could benefit from logging. label Aug 5, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels logging Creates a UI or API endpoint that could benefit from logging. size/XL 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants