add copy document link to the share menu

This commit is contained in:
2019-09-15 17:57:12 +03:00
parent 49ada9f963
commit d2b42b1014

View File

@@ -67,6 +67,7 @@ export class DocumentEditComponent extends React.PureComponent<
this.handleNameKeyPress = this.handleNameKeyPress.bind(this); this.handleNameKeyPress = this.handleNameKeyPress.bind(this);
this.share = this.share.bind(this); this.share = this.share.bind(this);
this.remove = this.remove.bind(this); this.remove = this.remove.bind(this);
this.copyLink = this.copyLink.bind(this);
this.save = this.save.bind(this); this.save = this.save.bind(this);
this.onUnload = this.onUnload.bind(this); this.onUnload = this.onUnload.bind(this);
} }
@@ -101,6 +102,13 @@ export class DocumentEditComponent extends React.PureComponent<
} }
content={ content={
<Menu> <Menu>
{doc.shared && (
<MenuItem
icon="clipboard"
text={"Copy link"}
onClick={this.copyLink}
/>
)}
<MenuItem <MenuItem
icon="globe" icon="globe"
text={ text={
@@ -165,16 +173,21 @@ export class DocumentEditComponent extends React.PureComponent<
} }
} }
public copyLink() {
const doc = this.props.allDocs[this.state.id];
navigator.clipboard.writeText(
`http://localhost:1234/shared/${this.props.username}/${doc.id}`,
);
showSharedToast();
}
public share() { public share() {
const doc = this.props.allDocs[this.state.id]; const doc = this.props.allDocs[this.state.id];
const updShared = !doc.shared; const updShared = !doc.shared;
if (updShared) { if (updShared) {
navigator.clipboard.writeText( this.copyLink();
`http://localhost:1234/shared/${this.props.username}/${doc.id}`,
);
showSharedToast();
} }
this.props.updateDoc(this.state.id, doc.name, doc.content, updShared); this.props.updateDoc(this.state.id, doc.name, doc.content, updShared);