mirror of
https://github.com/apache/superset.git
synced 2026-04-28 04:25:07 +00:00
Add an "Edit Mode" to Dashboard view (#3940)
* Add a togglable edit mode to dashboard * Submenu for controls * Allowing 'Save as' outside of editMode * Set editMode to false as default
This commit is contained in:
committed by
Grace Guo
parent
6cbe0e6096
commit
d9fda346cb
@@ -8,10 +8,12 @@ const propTypes = {
|
||||
canEdit: PropTypes.bool,
|
||||
onSaveTitle: PropTypes.func,
|
||||
noPermitTooltip: PropTypes.string,
|
||||
showTooltip: PropTypes.bool,
|
||||
};
|
||||
const defaultProps = {
|
||||
title: t('Title'),
|
||||
canEdit: false,
|
||||
showTooltip: true,
|
||||
};
|
||||
|
||||
class EditableTitle extends React.PureComponent {
|
||||
@@ -85,24 +87,30 @@ class EditableTitle extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<span className="editable-title">
|
||||
let input = (
|
||||
<input
|
||||
required
|
||||
type={this.state.isEditing ? 'text' : 'button'}
|
||||
value={this.state.title}
|
||||
onChange={this.handleChange}
|
||||
onBlur={this.handleBlur}
|
||||
onClick={this.handleClick}
|
||||
onKeyPress={this.handleKeyPress}
|
||||
/>
|
||||
);
|
||||
if (this.props.showTooltip) {
|
||||
input = (
|
||||
<TooltipWrapper
|
||||
label="title"
|
||||
tooltip={this.props.canEdit ? t('click to edit title') :
|
||||
this.props.noPermitTooltip || t('You don\'t have the rights to alter this title.')}
|
||||
>
|
||||
<input
|
||||
required
|
||||
type={this.state.isEditing ? 'text' : 'button'}
|
||||
value={this.state.title}
|
||||
onChange={this.handleChange}
|
||||
onBlur={this.handleBlur}
|
||||
onClick={this.handleClick}
|
||||
onKeyPress={this.handleKeyPress}
|
||||
/>
|
||||
{input}
|
||||
</TooltipWrapper>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span className="editable-title">{input}</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal } from 'react-bootstrap';
|
||||
import { Modal, MenuItem } from 'react-bootstrap';
|
||||
import cx from 'classnames';
|
||||
|
||||
import Button from './Button';
|
||||
|
||||
const propTypes = {
|
||||
@@ -13,6 +14,7 @@ const propTypes = {
|
||||
beforeOpen: PropTypes.func,
|
||||
onExit: PropTypes.func,
|
||||
isButton: PropTypes.bool,
|
||||
isMenuItem: PropTypes.bool,
|
||||
bsSize: PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
tooltip: PropTypes.string,
|
||||
@@ -23,6 +25,7 @@ const defaultProps = {
|
||||
beforeOpen: () => {},
|
||||
onExit: () => {},
|
||||
isButton: false,
|
||||
isMenuItem: false,
|
||||
bsSize: null,
|
||||
className: '',
|
||||
};
|
||||
@@ -86,6 +89,13 @@ export default class ModalTrigger extends React.Component {
|
||||
{this.renderModal()}
|
||||
</Button>
|
||||
);
|
||||
} else if (this.props.isMenuItem) {
|
||||
return (
|
||||
<MenuItem onClick={this.open}>
|
||||
{this.props.triggerNode}
|
||||
{this.renderModal()}
|
||||
</MenuItem>
|
||||
);
|
||||
}
|
||||
/* eslint-disable jsx-a11y/interactive-supports-focus */
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user