Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7213d66
add required inputs
SaxonF Jun 9, 2023
c938235
schedule date
SaxonF Jun 12, 2023
e46f5ff
add password and fix a few things
SaxonF Jun 12, 2023
511bacc
re-add status modal
SaxonF Jun 13, 2023
73f89b4
update change status modal
SaxonF Jun 13, 2023
d5013da
revert in sidebar status change
SaxonF Jun 13, 2023
fc692d0
refine a few status details
SaxonF Jun 13, 2023
0d25392
fix merge issues
SaxonF Jun 14, 2023
42145f0
fix status label
SaxonF Jun 14, 2023
736fac9
use null for status date
SaxonF Jun 14, 2023
46f7ad5
handle empty date
SaxonF Jun 15, 2023
2df2fc9
change to add fields instead of modal
SaxonF Jun 15, 2023
710e36c
default publish not draft
SaxonF Jun 15, 2023
01b0a07
remove style import
SaxonF Jun 15, 2023
7dec51c
add required inputs
SaxonF Jun 9, 2023
368cdef
schedule date
SaxonF Jun 12, 2023
12554e3
add password and fix a few things
SaxonF Jun 12, 2023
01f58b3
re-add status modal
SaxonF Jun 13, 2023
94031eb
update change status modal
SaxonF Jun 13, 2023
6582538
revert in sidebar status change
SaxonF Jun 13, 2023
2c05b56
refine a few status details
SaxonF Jun 13, 2023
41e15e9
fix merge issues
SaxonF Jun 14, 2023
fc295e0
fix status label
SaxonF Jun 14, 2023
96ba33f
use null for status date
SaxonF Jun 14, 2023
1fa27ab
handle empty date
SaxonF Jun 15, 2023
14e2254
change to add fields instead of modal
SaxonF Jun 15, 2023
053c3cf
default publish not draft
SaxonF Jun 15, 2023
a3949c2
remove style import
SaxonF Jun 15, 2023
2f088b9
Merge branch 'try/publish-in-site-editor' of https://github.com/WordP…
SaxonF Jun 16, 2023
cfbb607
Merge branch 'trunk' into try/publish-in-site-editor
SaxonF Jun 16, 2023
3e51dff
remove css
SaxonF Jun 16, 2023
d07a143
only autofocus password field if empty
SaxonF Jun 19, 2023
ff96c4c
aria label on status popover
SaxonF Jun 20, 2023
9e28a27
remove end line
SaxonF Jun 20, 2023
2a13222
Merge branch 'trunk' into try/publish-in-site-editor
SaxonF Jun 20, 2023
ca88703
create radio with help component
SaxonF Jun 20, 2023
8dbad15
Merge branch 'trunk' into try/publish-in-site-editor
SaxonF Jun 20, 2023
d0b09cc
adjust to use radiocontrol and hide password
SaxonF Jun 20, 2023
d4d7fde
radio label alignment
SaxonF Jun 20, 2023
7cf6f3c
add form wrapper
SaxonF Jun 20, 2023
6c55aa1
aria label
SaxonF Jun 20, 2023
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
Prev Previous commit
Next Next commit
refine a few status details
  • Loading branch information
SaxonF committed Jun 14, 2023
commit fc692d0a1b51ac0fba7eb8b35d6f0912afbffec8
35 changes: 27 additions & 8 deletions packages/edit-site/src/components/change-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@ import { useDispatch } from '@wordpress/data';
import { useState } from '@wordpress/element';
import { store as coreStore } from '@wordpress/core-data';
import { store as noticesStore } from '@wordpress/notices';
/**
* Internal dependencies
*/
import StatusLabel from '../sidebar-navigation-screen-page/status-label';

const STATUS_OPTIONS = [
{
label: __( 'Draft' ),
value: 'draft',
hint: __( 'Not ready to publish' ),
},
{
label: __( 'Published' ),
value: 'publish',
hint: __( 'Anyone with the url can access' ),
},
{
label: __( 'Private' ),
value: 'private',
Expand All @@ -39,11 +48,6 @@ const STATUS_OPTIONS = [
value: 'future',
hint: __( 'Publish automatically on a chosen date' ),
},
{
label: __( 'Published' ),
value: 'publish',
hint: __( 'Anyone with the url can access' ),
},
];

export default function ChangeStatus( { post } ) {
Expand Down Expand Up @@ -102,10 +106,24 @@ export default function ChangeStatus( { post } ) {
}
};

const handleStatus = ( value ) => {
if ( value === 'published' ) {
setDate( undefined );
}
setStatus( value );
};

return (
<>
<Button variant="secondary" onClick={ openModal }>
Change status
<Button
className="edit-site-change-status__trigger"
variant="tertiary"
onClick={ openModal }
>
<StatusLabel
status={ post?.password ? 'protected' : post.status }
date={ post?.date }
/>
</Button>
{ isOpen && (
<Modal
Expand Down Expand Up @@ -136,7 +154,7 @@ export default function ChangeStatus( { post } ) {
name={ `edit-site-change-status__status` }
value={ option.value }
onChange={ ( e ) =>
setStatus( e.target.value )
handleStatus( e.target.value )
}
checked={ option.value === status }
/>
Expand All @@ -161,6 +179,7 @@ export default function ChangeStatus( { post } ) {
<DateTimePicker
className="components-datetime__time__one-row"
currentDate={ date }
is12Hour
onChange={ setDate }
/>
</div>
Expand Down
4 changes: 1 addition & 3 deletions packages/edit-site/src/components/change-status/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.edit-site-change-status {
min-width: 480px;
width: 540px;
min-height: 400px;
.components-radio-control__option.with-hint {
display: flex;
Expand Down Expand Up @@ -60,8 +60,6 @@

fieldset:first-child {
.components-datetime__time-wrapper {
flex-direction: column;
align-items: flex-start;
> .components-flex-item {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/**
* WordPress dependencies
*/
import { PanelBody } from '@wordpress/components';
import {
PanelBody,
__experimentalText as Text,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { page as pageIcon } from '@wordpress/icons';
import { __, sprintf } from '@wordpress/i18n';
import { humanTimeDiff } from '@wordpress/date';
Expand All @@ -15,25 +19,32 @@ import { decodeEntities } from '@wordpress/html-entities';
import { store as editSiteStore } from '../../../store';
import SidebarCard from '../sidebar-card';
import PageContent from './page-content';
import ChangeStatus from '../../change-status';
import EditTemplate from './edit-template';

export default function PagePanels() {
const { hasResolved, title, modified } = useSelect( ( select ) => {
const { getEditedPostContext } = select( editSiteStore );
const { getEditedEntityRecord, hasFinishedResolution } =
select( coreStore );
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,
};
}, [] );
const { id, type, hasResolved, status, date, password, title, modified } =
useSelect( ( select ) => {
const { getEditedPostContext } = select( editSiteStore );
const { getEditedEntityRecord, hasFinishedResolution } =
select( coreStore );
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,
};
}, [] );

if ( ! hasResolved ) {
return null;
Expand All @@ -45,11 +56,24 @@ export default function PagePanels() {
<SidebarCard
title={ decodeEntities( title ) }
icon={ pageIcon }
description={ sprintf(
// translators: %s: Human-readable time difference, e.g. "2 days ago".
__( 'Last edited %s' ),
humanTimeDiff( modified )
) }
description={
<VStack>
<Text>
{ sprintf(
// translators: %s: Human-readable time difference, e.g. "2 days ago".
__( 'Last edited %s' ),
humanTimeDiff( modified )
) }
</Text>
<ChangeStatus
status={ status }
date={ date }
password={ password }
postId={ id }
postType={ type }
/>
</VStack>
}
/>
</PanelBody>
<PanelBody title={ __( 'Content' ) }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
.edit-site-page-panels__edit-template-button {
justify-content: center;
}

.edit-site-sidebar-card__description {
.edit-site-change-status__trigger {
margin-left: -$grid-unit-15;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import SidebarButton from '../sidebar-button';
import SidebarNavigationSubtitle from '../sidebar-navigation-subtitle';
import PageDetails from './page-details';
import PageActions from '../page-actions';
import ChangeStatus from '../change-status';

export default function SidebarNavigationScreenPage() {
const navigator = useNavigator();
Expand Down Expand Up @@ -96,15 +95,12 @@ export default function SidebarNavigationScreenPage() {
</>
}
meta={
<VStack>
<ExternalLink
className="edit-site-sidebar-navigation-screen__page-link"
href={ record.link }
>
{ record.link.replace( /^(https?:\/\/)?/, '' ) }
</ExternalLink>
<ChangeStatus post={ record } />
</VStack>
<ExternalLink
className="edit-site-sidebar-navigation-screen__page-link"
href={ record.link }
>
{ record.link.replace( /^(https?:\/\/)?/, '' ) }
</ExternalLink>
}
content={
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function getPageDetails( page ) {
<StatusLabel
status={ page?.password ? 'protected' : page.status }
date={ page?.date }
short
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { dateI18n, getDate, getSettings, humanTimeDiff } from '@wordpress/date';
import { dateI18n, getDate, humanTimeDiff } from '@wordpress/date';
import { createInterpolateElement } from '@wordpress/element';
import { Path, SVG } from '@wordpress/primitives';

Expand Down Expand Up @@ -41,7 +41,7 @@ const pendingIcon = (
</SVG>
);

export default function StatusLabel( { status, date } ) {
export default function StatusLabel( { status, date, short } ) {
const relateToNow = humanTimeDiff( date );
let statusLabel = '';
let statusIcon = pendingIcon;
Expand All @@ -59,13 +59,13 @@ export default function StatusLabel( { status, date } ) {
break;
case 'future':
const formattedDate = dateI18n(
getSettings().formats.date,
short ? 'M j' : 'F j',
getDate( date )
);
statusLabel = createInterpolateElement(
sprintf(
/* translators: %s: is the formatted date and time on which the post is scheduled to be published. */
__( 'Scheduled for <time>%s</time>' ),
__( 'Scheduled: <time>%s</time>' ),
formattedDate
),
{ time: <time dateTime={ date } /> }
Expand Down