mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-07 07:30:23 +03:00
Merge pull request #2601 from urbit/mp/publish/delete-note
publish: delete notes
This commit is contained in:
commit
024b0717e0
@ -33,6 +33,7 @@ export class Note extends Component {
|
|||||||
});
|
});
|
||||||
this.scrollElement = React.createRef();
|
this.scrollElement = React.createRef();
|
||||||
this.onScroll = this.onScroll.bind(this);
|
this.onScroll = this.onScroll.bind(this);
|
||||||
|
this.deletePost = this.deletePost.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
@ -47,6 +48,16 @@ export class Note extends Component {
|
|||||||
window.api.fetchNote(this.props.ship, this.props.book, this.props.note);
|
window.api.fetchNote(this.props.ship, this.props.book, this.props.note);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
if (!(this.props.notebooks[this.props.ship]) ||
|
||||||
|
!(this.props.notebooks[this.props.ship][this.props.book]) ||
|
||||||
|
!(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note]) ||
|
||||||
|
!(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note].file)) {
|
||||||
|
window.api.fetchNote(this.props.ship, this.props.book, this.props.note);
|
||||||
|
}
|
||||||
|
this.onScroll();
|
||||||
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
if (!(this.props.notebooks[this.props.ship]) ||
|
if (!(this.props.notebooks[this.props.ship]) ||
|
||||||
!(this.props.notebooks[this.props.ship][this.props.book]) ||
|
!(this.props.notebooks[this.props.ship][this.props.book]) ||
|
||||||
@ -97,15 +108,23 @@ export class Note extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
deletePost() {
|
||||||
if (!(this.props.notebooks[this.props.ship]) ||
|
const { props } = this;
|
||||||
!(this.props.notebooks[this.props.ship][this.props.book]) ||
|
let deleteAction = {
|
||||||
!(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note]) ||
|
"del-note": {
|
||||||
!(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note].file))
|
who: this.props.ship.slice(1),
|
||||||
{
|
book: this.props.book,
|
||||||
window.api.fetchNote(this.props.ship, this.props.book, this.props.note);
|
note: this.props.note,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.onScroll();
|
let popout = (props.popout) ? "popout/" : "";
|
||||||
|
let baseUrl = `/~publish/${popout}notebook/${props.ship}/${props.book}`;
|
||||||
|
window.api.setSpinner(true);
|
||||||
|
window.api.action("publish", "publish-action", deleteAction)
|
||||||
|
.then(() => {
|
||||||
|
window.api.setSpinner(false);
|
||||||
|
props.history.push(baseUrl);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -156,8 +175,11 @@ export class Note extends Component {
|
|||||||
let editPost = null;
|
let editPost = null;
|
||||||
let editUrl = props.location.pathname + "/edit";
|
let editUrl = props.location.pathname + "/edit";
|
||||||
if (`~${window.ship}` === author) {
|
if (`~${window.ship}` === author) {
|
||||||
editPost =
|
editPost = <div className="dib">
|
||||||
<Link className="green2 f9" to={editUrl}>Edit</Link>
|
<Link className="green2 f9" to={editUrl}>Edit</Link>
|
||||||
|
<p className="dib f9 red2 ml2 pointer"
|
||||||
|
onClick={(() => this.deletePost())}>Delete</p>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
let popout = (props.popout) ? "popout/" : "";
|
let popout = (props.popout) ? "popout/" : "";
|
||||||
|
@ -183,15 +183,15 @@ export class Notebook extends Component {
|
|||||||
ref={el => {
|
ref={el => {
|
||||||
this.scrollElement = el;
|
this.scrollElement = el;
|
||||||
}}>
|
}}>
|
||||||
|
<div className="w-100 dn-m dn-l dn-xl inter pt4 pb6 f9">
|
||||||
|
<Link to="/~publish">{"<- All Notebooks"}</Link>
|
||||||
|
</div>
|
||||||
<div className="center mw6 f9 h-100"
|
<div className="center mw6 f9 h-100"
|
||||||
style={{ paddingLeft: 16, paddingRight: 16 }}>
|
style={{ paddingLeft: 16, paddingRight: 16 }}>
|
||||||
<SidebarSwitcher
|
<SidebarSwitcher
|
||||||
popout={props.popout}
|
popout={props.popout}
|
||||||
sidebarShown={props.sidebarShown}
|
sidebarShown={props.sidebarShown}
|
||||||
/>
|
/>
|
||||||
<div className="w-100 dn-m dn-l dn-xl inter pt4 pb6 f9">
|
|
||||||
<Link to="/~publish">{"<- All Notebooks"}</Link>
|
|
||||||
</div>
|
|
||||||
<Link
|
<Link
|
||||||
className={"dn absolute right-1 top-1 " + hiddenOnPopout}
|
className={"dn absolute right-1 top-1 " + hiddenOnPopout}
|
||||||
to={popoutHref}
|
to={popoutHref}
|
||||||
|
Loading…
Reference in New Issue
Block a user