Skip to content

Commit

Permalink
Add possibility to disable buttons inside group block
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Mar 23, 2021
1 parent 5b83746 commit fc21b15
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
5 changes: 3 additions & 2 deletions src/components/manage/Blocks/Group/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dissatisfiedSVG from '@plone/volto/icons/dissatisfied.svg';
import PropTypes from 'prop-types';
import { Button } from 'semantic-ui-react';
import EditBlockWrapper from './EditBlockWrapper';
import tuneSVG from '@plone/volto/icons/configuration.svg';
import tuneSVG from '@plone/volto/icons/show-blocks.svg';
import helpSVG from '@plone/volto/icons/help.svg';

import './editor.less';
Expand Down Expand Up @@ -140,6 +140,7 @@ const Edit = (props) => {
<EditBlockWrapper
draginfo={draginfo}
blockProps={blockProps}
disabled={data.disableInnerButtons}
extraControls={
<>
{!data?.readOnlySettings && (
Expand All @@ -148,7 +149,7 @@ const Edit = (props) => {
<Button
icon
basic
title="Group settings"
title="Section (Group) settings"
onClick={() => {
setSelectedBlock();
props.setSidebarTab(1);
Expand Down
16 changes: 12 additions & 4 deletions src/components/manage/Blocks/Group/EditBlockWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ class EditBlockWrapper extends React.Component {
blockNode = React.createRef();

render() {
const { intl, blockProps, draginfo, extraControls, children } = this.props;
const {
intl,
blockProps,
draginfo,
extraControls,
disabled,
children,
} = this.props;

const {
allowedBlocks,
Expand All @@ -70,7 +77,8 @@ class EditBlockWrapper extends React.Component {
} = blockProps;
const type = data['@type'];
const { disableNewBlocks } = data;
const visible = !data.fixed;
const dragVisible = !data.fixed;
const visible = selected && !disabled;

const required = isBoolean(data.required)
? data.required
Expand All @@ -92,11 +100,11 @@ class EditBlockWrapper extends React.Component {
{...draginfo.dragHandleProps}
></div>
)}
{selected && (
{visible && (
<div className="block-toolbar">
<div
style={{
display: visible ? 'inline-block' : 'none',
display: dragVisible ? 'inline-block' : 'none',
}}
{...draginfo.dragHandleProps}
className="drag handle wrapper-group-block"
Expand Down
14 changes: 13 additions & 1 deletion src/components/manage/Blocks/Group/Schema.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const Schema = {
title: 'Group block settings',
title: 'Section (Group) settings',
fieldsets: [
{
id: 'default',
title: 'Default',
fields: [
'id',
'placeholder',
'instructions',
'allowedBlocks',
Expand All @@ -14,10 +15,16 @@ const Schema = {
'fixed',
'disableNewBlocks',
'readOnly',
'disableInnerButtons',
],
},
],
properties: {
id: {
title: 'Name',
description: 'Section friendly name',
type: 'string',
},
allowedBlocks: {
title: 'Allowed blocks',
description: 'Allow only the following blocks types',
Expand Down Expand Up @@ -78,6 +85,11 @@ const Schema = {
description: 'Disable editing on this block',
type: 'boolean',
},
disableInnerButtons: {
title: 'Disable inner buttons',
description: 'Hide all block related buttons within this block',
type: 'boolean',
},
},
required: [],
};
Expand Down
37 changes: 8 additions & 29 deletions src/components/manage/Blocks/Group/editor.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
.block-editor-group {
margin: 0 -2.2rem;

.block-editor-group {
margin: 0 0.1rem;
// .block-editor-group {
// margin: 0 0.1rem;
// }

[data-rbd-draggable-context-id] {
margin-bottom: 1rem;
}

.selected {
Expand Down Expand Up @@ -52,38 +56,13 @@
border-bottom: 1px solid #fff;
margin-top: -45px;
background-color: #fff;
border-top-left-radius: 1rem;
border-top-right-radius: 1rem;

.ui.basic.button {
padding: 3px;
padding-right: 0;
}

.wrapper-column-block {
> .ui.basic.button {
&:hover {
background-color: transparent !important;
}
}
}

> .ui.basic.button {
&:hover {
background-color: transparent !important;
}

svg {
color: #134448;
}
}

.drag.handle.wrapper-column-block {
position: initial;
left: initial;
min-height: 1em;
margin-left: initial !important;
font-size: 1rem;
line-height: 1em;
vertical-align: baseline;
}
}
}

0 comments on commit fc21b15

Please sign in to comment.