Skip to content

Commit c54d45a

Browse files
committed
Add the temporary edit template button under SIG
1 parent 6f7493c commit c54d45a

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: added
3+
4+
Add edit template modal.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Button } from '@wordpress/components';
2+
import { useDispatch } from '@wordpress/data';
3+
import { useCallback } from '@wordpress/element';
4+
import { __ } from '@wordpress/i18n';
5+
import { store as socialStore } from '../../../social-store';
6+
7+
/**
8+
* Edit Template Button component.
9+
*
10+
* @return - React element
11+
*/
12+
export function EditTemplate() {
13+
const { openUnifiedModal } = useDispatch( socialStore );
14+
15+
const handleOpenModal = useCallback( () => {
16+
// When opening modal from the sidebar, we want to lock the screen to prevent navigation.
17+
openUnifiedModal( { initialPath: '/edit-template', isScreenLocked: true } );
18+
}, [ openUnifiedModal ] );
19+
20+
return (
21+
<Button variant="secondary" onClick={ handleOpenModal }>
22+
{ __( 'Edit template', 'jetpack-publicize-components' ) }
23+
</Button>
24+
);
25+
}

projects/js-packages/publicize-components/src/components/social-image-generator/panel/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ThemeProvider, useGlobalNotices } from '@automattic/jetpack-components';
2+
import { siteHasFeature } from '@automattic/jetpack-script-data';
23
import {
34
ToggleControl,
45
Button,
@@ -9,7 +10,9 @@ import { useCallback, useState } from '@wordpress/element';
910
import { __, _x } from '@wordpress/i18n';
1011
import useImageGeneratorConfig from '../../../hooks/use-image-generator-config';
1112
import { useSaveImageToLibrary } from '../../../hooks/use-save-image-to-library';
13+
import { features } from '../../../utils';
1214
import GeneratedImagePreview from '../../generated-image-preview';
15+
import { EditTemplate } from './edit-template';
1316
import SocialImageGeneratorSettingsModal from './modal';
1417

1518
const SocialImageGeneratorPanel = () => {
@@ -92,6 +95,10 @@ const SocialImageGeneratorPanel = () => {
9295
)
9396
: __( 'Save to media library', 'jetpack-publicize-components' ) }
9497
</Button>
98+
{ siteHasFeature( features.UNIFIED_UI_V1 ) ? (
99+
// TODO: Replace EditTemplate button with full image UI controls integrated with the sidebar
100+
<EditTemplate />
101+
) : null }
95102
</HStack>
96103
</>
97104
) }

0 commit comments

Comments
 (0)