Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add action dropdown. Move delete button. #345

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 34 additions & 13 deletions client/src/components/ElementEditor/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { compose } from 'redux';
import { inject } from 'lib/Injector';
import deleteBlockMutation from 'state/editor/deleteBlockMutation';
import i18n from 'i18n';
import classNames from 'classnames';

class Header extends Component {
constructor(props) {
Expand Down Expand Up @@ -45,7 +46,17 @@ class Header extends Component {
}

render() {
const { id, title, elementType, fontIcon, FormActionComponent } = this.props;
const {
id,
title,
elementType,
fontIcon,
ActionMenuComponent,
} = this.props;

const deleteTitle = i18n._t('ElementHeader.DELETE', 'Delete');

const deleteButtonClassNames = classNames('dropdown-item', 'element-editor__actions-delete');

return (
<div className="element-editor-header">
Expand All @@ -63,14 +74,23 @@ class Header extends Component {
</div>
<h3 className="element-editor-header__title">{title}</h3>
</div>
<FormActionComponent
onClick={this.handleDelete}
title={null}
icon="trash-bin"
attributes={{
title: i18n._t('ElementHeader.DELETE', 'Delete'),
}}
/>
<div className="element-editor-header__actions">
<ActionMenuComponent
id={`element-editor-actions-${id}`}
className="element-editor-header__actions-dropdown"
dropdownMenuProps={{ right: true }}
toggleCallback={(event) => event.stopPropagation()}
>
<button
onClick={this.handleDelete}
title={deleteTitle}
type="button"
className={deleteButtonClassNames}
>
{deleteTitle}
</button>
</ActionMenuComponent>
</div>
</div>
);
}
Expand All @@ -84,16 +104,17 @@ Header.propTypes = {
actions: PropTypes.shape({
handleDeleteBlock: PropTypes.func.isRequired,
}),
FormActionComponent: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
ActionMenuComponent: React.PropTypes.oneOfType([React.PropTypes.node, React.PropTypes.func]),

};

export { Header as Component };

export default compose(
inject(
['FormAction'],
(FormActionComponent) => ({
FormActionComponent,
['ActionMenu'],
(ActionMenuComponent) => ({
ActionMenuComponent,
}),
() => 'ElementEditor.ElementList.Element'
),
Expand Down
7 changes: 6 additions & 1 deletion client/src/components/ElementEditor/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
-webkit-font-smoothing: antialiased;
}

&__info {
&__info,
&__actions {
align-items: center;
display: flex;
flex-grow: 1;
}

&__actions {
justify-content: flex-end;
}

&__icon-container {
color: $gray-600;
font-size: 2.3rem;
Expand Down
10 changes: 1 addition & 9 deletions tests/Behat/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ public function iClickOnBlock($position)
$block->click();
}

/**
* @When I click on the delete button for block :position
*/
public function iClickOnTheDeleteButtonForBlock($position)
{
$this->getDeleteButton($position)->click();
}

/**
* @Then I should see :text as the title for block :position
*/
Expand Down Expand Up @@ -142,7 +134,7 @@ protected function getDeleteButton($position)
$block = $this->getSpecificBlock($position);
assertNotNull($block, 'Block ' . $position . ' was not found in the page.');

$button = $block->find('css', '.font-icon-trash-bin');
$button = $block->find('css', '.element-editor__actions-delete');
assertNotNull($button, 'Delete button not found');

return $button;
Expand Down
5 changes: 3 additions & 2 deletions tests/Behat/features/element-editor.feature
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ Feature: View types of elements in a report
And I wait 1 second
And I should see "Second Sample Block"
And I should see block 1
And I should see the delete button for block 1
And I click on the delete button for block 1
And I press the "View actions" button
Then I should see the delete button for block 1
When I press the "Delete" button
And I see the text "Are you sure you want to delete this block?" in the alert
And I confirm the dialog
And I wait until I see the ".element-editor__element" element
Expand Down