Web:Client:PeopleArticle:MainButton: rewrite to functional component

This commit is contained in:
Timofey Boyko 2023-04-05 11:27:29 +03:00
parent cb265de91e
commit 2d59439aba

View File

@ -24,56 +24,30 @@ import MobileView from "./MobileView";
import withLoader from "../../../HOCs/withLoader";
class ArticleMainButtonContent extends React.Component {
constructor(props) {
super(props);
this.state = {
dialogVisible: false,
};
}
goToEmployeeCreate = () => {
const { history, homepage } = this.props;
history.push(
combineUrl(window.DocSpaceConfig?.proxy?.url, homepage, "/create/user")
);
if (isMobile || isMobileUtils()) this.props.toggleShowText();
};
// goToGuestCreate = () => {
// const { history, homepage } = this.props;
// history.push(
// combineUrl(window.DocSpaceConfig?.proxy?.url, homepage, "/create/guest")
// );
// if (isMobile || isMobileUtils()) this.props.toggleShowText();
// };
// goToGroupCreate = () => {
// const { history, homepage } = this.props;
// history.push(
// combineUrl(window.DocSpaceConfig?.proxy?.url, homepage, "/group/create")
// );
// if (isMobile || isMobileUtils()) this.props.toggleShowText();
// };
onInvitationDialogClick = () =>
this.setState({ dialogVisible: !this.state.dialogVisible });
render() {
//console.log("People ArticleMainButtonContent render");
const ArticleMainButtonContent = (props) => {
const [dialogVisible, setDialogVisible] = React.useState(false);
const {
history,
homepage,
toggleShowText,
t,
isAdmin,
homepage,
userCaption,
// guestCaption,
// groupCaption,
sectionWidth,
isMobileArticle,
} = this.props;
} = props;
const { dialogVisible } = this.state;
const goToEmployeeCreate = () => {
history.push(
combineUrl(window.DocSpaceConfig?.proxy?.url, homepage, "/create/user")
);
if (isMobile || isMobileUtils()) toggleShowText();
};
const onInvitationDialogClick = () => setDialogVisible((val) => !val);
const separator = {
key: "separator",
@ -89,28 +63,8 @@ class ArticleMainButtonContent extends React.Component {
AddEmployeeReactSvgUrl
),
label: userCaption,
onClick: this.goToEmployeeCreate,
onClick: goToEmployeeCreate,
},
// {
// key: "create-guest",
// icon: combineUrl(
// window.DocSpaceConfig?.proxy?.url,
// homepage,
// AddGuestReactSvgUrl
// ),
// label: guestCaption,
// onClick: this.goToGuestCreate,
// },
// {
// key: "create-group",
// icon: combineUrl(
// window.DocSpaceConfig?.proxy?.url,
// homepage,
// AddDepartmentReactSvgUrl
// ),
// label: groupCaption,
// onClick: this.goToGroupCreate,
// },
];
const links = [
@ -121,7 +75,7 @@ class ArticleMainButtonContent extends React.Component {
InvitationLinkReactSvgUrl
),
label: t("PeopleTranslations:InviteLinkTitle"),
onClick: this.onInvitationDialogClick,
onClick: onInvitationDialogClick,
},
];
@ -147,16 +101,15 @@ class ArticleMainButtonContent extends React.Component {
{dialogVisible && (
<InviteDialog
visible={dialogVisible}
onClose={this.onInvitationDialogClick}
onCloseButton={this.onInvitationDialogClick}
onClose={onInvitationDialogClick}
onCloseButton={onInvitationDialogClick}
/>
)}
</>
) : (
<></>
);
}
}
};
export default withRouter(
inject(({ auth }) => {