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

WooCommerce Labels - fix the build errors #17755

Merged
merged 25 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1bf2f52
Fixed the PropTypes imports
marcinbot Sep 4, 2017
37dcdad
Conditionally rendering the labels UI in order details
marcinbot Sep 4, 2017
99ca2ee
Fixed some of the imports
marcinbot Sep 4, 2017
c20028a
Copied over ActionButtons component
marcinbot Sep 4, 2017
54b78af
Fixed ActionButtons imports
marcinbot Sep 4, 2017
d285ef3
Fixed /lib imports
marcinbot Sep 4, 2017
5249636
Fixed build errors for missing components
marcinbot Sep 4, 2017
35bb77c
Fixed the rest of the imports and copied over missing components
marcinbot Sep 4, 2017
668abaa
Tweaked the main label view and purchase label to work
marcinbot Sep 4, 2017
6666a63
Merged the selectors files, removed reselect usages
marcinbot Sep 5, 2017
a4bf052
Minor fix
marcinbot Sep 5, 2017
6320dd9
Added siteId and orderId to all action definitions
marcinbot Sep 5, 2017
a1345ba
Made the modal render
marcinbot Sep 9, 2017
c1a8067
Address normalization fix
marcinbot Sep 11, 2017
9b57481
Made the packages step work
marcinbot Sep 11, 2017
1b5a5ae
Tweaked the rates step
marcinbot Sep 12, 2017
3ff1b9e
Made the label items not throw errors
marcinbot Sep 12, 2017
4d05f4c
Added CSS import for the label
marcinbot Sep 12, 2017
7614977
Fixed print url and cross-browser warnings
marcinbot Sep 13, 2017
289230d
Style fixes
marcinbot Sep 21, 2017
dc45256
Fixed the spinners
marcinbot Sep 21, 2017
86fc753
Replaced formatDate with moment's format method
marcinbot Sep 21, 2017
9642811
Fixed a typo in CSS class selector
marcinbot Sep 21, 2017
8863bca
Made the refund and reprint dialogs render
marcinbot Sep 21, 2017
88aff8b
Changed the order of orderId, siteId arguments in actions to match se…
marcinbot Sep 22, 2017
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
Prev Previous commit
Next Next commit
Made the packages step work
  • Loading branch information
marcinbot committed Sep 11, 2017
commit 9b574818df41017971f8fe5ea5a21b50ba058634
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ import ActionButtons from 'woocommerce/woocommerce-services/components/action-bu
import getPackageDescriptions from './get-package-descriptions';
import FormSectionHeading from 'components/forms/form-section-heading';
import { closeAddItem, setAddedItem, addItems } from 'woocommerce/woocommerce-services/state/shipping-label/actions';
import { getShippingLabel } from 'woocommerce/woocommerce-services/state/shipping-label/selectors';

const AddItemDialog = ( props ) => {
const {
siteId,
orderId,
showAddItemDialog,
addedItems,
openedPackageId,
Expand All @@ -42,7 +45,7 @@ const AddItemDialog = ( props ) => {
? __( '%(item)s from {{pckg/}}', { args: { item: item.name }, components: { pckg: getPackageNameElement( pckgId ) } } )
: item;

const onChange = ( event ) => props.setAddedItem( pckgId, itemIdx, event.target.checked );
const onChange = ( event ) => props.setAddedItem( siteId, orderId, pckgId, itemIdx, event.target.checked );
return (
<FormLabel
key={ `${ pckgId }-${ itemIdx }` }
Expand All @@ -67,11 +70,13 @@ const AddItemDialog = ( props ) => {
} );
} );

const onClose = () => props.closeAddItem( siteId, orderId );

return (
<Dialog isVisible={ showAddItemDialog }
isFullScreen={ false }
onClickOutside={ props.closeAddItem }
onClose={ props.closeAddItem }
onClickOutside={ onClose }
onClose={ onClose }
additionalClassNames="wcc-root packages-step__dialog" >
<FormSectionHeading>{ __( 'Add item' ) }</FormSectionHeading>
<div className="packages-step__dialog-body">
Expand All @@ -89,9 +94,9 @@ const AddItemDialog = ( props ) => {
label: __( 'Add' ),
isPrimary: true,
isDisabled: ! _.some( addedItems, _.size ),
onClick: () => props.addItems( openedPackageId ),
onClick: () => props.addItems( siteId, orderId, openedPackageId ),
},
{ label: __( 'Close' ), onClick: props.closeAddItem },
{ label: __( 'Close' ), onClick: onClose },
] } />
</Dialog>
);
Expand All @@ -110,13 +115,14 @@ AddItemDialog.propTypes = {
addItems: PropTypes.func.isRequired,
};

const mapStateToProps = ( state ) => {
const mapStateToProps = ( state, { siteId, orderId } ) => {
const shippingLabel = getShippingLabel( state, orderId, siteId );
return {
showAddItemDialog: state.shippingLabel.showAddItemDialog || false,
addedItems: state.shippingLabel.addedItems,
openedPackageId: state.shippingLabel.openedPackageId,
selected: state.shippingLabel.form.packages.selected,
all: state.shippingLabel.form.packages.all,
showAddItemDialog: shippingLabel.showAddItemDialog || false,
addedItems: shippingLabel.addedItems,
openedPackageId: shippingLabel.openedPackageId,
selected: shippingLabel.form.packages.selected,
all: shippingLabel.form.packages.all,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { translate as __ } from 'i18n-calypso';
* Internal dependencies
*/
import Button from 'components/button';
import { openItemMove, removeItem } from 'woocommerce/woocommerce-services/state/shipping-label/actions';
import { openItemMove } from 'woocommerce/woocommerce-services/state/shipping-label/actions';

const ItemInfo = ( props ) => {
const { item, itemIndex } = props;
const onMoveClick = () => props.openItemMove( itemIndex );
const { siteId, orderId, item, itemIndex } = props;
const onMoveClick = () => props.openItemMove( siteId, orderId, itemIndex );

const renderMoveToPackage = () => {
return (
Expand Down Expand Up @@ -54,7 +54,6 @@ ItemInfo.propTypes = {
const mapDispatchToProps = ( dispatch ) => {
return bindActionCreators( {
openItemMove,
removeItem,
}, dispatch );
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ import classNames from 'classnames';
* Internal dependencies
*/
import getPackageDescriptions from './get-package-descriptions';
import { getFormErrors } from 'woocommerce/woocommerce-services/state/shipping-label/selectors';
import { openPackage } from 'woocommerce/woocommerce-services/state/shipping-label/actions';
import {
getShippingLabel,
isLoaded,
getFormErrors,
} from 'woocommerce/woocommerce-services/state/shipping-label/selectors';

const PackageList = ( props ) => {
const { selected, all, errors, packageId } = props;
const { siteId, orderId, selected, all, errors, packageId } = props;

const renderCountOrError = ( isError, count ) => {
if ( isError ) {
Expand All @@ -34,7 +38,7 @@ const PackageList = ( props ) => {

const renderPackageListItem = ( pckgId, name, count ) => {
const isError = 0 < Object.keys( errors[ pckgId ] || {} ).length;
const onOpenClick = () => props.openPackage( pckgId );
const onOpenClick = () => props.openPackage( siteId, orderId, pckgId );
return (
<div className="packages-step__list-item" key={ pckgId }>
<div
Expand Down Expand Up @@ -87,15 +91,15 @@ PackageList.propTypes = {
openPackage: PropTypes.func.isRequired,
};

const mapStateToProps = ( state ) => {
const loaded = state.shippingLabel.loaded;
const storeOptions = loaded ? state.shippingLabel.storeOptions : {};
const errors = loaded && getFormErrors( state, storeOptions ).packages;
const mapStateToProps = ( state, { orderId, siteId } ) => {
const loaded = isLoaded( state, orderId, siteId );
const shippingLabel = getShippingLabel( state, orderId, siteId );
const errors = loaded && getFormErrors( state, orderId, siteId ).packages;
return {
errors,
packageId: state.shippingLabel.openedPackageId,
selected: state.shippingLabel.form.packages.selected,
all: state.shippingLabel.form.packages.all,
packageId: shippingLabel.openedPackageId,
selected: shippingLabel.form.packages.selected,
all: shippingLabel.form.packages.all,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ import ActionButtons from 'woocommerce/woocommerce-services/components/action-bu
import getPackageDescriptions from './get-package-descriptions';
import FormSectionHeading from 'components/forms/form-section-heading';
import { closeItemMove, setTargetPackage, moveItem } from 'woocommerce/woocommerce-services/state/shipping-label/actions';
import { getShippingLabel } from 'woocommerce/woocommerce-services/state/shipping-label/selectors';

const MoveItemDialog = ( props ) => {
const {
siteId,
orderId,
showItemMoveDialog,
movedItemIndex,
targetPackageId,
Expand All @@ -33,7 +36,7 @@ const MoveItemDialog = ( props ) => {
}

const renderRadioButton = ( pckgId, label ) => {
const onChange = () => props.setTargetPackage( pckgId );
const onChange = () => props.setTargetPackage( siteId, orderId, pckgId );
return (
<FormLabel
key={ pckgId }
Expand Down Expand Up @@ -94,11 +97,13 @@ const MoveItemDialog = ( props ) => {
);
}

const onClose = () => props.closeItemMove( siteId, orderId );

return (
<Dialog isVisible={ showItemMoveDialog }
isFullScreen={ false }
onClickOutside={ props.closeItemMove }
onClose={ props.closeItemMove }
onClickOutside={ onClose }
onClose={ onClose }
additionalClassNames="wcc-root packages-step__dialog" >
<FormSectionHeading>{ __( 'Move item' ) }</FormSectionHeading>
<div className="packages-step__dialog-body">
Expand All @@ -113,9 +118,9 @@ const MoveItemDialog = ( props ) => {
label: __( 'Move' ),
isPrimary: true,
isDisabled: targetPackageId === openedPackageId, // Result of targetPackageId initialization
onClick: () => props.moveItem( openedPackageId, movedItemIndex, targetPackageId ),
onClick: () => props.moveItem( siteId, orderId, openedPackageId, movedItemIndex, targetPackageId ),
},
{ label: __( 'Cancel' ), onClick: props.closeItemMove },
{ label: __( 'Cancel' ), onClick: onClose },
] } />
</Dialog>
);
Expand All @@ -133,14 +138,15 @@ MoveItemDialog.propTypes = {
moveItem: PropTypes.func.isRequired,
};

const mapStateToProps = ( state ) => {
const mapStateToProps = ( state, { orderId, siteId } ) => {
const shippingLabel = getShippingLabel( state, orderId, siteId );
return {
showItemMoveDialog: state.shippingLabel.showItemMoveDialog || false,
movedItemIndex: isNaN( state.shippingLabel.movedItemIndex ) ? -1 : state.shippingLabel.movedItemIndex,
targetPackageId: state.shippingLabel.targetPackageId,
openedPackageId: state.shippingLabel.openedPackageId,
selected: state.shippingLabel.form.packages.selected,
all: state.shippingLabel.form.packages.all,
showItemMoveDialog: shippingLabel.showItemMoveDialog || false,
movedItemIndex: isNaN( shippingLabel.movedItemIndex ) ? -1 : shippingLabel.movedItemIndex,
targetPackageId: shippingLabel.targetPackageId,
openedPackageId: shippingLabel.openedPackageId,
selected: shippingLabel.form.packages.selected,
all: shippingLabel.form.packages.all,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ import FormLegend from 'components/forms/form-legend';
import FormSelect from 'components/forms/form-select';
import Button from 'components/button';
import getBoxDimensions from 'woocommerce/woocommerce-services/lib/utils/get-box-dimensions';
import { getFormErrors } from 'woocommerce/woocommerce-services/state/shipping-label/selectors';
import {
updatePackageWeight,
removePackage,
setPackageType,
openAddItem,
} from 'woocommerce/woocommerce-services/state/shipping-label/actions';
import {
getShippingLabel,
isLoaded,
getFormErrors,
} from 'woocommerce/woocommerce-services/state/shipping-label/selectors';

const renderPackageDimensions = ( dimensions, dimensionUnit ) => {
return [
Expand All @@ -37,6 +40,8 @@ const renderPackageDimensions = ( dimensions, dimensionUnit ) => {

const PackageInfo = ( props ) => {
const {
siteId,
orderId,
packageId,
selected,
all,
Expand All @@ -56,12 +61,15 @@ const PackageInfo = ( props ) => {

const renderItemInfo = ( item, itemIndex ) => {
return (
<ItemInfo key={ itemIndex }
item={ item }
itemIndex={ itemIndex }
packageId={ packageId }
showRemove
isIndividualPackage={ isIndividualPackage } />
<ItemInfo
siteId={ siteId }
orderId={ orderId }
key={ itemIndex }
item={ item }
itemIndex={ itemIndex }
packageId={ packageId }
showRemove
isIndividualPackage={ isIndividualPackage } />
);
};

Expand All @@ -70,16 +78,17 @@ const PackageInfo = ( props ) => {
return ( <option value={ boxId } key={ boxId }>{ box.name } - { renderPackageDimensions( dimensions, dimensionUnit ) }</option> );
};

const onAddItem = () => props.openAddItem( siteId, orderId );
const renderAddItemButton = () => {
if ( isIndividualPackage ) {
return null;
}

return ( <Button className="packages-step__add-item-btn" compact onClick={ props.openAddItem }>{ __( 'Add items' ) }</Button> );
return ( <Button className="packages-step__add-item-btn" compact onClick={ onAddItem }>{ __( 'Add items' ) }</Button> );
};

const packageOptionChange = ( e ) => {
props.setPackageType( packageId, e.target.value );
props.setPackageType( siteId, orderId, packageId, e.target.value );
};

const renderItems = () => {
Expand Down Expand Up @@ -150,7 +159,7 @@ const PackageInfo = ( props ) => {
);
};

const onWeightChange = ( value ) => props.updatePackageWeight( packageId, value );
const onWeightChange = ( value ) => props.updatePackageWeight( siteId, orderId, packageId, value );

return (
<div className="packages-step__package">
Expand Down Expand Up @@ -192,16 +201,17 @@ PackageInfo.propTypes = {
openAddItem: PropTypes.func.isRequired,
};

const mapStateToProps = ( state ) => {
const loaded = state.shippingLabel.loaded;
const storeOptions = loaded ? state.shippingLabel.storeOptions : {};
const errors = loaded && getFormErrors( state, storeOptions ).packages;
const mapStateToProps = ( state, { orderId, siteId } ) => {
const loaded = isLoaded( state, orderId, siteId );
const shippingLabel = getShippingLabel( state, orderId, siteId );
const storeOptions = loaded ? shippingLabel.storeOptions : {};
const errors = loaded && getFormErrors( state, orderId, siteId ).packages;
return {
errors,
packageId: state.shippingLabel.openedPackageId,
selected: state.shippingLabel.form.packages.selected,
all: state.shippingLabel.form.packages.all,
flatRateGroups: state.shippingLabel.form.packages.flatRateGroups,
packageId: shippingLabel.openedPackageId,
selected: shippingLabel.form.packages.selected,
all: shippingLabel.form.packages.all,
flatRateGroups: shippingLabel.form.packages.flatRateGroups,
dimensionUnit: storeOptions.dimension_unit,
weightUnit: storeOptions.weight_unit,
};
Expand All @@ -210,7 +220,6 @@ const mapStateToProps = ( state ) => {
const mapDispatchToProps = ( dispatch ) => {
return bindActionCreators( {
updatePackageWeight,
removePackage,
setPackageType,
openAddItem,
}, dispatch );
Expand Down