mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix: Alpha should not be able to edit datasets that they don't own (#19854)
* fix api for checking owners * fix styles for disabling * fix styles for disabling * fix lint * fix lint * add owners key * plzz * remove * update test * add tooltip * add type * fix test * fix user reference * lit * fix test * work
This commit is contained in:
@@ -35,6 +35,7 @@ import Button from 'src/components/Button';
|
||||
import ErrorAlert from 'src/components/ErrorMessage/ErrorAlert';
|
||||
import WarningIconWithTooltip from 'src/components/WarningIconWithTooltip';
|
||||
import { URL_PARAMS } from 'src/constants';
|
||||
import { isUserAdmin } from 'src/dashboard/util/findPermission';
|
||||
|
||||
const propTypes = {
|
||||
actions: PropTypes.object.isRequired,
|
||||
@@ -196,12 +197,32 @@ class DatasourceControl extends React.PureComponent {
|
||||
}
|
||||
|
||||
const isSqlSupported = datasource.type === 'table';
|
||||
const { user } = this.props;
|
||||
const allowEdit =
|
||||
datasource.owners.map(o => o.id).includes(user.userId) ||
|
||||
isUserAdmin(user);
|
||||
|
||||
const editText = t('Edit dataset');
|
||||
|
||||
const datasourceMenu = (
|
||||
<Menu onClick={this.handleMenuItemClick}>
|
||||
{this.props.isEditable && (
|
||||
<Menu.Item key={EDIT_DATASET} data-test="edit-dataset">
|
||||
{t('Edit dataset')}
|
||||
<Menu.Item
|
||||
key={EDIT_DATASET}
|
||||
data-test="edit-dataset"
|
||||
disabled={!allowEdit}
|
||||
>
|
||||
{!allowEdit ? (
|
||||
<Tooltip
|
||||
title={t(
|
||||
'You must be a dataset owner in order to edit. Please reach out to a dataset owner to request modifications or edit access.',
|
||||
)}
|
||||
>
|
||||
{editText}
|
||||
</Tooltip>
|
||||
) : (
|
||||
editText
|
||||
)}
|
||||
</Menu.Item>
|
||||
)}
|
||||
<Menu.Item key={CHANGE_DATASET}>{t('Change dataset')}</Menu.Item>
|
||||
|
||||
Reference in New Issue
Block a user