Mini Cart Block: add link to edit template part from sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/5201)
* Mini Cart Block: add link to edit template part from sidebar woocommerce/woocommerce-blocks#5186 Mini Cart Block: add link to edit template part from sidebar * fix e2e tests
This commit is contained in:
parent
a9fbc828c0
commit
67ad9e4f27
|
@ -11,10 +11,13 @@ import {
|
|||
import type { ReactElement } from 'react';
|
||||
import { formatPrice } from '@woocommerce/price-format';
|
||||
import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices';
|
||||
import { PanelBody, ExternalLink, ToggleControl } from '@wordpress/components';
|
||||
import { addQueryArgs } from '@wordpress/url';
|
||||
import { ADMIN_URL, getSetting } from '@woocommerce/settings';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { positionCenter, positionRight, positionLeft } from '@wordpress/icons';
|
||||
import { PanelBody, ToggleControl } from '@wordpress/components';
|
||||
import classnames from 'classnames';
|
||||
import { isString } from '@woocommerce/types';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -52,6 +55,10 @@ const MiniCartBlock = ( {
|
|||
} ),
|
||||
} );
|
||||
|
||||
const themeSlug = getSetting( 'themeSlug', '' );
|
||||
|
||||
const isSiteEditorAvailable = getSetting( 'isSiteEditorAvailable', false );
|
||||
|
||||
/**
|
||||
* @todo Replace `getColorClassName` and manual style manipulation with
|
||||
* `useColorProps` once the hook is no longer experimental.
|
||||
|
@ -131,6 +138,32 @@ const MiniCartBlock = ( {
|
|||
}
|
||||
/>
|
||||
</PanelBody>
|
||||
{ isSiteEditorAvailable &&
|
||||
isString( themeSlug ) &&
|
||||
themeSlug.length > 0 && (
|
||||
<PanelBody
|
||||
title={ __(
|
||||
'Template Editor',
|
||||
'woo-gutenberg-products-block'
|
||||
) }
|
||||
>
|
||||
<ExternalLink
|
||||
href={ addQueryArgs(
|
||||
`${ ADMIN_URL }themes.php`,
|
||||
{
|
||||
page: 'gutenberg-edit-site',
|
||||
postId: `${ themeSlug }//mini-cart`,
|
||||
postType: 'wp_template_part',
|
||||
}
|
||||
) }
|
||||
>
|
||||
{ __(
|
||||
'Edit template part',
|
||||
'woo-gutenberg-products-block'
|
||||
) }
|
||||
</ExternalLink>
|
||||
</PanelBody>
|
||||
) }
|
||||
</InspectorControls>
|
||||
<button
|
||||
className={ classnames(
|
||||
|
|
|
@ -123,6 +123,26 @@ class MiniCart extends AbstractBlock {
|
|||
true
|
||||
);
|
||||
|
||||
$this->asset_data_registry->add(
|
||||
'themeSlug',
|
||||
wp_get_theme()->get_stylesheet(),
|
||||
''
|
||||
);
|
||||
|
||||
if ( function_exists( 'gutenberg_experimental_is_site_editor_available' ) ) {
|
||||
$this->asset_data_registry->add(
|
||||
'isSiteEditorAvailable',
|
||||
gutenberg_experimental_is_site_editor_available(),
|
||||
false
|
||||
);
|
||||
} else {
|
||||
$this->asset_data_registry->add(
|
||||
'isSiteEditorAvailable',
|
||||
false,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires after cart block data is registered.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue