Skip to content

Commit

Permalink
FIX Allowing ElementActions transformers access to the area ID
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ committed Dec 1, 2018
1 parent c318eb9 commit 67b55d2
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/src/components/ElementEditor/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class Element extends Component {
const {
element,
type,
areaId,
HeaderComponent,
ContentComponent,
link,
Expand Down Expand Up @@ -215,6 +216,7 @@ class Element extends Component {
<HeaderComponent
element={element}
type={type}
areaId={areaId}
expandable={type.inlineEditable}
link={link}
previewExpanded={previewExpanded}
Expand Down Expand Up @@ -283,6 +285,7 @@ function mapDispatchToProps(dispatch, ownProps) {
Element.propTypes = {
element: elementType,
type: elementTypeType.isRequired,
areaId: PropTypes.number.isRequired,
link: PropTypes.string.isRequired,
// Redux mapped props:
activeTab: PropTypes.string,
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/ElementEditor/ElementActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ class ElementActions extends Component {
}
}

// There's some extra prop types in here for registered transformations to consume
ElementActions.propTypes = {
// eslint-disable-next-line react/no-unused-prop-types
element: elementType,
// eslint-disable-next-line react/no-unused-prop-types
areaId: PropTypes.number.isRequired,
activeTab: PropTypes.string,
editTabs: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions client/src/components/ElementEditor/ElementList.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ElementList extends Component {
<div key={element.ID}>
<ElementComponent
element={element}
areaId={areaId}
type={getElementTypeConfig(element.BlockSchema.typeName, elementTypes)}
link={element.BlockSchema.actions.edit}
onDragOver={onDragOver}
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/ElementEditor/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Header extends Component {
const {
element,
type,
areaId,
previewExpanded,
simple,
disableTooltip,
Expand Down Expand Up @@ -148,6 +149,7 @@ class Header extends Component {
>
<ElementActionsComponent
element={element}
areaId={areaId}
activeTab={activeTab}
editTabs={type.editTabs}
handleEditTabsClick={handleEditTabsClick}
Expand All @@ -163,6 +165,7 @@ class Header extends Component {

Header.propTypes = {
element: elementType.isRequired,
areaId: PropTypes.number.isRequired,
type: elementTypeType.isRequired,
activeTab: PropTypes.string,
simple: PropTypes.bool,
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/ElementEditor/tests/Element-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('Element', () => {
const wrapper = shallow(
<Element
element={element}
areaId={1}
type={type}
link={'admin/pages/edit/EditForm/7/field/ElementalArea/item/2/edit?stage=Stage'}
{...defaultProps}
Expand All @@ -66,6 +67,7 @@ describe('Element', () => {
...element,
ID: ''
}}
areaId={1}
type={type}
link={'admin/pages/edit/EditForm/7/field/ElementalArea/item/2/edit?stage=Stage'}
{...defaultProps}
Expand All @@ -86,6 +88,7 @@ describe('Element', () => {
...element,
IsPublished: false,
}}
areaId={1}
type={type}
link="/"
{...defaultProps}
Expand All @@ -103,6 +106,7 @@ describe('Element', () => {
IsPublished: true,
IsLiveVersion: false,
}}
areaId={1}
type={type}
link="/"
{...defaultProps}
Expand All @@ -120,6 +124,7 @@ describe('Element', () => {
IsPublished: true,
IsLiveVersion: true,
}}
areaId={1}
type={type}
link="/"
{...defaultProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('ElementActions', () => {
it('should map input tabs into an array of buttons', () => {
const wrapper = shallow(
<ElementActions
areaId={1}
editTabs={testTabs}
ActionMenuComponent={ActionMenuComponent}
/>
Expand All @@ -38,6 +39,7 @@ describe('ElementActions', () => {
it('should render the given "edit tabs" in the action menu', () => {
const wrapper = shallow(
<ElementActions
areaId={1}
editTabs={testTabs}
ActionMenuComponent={ActionMenuComponent}
/>
Expand All @@ -55,6 +57,7 @@ describe('ElementActions', () => {
it('should render a divider when CMS tab actions and default actions are rendered', () => {
const wrapper = shallow(
<ElementActions
areaId={1}
editTabs={testTabs}
ActionMenuComponent={ActionMenuComponent}
>
Expand Down
11 changes: 11 additions & 0 deletions client/src/components/ElementEditor/tests/Header-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
ElementActionsComponent={ElementActionsComponent}
/>
Expand All @@ -45,6 +46,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
ElementActionsComponent={ElementActionsComponent}
/>
Expand All @@ -58,6 +60,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
ElementActionsComponent={ElementActionsComponent}
/>
Expand All @@ -72,6 +75,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
expandable={false}
ElementActionsComponent={ElementActionsComponent}
Expand All @@ -87,6 +91,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
expandable
previewExpanded={false}
Expand All @@ -103,6 +108,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
expandable
previewExpanded
Expand All @@ -119,6 +125,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
expandable
ElementActionsComponent={ElementActionsComponent}
Expand All @@ -132,6 +139,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
expandable={false}
ElementActionsComponent={ElementActionsComponent}
Expand All @@ -149,6 +157,7 @@ describe('Header', () => {
const wrapper = shallow(
<Header
element={element}
areaId={1}
type={type}
ElementActionsComponent={ElementActionsComponent}
/>
Expand All @@ -164,6 +173,7 @@ describe('Header', () => {
element.IsLiveVersion = false;
const wrapper = shallow(
<Header
areaId={1}
type={type}
ElementActionsComponent={ElementActionsComponent}
element={element}
Expand All @@ -180,6 +190,7 @@ describe('Header', () => {
element.IsLiveVersion = true;
const wrapper = shallow(
<Header
areaId={1}
type={type}
ElementActionsComponent={ElementActionsComponent}
element={element}
Expand Down

0 comments on commit 67b55d2

Please sign in to comment.