From 3d4b5e92e0b7cef61d251038dfaef4a6cc42885c Mon Sep 17 00:00:00 2001 From: Alex P Date: Mon, 18 Sep 2017 10:13:37 -0700 Subject: [PATCH] Require user confirmation to delete a cell --- ui/src/shared/components/ContextMenu.js | 21 ++++++++++++++++++--- ui/src/shared/components/NameableGraph.js | 10 +++++++++- ui/src/style/pages/dashboards.scss | 8 +++++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ui/src/shared/components/ContextMenu.js b/ui/src/shared/components/ContextMenu.js index c917485e5d..91d620e5ba 100644 --- a/ui/src/shared/components/ContextMenu.js +++ b/ui/src/shared/components/ContextMenu.js @@ -3,10 +3,19 @@ import classnames from 'classnames' import OnClickOutside from 'react-onclickoutside' const ContextMenu = OnClickOutside( - ({isOpen, toggleMenu, onEdit, onRename, onDelete, cell}) => + ({ + isOpen, + isDeleting, + toggleMenu, + onEdit, + onRename, + onDelete, + onDeleteClick, + cell, + }) =>
@@ -16,7 +25,11 @@ const ContextMenu = OnClickOutside(
) @@ -33,10 +46,12 @@ const {bool, func, shape} = PropTypes ContextMenuContainer.propTypes = { isOpen: bool, + isDeleting: bool, toggleMenu: func, onEdit: func, onRename: func, onDelete: func, + onDeleteClick: func, cell: shape(), isEditable: bool, } diff --git a/ui/src/shared/components/NameableGraph.js b/ui/src/shared/components/NameableGraph.js index 6908045942..bfc747bc7f 100644 --- a/ui/src/shared/components/NameableGraph.js +++ b/ui/src/shared/components/NameableGraph.js @@ -10,6 +10,7 @@ class NameableGraph extends Component { this.state = { isMenuOpen: false, cellName: props.cell.name, + isDeleting: false, } } @@ -33,9 +34,14 @@ class NameableGraph extends Component { closeMenu = () => { this.setState({ isMenuOpen: false, + isDeleting: false, }) } + handleDeleteClick = () => { + this.setState({isDeleting: true}) + } + handleDeleteCell = cell => () => { this.props.onDeleteCell(cell) } @@ -47,7 +53,7 @@ class NameableGraph extends Component { render() { const {cell, children, isEditable, onEditCell, onUpdateCell} = this.props - const {cellName, isMenuOpen} = this.state + const {cellName, isMenuOpen, isDeleting} = this.state const queries = _.get(cell, ['queries'], []) return ( @@ -62,9 +68,11 @@ class NameableGraph extends Component { /> {}} toggleMenu={this.toggleMenu} + isDeleting={isDeleting} isOpen={isMenuOpen} isEditable={isEditable} handleClickOutside={this.closeMenu} diff --git a/ui/src/style/pages/dashboards.scss b/ui/src/style/pages/dashboards.scss index 1fab0d3975..3ae18fbf35 100644 --- a/ui/src/style/pages/dashboards.scss +++ b/ui/src/style/pages/dashboards.scss @@ -215,7 +215,7 @@ input.form-control.dash-graph--name-edit { list-style: none; padding: 0; margin: 0; - width: 90px; + width: auto; visibility: hidden; transition-property: all; @@ -230,6 +230,7 @@ input.form-control.dash-graph--name-edit { margin: 0; text-align: left; color: $g15-platinum; + white-space: nowrap; opacity: 0; transition: opacity 0.25s ease, @@ -263,6 +264,11 @@ input.form-control.dash-graph--name-edit { } } } +.dash-graph--options-menu > li.dash-graph--confirm-delete { + color: $c-curacao; + + &:hover {color: $c-dreamsicle;} +} /* Menu Open State */ .dash-graph--options.dash-graph--options-show {