Skip to content

Commit

Permalink
Rename prepublish panel
Browse files Browse the repository at this point in the history
  • Loading branch information
octaedro committed Feb 7, 2024
1 parent 69e80d5 commit 6a1ed97
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 52 deletions.
@@ -1,4 +1,4 @@
Significance: minor
Type: add

Add prepublish sidebar #44331
Add prepublish panel #44331
10 changes: 5 additions & 5 deletions packages/js/product-editor/src/components/editor/editor.tsx
Expand Up @@ -34,7 +34,7 @@ import { BlockEditor } from '../block-editor';
import { ValidationProvider } from '../../contexts/validation-context';
import { EditorProps } from './types';
import { store as productEditorUiStore } from '../../store/product-editor-ui';
import { PrepublishSidebar } from '../prepublish-sidebar/prepublish-sidebar';
import { PrepublishPanel } from '../prepublish-panel/prepublish-panel';

export function Editor( {
product,
Expand All @@ -46,8 +46,8 @@ export function Editor( {
const updatedLayoutContext = useExtendLayout( 'product-block-editor' );

// Check if the prepublish sidebar is open from the store.
const isPrepublishSidebarOpen = useSelect( ( select ) => {
return select( productEditorUiStore ).isPrepublishSidebarOpen();
const isPrepublishPanelOpen = useSelect( ( select ) => {
return select( productEditorUiStore ).isPrepublishPanelOpen();
}, [] );

return (
Expand Down Expand Up @@ -82,8 +82,8 @@ export function Editor( {
</>
}
sidebar={
isPrepublishSidebarOpen && (
<PrepublishSidebar
isPrepublishPanelOpen && (
<PrepublishPanel
productType={ productType }
productId={ product.id }
/>
Expand Down
Expand Up @@ -23,7 +23,7 @@ import { MoreMenu } from './more-menu';
import { PreviewButton } from './preview-button';
import { SaveDraftButton } from './save-draft-button';
import { PublishButton } from './publish-button';
import { PrepublishButton } from '../prepublish-sidebar';
import { PrepublishButton } from '../prepublish-panel';
import { Tabs } from '../tabs';
import { HEADER_PINNED_ITEMS_SCOPE, TRACKS_SOURCE } from '../../constants';

Expand Down
@@ -1,3 +1,3 @@
export * from './prepublish-button';
export * from './prepublish-sidebar';
export * from './prepublish-panel';
export * from './types';
Expand Up @@ -20,7 +20,7 @@ export function PrepublishButton( {
productId,
productType = 'product',
}: PrepublishButtonProps ) {
const { openPrepublishSidebar } = useDispatch( productEditorUiStore );
const { openPrepublishPanel } = useDispatch( productEditorUiStore );
const { isValidating } = useValidations< Product >();
const { isSaving, isDirty } = useSelect(
( select ) => {
Expand Down Expand Up @@ -54,7 +54,7 @@ export function PrepublishButton( {
<Button
onClick={ () => {
recordEvent( 'product_prepublish', { source: TRACKS_SOURCE } );
openPrepublishSidebar();
openPrepublishPanel();
} }
isBusy={ isBusy }
aria-disabled={ isDisabled }
Expand Down
Expand Up @@ -11,19 +11,19 @@ import { recordEvent } from '@woocommerce/tracks';
* Internal dependencies
*/
import { PublishButton } from '../header/publish-button';
import { PrepublishSidebarProps } from './types';
import { PrepublishPanelProps } from './types';
import { store as productEditorUiStore } from '../../store/product-editor-ui';
import { TRACKS_SOURCE } from '../../constants';

export function PrepublishSidebar( {
export function PrepublishPanel( {
productId,
productType = 'product',
title = __( 'Are you ready to add this product?', 'woocommerce' ),
description = __(
'Double-check your settings before sharing this product with customers.',
'woocommerce'
),
}: PrepublishSidebarProps ) {
}: PrepublishPanelProps ) {
const lastPersistedProduct = useSelect(
( select ) => {
const { getEntityRecord } = select( 'core' );
Expand All @@ -32,23 +32,23 @@ export function PrepublishSidebar( {
[ productType, productId ]
);

const { closePrepublishSidebar } = useDispatch( productEditorUiStore );
const { closePrepublishPanel } = useDispatch( productEditorUiStore );

return (
<div className="woocommerce-product-publish-panel">
<div className="woocommerce-product-publish-panel__actions">
<PublishButton
productType={ productType }
productStatus={ lastPersistedProduct?.status }
onSuccess={ closePrepublishSidebar }
onSuccess={ closePrepublishPanel }
/>
<Button
variant={ 'secondary' }
onClick={ () => {
recordEvent( 'product_prepublish_cancel', {
source: TRACKS_SOURCE,
} );
closePrepublishSidebar();
closePrepublishPanel();
} }
>
{ __( 'Cancel', 'woocommerce' ) }
Expand Down
@@ -1,4 +1,4 @@
export type PrepublishSidebarProps = {
export type PrepublishPanelProps = {
productId: number;
productType: string;
title?: string;
Expand Down
10 changes: 5 additions & 5 deletions packages/js/product-editor/src/store/product-editor-ui/Readme.md
Expand Up @@ -8,22 +8,22 @@ Defines action types for the UI state:

- `ACTION_MODAL_EDITOR_OPEN`
- `ACTION_MODAL_EDITOR_CLOSE`
- `ACTION_PREPUBLISH_SIDEBAR_OPEN`
- `ACTION_PREPUBLISH_SIDEBAR_CLOSE`
- `ACTION_PANEL_PREPUBLISH_OPEN`
- `ACTION_PANEL_PREPUBLISH_CLOSE`

### Actions

- `openModalEditor`
- `closeModalEditor`
- `openPrepublishSidebar`
- `closePrepublishSidebar`
- `openPrepublishPanel`
- `closePrepublishPanel`

### Selectors

Selector function:

- `isModalEditorOpen`
- `isPrepublishSidebarOpen`
- `isPrepublishPanelOpen`

### Store

Expand Down
Expand Up @@ -11,8 +11,8 @@ import {
ACTION_MODAL_EDITOR_OPEN,
ACTION_MODAL_EDITOR_SET_BLOCKS,
ACTION_MODAL_EDITOR_CONTENT_HAS_CHANGED,
ACTION_SIDEBAR_PREPUBLISH_OPEN,
ACTION_SIDEBAR_PREPUBLISH_CLOSE,
ACTION_PANEL_PREPUBLISH_OPEN,
ACTION_PANEL_PREPUBLISH_CLOSE,
} from './constants';

const modalEditorActions = {
Expand All @@ -35,17 +35,17 @@ const modalEditorActions = {
} ),
};

const prepublishSidebarActions = {
openPrepublishSidebar: () => ( {
type: ACTION_SIDEBAR_PREPUBLISH_OPEN,
const prepublishPanelActions = {
openPrepublishPanel: () => ( {
type: ACTION_PANEL_PREPUBLISH_OPEN,
} ),

closePrepublishSidebar: () => ( {
type: ACTION_SIDEBAR_PREPUBLISH_CLOSE,
closePrepublishPanel: () => ( {
type: ACTION_PANEL_PREPUBLISH_CLOSE,
} ),
};

export default {
...modalEditorActions,
...prepublishSidebarActions,
...prepublishPanelActions,
};
Expand Up @@ -6,5 +6,5 @@ export const ACTION_MODAL_EDITOR_CLOSE = 'MODAL_EDITOR_CLOSE';
export const ACTION_MODAL_EDITOR_SET_BLOCKS = 'MODAL_EDITOR_SET_BLOCKS';
export const ACTION_MODAL_EDITOR_CONTENT_HAS_CHANGED =
'MODAL_EDITOR_CONTENT_HAS_CHANGED';
export const ACTION_SIDEBAR_PREPUBLISH_OPEN = 'SIDEBAR_PREPUBLISH_OPEN';
export const ACTION_SIDEBAR_PREPUBLISH_CLOSE = 'SIDEBAR_PREPUBLISH_CLOSE';
export const ACTION_PANEL_PREPUBLISH_OPEN = 'PANEL_PREPUBLISH_OPEN';
export const ACTION_PANEL_PREPUBLISH_CLOSE = 'PANEL_PREPUBLISH_CLOSE';
20 changes: 9 additions & 11 deletions packages/js/product-editor/src/store/product-editor-ui/reducer.ts
Expand Up @@ -6,12 +6,12 @@ import {
ACTION_MODAL_EDITOR_CLOSE,
ACTION_MODAL_EDITOR_OPEN,
ACTION_MODAL_EDITOR_SET_BLOCKS,
ACTION_SIDEBAR_PREPUBLISH_CLOSE,
ACTION_SIDEBAR_PREPUBLISH_OPEN,
ACTION_PANEL_PREPUBLISH_CLOSE,
ACTION_PANEL_PREPUBLISH_OPEN,
} from './constants';
import type {
ProductEditorModalEditorAction,
ProductEditorPrepublishSidebarAction,
ProductEditorPrepublishPanelAction,
ProductEditorUIStateProps,
} from './types';

Expand All @@ -24,16 +24,14 @@ const INITIAL_STATE: ProductEditorUIStateProps = {
blocks: [],
hasChanged: false,
},
prepublishSidebar: {
prepublishPanel: {
isOpen: false,
},
};

export default function reducer(
state = INITIAL_STATE,
action:
| ProductEditorModalEditorAction
| ProductEditorPrepublishSidebarAction
action: ProductEditorModalEditorAction | ProductEditorPrepublishPanelAction
) {
switch ( action.type ) {
case ACTION_MODAL_EDITOR_OPEN:
Expand Down Expand Up @@ -72,18 +70,18 @@ export default function reducer(
},
};

case ACTION_SIDEBAR_PREPUBLISH_OPEN:
case ACTION_PANEL_PREPUBLISH_OPEN:
return {
...state,
prepublishSidebar: {
prepublishPanel: {
isOpen: true,
},
};

case ACTION_SIDEBAR_PREPUBLISH_CLOSE:
case ACTION_PANEL_PREPUBLISH_CLOSE:
return {
...state,
prepublishSidebar: {
prepublishPanel: {
isOpen: false,
},
};
Expand Down
Expand Up @@ -26,9 +26,9 @@ export default {
): boolean {
return !! state.modalEditor?.hasChanged;
},
isPrepublishSidebarOpen: function isPrepublishSidebarOpen(
isPrepublishPanelOpen: function isPrepublishPanelOpen(
state: ProductEditorUIStateProps
) {
return state.prepublishSidebar?.isOpen;
return state.prepublishPanel?.isOpen;
},
};
12 changes: 6 additions & 6 deletions packages/js/product-editor/src/store/product-editor-ui/types.ts
Expand Up @@ -11,8 +11,8 @@ import {
ACTION_MODAL_EDITOR_CLOSE,
ACTION_MODAL_EDITOR_OPEN,
ACTION_MODAL_EDITOR_SET_BLOCKS,
ACTION_SIDEBAR_PREPUBLISH_CLOSE,
ACTION_SIDEBAR_PREPUBLISH_OPEN,
ACTION_PANEL_PREPUBLISH_CLOSE,
ACTION_PANEL_PREPUBLISH_OPEN,
} from './constants';

export type ProductEditorUIStateProps = {
Expand All @@ -21,7 +21,7 @@ export type ProductEditorUIStateProps = {
blocks?: BlockInstance[];
hasChanged?: boolean;
};
prepublishSidebar?: {
prepublishPanel?: {
isOpen: boolean;
};
};
Expand All @@ -38,8 +38,8 @@ export type ProductEditorModalEditorAction = {
hasChanged?: boolean;
};

export type ProductEditorPrepublishSidebarAction = {
export type ProductEditorPrepublishPanelAction = {
type:
| typeof ACTION_SIDEBAR_PREPUBLISH_CLOSE
| typeof ACTION_SIDEBAR_PREPUBLISH_OPEN;
| typeof ACTION_PANEL_PREPUBLISH_CLOSE
| typeof ACTION_PANEL_PREPUBLISH_OPEN;
};
2 changes: 1 addition & 1 deletion packages/js/product-editor/src/style.scss
Expand Up @@ -45,7 +45,7 @@
@import "components/product-list/styles.scss";
@import "components/product-select/styles.scss";
@import "components/product-image/styles.scss";
@import "components/prepublish-sidebar/style.scss";
@import "components/prepublish-panel/style.scss";

/* Field Blocks */

Expand Down

0 comments on commit 6a1ed97

Please sign in to comment.