-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- move preview button to post status slot - slight refactoring - handle campaign fetching in editor plugin
- Loading branch information
Showing
8 changed files
with
511 additions
and
108 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,39 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { WebPreview } from 'newspack-components'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { withSelect } from '@wordpress/data'; | ||
import { PluginPostStatusInfo } from '@wordpress/edit-post'; | ||
import { registerPlugin } from '@wordpress/plugins'; | ||
import { Button } from '@wordpress/components'; | ||
|
||
const StatusInfoPreviewButton = ( { url } ) => | ||
url ? ( | ||
<PluginPostStatusInfo> | ||
<WebPreview | ||
url={ url } | ||
renderButton={ ( { showPreview } ) => ( | ||
<Button isPrimary onClick={ showPreview }> | ||
{ __( 'Preview', 'newspack-newsletters' ) } | ||
</Button> | ||
) } | ||
/> | ||
</PluginPostStatusInfo> | ||
) : null; | ||
|
||
const StatusInfoPreviewButtonWithSelect = withSelect( select => { | ||
const { getEditedPostAttribute } = select( 'core/editor' ); | ||
const meta = getEditedPostAttribute( 'meta' ); | ||
return { url: meta.campaign && meta.campaign.long_archive_url }; | ||
} )( StatusInfoPreviewButton ); | ||
|
||
export default () => { | ||
registerPlugin( 'newspack-newsletters-post-status-info', { | ||
render: StatusInfoPreviewButtonWithSelect, | ||
} ); | ||
}; |
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
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
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