Skip to content
This repository has been archived by the owner on Dec 22, 2020. It is now read-only.

Add event ticket block #307

Merged
merged 4 commits into from
Sep 11, 2018
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: 2 additions & 0 deletions plugins/tickets/src/modules/blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import { registerBlockType } from '@wordpress/blocks';
*/
import { initStore } from '@moderntribe/tickets/data';
import tickets from '@moderntribe/tickets/blocks/tickets';
import ticket from '@moderntribe/tickets/blocks/ticket';

const blocks = [
tickets,
ticket,
];

blocks.forEach( ( block ) => registerBlockType( `tribe/${ block.id }`, block ) );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Single ticket block declaration Block declaration 1`] = `
Object {
"attributes": Object {},
"category": "tribe-tickets",
"description": "Entry for ticket",
"edit": [Function],
"icon": [Function],
"id": "event-tickets-ticket",
"keywords": Array [
"event",
"events-tickets",
"tribe",
],
"parent": Array [
"tribe/event-tickets",
],
"save": [Function],
"supports": Object {
"html": false,
},
"title": "Event Ticket",
}
`;
10 changes: 10 additions & 0 deletions plugins/tickets/src/modules/blocks/ticket/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Internal dependencies
*/
import TicketBlock from '@moderntribe/tickets/blocks/ticket';

describe( 'Single ticket block declaration', () => {
test( 'Block declaration', () => {
expect( TicketBlock ).toMatchSnapshot();
} );
} );
29 changes: 29 additions & 0 deletions plugins/tickets/src/modules/blocks/ticket/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { BlockIcon } from '@moderntribe/common/elements';

export default {
id: 'event-tickets-ticket',
title: __( 'Event Ticket', 'events-gutenberg' ),
description: __( 'Entry for ticket', 'events-gutenberg' ),
icon: BlockIcon,
category: 'tribe-tickets',
keywords: [ 'event', 'events-tickets', 'tribe' ],

parent: [ 'tribe/event-tickets' ],

supports: {
html: false,
},

attributes: {},

edit: ( { clientId }) => <div>Ticket { clientId }</div>,
save: () => null,
};
1 change: 1 addition & 0 deletions plugins/tickets/src/modules/blocks/tickets/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const mapStateToProps = ( state, props ) => ( {
<ActionButton icon={ <UserIcon /> }>Attendees </ActionButton>,
<ActionButton icon={ <TagIcon /> }>Orders</ActionButton>,
],
allowedBlockTypes: [ 'tribe/event-tickets', 'tribe/event-tickets-ticket', 'core/image' ],
} );

export default compose(
Expand Down
9 changes: 9 additions & 0 deletions plugins/tickets/src/modules/blocks/tickets/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { InnerBlocks } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -31,6 +32,11 @@ const TicketsTemplate = ( props ) => {
total,
footerActions,
footerConfirmLabel,
// @todo limit the usage of the available blocks for this one, however at this point the
// appender button is only available on the paragraph block
// see https://github.com/WordPress/gutenberg/issues/8589 once is resolved we should be able
// to address this one and limit this to only this property
allowedBlockTypes,
} = props;

const availability = isSelected && (
Expand All @@ -52,6 +58,7 @@ const TicketsTemplate = ( props ) => {
) }
>
<div className="tribe-editor__tickets-body">
<InnerBlocks />
<DisabledTickets title={ disabled.title }>
{ disabled.description }
</DisabledTickets>
Expand All @@ -66,12 +73,14 @@ TicketsTemplate.propTypes = {
isSelected: PropTypes.bool,
footerActions: PropTypes.arrayOf( PropTypes.node ),
footerConfirmLabel: PropTypes.string,
allowedBlockTypes: PropTypes.arrayOf( PropTypes.string ),
}

TicketsTemplate.defaultProps = {
isSelected: false,
footerActions: [],
footerConfirmLabel: __( 'Add Tickets', 'events-gutenberg' ),
allowedBlockTypes: [],
}

export default TicketsTemplate;
5 changes: 1 addition & 4 deletions plugins/tickets/src/modules/blocks/tickets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import TicketsBlock from './Container';
export default {
id: 'event-tickets',
title: __( 'Event Tickets', 'events-gutenberg' ),
description: __(
'Basic ticket functionality',
'events-gutenberg',
),
description: __( 'Basic ticket functionality', 'events-gutenberg' ),
icon: BlockIcon,
category: 'tribe-tickets',
keywords: [ 'event', 'events-gutenberg', 'tribe' ],
Expand Down