superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] branch master updated: User can turn off download - export csv from a dashboard (#6821)
Date Sat, 16 Mar 2019 17:33:55 GMT
This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 4a30094  User can turn off download - export csv from a dashboard (#6821)
4a30094 is described below

commit 4a3009406a568735cf7826ff53cff26bec797b14
Author: Enrique Macip <emacipbelmonte@gmail.com>
AuthorDate: Sat Mar 16 17:33:45 2019 +0000

    User can turn off download - export csv from a dashboard (#6821)
    
    * User can turn off download - export csv from a dashboard
    
    * Revert changes in the backendSync
    
    * Fix space error in the MenuItem Export CSV
---
 .../javascripts/dashboard/components/gridComponents/Chart_spec.jsx  | 1 +
 superset/assets/src/dashboard/components/SliceHeader.jsx            | 4 ++++
 superset/assets/src/dashboard/components/SliceHeaderControls.jsx    | 6 +++++-
 superset/assets/src/dashboard/components/gridComponents/Chart.jsx   | 3 +++
 superset/assets/src/dashboard/containers/Chart.jsx                  | 1 +
 superset/assets/src/dashboard/reducers/getInitialState.js           | 1 +
 superset/views/core.py                                              | 2 ++
 7 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/superset/assets/spec/javascripts/dashboard/components/gridComponents/Chart_spec.jsx
b/superset/assets/spec/javascripts/dashboard/components/gridComponents/Chart_spec.jsx
index 5e75edf..a96a44c 100644
--- a/superset/assets/spec/javascripts/dashboard/components/gridComponents/Chart_spec.jsx
+++ b/superset/assets/spec/javascripts/dashboard/components/gridComponents/Chart_spec.jsx
@@ -58,6 +58,7 @@ describe('Chart', () => {
     editMode: false,
     isExpanded: false,
     supersetCanExplore: false,
+    supersetCanCSV: false,
     sliceCanEdit: false,
   };
 
diff --git a/superset/assets/src/dashboard/components/SliceHeader.jsx b/superset/assets/src/dashboard/components/SliceHeader.jsx
index 9da155d..913a00d 100644
--- a/superset/assets/src/dashboard/components/SliceHeader.jsx
+++ b/superset/assets/src/dashboard/components/SliceHeader.jsx
@@ -41,6 +41,7 @@ const propTypes = {
   annotationError: PropTypes.object,
   sliceName: PropTypes.string,
   supersetCanExplore: PropTypes.bool,
+  supersetCanCSV: PropTypes.bool,
   sliceCanEdit: PropTypes.bool,
 };
 
@@ -61,6 +62,7 @@ const defaultProps = {
   isExpanded: false,
   sliceName: '',
   supersetCanExplore: false,
+  supersetCanCSV: false,
   sliceCanEdit: false,
 };
 
@@ -82,6 +84,7 @@ class SliceHeader extends React.PureComponent {
       innerRef,
       sliceName,
       supersetCanExplore,
+      supersetCanCSV,
       sliceCanEdit,
       editMode,
       updateSliceName,
@@ -133,6 +136,7 @@ class SliceHeader extends React.PureComponent {
               exploreChart={exploreChart}
               exportCSV={exportCSV}
               supersetCanExplore={supersetCanExplore}
+              supersetCanCSV={supersetCanCSV}
               sliceCanEdit={sliceCanEdit}
             />
           )}
diff --git a/superset/assets/src/dashboard/components/SliceHeaderControls.jsx b/superset/assets/src/dashboard/components/SliceHeaderControls.jsx
index c228702..18a9207 100644
--- a/superset/assets/src/dashboard/components/SliceHeaderControls.jsx
+++ b/superset/assets/src/dashboard/components/SliceHeaderControls.jsx
@@ -29,6 +29,7 @@ const propTypes = {
   cachedDttm: PropTypes.string,
   updatedDttm: PropTypes.number,
   supersetCanExplore: PropTypes.bool,
+  supersetCanCSV: PropTypes.bool,
   sliceCanEdit: PropTypes.bool,
   toggleExpandSlice: PropTypes.func,
   forceRefresh: PropTypes.func,
@@ -46,6 +47,7 @@ const defaultProps = {
   isCached: false,
   isExpanded: false,
   supersetCanExplore: false,
+  supersetCanCSV: false,
   sliceCanEdit: false,
 };
 
@@ -134,7 +136,9 @@ class SliceHeaderControls extends React.PureComponent {
             </MenuItem>
           )}
 
-          <MenuItem onClick={this.exportCSV}>{t('Export CSV')}</MenuItem>
+          {this.props.supersetCanCSV && (
+            <MenuItem onClick={this.exportCSV}>{t('Export CSV')}</MenuItem>
+          )}
 
           {this.props.supersetCanExplore && (
             <MenuItem onClick={this.exploreChart}>
diff --git a/superset/assets/src/dashboard/components/gridComponents/Chart.jsx b/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
index 1765525..d8b01d0 100644
--- a/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
+++ b/superset/assets/src/dashboard/components/gridComponents/Chart.jsx
@@ -53,6 +53,7 @@ const propTypes = {
   isExpanded: PropTypes.bool.isRequired,
   isCached: PropTypes.bool,
   supersetCanExplore: PropTypes.bool.isRequired,
+  supersetCanCSV: PropTypes.bool.isRequired,
   sliceCanEdit: PropTypes.bool.isRequired,
 };
 
@@ -195,6 +196,7 @@ class Chart extends React.Component {
       toggleExpandSlice,
       timeout,
       supersetCanExplore,
+      supersetCanCSV,
       sliceCanEdit,
     } = this.props;
 
@@ -229,6 +231,7 @@ class Chart extends React.Component {
           updateSliceName={updateSliceName}
           sliceName={sliceName}
           supersetCanExplore={supersetCanExplore}
+          supersetCanCSV={supersetCanCSV}
           sliceCanEdit={sliceCanEdit}
         />
 
diff --git a/superset/assets/src/dashboard/containers/Chart.jsx b/superset/assets/src/dashboard/containers/Chart.jsx
index ddec2ff..1e0e64c 100644
--- a/superset/assets/src/dashboard/containers/Chart.jsx
+++ b/superset/assets/src/dashboard/containers/Chart.jsx
@@ -63,6 +63,7 @@ function mapStateToProps(
     editMode: dashboardState.editMode,
     isExpanded: !!dashboardState.expandedSlices[id],
     supersetCanExplore: !!dashboardInfo.superset_can_explore,
+    supersetCanCSV: !!dashboardInfo.superset_can_csv,
     sliceCanEdit: !!dashboardInfo.slice_can_edit,
   };
 }
diff --git a/superset/assets/src/dashboard/reducers/getInitialState.js b/superset/assets/src/dashboard/reducers/getInitialState.js
index 9b093cd..57354c8 100644
--- a/superset/assets/src/dashboard/reducers/getInitialState.js
+++ b/superset/assets/src/dashboard/reducers/getInitialState.js
@@ -174,6 +174,7 @@ export default function(bootstrapData) {
       dash_edit_perm: dashboard.dash_edit_perm,
       dash_save_perm: dashboard.dash_save_perm,
       superset_can_explore: dashboard.superset_can_explore,
+      superset_can_csv: dashboard.superset_can_csv,
       slice_can_edit: dashboard.slice_can_edit,
       common: {
         flash_messages: common.flash_messages,
diff --git a/superset/views/core.py b/superset/views/core.py
index 197dbe7..d3cfb88 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2175,6 +2175,7 @@ class Superset(BaseSupersetView):
             security_manager.can_access('can_save_dash', 'Superset')
         dash_save_perm = security_manager.can_access('can_save_dash', 'Superset')
         superset_can_explore = security_manager.can_access('can_explore', 'Superset')
+        superset_can_csv = security_manager.can_access('can_csv', 'Superset')
         slice_can_edit = security_manager.can_access('can_edit', 'SliceModelView')
 
         standalone_mode = request.args.get('standalone') == 'true'
@@ -2196,6 +2197,7 @@ class Superset(BaseSupersetView):
             'dash_save_perm': dash_save_perm,
             'dash_edit_perm': dash_edit_perm,
             'superset_can_explore': superset_can_explore,
+            'superset_can_csv': superset_can_csv,
             'slice_can_edit': slice_can_edit,
         })
 


Mime
View raw message