| |
@@ -2,7 +2,7 @@
|
| |
import PropTypes from 'prop-types';
|
| |
import { connect } from 'react-redux';
|
| |
import { SortableHandle } from 'react-sortable-hoc';
|
| |
- import { openConfigDialog } from "../core/actions/widget";
|
| |
+ import { openConfigDialog, deleteWidget } from "../core/actions/widget";
|
| |
import "./WidgetChrome.css";
|
| |
|
| |
|
| |
@@ -24,6 +24,7 @@
|
| |
constructor(props) {
|
| |
super(props);
|
| |
this.handleEditButtonClicked = this.handleEditButtonClicked.bind(this)
|
| |
+ this.handleWidgetDeleted = this.handleWidgetDeleted.bind(this);
|
| |
}
|
| |
|
| |
handleEditButtonClicked(e) {
|
| |
@@ -31,6 +32,11 @@
|
| |
this.props.onEdit(this.props.widget.idx);
|
| |
}
|
| |
|
| |
+ handleWidgetDeleted(e) {
|
| |
+ e.preventDefault();
|
| |
+ this.props.onDelete(this.props.widget.idx);
|
| |
+ }
|
| |
+
|
| |
render() {
|
| |
// Make sure there's always a title in edit mode
|
| |
const title = (this.props.editMode && !this.props.widget.title) ? this.props.widget.label : this.props.widget.title;
|
| |
@@ -45,11 +51,19 @@
|
| |
<DragHandle />
|
| |
{title}
|
| |
<a href="#"
|
| |
+ className="float-right text-danger pl-2"
|
| |
+ onClick={this.handleWidgetDeleted}
|
| |
+ >
|
| |
+ <i className="fa fa-trash" aria-hidden="true" title="Delete this widget"></i>
|
| |
+ </a>
|
| |
+ { this.props.widget.params.length > 0 &&
|
| |
+ <a href="#"
|
| |
className="float-right text-dark"
|
| |
onClick={this.handleEditButtonClicked}
|
| |
>
|
| |
<i className="fa fa-cog" aria-hidden="true"></i>
|
| |
</a>
|
| |
+ }
|
| |
</div>
|
| |
);
|
| |
} else if (title) {
|
| |
@@ -86,7 +100,9 @@
|
| |
};
|
| |
const mapDispatchToProps = dispatch => {
|
| |
return {
|
| |
- onEdit: (widgetId) => { dispatch(openConfigDialog(widgetId)); }
|
| |
+ onEdit: (widgetId) => { dispatch(openConfigDialog(widgetId)); },
|
| |
+ onDelete: (widgetId) => { dispatch(deleteWidget(widgetId)); }
|
| |
+
|
| |
}
|
| |
}
|
| |
|
| |
In the edit mode, if a widget does not have config options, the
cog icon is not displayed anymore. As the ability to delete a widget
was previously in the config dialog, this is now moved to the widget
titlebar itself.
Signed-off-by: Ryan Lerch rlerch@redhat.com