Skip to content

Commit 1c4d008

Browse files
committed
Merge pull request #1158 from Automattic/fix/show-scheduled-pages-452
Pages: show scheduled pages and fix empty placeholders
2 parents 31af68a + 1e7323f commit 1c4d008

File tree

2 files changed

+47
-39
lines changed

2 files changed

+47
-39
lines changed

client/my-sites/pages/main.jsx

+37-36
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ var PageList = require( './page-list' ),
1818
config = require( 'config' ),
1919
notices = require( 'notices' );
2020

21-
module.exports = React.createClass({
21+
const statuses = [ 'published', 'drafts', 'scheduled', 'trashed' ];
22+
23+
module.exports = React.createClass( {
2224

2325
displayName: 'Pages',
2426

@@ -49,59 +51,58 @@ module.exports = React.createClass({
4951
},
5052

5153
render: function() {
52-
var siteFilter = this.props.sites.selected ? '/' + this.props.sites.selected : '',
53-
statusSlug = this.props.status,
54-
searchPlaceholder, selectedText, filterStrings;
55-
56-
filterStrings = {
57-
drafts: this.translate( 'Drafts', { context: 'Filter label for pages list' } ),
54+
const status = this.props.status || 'published';
55+
const filterStrings = {
5856
published: this.translate( 'Published', { context: 'Filter label for pages list' } ),
59-
trashed: this.translate( 'Trash', { context: 'Filter label for pages list' } ),
60-
status: this.translate( 'Status' )
57+
drafts: this.translate( 'Drafts', { context: 'Filter label for pages list' } ),
58+
scheduled: this.translate( 'Scheduled', { context: 'Filter label for pages list' } ),
59+
trashed: this.translate( 'Trash', { context: 'Filter label for pages list' } )
60+
};
61+
const searchStrings = {
62+
published: this.translate( 'Search published…', { context: 'Search placeholder for pages list', textOnly: true } ),
63+
drafts: this.translate( 'Search drafts…', { context: 'Search placeholder for pages list', textOnly: true } ),
64+
scheduled: this.translate( 'Search scheduled…', { context: 'Search placeholder for pages list', textOnly: true } ),
65+
trashed: this.translate( 'Search trash…', { context: 'Search placeholder for pages list', textOnly: true } )
6166
};
62-
63-
64-
65-
switch( statusSlug ) {
66-
case 'drafts':
67-
searchPlaceholder = this.translate( 'Search drafts…', { context: 'Search placeholder for pages list', textOnly: true } );
68-
selectedText = filterStrings.drafts;
69-
break;
70-
case 'trashed':
71-
searchPlaceholder = this.translate( 'Search trash…', { context: 'Search placeholder for pages list', textOnly: true } );
72-
selectedText = filterStrings.trashed;
73-
break;
74-
default:
75-
searchPlaceholder = this.translate( 'Search published…', { context: 'Search placeholder for pages list', textOnly: true } );
76-
selectedText = filterStrings.published;
77-
break;
78-
}
79-
8067
return (
8168
<div className="main main-column pages" role="main">
8269
<SidebarNavigation />
83-
84-
<SectionNav selectedText={ selectedText }>
85-
<NavTabs label={ filterStrings.status }>
86-
<NavItem path={ '/pages' + siteFilter } selected={ ! statusSlug }>{ filterStrings.published }</NavItem>
87-
<NavItem path={ '/pages/drafts' + siteFilter } selected={ statusSlug === 'drafts' } >{ filterStrings.drafts }</NavItem>
88-
<NavItem path={ '/pages/trashed' + siteFilter } selected={ statusSlug === 'trashed' } >{ filterStrings.trashed }</NavItem>
70+
<SectionNav selectedText={ filterStrings[ status ] }>
71+
<NavTabs label={ this.translate( 'Status', { context: 'Filter page group label for tabs' } ) }>
72+
{ this.getNavItems( filterStrings, status ) }
8973
</NavTabs>
9074
<Search
9175
pinned={ true }
9276
onSearch={ this.doSearch }
9377
initialValue={ this.props.search }
94-
placeholder={ searchPlaceholder }
78+
placeholder={ searchStrings[ status ] }
9579
analyticsGroup="Pages"
9680
delaySearch={ true }
9781
/>
9882
</SectionNav>
99-
10083
<PageList { ...this.props } />
10184
</div>
10285
);
10386
},
10487

88+
getNavItems( filterStrings, currentStatus ) {
89+
const siteFilter = this.props.sites.selected ? '/' + this.props.sites.selected : '';
90+
return statuses.map( function( status ) {
91+
let path = `/pages${ siteFilter }`;
92+
if ( status !== 'publish' ) {
93+
path = `/pages/${ status }${ siteFilter }`;
94+
}
95+
return (
96+
<NavItem
97+
path={ path }
98+
selected={ currentStatus === status }
99+
key={ `page-filter-${ status }` }>
100+
{ filterStrings[ status ] }
101+
</NavItem>
102+
);
103+
} );
104+
},
105+
105106
_setWarning( selectedSite ) {
106107
if ( selectedSite && selectedSite.jetpack && ! selectedSite.hasMinimumJetpackVersion ) {
107108
notices.warning(
@@ -110,4 +111,4 @@ module.exports = React.createClass({
110111
);
111112
}
112113
}
113-
});
114+
} );

client/my-sites/pages/page-list.jsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ var PageList = React.createClass( {
2626
context: React.PropTypes.object,
2727
search: React.PropTypes.string,
2828
sites: React.PropTypes.object,
29-
statusSlug: React.PropTypes.string,
3029
siteID: React.PropTypes.any
3130
},
3231

@@ -60,7 +59,6 @@ var Pages = React.createClass({
6059
search: React.PropTypes.string,
6160
siteID: React.PropTypes.any,
6261
sites: React.PropTypes.object.isRequired,
63-
statusSlug: React.PropTypes.string,
6462
trackScrollPage: React.PropTypes.func.isRequired
6563
},
6664

@@ -137,7 +135,8 @@ var Pages = React.createClass({
137135
newPageLink = selectedSite ? '//wordpress.com/page/' + selectedSite.ID + '/new' : '//wordpress.com/page';
138136
}
139137

140-
switch( this.props.statusSlug ) {
138+
const status = this.props.status || 'published';
139+
switch ( status ) {
141140
case 'drafts':
142141
attributes = {
143142
title: this.translate( 'You don\'t have any drafts.' ),
@@ -146,6 +145,14 @@ var Pages = React.createClass({
146145
actionURL: newPageLink
147146
};
148147
break;
148+
case 'scheduled':
149+
attributes = {
150+
title: this.translate( 'You don\'t have any scheduled pages yet.' ),
151+
line: this.translate( 'Would you like to create one?' ),
152+
action: this.translate( 'Start a Page' ),
153+
actionURL: newPageLink
154+
};
155+
break;
149156
case 'trashed':
150157
attributes = {
151158
title: this.translate( 'You don\'t have any pages in your trash folder.' ),

0 commit comments

Comments
 (0)