@wordpress/patterns 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/build/components/category-selector.js +9 -41
  2. package/build/components/category-selector.js.map +1 -1
  3. package/build/components/create-pattern-modal.js +45 -9
  4. package/build/components/create-pattern-modal.js.map +1 -1
  5. package/build/components/pattern-convert-button.js +11 -8
  6. package/build/components/pattern-convert-button.js.map +1 -1
  7. package/build/constants.js +3 -1
  8. package/build/constants.js.map +1 -1
  9. package/build/private-apis.js +1 -0
  10. package/build/private-apis.js.map +1 -1
  11. package/build/store/actions.js +1 -1
  12. package/build/store/actions.js.map +1 -1
  13. package/build-module/components/category-selector.js +8 -42
  14. package/build-module/components/category-selector.js.map +1 -1
  15. package/build-module/components/create-pattern-modal.js +43 -8
  16. package/build-module/components/create-pattern-modal.js.map +1 -1
  17. package/build-module/components/pattern-convert-button.js +11 -8
  18. package/build-module/components/pattern-convert-button.js.map +1 -1
  19. package/build-module/constants.js +1 -0
  20. package/build-module/constants.js.map +1 -1
  21. package/build-module/private-apis.js +2 -1
  22. package/build-module/private-apis.js.map +1 -1
  23. package/build-module/store/actions.js +1 -1
  24. package/build-module/store/actions.js.map +1 -1
  25. package/package.json +15 -15
  26. package/src/components/category-selector.js +7 -45
  27. package/src/components/create-pattern-modal.js +51 -9
  28. package/src/components/pattern-convert-button.js +11 -8
  29. package/src/constants.js +1 -0
  30. package/src/private-apis.js +2 -0
  31. package/src/store/actions.js +1 -1
@@ -21,6 +21,7 @@ import { store as noticesStore } from '@wordpress/notices';
21
21
  import { store as patternsStore } from '../store';
22
22
  import CreatePatternModal from './create-pattern-modal';
23
23
  import { unlock } from '../lock-unlock';
24
+ import { PATTERN_SYNC_TYPES } from '../constants';
24
25
 
25
26
  /**
26
27
  * Menu control to convert block(s) to a pattern block.
@@ -96,23 +97,25 @@ export default function PatternConvertButton( { clientIds, rootClientId } ) {
96
97
  }
97
98
 
98
99
  const handleSuccess = ( { pattern } ) => {
99
- const newBlock = createBlock( 'core/block', {
100
- ref: pattern.id,
101
- } );
100
+ if ( pattern.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced ) {
101
+ const newBlock = createBlock( 'core/block', {
102
+ ref: pattern.id,
103
+ } );
102
104
 
103
- replaceBlocks( clientIds, newBlock );
104
- setEditingPattern( newBlock.clientId, true );
105
+ replaceBlocks( clientIds, newBlock );
106
+ setEditingPattern( newBlock.clientId, true );
107
+ }
105
108
 
106
109
  createSuccessNotice(
107
- pattern.wp_pattern_sync_status === 'unsynced'
110
+ pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced
108
111
  ? sprintf(
109
112
  // translators: %s: the name the user has given to the pattern.
110
- __( 'Unsynced Pattern created: %s' ),
113
+ __( 'Unsynced pattern created: %s' ),
111
114
  pattern.title.raw
112
115
  )
113
116
  : sprintf(
114
117
  // translators: %s: the name the user has given to the pattern.
115
- __( 'Synced Pattern created: %s' ),
118
+ __( 'Synced pattern created: %s' ),
116
119
  pattern.title.raw
117
120
  ),
118
121
  {
package/src/constants.js CHANGED
@@ -4,6 +4,7 @@ export const PATTERN_TYPES = {
4
4
  };
5
5
 
6
6
  export const PATTERN_DEFAULT_CATEGORY = 'all-patterns';
7
+ export const PATTERN_USER_CATEGORY = 'my-patterns';
7
8
  export const PATTERN_CORE_SOURCES = [
8
9
  'core',
9
10
  'pattern-directory/core',
@@ -7,6 +7,7 @@ import PatternsMenuItems from './components';
7
7
  import {
8
8
  PATTERN_TYPES,
9
9
  PATTERN_DEFAULT_CATEGORY,
10
+ PATTERN_USER_CATEGORY,
10
11
  PATTERN_CORE_SOURCES,
11
12
  PATTERN_SYNC_TYPES,
12
13
  } from './constants';
@@ -17,6 +18,7 @@ lock( privateApis, {
17
18
  PatternsMenuItems,
18
19
  PATTERN_TYPES,
19
20
  PATTERN_DEFAULT_CATEGORY,
21
+ PATTERN_USER_CATEGORY,
20
22
  PATTERN_CORE_SOURCES,
21
23
  PATTERN_SYNC_TYPES,
22
24
  } );
@@ -69,7 +69,7 @@ export const createPatternFromFile =
69
69
  ( parsedContent.syncStatus &&
70
70
  typeof parsedContent.syncStatus !== 'string' )
71
71
  ) {
72
- throw new Error( 'Invalid Pattern JSON file' );
72
+ throw new Error( 'Invalid pattern JSON file' );
73
73
  }
74
74
 
75
75
  const pattern = await dispatch.createPattern(