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 label items not throw errors
  • Loading branch information
marcinbot committed Sep 12, 2017
commit 3ff1b9e892b46bcdba55a30c2f0ab7495e52ae9c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import notices from 'notices';
import GlobalNotices from 'components/global-notices';
import Notice from 'components/notice';
import { isLoaded, getShippingLabel } from 'woocommerce/woocommerce-services/state/shipping-label/selectors';
import { getSelectedSiteId } from 'state/ui/selectors';

class ShippingLabelRootView extends Component {
componentWillMount() {
Expand Down Expand Up @@ -97,6 +98,8 @@ class ShippingLabelRootView extends Component {
return (
<LabelItem
key={ label.label_id }
siteId={ this.props.siteId }
orderId={ this.props.orderId }
label={ label }
labelNum={ labelsToRender.length - index }
/>
Expand Down Expand Up @@ -138,6 +141,7 @@ const mapStateToProps = ( state, { orderId } ) => {
const loaded = isLoaded( state, orderId );
const shippingLabel = getShippingLabel( state, orderId );
return {
siteId: getSelectedSiteId( state ),
loaded,
needToFetchLabelStatus: loaded && ! shippingLabel.refreshedLabelStatus,
numPaymentMethods: loaded && shippingLabel.numPaymentMethods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { openRefundDialog, openReprintDialog } from 'woocommerce/woocommerce-ser

class LabelItem extends Component {
renderRefundLink = ( label ) => {
const { siteId, orderId } = this.props;

const today = new Date();
const thirtyDaysAgo = new Date().setDate( today.getDate() - 30 );
if ( ( label.used_date && label.used_date < today.getTime() ) || ( label.created_date && label.created_date < thirtyDaysAgo ) ) {
Expand All @@ -29,12 +31,12 @@ class LabelItem extends Component {

const openDialog = ( e ) => {
e.preventDefault();
this.props.openRefundDialog( label.label_id );
this.props.openRefundDialog( siteId, orderId, label.label_id );
};

return (
<span>
<RefundDialog { ...label } />
<RefundDialog siteId={ siteId } orderId={ orderId } { ...label } />
<a href="#" onClick={ openDialog } >
<Gridicon icon="refund" size={ 12 } />{ __( 'Request refund' ) }
</a>
Expand Down Expand Up @@ -84,14 +86,16 @@ class LabelItem extends Component {
return null;
}

const { siteId, orderId } = this.props;

const openDialog = ( e ) => {
e.preventDefault();
this.props.openReprintDialog( label.label_id );
this.props.openReprintDialog( siteId, orderId, label.label_id );
};

return (
<span>
<ReprintDialog { ...label } />
<ReprintDialog siteId={ siteId } orderId={ orderId } { ...label } />
<a href="#" onClick={ openDialog } >
<Gridicon icon="print" size={ 12 } />{ __( 'Reprint' ) }
</a>
Expand Down Expand Up @@ -147,6 +151,8 @@ class LabelItem extends Component {
}

LabelItem.propTypes = {
siteId: PropTypes.number.isRequired,
orderId: PropTypes.number.isRequired,
label: PropTypes.object.isRequired,
openRefundDialog: PropTypes.func.isRequired,
openReprintDialog: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ import ActionButtons from 'woocommerce/woocommerce-services/components/action-bu
import formatDate from 'woocommerce/woocommerce-services/lib/utils/format-date';
import FormSectionHeading from 'components/forms/form-section-heading';
import { closeRefundDialog, confirmRefund } from '../../state/actions';
import { isLoaded, getShippingLabel } from 'woocommerce/woocommerce-services/state/shipping-label/selectors';

const RefundDialog = ( props ) => {
const { refundDialog, storeOptions, created, refundable_amount, label_id } = props;
const { siteId, orderId, refundDialog, storeOptions, created, refundable_amount, label_id } = props;

const getRefundableAmount = () => {
return storeOptions.currency_symbol + Number( refundable_amount ).toFixed( 2 );
};

const onClose = () => props.closeRefundDialog( siteId, orderId );
const onConfirm = () => props.confirmRefund( siteId, orderId );
return (
<Dialog
additionalClassNames="label-refund-modal woocommerce"
isVisible={ Boolean( refundDialog && refundDialog.labelId === label_id ) }
onClose={ props.closeRefundDialog }>
onClose={ onClose }>
<FormSectionHeading>
{ __( 'Request a refund' ) }
</FormSectionHeading>
Expand All @@ -45,13 +48,13 @@ const RefundDialog = ( props ) => {
</dl>
<ActionButtons buttons={ [
{
onClick: props.confirmRefund,
onClick: onConfirm,
isPrimary: true,
isDisabled: refundDialog && refundDialog.isSubmitting,
label: __( 'Refund label (-%(amount)s)', { args: { amount: getRefundableAmount() } } ),
},
{
onClick: props.closeRefundDialog,
onClick: onClose,
label: __( 'Cancel' ),
},
] } />
Expand All @@ -60,6 +63,8 @@ const RefundDialog = ( props ) => {
};

RefundDialog.propTypes = {
siteId: PropTypes.number.isRequired,
orderId: PropTypes.number.isRequired,
refundDialog: PropTypes.object,
storeOptions: PropTypes.object.isRequired,
created: PropTypes.number,
Expand All @@ -69,9 +74,9 @@ RefundDialog.propTypes = {
confirmRefund: PropTypes.func.isRequired,
};

const mapStateToProps = ( state ) => {
const shippingLabel = state.shippingLabel;
const loaded = shippingLabel.loaded;
const mapStateToProps = ( state, { siteId, orderId } ) => {
const loaded = isLoaded( state, orderId, siteId );
const shippingLabel = getShippingLabel( state, orderId, siteId );
return {
refundDialog: loaded ? shippingLabel.refundDialog : {},
storeOptions: loaded ? shippingLabel.storeOptions : {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Dropdown from 'woocommerce/woocommerce-services/components/dropdown';
import { getPaperSizes } from 'woocommerce/woocommerce-services/lib/pdf-label-utils';
import FormSectionHeading from 'components/forms/form-section-heading';
import { closeReprintDialog, confirmReprint, updatePaperSize } from '../../state/actions';
import { isLoaded, getShippingLabel } from 'woocommerce/woocommerce-services/state/shipping-label/selectors';

const ReprintDialog = ( props ) => {
const { reprintDialog, paperSize, storeOptions, label_id } = props;
Expand Down Expand Up @@ -58,6 +59,8 @@ const ReprintDialog = ( props ) => {
};

ReprintDialog.propTypes = {
siteId: PropTypes.number.isRequired,
orderId: PropTypes.number.isRequired,
reprintDialog: PropTypes.object,
paperSize: PropTypes.string.isRequired,
storeOptions: PropTypes.object.isRequired,
Expand All @@ -66,9 +69,9 @@ ReprintDialog.propTypes = {
updatePaperSize: PropTypes.func.isRequired,
};

const mapStateToProps = ( state ) => {
const shippingLabel = state.shippingLabel;
const loaded = shippingLabel.loaded;
const mapStateToProps = ( state, { siteId, orderId } ) => {
const loaded = isLoaded( state, orderId, siteId );
const shippingLabel = getShippingLabel( state, orderId, siteId );
return {
reprintDialog: loaded ? shippingLabel.reprintDialog : {},
paperSize: shippingLabel.paperSize,
Expand Down