Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
fix label
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed May 9, 2023
1 parent 83cbd76 commit 954335b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions assets/js/blocks/classic-template/archive-product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const getDescriptionAllowingConversion = ( templateTitle: string ) =>
sprintf(
/* translators: %s is the template title */
__(
"This block serves as a placeholder for your %s. We recommend upgrading to the Products block for more features to edit your products visually. Don't worry, you can always revert back.",
'Transform this template into multiple blocks so you can add, remove, reorder, and customize your %s template.',
'woo-gutenberg-products-block'
),
templateTitle
Expand All @@ -96,7 +96,7 @@ const getDescription = ( templateTitle: string, canConvert: boolean ) => {
};

const getButtonLabel = () =>
__( 'Upgrade to Products block', 'woo-gutenberg-products-block' );
__( 'Transform into blocks', 'woo-gutenberg-products-block' );

const onClickCallback = ( {
clientId,
Expand Down
16 changes: 14 additions & 2 deletions assets/js/blocks/classic-template/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import {
BlockInstance,
createBlock,
getBlockType,
registerBlockType,
Expand All @@ -23,6 +24,7 @@ import { box, Icon } from '@wordpress/icons';
import { useDispatch, subscribe, useSelect, select } from '@wordpress/data';
import { useEffect, useMemo, useState } from '@wordpress/element';
import { store as noticesStore } from '@wordpress/notices';
import { useEntityRecord } from '@wordpress/core-data';

/**
* Internal dependencies
Expand Down Expand Up @@ -81,12 +83,21 @@ const Edit = ( {
const { replaceBlock, selectBlock, replaceBlocks } =
useDispatch( blockEditorStore );

const { blocks } = useSelect( ( sel ) => {
const { blocks, editedPostId } = useSelect( ( sel ) => {
return {
blocks: sel( blockEditorStore ).getBlocks(),
editedPostId: sel( 'core/edit-site' ).getEditedPostId(),
};
}, [] );

const template = useEntityRecord< {
slug: string;
title: {
rendered?: string;
row: string;
};
} >( 'postType', 'wp_template', editedPostId );

const { createInfoNotice } = useDispatch( noticesStore );

const clientIds = useMemo( () => pickBlockClientIds( blocks ), [ blocks ] );
Expand All @@ -96,7 +107,8 @@ const Edit = ( {
attributes.template,
TEMPLATES
);
const templateTitle = templateDetails?.title ?? attributes.template;
const templateTitle =
template.record?.title.rendered?.toLowerCase() ?? attributes.template;
const templatePlaceholder = templateDetails?.placeholder ?? 'fallback';
const templateType = templateDetails?.type ?? 'fallback';

Expand Down
4 changes: 2 additions & 2 deletions assets/js/blocks/classic-template/product-search-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const getDescriptionAllowingConversion = ( templateTitle: string ) =>
sprintf(
/* translators: %s is the template title */
__(
"This block serves as a placeholder for your %s. We recommend upgrading to the Products block for more features to edit your products visually. Don't worry, you can always revert back.",
'Transform this template into multiple blocks so you can add, remove, reorder, and customize your %s template.',
'woo-gutenberg-products-block'
),
templateTitle
Expand Down Expand Up @@ -166,7 +166,7 @@ const onClickCallback = ( {
};

const getButtonLabel = () =>
__( 'Upgrade to Products block', 'woo-gutenberg-products-block' );
__( 'Transform into blocks', 'woo-gutenberg-products-block' );

export {
getBlockifiedTemplate,
Expand Down
14 changes: 9 additions & 5 deletions assets/js/blocks/classic-template/single-product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ const isConversionPossible = () => {
return isWpVersion( '6.1', '>=' );
};

const getDescriptionAllowingConversion = () =>
__(
'Transform this template into multiple blocks so you can add, remove, reorder, and customize your single product template.',
'woo-gutenberg-products-block'
const getDescriptionAllowingConversion = ( templateTitle: string ) =>
sprintf(
/* translators: %s is the template title */
__(
'Transform this template into multiple blocks so you can add, remove, reorder, and customize your %s.',
'woo-gutenberg-products-block'
),
templateTitle
);

const getDescriptionDisallowingConversion = ( templateTitle: string ) =>
Expand All @@ -77,7 +81,7 @@ const getDescriptionDisallowingConversion = ( templateTitle: string ) =>

const getDescription = ( templateTitle: string, canConvert: boolean ) => {
if ( canConvert ) {
return getDescriptionAllowingConversion();
return getDescriptionAllowingConversion( templateTitle );
}

return getDescriptionDisallowingConversion( templateTitle );
Expand Down

0 comments on commit 954335b

Please sign in to comment.