Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor]: Move Post Status to editor package #59877

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
PostURLPanel,
PostTemplatePanel,
PostFeaturedImagePanel,
PostStatus as PostStatusPanel,
store as editorStore,
} from '@wordpress/editor';

Expand Down Expand Up @@ -62,6 +63,7 @@ export default function PostStatus() {
{ ( fills ) => (
<>
<PostFeaturedImagePanel withPanelBody={ false } />
<PostStatusPanel />
<PostVisibility />
<PostSchedulePanel />
<PostTemplatePanel />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,27 @@ import PageContent from './page-content';
import PageSummary from './page-summary';

export default function PagePanels() {
const {
id,
type,
hasResolved,
status,
date,
password,
title,
modified,
renderingMode,
} = useSelect( ( select ) => {
const { getEditedPostContext } = select( editSiteStore );
const { getEditedEntityRecord, hasFinishedResolution } =
select( coreStore );
const { getRenderingMode } = select( editorStore );
const context = getEditedPostContext();
const queryArgs = [ 'postType', context.postType, context.postId ];
const page = getEditedEntityRecord( ...queryArgs );
return {
hasResolved: hasFinishedResolution(
'getEditedEntityRecord',
queryArgs
),
title: page?.title,
id: page?.id,
type: page?.type,
status: page?.status,
date: page?.date,
password: page?.password,
modified: page?.modified,
renderingMode: getRenderingMode(),
};
}, [] );
const { hasResolved, title, modified, renderingMode } = useSelect(
( select ) => {
const { getEditedPostContext } = select( editSiteStore );
const { getEditedEntityRecord, hasFinishedResolution } =
select( coreStore );
const { getRenderingMode } = select( editorStore );
const context = getEditedPostContext();
const queryArgs = [ 'postType', context.postType, context.postId ];
const page = getEditedEntityRecord( ...queryArgs );
return {
hasResolved: hasFinishedResolution(
'getEditedEntityRecord',
queryArgs
),
title: page?.title,
modified: page?.modified,
renderingMode: getRenderingMode(),
};
},
[]
);

if ( ! hasResolved ) {
return null;
Expand All @@ -88,13 +76,7 @@ export default function PagePanels() {
/>
</PanelBody>
<PanelBody title={ __( 'Summary' ) }>
<PageSummary
status={ status }
date={ date }
password={ password }
postId={ id }
postType={ type }
/>
<PageSummary />
</PanelBody>
{ renderingMode !== 'post-only' && (
<PanelBody title={ __( 'Content' ) }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,14 @@ import {
PostSchedulePanel,
PostTemplatePanel,
PostFeaturedImagePanel,
PostStatus,
} from '@wordpress/editor';

/**
* Internal dependencies
*/
import PageStatus from './page-status';

export default function PageSummary( {
status,
date,
password,
postId,
postType,
} ) {
export default function PageSummary() {
return (
<VStack spacing={ 0 }>
<PostFeaturedImagePanel withPanelBody={ false } />
<PageStatus
status={ status }
date={ date }
password={ password }
postId={ postId }
postType={ postType }
/>
<PostStatus />
<PostSchedulePanel />
<PostTemplatePanel />
<PostURLPanel />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,3 @@
.edit-site-page-panels__swap-template__confirm-modal__actions {
margin-top: $grid-unit-30;
}

.edit-site-change-status__content {
.components-popover__content {
min-width: 320px;
padding: $grid-unit-20;
}

.edit-site-change-status__options {
.components-base-control__field > .components-v-stack {
gap: $grid-unit-10;
}

label {
.components-text {
display: block;
}
}
}

.edit-site-change-status__password-legend {
padding: 0;
margin-bottom: $grid-unit-10;
}
}

.edit-site-summary-field__trigger {
max-width: 100%;

// Truncate
display: block;
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { useSelect } from '@wordpress/data';
import { decodeEntities } from '@wordpress/html-entities';
import { store as coreStore, useEntityRecord } from '@wordpress/core-data';
import { safeDecodeURIComponent } from '@wordpress/url';
import { PostStatusLabel } from '@wordpress/editor';

/**
* Internal dependencies
*/
import StatusLabel from './status-label';
import { unlock } from '../../lock-unlock';
import { store as editSiteStore } from '../../store';
import {
Expand All @@ -35,7 +35,7 @@ function getPageDetails( page ) {
{
label: __( 'Status' ),
value: (
<StatusLabel
<PostStatusLabel
status={ page?.password ? 'protected' : page.status }
date={ page?.date }
short
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions packages/editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export {
} from './post-schedule/label';
export { default as PostSchedulePanel } from './post-schedule/panel';
export { default as PostSlug } from './post-slug';
export { default as PostStatus, PostStatusLabel } from './post-status';
export { default as PostSlugCheck } from './post-slug/check';
export { default as PostSticky } from './post-sticky';
export { default as PostStickyCheck } from './post-sticky/check';
Expand Down
23 changes: 4 additions & 19 deletions packages/editor/src/components/post-publish-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export class PostPublishButton extends Component {
render() {
const {
forceIsDirty,
hasPublishAction,
isBeingScheduled,
isOpen,
isPostSavingLocked,
Expand All @@ -116,9 +115,9 @@ export class PostPublishButton extends Component {
onStatusChange,
onSubmit = noop,
onToggle,
visibility,
hasNonPostEntityChanges,
isSavingNonPostEntityChanges,
status,
} = this.props;

const isButtonDisabled =
Expand All @@ -135,23 +134,12 @@ export class PostPublishButton extends Component {
( ! isPublishable && ! forceIsDirty ) ) &&
( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges );

let publishStatus;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have been missing something here, but it seems we only did that because we hadn't all the available status options in post editor.. I'll cc @jorgefilipecosta as I saw he has made changes in the past..

if ( ! hasPublishAction ) {
publishStatus = 'pending';
} else if ( visibility === 'private' ) {
publishStatus = 'private';
} else if ( isBeingScheduled ) {
publishStatus = 'future';
} else {
publishStatus = 'publish';
}

const onClickButton = () => {
if ( isButtonDisabled ) {
return;
}
onSubmit();
onStatusChange( publishStatus );
onStatusChange( status );
onSave();
};

Expand Down Expand Up @@ -218,32 +206,29 @@ export default compose( [
isSavingPost,
isAutosavingPost,
isEditedPostBeingScheduled,
getEditedPostVisibility,
isCurrentPostPublished,
isEditedPostSaveable,
isEditedPostPublishable,
isPostSavingLocked,
getCurrentPost,
getCurrentPostType,
getCurrentPostId,
getEditedPostAttribute,
hasNonPostEntityChanges,
isSavingNonPostEntityChanges,
} = select( editorStore );
return {
isSaving: isSavingPost(),
isAutoSaving: isAutosavingPost(),
isBeingScheduled: isEditedPostBeingScheduled(),
visibility: getEditedPostVisibility(),
isSaveable: isEditedPostSaveable(),
isPostSavingLocked: isPostSavingLocked(),
isPublishable: isEditedPostPublishable(),
isPublished: isCurrentPostPublished(),
hasPublishAction:
getCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,
postType: getCurrentPostType(),
postId: getCurrentPostId(),
hasNonPostEntityChanges: hasNonPostEntityChanges(),
isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
status: getEditedPostAttribute( 'status' ),
};
} ),
withDispatch( ( dispatch ) => {
Expand Down
Loading
Loading