mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
Hide restricted ui elements, remove <br> from error message (#4900)
* hide forbidden ui elements, remove <br> from message * add comma for flake8 * add commma for flake8 * change js variables from snake to camel case
This commit is contained in:
parent
976e43e681
commit
e2d5c33638
@ -143,20 +143,22 @@ class Controls extends React.PureComponent {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<SaveModal
|
{dashboard.dash_save_perm &&
|
||||||
dashboard={dashboard}
|
<SaveModal
|
||||||
filters={filters}
|
dashboard={dashboard}
|
||||||
serialize={serialize}
|
filters={filters}
|
||||||
onSave={onSave}
|
serialize={serialize}
|
||||||
css={this.state.css}
|
onSave={onSave}
|
||||||
triggerNode={
|
css={this.state.css}
|
||||||
<MenuItemContent
|
triggerNode={
|
||||||
text={saveText}
|
<MenuItemContent
|
||||||
tooltip={t('Save the dashboard')}
|
text={saveText}
|
||||||
faIcon="save"
|
tooltip={t('Save the dashboard')}
|
||||||
/>
|
faIcon="save"
|
||||||
}
|
/>
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
{editMode &&
|
{editMode &&
|
||||||
<ActionMenuItem
|
<ActionMenuItem
|
||||||
text={t('Edit properties')}
|
text={t('Edit properties')}
|
||||||
|
@ -69,7 +69,7 @@ class SaveModal extends React.PureComponent {
|
|||||||
error(error) {
|
error(error) {
|
||||||
saveModal.close();
|
saveModal.close();
|
||||||
const errorMsg = getAjaxErrorMsg(error);
|
const errorMsg = getAjaxErrorMsg(error);
|
||||||
notify.error(t('Sorry, there was an error saving this dashboard: ') + '</ br>' + errorMsg);
|
notify.error(t('Sorry, there was an error saving this dashboard: ') + errorMsg);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { t } from '../../locales';
|
import { t } from '../../locales';
|
||||||
import EditableTitle from '../../components/EditableTitle';
|
import EditableTitle from '../../components/EditableTitle';
|
||||||
@ -8,6 +9,8 @@ import TooltipWrapper from '../../components/TooltipWrapper';
|
|||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
slice: PropTypes.object.isRequired,
|
slice: PropTypes.object.isRequired,
|
||||||
|
supersetCanExplore: PropTypes.bool,
|
||||||
|
sliceCanEdit: PropTypes.bool,
|
||||||
isExpanded: PropTypes.bool,
|
isExpanded: PropTypes.bool,
|
||||||
isCached: PropTypes.bool,
|
isCached: PropTypes.bool,
|
||||||
cachedDttm: PropTypes.string,
|
cachedDttm: PropTypes.string,
|
||||||
@ -72,6 +75,7 @@ class SliceHeader extends React.PureComponent {
|
|||||||
title={slice.slice_name}
|
title={slice.slice_name}
|
||||||
canEdit={!!this.props.updateSliceName && this.props.editMode}
|
canEdit={!!this.props.updateSliceName && this.props.editMode}
|
||||||
onSaveTitle={this.onSaveTitle}
|
onSaveTitle={this.onSaveTitle}
|
||||||
|
showTooltip={this.props.editMode}
|
||||||
noPermitTooltip={'You don\'t have the rights to alter this dashboard.'}
|
noPermitTooltip={'You don\'t have the rights to alter this dashboard.'}
|
||||||
/>
|
/>
|
||||||
{!!Object.values(this.props.annotationQuery || {}).length &&
|
{!!Object.values(this.props.annotationQuery || {}).length &&
|
||||||
@ -126,15 +130,17 @@ class SliceHeader extends React.PureComponent {
|
|||||||
</TooltipWrapper>
|
</TooltipWrapper>
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
<a href={slice.edit_url} target="_blank">
|
{this.props.sliceCanEdit &&
|
||||||
<TooltipWrapper
|
<a href={slice.edit_url} target="_blank">
|
||||||
placement="top"
|
<TooltipWrapper
|
||||||
label="edit"
|
placement="top"
|
||||||
tooltip={t('Edit chart')}
|
label="edit"
|
||||||
>
|
tooltip={t('Edit chart')}
|
||||||
<i className="fa fa-pencil" />
|
>
|
||||||
</TooltipWrapper>
|
<i className="fa fa-pencil" />
|
||||||
</a>
|
</TooltipWrapper>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
<a className="exportCSV" onClick={this.exportCSV}>
|
<a className="exportCSV" onClick={this.exportCSV}>
|
||||||
<TooltipWrapper
|
<TooltipWrapper
|
||||||
placement="top"
|
placement="top"
|
||||||
@ -144,15 +150,17 @@ class SliceHeader extends React.PureComponent {
|
|||||||
<i className="fa fa-table" />
|
<i className="fa fa-table" />
|
||||||
</TooltipWrapper>
|
</TooltipWrapper>
|
||||||
</a>
|
</a>
|
||||||
<a className="exploreChart" onClick={this.exploreChart}>
|
{this.props.supersetCanExplore &&
|
||||||
<TooltipWrapper
|
<a className="exploreChart" onClick={this.exploreChart}>
|
||||||
placement="top"
|
<TooltipWrapper
|
||||||
label="exploreChart"
|
placement="top"
|
||||||
tooltip={t('Explore chart')}
|
label="exploreChart"
|
||||||
>
|
tooltip={t('Explore chart')}
|
||||||
<i className="fa fa-share" />
|
>
|
||||||
</TooltipWrapper>
|
<i className="fa fa-share" />
|
||||||
</a>
|
</TooltipWrapper>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
{this.props.editMode &&
|
{this.props.editMode &&
|
||||||
<a className="remove-chart" onClick={this.removeSlice}>
|
<a className="remove-chart" onClick={this.removeSlice}>
|
||||||
<TooltipWrapper
|
<TooltipWrapper
|
||||||
@ -175,4 +183,12 @@ class SliceHeader extends React.PureComponent {
|
|||||||
SliceHeader.propTypes = propTypes;
|
SliceHeader.propTypes = propTypes;
|
||||||
SliceHeader.defaultProps = defaultProps;
|
SliceHeader.defaultProps = defaultProps;
|
||||||
|
|
||||||
export default SliceHeader;
|
function mapStateToProps({ dashboard }) {
|
||||||
|
return {
|
||||||
|
supersetCanExplore: dashboard.dashboard.superset_can_explore,
|
||||||
|
sliceCanEdit: dashboard.dashboard.slice_can_edit,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export { SliceHeader };
|
||||||
|
export default connect(mapStateToProps, () => ({}))(SliceHeader);
|
||||||
|
@ -2046,6 +2046,8 @@ class Superset(BaseSupersetView):
|
|||||||
dash_edit_perm = check_ownership(dash, raise_if_false=False)
|
dash_edit_perm = check_ownership(dash, raise_if_false=False)
|
||||||
dash_save_perm = \
|
dash_save_perm = \
|
||||||
dash_edit_perm and security_manager.can_access('can_save_dash', 'Superset')
|
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'
|
standalone_mode = request.args.get('standalone') == 'true'
|
||||||
|
|
||||||
@ -2054,6 +2056,8 @@ class Superset(BaseSupersetView):
|
|||||||
'standalone_mode': standalone_mode,
|
'standalone_mode': standalone_mode,
|
||||||
'dash_save_perm': dash_save_perm,
|
'dash_save_perm': dash_save_perm,
|
||||||
'dash_edit_perm': dash_edit_perm,
|
'dash_edit_perm': dash_edit_perm,
|
||||||
|
'superset_can_explore': superset_can_explore,
|
||||||
|
'slice_can_edit': slice_can_edit,
|
||||||
})
|
})
|
||||||
|
|
||||||
bootstrap_data = {
|
bootstrap_data = {
|
||||||
|
Loading…
Reference in New Issue
Block a user