/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from 'wordpress-element';
import {
Notice,
ToggleControl,
ToolbarGroup,
RangeControl,
SelectControl,
} from '@wordpress/components';
import { BlockControls } from '@wordpress/block-editor';
import { getAdminLink } from '@woocommerce/settings';
import {
REVIEW_RATINGS_ENABLED,
SHOW_AVATARS,
} from '@woocommerce/block-settings';
import ToggleButtonControl from '@woocommerce/editor-components/toggle-button-control';
export const getBlockControls = ( editMode, setAttributes ) => (
setAttributes( { editMode: ! editMode } ),
isActive: editMode,
},
] }
/>
);
export const getSharedReviewContentControls = ( attributes, setAttributes ) => {
return (
<>
setAttributes( {
showReviewRating: ! attributes.showReviewRating,
} )
}
/>
{ attributes.showReviewRating && ! REVIEW_RATINGS_ENABLED && (
{ createInterpolateElement(
__(
'Product rating is disabled in your store settings.',
'woo-gutenberg-products-block'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
),
}
) }
) }
setAttributes( {
showReviewerName: ! attributes.showReviewerName,
} )
}
/>
setAttributes( {
showReviewImage: ! attributes.showReviewImage,
} )
}
/>
setAttributes( {
showReviewDate: ! attributes.showReviewDate,
} )
}
/>
setAttributes( {
showReviewContent: ! attributes.showReviewContent,
} )
}
/>
{ attributes.showReviewImage && (
<>
setAttributes( { imageType: value } )
}
/>
{ attributes.imageType === 'reviewer' && ! SHOW_AVATARS && (
{ createInterpolateElement(
__(
'Reviewer photo is disabled in your site settings.',
'woo-gutenberg-products-block'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
),
}
) }
) }
>
) }
>
);
};
export const getSharedReviewListControls = ( attributes, setAttributes ) => {
const minPerPage = 1;
const maxPerPage = 20;
return (
<>
setAttributes( { showOrderby: ! attributes.showOrderby } )
}
/>
setAttributes( { orderby } ) }
/>
setAttributes( { reviewsOnPageLoad } )
}
max={ maxPerPage }
min={ minPerPage }
/>
setAttributes( { showLoadMore: ! attributes.showLoadMore } )
}
/>
{ attributes.showLoadMore && (
setAttributes( { reviewsOnLoadMore } )
}
max={ maxPerPage }
min={ minPerPage }
/>
) }
>
);
};