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

fix(explore): CSV Export Permission is incorrect on Explore page #13713

Merged

Conversation

duynguyenhoang
Copy link
Contributor

SUMMARY

  • Add CSV Export permission when exporting CSV.
  • Fix CSV Export permission on Expore page.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before

Screenshot_20210320_005126
After
Screenshot_20210320_005059

TEST PLAN

  • Log in with user without "Can CSV on Superset" permission.
  • Go to Dashboard page, verify there is no "Export CSV" in chart context menu.
  • Click "View chart in Explore", verify that "Export CSV" button is disabled and unclickable.
  • Try to access CSV export manually => 403 error returned with message { "error": "You don't have the rights to download as csv" }

ADDITIONAL INFORMATION

@duynguyenhoang duynguyenhoang changed the title fix: CSV Export Permission is incorrect on Explore page fix(explore): CSV Export Permission is incorrect on Explore page Mar 19, 2021
@codecov
Copy link

codecov bot commented Mar 19, 2021

Codecov Report

Merging #13713 (bbb4767) into master (1f8de1d) will increase coverage by 0.01%.
The diff coverage is 92.85%.

❗ Current head bbb4767 differs from pull request most recent head b26cc92. Consider uploading reports for the commit b26cc92 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13713      +/-   ##
==========================================
+ Coverage   76.98%   76.99%   +0.01%     
==========================================
  Files         955      955              
  Lines       48085    48095      +10     
  Branches     6036     6038       +2     
==========================================
+ Hits        37020    37033      +13     
+ Misses      10867    10864       -3     
  Partials      198      198              
Flag Coverage Δ
hive 80.75% <90.00%> (+<0.01%) ⬆️
javascript 71.71% <100.00%> (+0.02%) ⬆️
mysql 81.01% <90.00%> (+<0.01%) ⬆️
postgres 81.05% <90.00%> (+<0.01%) ⬆️
presto 80.74% <90.00%> (+<0.01%) ⬆️
python 81.57% <90.00%> (+<0.01%) ⬆️
sqlite 80.65% <90.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...tend/src/explore/components/ExploreChartHeader.jsx 63.15% <ø> (ø)
superset/views/core.py 75.66% <66.66%> (-0.04%) ⬇️
...nd/src/explore/components/ExploreActionButtons.tsx 72.34% <100.00%> (+10.11%) ⬆️
superset/charts/api.py 81.92% <100.00%> (+0.10%) ⬆️
superset/cli.py 51.47% <100.00%> (+0.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f8de1d...b26cc92. Read the comment docs.

@junlincc
Copy link
Member

junlincc commented Apr 9, 2021

/testenv up

@junlincc junlincc added the !deprecated-label:viz:explore:others Deprecated label - Use explore instead label Apr 9, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2021

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

Copy link
Member

@junlincc junlincc left a comment

Choose a reason for hiding this comment

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

Tested locally, LGTM! Sorry for the delay and thanks for the fix. do you mind rebasing since it has been quite a while. 🙏

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! You should probably add it here, too (it's the new chart data endpoint that will ultimately replace explore_json):

def get_data(self, df: pd.DataFrame,) -> Union[str, List[Dict[str, Any]]]:
if self.result_format == ChartDataResultFormat.CSV:
include_index = not isinstance(df.index, pd.RangeIndex)
result = csv.df_to_escaped_csv(
df, index=include_index, **config["CSV_EXPORT"]
)
return result or ""
return df.to_dict(orient="records")

@pull-request-size pull-request-size bot added size/L and removed size/M labels Apr 17, 2021
@duynguyenhoang duynguyenhoang force-pushed the fix/improve-csv-button-explore branch 2 times, most recently from 5347655 to bbb4767 Compare May 2, 2021 07:39
@duynguyenhoang
Copy link
Contributor Author

@villebro PR is ready, please review it again.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM - stellar PR with both frontend and backend tests! 🚀 Big thanks!

@villebro villebro merged commit 9a22fb0 into apache:master May 4, 2021
@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2021

Ephemeral environment shutdown and build artifacts deleted.

cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 12, 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 !deprecated-label:viz:explore:others Deprecated label - Use explore instead size/L 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[explore] CSV Export permission is not consistent between Dashboard and Explore window
4 participants