Skip to content

Commit 33da12c

Browse files
authored
Merge pull request #19 from rtCamp/chore/refactor-code
chore: template sharing, core refactor, and UI improvements
2 parents 2393df6 + d12b708 commit 33da12c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+8371
-2682
lines changed

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
},
1212
"globals": {
1313
"_": true,
14-
"patternSyncData": true
14+
"patternSyncData": true,
15+
"TemplateLibraryData": true,
16+
"OneDesignSettings": true
1517
},
1618
"rules": {
1719
"jsdoc/check-indentation": "error",

.github/workflows/release_on_tag.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ jobs:
3737
cp composer.json /tmp/onedesign/
3838
cp -r inc/ /tmp/onedesign/
3939
cp onedesign.php /tmp/onedesign/
40-
cp README.md /tmp/onedesign/
40+
cp readme.txt /tmp/onedesign/
4141
cp -r vendor/ /tmp/onedesign/
4242
cp uninstall.php /tmp/onedesign/
43+
cp -r languages/ /tmp/onedesign/
4344
4445
# Create the zip file
4546
cd /tmp

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
![Banner V3](https://rtcamp.com/wp-content/uploads/sites/2/2024/09/OneDesign-Banner.png)
1+
![Banner V3](./assets/images/banner.webp)
22

33
# OneDesign
4-
Contributors: [rtcamp](https://profiles.wordpress.org/rtcamp), [parthnvaswani](https://github.com/parthnvaswani), [up1512001](https://github.com/up1512001), [singhakanshu00](https://github.com/singhakanshu00), [danish17](https://github.com/danish17), [aviral-mittal](https://github.com/aviral-mittal), [vaishaliagola27](https://github.com/vaishaliagola27), [rishavjeet](https://github.com/rishavjeet), [vishal4669](https://github.com/vishal4669), [iamimmanuelraj](https://github.com/iamimmanuelraj)
4+
Contributors: [rtcamp](https://profiles.wordpress.org/rtcamp), [parthnvaswani](https://github.com/parthnvaswani), [up1512001](https://github.com/up1512001), [singhakanshu00](https://github.com/singhakanshu00), [danish17](https://github.com/danish17), [aviral-mittal](https://github.com/aviral-mittal), [vaishaliagola27](https://github.com/vaishaliagola27), [rishavjeet](https://github.com/rishavjeet), [vishal4669](https://github.com/vishal4669), [iamimmanuelraj](https://github.com/iamimmanuelraj) [vishalkakadiya](https://github.com/vishalkakadiya)
55

66
Tags: OnePress, Pattern distribution, Pattern sync, OneDesign, WordPress multisite, WordPress network, Gutenberg, WordPress Site Editor, Block Patterns, Pattern management, WordPress plugin, Design consistency, Pattern library
77

@@ -12,7 +12,7 @@ This plugin is licensed under the GPL v2 or later.
1212
This tool enables synchronization of block patterns across multiple sites in a WordPress multisite network.
1313

1414
## Description
15-
OneDesign allows you to define patterns on a Dashboard site and apply them to consumer sites, maintaining consistency across your network. The plugin provides an intuitive interface for browsing, searching, and applying patterns, making it easy to maintain design consistency across all your network sites.
15+
OneDesign allows you to define patterns on a Governing site and apply them to brand sites, maintaining consistency across your network. The plugin provides an intuitive interface for browsing, searching, and applying patterns, making it easy to maintain design consistency across all your network sites.
1616

1717
## Why OneDesign?
1818
Managing multiple websites—whether for different brands, regions, or languages shouldn’t mean reinventing the wheel each time. Instead of designing layouts from scratch for each site, OneDesign lets you create once and deploy anywhere, in just one click.
@@ -43,7 +43,7 @@ Built for enterprise teams, OneDesign unifies your design, editorial, and develo
4343

4444
- **Pattern Status Monitoring**: Track deployment success and synchronization across all connected sites
4545

46-
- **Multisite Pattern Sync**: Define patterns on the dashboard site and apply to multiple consumer sites
46+
- **Multisite Pattern Sync**: Define patterns on the governing site and apply to multiple brand sites
4747

4848
- **Pattern Management**: View and manage already applied patterns
4949

@@ -64,19 +64,19 @@ Built for enterprise teams, OneDesign unifies your design, editorial, and develo
6464

6565
## How It Works
6666

67-
### Setting Up Dashboard and Consumer Sites
67+
### Setting Up Governing and Brand Sites
6868
1. Install and activate the OneDesign plugin on all sites in your network
69-
2. From the OneDesign settings, designate one site as the “Dashboard Site” (source of patterns)
70-
3. Designate all other sites as “Consumer Sites” (where patterns will be applied)
71-
4. Copy the API keys generated for each Consumer Site from their respective settings pages
72-
5. In the Dashboard Site settings, register each Consumer Site by adding:
69+
2. From the OneDesign settings, designate one site as the “Governing Site” (source of patterns)
70+
3. Designate all other sites as “Brand Sites” (where patterns will be applied)
71+
4. Copy the API keys generated for each Brand Site from their respective settings pages
72+
5. In the Governing Site settings, register each Brand Site by adding:
7373
- Site name
7474
- URL
7575
- Logo
7676
- API key
7777

7878
### Accessing the Pattern Library
79-
1. On your Dashboard Site, access the Design Library from the sidebar menu
79+
1. On your Governing Site, access the Pattern Library from the sidebar menu
8080
2. This opens a full-page interface showing all available patterns
8181
3. Patterns are organized by categories with vertical tabs for your registered sites
8282

@@ -113,15 +113,15 @@ For development guidelines, please refer to our [Development Guide](./docs/DEVEL
113113
### How are patterns transferred between sites?
114114
Patterns are transferred securely via WordPress REST API, ensuring that all pattern data, including blocks and settings, are properly synchronized.
115115
### Can I customize which patterns are available to specific sites?
116-
Yes, you can control which patterns are applied to each consumer site by managing the selections in the Design Library.
116+
Yes, you can control which patterns are applied to each brand site by managing the selections in the Pattern Library.
117117
### Are there any limits to how many patterns I can sync?
118118
There are no hard limits on the number of patterns you can sync, but performance may vary depending on your server resources and the complexity of the patterns.
119119
### Can I also remove patterns from specific sites?
120120
Yes. You are able to do that from the dashboard itself.
121121

122122
### Troubleshooting
123123
1. **Patterns not showing up in the library**
124-
- Ensure your dashboard site is correctly set up
124+
- Ensure your governing site is correctly set up
125125
- Check network connectivity between sites
126126
- Verify REST API permissions
127127
2. **Search not working correctly**

assets/images/banner.webp

184 KB
Loading

assets/src/patterns-popover/components/app.js renamed to assets/src/admin/patterns/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { registerPlugin } from '@wordpress/plugins';
77
/**
88
* Internal dependencies
99
*/
10-
import LibraryModal from './LibraryModal';
10+
import PatternModal from './components/PatternModal';
1111

1212
/**
1313
* Registers the Pattern Sync Library plugin.
@@ -30,6 +30,6 @@ registerPlugin( 'onedesign-library', {
3030
const modalWrap = document.createElement( 'div' );
3131
const modal = Object.assign( modalWrap, { id: modalID, className } );
3232
document.body?.appendChild( modal );
33-
createRoot( modal ).render( <LibraryModal /> );
33+
createRoot( modal ).render( <PatternModal /> );
3434
},
3535
} );

assets/src/patterns-popover/components/AppliedPatternsTab.js renamed to assets/src/admin/patterns/components/AppliedPatternsTab.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,19 @@ import MemoizedPatternPreview from './MemoizedPatternPreview';
1313
/**
1414
* AppliedPatternsTab component displays a list of applied patterns with options to remove them.
1515
*
16-
* @param {Object} props - Component properties.
17-
* @param {boolean} props.isLoadingApplied - Indicates if applied patterns are loading.
18-
* @param {Array} props.appliedPatterns - List of applied patterns.
19-
* @param {number} props.visibleAppliedCount - Number of applied patterns currently visible.
20-
* @param {Array} props.selectedPatterns - List of selected patterns (not used in this component).
21-
* @param {boolean} props.hasMoreAppliedPatterns - Indicates if there are more applied patterns to load (not used in this component).
22-
* @param {Function} props.loadMoreAppliedPatterns - Function to load more applied patterns (not used in this component).
23-
* @param {Function} props.applySelectedPatterns - Function to apply selected patterns.
24-
* @param {Function} props.setVisibleAppliedCount - Function to set the number of visible applied patterns.
25-
* @param {Object} props.siteInfo - Information about the site (used for applying patterns).
16+
* @param {Object} props - Component properties.
17+
* @param {boolean} props.isLoadingApplied - Indicates if applied patterns are loading.
18+
* @param {Array} props.appliedPatterns - List of applied patterns.
19+
* @param {number} props.visibleAppliedCount - Number of applied patterns currently visible.
20+
* @param {Function} props.applySelectedPatterns - Function to apply selected patterns.
21+
* @param {Function} props.setVisibleAppliedCount - Function to set the number of visible applied patterns.
22+
* @param {Object} props.siteInfo - Information about the site (used for applying patterns).
2623
* @return {JSX.Element} Rendered component.
2724
*/
2825
const AppliedPatternsTab = memo( ( {
2926
isLoadingApplied,
3027
appliedPatterns,
3128
visibleAppliedCount,
32-
selectedPatterns, // eslint-disable-line no-unused-vars
33-
hasMoreAppliedPatterns, // eslint-disable-line no-unused-vars
34-
loadMoreAppliedPatterns, // eslint-disable-line no-unused-vars
3529
applySelectedPatterns,
3630
setVisibleAppliedCount,
3731
siteInfo,

assets/src/patterns-popover/components/BasePatternsTab.js renamed to assets/src/admin/patterns/components/BasePatternsTab.js

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { Button, Modal, Spinner, Notice } from '@wordpress/components';
99
* Internal dependencies
1010
*/
1111
import MemoizedPatternPreview from './MemoizedPatternPreview';
12-
import RenderConsumerSiteMeta from '../../plugins/consumer-site';
12+
import SiteSelection from './SiteSelection';
1313

1414
/**
15-
* BasePatternsTab component displays a list of base patterns with options to apply them to consumer sites
15+
* BasePatternsTab component displays a list of base patterns with options to apply them to brand sites
1616
*
1717
* @param {Object} props - Component properties.
1818
* @param {boolean} props.isLoading - Indicates if base patterns are loading.
@@ -24,7 +24,7 @@ import RenderConsumerSiteMeta from '../../plugins/consumer-site';
2424
* @param {Function} props.loadMorePatterns - Function to load more base patterns.
2525
* @param {Function} props.applySelectedPatterns - Function to apply selected patterns.
2626
* @param {Function} props.setSelectedPatterns - Function to set the selected patterns.
27-
* @param {Object} props.sitePatterns - Patterns from the consumer site.
27+
* @param {Object} props.sitePatterns - Patterns from the brand site.
2828
* @return {JSX.Element} Rendered component.
2929
*/
3030
const BasePatternsTab = memo(
@@ -66,7 +66,7 @@ const BasePatternsTab = memo(
6666
);
6767
}
6868

69-
const openConsumerSiteModal = () => {
69+
const OpenBrandSiteModal = () => {
7070
if ( selectedPatterns.length === 0 ) {
7171
setApplicationStatus( {
7272
type: 'warning',
@@ -82,7 +82,7 @@ const BasePatternsTab = memo(
8282
setIsModalOpen( true );
8383
};
8484

85-
const closeConsumerSiteModal = () => {
85+
const CloseBrandSiteModal = () => {
8686
// If we're in the middle of applying patterns, show confirmation first
8787
if ( isApplying && ! showCloseConfirmation ) {
8888
setShowCloseConfirmation( true );
@@ -104,10 +104,6 @@ const BasePatternsTab = memo(
104104

105105
const handleApplyPatterns = async () => {
106106
setIsApplying( true );
107-
setApplicationStatus( {
108-
type: 'info',
109-
message: __( 'Applying patterns to selected sites…', 'onedesign' ),
110-
} );
111107

112108
try {
113109
const result = await applySelectedPatterns();
@@ -121,8 +117,9 @@ const BasePatternsTab = memo(
121117

122118
// Close modal after success with slightly longer delay for better user feedback
123119
setTimeout( () => {
124-
closeConsumerSiteModal();
125-
}, 2000 );
120+
CloseBrandSiteModal();
121+
setSelectedPatterns( [] );
122+
}, 3000 );
126123
} else {
127124
setApplicationStatus( {
128125
type: 'error',
@@ -178,52 +175,29 @@ const BasePatternsTab = memo(
178175
}
179176
};
180177

181-
const consumerSiteSelection = () => {
178+
const BrandSiteSelection = () => {
182179
return (
183-
<div className="od-consumer-site-modal-content">
184-
<div className="od-site-selection-wrapper">
185-
<RenderConsumerSiteMeta
186-
setIsSiteSelected={ setIsSiteSelected }
187-
selectedPatterns={ selectedPatterns }
188-
basePatterns={ basePatterns }
189-
sitePatterns={ sitePatterns }
190-
/>
191-
</div>
180+
<div className="od-brand-site-modal-content">
192181

193182
{ applicationStatus && (
194183
<Notice
195-
status={ applicationStatus.type }
196-
isDismissible={ false }
184+
status={ applicationStatus?.type ?? 'info' }
185+
isDismissible={ true }
197186
className="od-application-notice od-error-notice"
198187
>
199188
<div className="od-error-notice-summary">
200189
<div className="od-notice-message">
201-
{ applicationStatus.message }
190+
{ applicationStatus?.message }
202191
</div>
203-
204-
{ applicationStatus.hasDetails && (
205-
<button
206-
type="button"
207-
className="od-error-notice-toggle"
208-
onClick={ () => setShowDetailedErrors( ( prev ) => ! prev ) }
209-
>
210-
{ showDetailedErrors
211-
? __( 'Hide Details', 'onedesign' )
212-
: __( 'Show Details', 'onedesign' ) }
213-
<span className="od-toggle-icon">
214-
{ showDetailedErrors ? '▲' : '▼' }
215-
</span>
216-
</button>
217-
) }
218192
</div>
219193

220-
{ showDetailedErrors && applicationStatus.hasDetails && (
194+
{ showDetailedErrors && applicationStatus?.hasDetails && (
221195
<div className="od-error-details">
222196
{ detailedErrors.map( ( error, index ) => (
223197
<div key={ index } className="od-error-site">
224-
<div className="od-error-site-name">{ error.site }</div>
198+
<div className="od-error-site-name">{ error?.site }</div>
225199
<div className="od-error-site-message">
226-
{ error.message }
200+
{ error?.message }
227201
</div>
228202
</div>
229203
) ) }
@@ -232,10 +206,19 @@ const BasePatternsTab = memo(
232206
</Notice>
233207
) }
234208

209+
<div className="od-site-selection-wrapper">
210+
<SiteSelection
211+
setIsSiteSelected={ setIsSiteSelected }
212+
selectedPatterns={ selectedPatterns }
213+
basePatterns={ basePatterns }
214+
sitePatterns={ sitePatterns }
215+
/>
216+
</div>
217+
235218
<div className="od-modal-actions">
236219
<Button
237220
variant="secondary"
238-
onClick={ closeConsumerSiteModal }
221+
onClick={ CloseBrandSiteModal }
239222
disabled={ isApplying && ! showCloseConfirmation }
240223
>
241224
{ showCloseConfirmation
@@ -325,7 +308,7 @@ const BasePatternsTab = memo(
325308
) }
326309

327310
<Button
328-
onClick={ openConsumerSiteModal }
311+
onClick={ OpenBrandSiteModal }
329312
variant="primary"
330313
className="od-apply-to-sites-button"
331314
disabled={ selectedPatterns.length === 0 }
@@ -340,13 +323,13 @@ const BasePatternsTab = memo(
340323
{ isModalOpen && (
341324
<Modal
342325
title=""
343-
onRequestClose={ closeConsumerSiteModal }
344-
className="od-consumer-site-modal"
326+
onRequestClose={ CloseBrandSiteModal }
327+
className="od-brand-site-modal"
345328
shouldCloseOnClickOutside={ ! isApplying }
346329
shouldCloseOnEsc={ ! isApplying }
347330
isFullScreen={ true }
348331
>
349-
{ consumerSiteSelection() }
332+
{ BrandSiteSelection() }
350333
</Modal>
351334
) }
352335
</div>

assets/src/patterns-popover/components/Category.js renamed to assets/src/admin/patterns/components/Category.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* WordPress dependencies
3+
*/
14
import { useState, useEffect, useCallback } from '@wordpress/element';
25
import { __ } from '@wordpress/i18n';
36
import { Button } from '@wordpress/components';

assets/src/patterns-popover/components/MemoizedPatternPreview.js renamed to assets/src/admin/patterns/components/MemoizedPatternPreview.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import { __ } from '@wordpress/i18n';
77
import { parse } from '@wordpress/blocks';
88
import { BlockPreview } from '@wordpress/block-editor';
99

10-
// Separate memoized component for the preview
10+
/**
11+
* Pattern content preview.
12+
*
13+
* @param {Object} props - Component properties.
14+
* @param {Array} props.parsedBlocks - Parsed blocks to preview.
15+
* @return {JSX.Element} Rendered component.
16+
*/
1117
const PatternPreviewContent = memo( ( { parsedBlocks } ) => {
1218
return (
1319
<div className="od-pattern-preview">
@@ -16,7 +22,13 @@ const PatternPreviewContent = memo( ( { parsedBlocks } ) => {
1622
);
1723
} );
1824

19-
// Separate memoized component for pattern categories
25+
/**
26+
* Separate memoized component for pattern categories
27+
*
28+
* @param {Object} props - Component properties.
29+
* @param {Object} props.categories - Categories object.
30+
* @return {JSX.Element} Rendered component.
31+
*/
2032
const PatternCategories = memo( ( { categories } ) => {
2133
if ( ! categories || typeof categories !== 'object' || Array.isArray( categories ) ) {
2234
return null;
@@ -40,7 +52,13 @@ const PatternCategories = memo( ( { categories } ) => {
4052
);
4153
} );
4254

43-
// Separate memoized component for provider site
55+
/**
56+
* Separate memoized component for provider site info
57+
*
58+
* @param {Object} props - Component properties.
59+
* @param {string} props.providerSite - Provider site name.
60+
* @return {JSX.Element} Rendered component.
61+
*/
4462
const ProviderSiteInfo = memo( ( { providerSite } ) => {
4563
if ( ! providerSite ) {
4664
return null;

0 commit comments

Comments
 (0)