From e2d5c3363859573d72cf3cb95d604bd56b8705de Mon Sep 17 00:00:00 2001
From: jasnovak <36554140+jasnovak@users.noreply.github.com>
Date: Thu, 3 May 2018 17:36:31 -0700
Subject: [PATCH] Hide restricted ui elements, remove
from error message
(#4900)
* hide forbidden ui elements, remove
from message
* add comma for flake8
* add commma for flake8
* change js variables from snake to camel case
---
.../src/dashboard/components/Controls.jsx | 30 ++++++-----
.../src/dashboard/components/SaveModal.jsx | 2 +-
.../src/dashboard/components/SliceHeader.jsx | 54 ++++++++++++-------
superset/views/core.py | 4 ++
4 files changed, 56 insertions(+), 34 deletions(-)
diff --git a/superset/assets/src/dashboard/components/Controls.jsx b/superset/assets/src/dashboard/components/Controls.jsx
index 00cb6d56dc..feacf961ba 100644
--- a/superset/assets/src/dashboard/components/Controls.jsx
+++ b/superset/assets/src/dashboard/components/Controls.jsx
@@ -143,20 +143,22 @@ class Controls extends React.PureComponent {
/>
}
/>
-
- }
- />
+ {dashboard.dash_save_perm &&
+
+ }
+ />
+ }
{editMode &&
' + errorMsg);
+ notify.error(t('Sorry, there was an error saving this dashboard: ') + errorMsg);
},
});
}
diff --git a/superset/assets/src/dashboard/components/SliceHeader.jsx b/superset/assets/src/dashboard/components/SliceHeader.jsx
index 8abcc86d61..6db9c683c9 100644
--- a/superset/assets/src/dashboard/components/SliceHeader.jsx
+++ b/superset/assets/src/dashboard/components/SliceHeader.jsx
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
+import { connect } from 'react-redux';
import { t } from '../../locales';
import EditableTitle from '../../components/EditableTitle';
@@ -8,6 +9,8 @@ import TooltipWrapper from '../../components/TooltipWrapper';
const propTypes = {
slice: PropTypes.object.isRequired,
+ supersetCanExplore: PropTypes.bool,
+ sliceCanEdit: PropTypes.bool,
isExpanded: PropTypes.bool,
isCached: PropTypes.bool,
cachedDttm: PropTypes.string,
@@ -72,6 +75,7 @@ class SliceHeader extends React.PureComponent {
title={slice.slice_name}
canEdit={!!this.props.updateSliceName && this.props.editMode}
onSaveTitle={this.onSaveTitle}
+ showTooltip={this.props.editMode}
noPermitTooltip={'You don\'t have the rights to alter this dashboard.'}
/>
{!!Object.values(this.props.annotationQuery || {}).length &&
@@ -126,15 +130,17 @@ class SliceHeader extends React.PureComponent {
}
-
-
-
-
-
+ {this.props.sliceCanEdit &&
+
+
+
+
+
+ }
-
-
-
-
-
+ {this.props.supersetCanExplore &&
+
+
+
+
+
+ }
{this.props.editMode &&
({}))(SliceHeader);
diff --git a/superset/views/core.py b/superset/views/core.py
index a79ff2b4da..0359cae739 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2046,6 +2046,8 @@ class Superset(BaseSupersetView):
dash_edit_perm = check_ownership(dash, raise_if_false=False)
dash_save_perm = \
dash_edit_perm and security_manager.can_access('can_save_dash', 'Superset')
+ superset_can_explore = security_manager.can_access('can_explore', 'Superset')
+ slice_can_edit = security_manager.can_access('can_edit', 'SliceModelView')
standalone_mode = request.args.get('standalone') == 'true'
@@ -2054,6 +2056,8 @@ class Superset(BaseSupersetView):
'standalone_mode': standalone_mode,
'dash_save_perm': dash_save_perm,
'dash_edit_perm': dash_edit_perm,
+ 'superset_can_explore': superset_can_explore,
+ 'slice_can_edit': slice_can_edit,
})
bootstrap_data = {