-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split "Status & visibility" into multiple panels.
- Loading branch information
1 parent
02a24e9
commit 78a47fa
Showing
17 changed files
with
254 additions
and
160 deletions.
There are no files selected for viewing
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,21 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { findSidebarPanelToggleButtonWithTitle } from './find-sidebar-panel-toggle-button-with-title'; | ||
|
||
/** | ||
* Opens a sidebar panel with the provided title. | ||
* | ||
* @param {string} panelTitle The name of sidebar panel. | ||
*/ | ||
export async function openSidebarPanel( panelTitle ) { | ||
const panelToggle = await findSidebarPanelToggleButtonWithTitle( | ||
panelTitle | ||
); | ||
const panelIsCollapsed = await panelToggle.evaluate( | ||
( node ) => node.getAttribute( 'aria-expanded' ) === 'false' | ||
); | ||
if ( panelIsCollapsed ) { | ||
await panelToggle.click(); | ||
} | ||
} |
67 changes: 41 additions & 26 deletions
67
packages/e2e-tests/specs/editor/various/datepicker.test.js
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 |
---|---|---|
@@ -1,88 +1,103 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createNewPost } from '@wordpress/e2e-test-utils'; | ||
import { | ||
createNewPost, | ||
findSidebarPanelToggleButtonWithTitle, | ||
} from '@wordpress/e2e-test-utils'; | ||
|
||
describe( 'Datepicker', () => { | ||
beforeEach( async () => { | ||
await createNewPost(); | ||
} ); | ||
|
||
it( 'should show the publishing date as "Immediately" if the date is not altered', async () => { | ||
const publishingDate = await page.$eval( | ||
'.edit-post-post-schedule__toggle', | ||
( dateLabel ) => dateLabel.textContent | ||
const panelToggle = await findSidebarPanelToggleButtonWithTitle( | ||
'Publish:' | ||
); | ||
const publishDate = await panelToggle.$eval( | ||
'.editor-post-publish-panel__link', | ||
( publishDateSpan ) => publishDateSpan.textContent | ||
); | ||
|
||
expect( publishingDate ).toEqual( 'Immediately' ); | ||
expect( publishDate ).toEqual( 'Immediately' ); | ||
} ); | ||
|
||
it( 'should show the publishing date if the date is in the past', async () => { | ||
// Open the datepicker. | ||
await page.click( '.edit-post-post-schedule__toggle' ); | ||
const panelToggle = await findSidebarPanelToggleButtonWithTitle( | ||
'Publish:' | ||
); | ||
await panelToggle.click(); | ||
|
||
// Change the publishing date to a year in the past. | ||
await page.click( '.components-datetime__time-field-year' ); | ||
await page.keyboard.press( 'ArrowDown' ); | ||
|
||
// Close the datepicker. | ||
await page.click( '.edit-post-post-schedule__toggle' ); | ||
await panelToggle.click(); | ||
|
||
const publishingDate = await page.$eval( | ||
'.edit-post-post-schedule__toggle', | ||
( dateLabel ) => dateLabel.textContent | ||
const publishDate = await panelToggle.$eval( | ||
'.editor-post-publish-panel__link', | ||
( publishDateSpan ) => publishDateSpan.textContent | ||
); | ||
|
||
expect( publishingDate ).toMatch( | ||
expect( publishDate ).toMatch( | ||
/[A-Za-z]{3} \d{1,2}, \d{4} \d{1,2}:\d{2} [ap]m/ | ||
); | ||
} ); | ||
|
||
it( 'should show the publishing date if the date is in the future', async () => { | ||
// Open the datepicker. | ||
await page.click( '.edit-post-post-schedule__toggle' ); | ||
const panelToggle = await findSidebarPanelToggleButtonWithTitle( | ||
'Publish:' | ||
); | ||
await panelToggle.click(); | ||
|
||
// Change the publishing date to a year in the future. | ||
await page.click( '.components-datetime__time-field-year' ); | ||
await page.keyboard.press( 'ArrowUp' ); | ||
|
||
// Close the datepicker. | ||
await page.click( '.edit-post-post-schedule__toggle' ); | ||
await panelToggle.click(); | ||
|
||
const publishingDate = await page.$eval( | ||
'.edit-post-post-schedule__toggle', | ||
( dateLabel ) => dateLabel.textContent | ||
const publishDate = await panelToggle.$eval( | ||
'.editor-post-publish-panel__link', | ||
( publishDateSpan ) => publishDateSpan.textContent | ||
); | ||
|
||
expect( publishingDate ).not.toEqual( 'Immediately' ); | ||
expect( publishDate ).not.toEqual( 'Immediately' ); | ||
// The expected date format will be "Sep 26, 2018 11:52 pm". | ||
expect( publishingDate ).toMatch( | ||
expect( publishDate ).toMatch( | ||
/[A-Za-z]{3} \d{1,2}, \d{4} \d{1,2}:\d{2} [ap]m/ | ||
); | ||
} ); | ||
|
||
it( 'should show the publishing date as "Immediately" if the date is cleared', async () => { | ||
// Open the datepicker. | ||
await page.click( '.edit-post-post-schedule__toggle' ); | ||
const panelToggle = await findSidebarPanelToggleButtonWithTitle( | ||
'Publish:' | ||
); | ||
await panelToggle.click(); | ||
|
||
// Change the publishing date to a year in the future. | ||
await page.click( '.components-datetime__time-field-year' ); | ||
await page.keyboard.press( 'ArrowUp' ); | ||
|
||
// Close the datepicker. | ||
await page.click( '.edit-post-post-schedule__toggle' ); | ||
await panelToggle.click(); | ||
|
||
// Open the datepicker. | ||
await page.click( '.edit-post-post-schedule__toggle' ); | ||
await panelToggle.click(); | ||
|
||
// Clear the date | ||
// Clear the date. | ||
await page.click( '.components-datetime__date-reset-button' ); | ||
|
||
const publishingDate = await page.$eval( | ||
'.edit-post-post-schedule__toggle', | ||
( dateLabel ) => dateLabel.textContent | ||
const publishDate = await panelToggle.$eval( | ||
'.editor-post-publish-panel__link', | ||
( publishDateSpan ) => publishDateSpan.textContent | ||
); | ||
|
||
expect( publishingDate ).toEqual( 'Immediately' ); | ||
expect( publishDate ).toEqual( 'Immediately' ); | ||
} ); | ||
} ); |
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
41 changes: 35 additions & 6 deletions
41
packages/edit-post/src/components/sidebar/post-format/index.js
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 |
---|---|---|
@@ -1,20 +1,49 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { PanelRow } from '@wordpress/components'; | ||
import { PanelBody } from '@wordpress/components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { | ||
PostFormat as PostFormatForm, | ||
PostFormatCheck, | ||
} from '@wordpress/editor'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
const PANEL_NAME = 'post-format'; | ||
|
||
export default function PostFormat() { | ||
const { isOpened, isRemoved } = useSelect( ( select ) => { | ||
// We use isEditorPanelRemoved to hide the panel if it was | ||
// programatically removed. We don't use isEditorPanelEnabled since | ||
// this panel should not be disabled through the UI. | ||
const { isEditorPanelRemoved, isEditorPanelOpened } = select( | ||
'core/edit-post' | ||
); | ||
|
||
return { | ||
isOpened: isEditorPanelOpened( PANEL_NAME ), | ||
isRemoved: isEditorPanelRemoved( PANEL_NAME ), | ||
}; | ||
}, [] ); | ||
|
||
const { toggleEditorPanelOpened } = useDispatch( 'core/edit-post' ); | ||
|
||
if ( isRemoved ) { | ||
return null; | ||
} | ||
|
||
export function PostFormat() { | ||
return ( | ||
<PostFormatCheck> | ||
<PanelRow> | ||
<PanelBody | ||
initialOpen={ false } | ||
opened={ isOpened } | ||
onToggle={ () => { | ||
toggleEditorPanelOpened( PANEL_NAME ); | ||
} } | ||
title={ __( 'Post Format' ) } | ||
> | ||
<PostFormatForm /> | ||
</PanelRow> | ||
</PanelBody> | ||
</PostFormatCheck> | ||
); | ||
} | ||
|
||
export default PostFormat; |
Oops, something went wrong.