{
this.setState({
organizationName: value,
groupName: "",
});
this.props.history.push(`/trees/${value}`);
}}
/>
);
}
}
newGroup(isRoot) {
const randomName = Setting.getRandomName();
return {
owner: this.state.organizationName,
name: `group_${randomName}`,
createdTime: moment().format(),
updatedTime: moment().format(),
displayName: `New Group - ${randomName}`,
type: "Virtual",
parentId: isRoot ? this.state.organizationName : this.state.groupName,
isTopGroup: isRoot,
isEnabled: true,
};
}
addGroup(isRoot = false) {
const newGroup = this.newGroup(isRoot);
GroupBackend.addGroup(newGroup)
.then((res) => {
if (res.status === "ok") {
sessionStorage.setItem("groupTreeUrl", window.location.pathname);
this.props.history.push({pathname: `/groups/${newGroup.owner}/${newGroup.name}`, mode: "add"});
Setting.showMessage("success", i18next.t("general:Successfully added"));
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to add")}: ${res.msg}`);
}
})
.catch(error => {
Setting.showMessage("error", `${i18next.t("general:Failed to connect to server")}: ${error}`);
});
}
render() {
return (
{this.renderOrganizationSelect()}
{this.renderTree()}
);
}
}
export default GroupTreePage;