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 (