-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58a7684
commit 6a58942
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/edit-site/src/components/page-patterns/dataviews-pattern-actions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { paramCase as kebabCase } from 'change-case'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { downloadBlob } from '@wordpress/blob'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { PATTERN_TYPES } from '../../utils/constants'; | ||
|
||
export const exportJSONaction = { | ||
id: 'duplicate-pattern', | ||
label: __( 'Export as JSON' ), | ||
isEligible: ( item ) => item.type === PATTERN_TYPES.user, | ||
callback: ( item ) => { | ||
const json = { | ||
__file: item.type, | ||
title: item.title || item.name, | ||
content: item.patternBlock.content.raw, | ||
syncStatus: item.patternBlock.wp_pattern_sync_status, | ||
}; | ||
return downloadBlob( | ||
`${ kebabCase( item.title || item.name ) }.json`, | ||
JSON.stringify( json, null, 2 ), | ||
'application/json' | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters