diff --git a/editor/post-permalink/index.js b/editor/post-permalink/index.js index 12a2e0535fbe2..7ca0f6ec32c81 100644 --- a/editor/post-permalink/index.js +++ b/editor/post-permalink/index.js @@ -21,8 +21,12 @@ class PostPermalink extends Component { super( ...arguments ); this.state = { showCopyConfirmation: false, + editingSlug: false, }; this.onCopy = this.onCopy.bind( this ); + this.onEditPermalink = this.onEditPermalink.bind( this ); + this.onCancelEditPermalink = this.onCancelEditPermalink.bind( this ); + this.onSavePermalink = this.onSavePermalink.bind( this ); } componentWillUnmount() { @@ -42,8 +46,24 @@ class PostPermalink extends Component { }, 4000 ); } + onEditPermalink( event ) { + event.preventDefault(); + this.setState( { editingSlug: true } ); + } + + onCancelEditPermalink( event ) { + event.preventDefault(); + this.setState( { editingSlug: false } ); + } + + onSavePermalink( event ) { + event.preventDefault(); + this.setState( { editingSlug: false } ); + } + render() { const { isNew, link, samplePermalink } = this.props; + const { showCopyConfirmation, editingSlug } = this.state; if ( isNew || ! link ) { return null; } @@ -55,15 +75,39 @@ class PostPermalink extends Component { viewLink += '&preview=true'; } + const prefix = permalink.replace( /[^/]+\/?$/, '' ), + slug = permalink.replace( /.*\/([^/]+)\/?$/, '$1' ); + return (
{ __( 'Permalink:' ) } - + + + { prefix } + + { ! editingSlug && + + { slug } + + } + { editingSlug && +
+ +
+ } +
- { this.state.showCopyConfirmation ? __( 'Copied!' ) : __( 'Copy' ) } + { showCopyConfirmation ? __( 'Copied!' ) : __( 'Copy' ) }
); diff --git a/editor/post-permalink/style.scss b/editor/post-permalink/style.scss index 533363079232c..b4f1b06bdd452 100644 --- a/editor/post-permalink/style.scss +++ b/editor/post-permalink/style.scss @@ -35,3 +35,13 @@ @include long-content-fade( $size: 20% ); } } + +.editor-post-permalink__slug { + color: $dark-gray-300; + font-weight: bold; + cursor: pointer; +} + +.editor-post-permalink__slug-form { + display: inline; +}