People.Client: Invite dialog: added copying after opening

This commit is contained in:
Daniil Senkiv 2019-09-18 18:18:18 +03:00
parent 2d28373abf
commit 27672cbbd4
3 changed files with 28 additions and 17 deletions

View File

@ -29,8 +29,13 @@ class PureArticleMainButtonContent extends React.Component {
toastr.success(text);
};
toggleDialogVisible = () => this.setState({ dialogVisible: !this.state.dialogVisible });
toggleDialogVisible = () => {
this.setState({ dialogVisible: !this.state.dialogVisible }, function () {
this.state.dialogVisible && this.clickChild();
});
}
onSetInviteDialogClick = click => this.clickChild = click;
render() {
console.log("People ArticleMainButtonContent render");
const { isAdmin, settings, t } = this.props;
@ -75,6 +80,7 @@ class PureArticleMainButtonContent extends React.Component {
/>
</MainButton>
<InviteDialog
setClick={this.onSetInviteDialogClick}
visible={this.state.dialogVisible}
onClose={this.toggleDialogVisible}
onCloseButton={this.toggleDialogVisible}

View File

@ -51,6 +51,7 @@ class PureInviteDialog extends React.Component {
}
onCopyLinkToClipboard = () => {
// console.log("COPY");
const { t } = this.props;
const link = document.getElementsByName(textAreaName)[0];
link.select();
@ -91,25 +92,12 @@ class PureInviteDialog extends React.Component {
};
componentDidUpdate(prevProps, prevState) {
if (!prevProps.visible && !prevState.peopleInvitationLink && !prevState.guestInvitationLink) {
componentDidUpdate() {
if (this.props.visible && this.state.peopleInvitationLink && !this.state.guestInvitationLink) {
// console.log('INVITE DIALOG DidUpdate');
const { getInvitationLink } = this.props;
const isGuest = true;
getInvitationLink()
.then((res) => {
// console.log("getInvitationLinkPeople success", res.data.response);
this.setState({
peopleInvitationLink: res.data.response,
isLoading: false
});
})
.catch(e => {
console.error("getInvitationLinkPeople error", e);
this.setState({ isLoading: false });
});
getInvitationLink(isGuest)
.then((res) => {
// console.log("getInvitationLinkGuest success", res.data.response);
@ -122,6 +110,23 @@ class PureInviteDialog extends React.Component {
};
}
componentDidMount() {
this.props.setClick(this.onCopyLinkToClipboard);
const { getInvitationLink } = this.props;
getInvitationLink()
.then((res) => {
console.log("getInvitationLinkPeople success", res.data.response);
this.setState({
peopleInvitationLink: res.data.response,
isLoading: false
});
})
.catch(e => {
console.error("getInvitationLinkPeople error", e);
this.setState({ isLoading: false });
});
}
onClickToCloseButton = () => this.props.onCloseButton && this.props.onCloseButton();
render() {

View File

@ -1802,7 +1802,7 @@ asap@~2.0.6:
integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
"asc-web-components@file:../../../packages/asc-web-components":
version "1.0.86"
version "1.0.87"
dependencies:
moment "^2.24.0"
prop-types "^15.7.2"