Skip to content

Commit

Permalink
Merge pull request #122 from 10up/feature/gutenberg-sidebar-status-av…
Browse files Browse the repository at this point in the history
…ailability-panel

Add Gutenberg sidebar status availability panel
  • Loading branch information
tlovett1 authored May 7, 2018
2 parents 4faa4bd + cd687e7 commit 5aa5a13
Show file tree
Hide file tree
Showing 28 changed files with 10,063 additions and 2,264 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets" : ["env"]
"presets" : ["env", "react"]
}
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"camelcase": [ 1 ],
"no-debugger": [ 1 ],
"no-unused-vars": [ 1 ],
"function-paren-newline": [ 1, "never" ]
"function-paren-newline": [ 1, "never" ],
"no-extra-boolean-cast": [ 1 ]
}
}
54 changes: 54 additions & 0 deletions assets/css/gutenberg-syndicated-post.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
body.dt-linked-post {

& .edit-post-visual-editor,
& .editor-post-excerpt__textarea {
opacity: .5;
pointer-events: none;
cursor: default;
}

& input,
& select,
& button,
& textarea,
& .button {
opacity: .5;
pointer-events: none;
cursor: default;
}

& .edit-post-header__settings,
& .components-time-picker,
& .react-datepicker,
& .components-panel__header {
& input,
& select,
& button,
& textarea,
& .button {
opacity: 1;
pointer-events: auto;
cursor: pointer;
}
}

& .components-panel__body-toggle,
& .edit-post-post-visibility__toggle,
& .editor-post-trash,
& .edit-post-post-schedule__toggle,
& .components-menu-item__button {
opacity: 1;
pointer-events: auto;
cursor: pointer;
}

& #post-sticky-toggle-0 {
pointer-events: auto;
cursor: pointer;
}

& .edit-post-last-revision__panel {
display: none;
}

}
36 changes: 36 additions & 0 deletions assets/js/gutenberg-status-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { wp, dtGutenberg } from 'window';

const { registerPlugin } = wp.plugins;
const { PluginPostStatusInfo } = wp.editPost;
const { __ } = wp.i18n;
const { PanelRow } = wp.components;

const renderDistributedFrom = () => {
return(
<PluginPostStatusInfo>
<span id='distributed-from'>
{ __( 'Distributed on: ' ) }
<strong> { dtGutenberg.syndicationTime } </strong>
</span>
</PluginPostStatusInfo>
)
}

const renderDistributedTo = () => {
return(
<PluginPostStatusInfo>
<span id='distributed-to'>
{ wp.i18n.sprintf(
wp.i18n.__( "Distributed to %1$s connection%2$s.", 'distributor' ),
dtGutenberg.syndicationCount,
'1' === dtGutenberg.syndicationCount ? '' : 's'
) }
</span>
</PluginPostStatusInfo>
)
}

const renderFunction = ( dtGutenberg.syndicationCount > 0 ) ? renderDistributedTo : renderDistributedFrom

registerPlugin( 'distributor-status-panel', { render: renderFunction } );

76 changes: 76 additions & 0 deletions assets/js/gutenberg-syndicated-post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { wp, dtGutenberg } from 'window'
const { registerPlugin } = wp.plugins;


wp.i18n.setLocaleData( dtGutenberg.i18n, 'distributor' )

if ( '0' !== dtGutenberg.originalSourceId ) {

const messages = []

if ( parseInt( dtGutenberg.originalDeleted ) ) {
messages.push( wp.i18n.sprintf( wp.i18n.__( 'This %s was distributed from ' ), dtGutenberg.postTypeSingular ) )
messages.push( wp.element.createElement( 'a', {
href: dtGutenberg.postUrl,
key: 'original-location-link'
}, [
dtGutenberg.originalLocationName
] ) )
messages.push( wp.i18n.__( '. However, the original has been deleted.' ) )
} else if ( ! parseInt( dtGutenberg.unlinked ) ) {
messages.push( wp.i18n.__( 'Distributed from ', 'distributor' ) )

messages.push( wp.element.createElement( 'a', {
href: dtGutenberg.postUrl,
key: 'original-location-link'
}, [
dtGutenberg.originalLocationName
] ) )

messages.push( '.' )

messages.push(
wp.element.createElement( 'span', {
key: 'message-span'
}, [
wp.i18n.sprintf( wp.i18n.__( " The original %1$s will update this version unless you ", 'distributor' ), dtGutenberg.postTypeSingular.toLowerCase() ),
wp.element.createElement( 'a', {
href: dtGutenberg.unlinkNonceUrl,
key: 'original-unlink'
}, [
wp.i18n.__( 'unlink from the original.', 'distributor' )
] )
] ) )
} else {
messages.push( wp.i18n.__( 'Originally distributed from ', 'distributor' ) )

messages.push( wp.element.createElement( 'a', {
href: dtGutenberg.postUrl,
key: 'original-location-link'
}, [
dtGutenberg.originalLocationName
] ) )

messages.push( '.' )

messages.push( wp.element.createElement( 'span', {
key: 'message-span'
}, [
wp.i18n.sprintf( wp.i18n.__( " This %1$s has been unlinked from the original. However, you can always ", 'distributor' ), dtGutenberg.postTypeSingular.toLowerCase() ),
wp.element.createElement( 'a', {
href: dtGutenberg.linkNonceUrl,
key: 'original-restore-link'
}, [
wp.i18n.__( 'restore it.', 'distributor' )
] )
] ) )
}

const messageElement = wp.element.createElement( 'p', {
className: 'dt-message-wrapper'
}, messages )

wp.data.dispatch( 'core/editor' ).createWarningNotice( messageElement, {
isDismissible: false
} )
}
2 changes: 2 additions & 0 deletions dist/css/gutenberg-syndicated-post.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/css/gutenberg-syndicated-post.min.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5aa5a13

Please sign in to comment.