2022-02-13 23:39:27 +08:00
|
|
|
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
|
2021-02-13 13:30:51 +08:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
import React from "react";
|
2023-02-01 22:06:40 +08:00
|
|
|
import {Button, Card, Col, Input, InputNumber, Radio, Row, Select, Switch} from "antd";
|
2021-02-13 12:15:19 +08:00
|
|
|
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
2022-09-10 20:41:45 +08:00
|
|
|
import * as ApplicationBackend from "./backend/ApplicationBackend";
|
2021-07-17 14:13:00 +08:00
|
|
|
import * as LdapBackend from "./backend/LdapBackend";
|
2021-02-13 12:15:19 +08:00
|
|
|
import * as Setting from "./Setting";
|
2023-02-12 18:56:56 +08:00
|
|
|
import * as Conf from "./Conf";
|
2021-02-19 23:23:59 +08:00
|
|
|
import i18next from "i18next";
|
2021-04-29 20:27:07 +08:00
|
|
|
import {LinkOutlined} from "@ant-design/icons";
|
2023-03-26 18:44:47 +08:00
|
|
|
import LdapTable from "./table/LdapTable";
|
|
|
|
import AccountTable from "./table/AccountTable";
|
2023-02-01 22:06:40 +08:00
|
|
|
import ThemeEditor from "./common/theme/ThemeEditor";
|
2023-05-17 01:13:13 +08:00
|
|
|
import MfaTable from "./table/MfaTable";
|
2021-02-13 12:15:19 +08:00
|
|
|
|
2022-07-10 15:45:55 +08:00
|
|
|
const {Option} = Select;
|
2021-05-05 23:32:21 +08:00
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
class OrganizationEditPage extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
classes: props,
|
|
|
|
organizationName: props.match.params.organizationName,
|
|
|
|
organization: null,
|
2022-09-10 20:41:45 +08:00
|
|
|
applications: [],
|
2021-07-17 14:13:00 +08:00
|
|
|
ldaps: null,
|
2022-02-25 18:16:02 +08:00
|
|
|
mode: props.location.mode !== undefined ? props.location.mode : "edit",
|
2021-02-13 12:15:19 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-03-27 11:38:15 +08:00
|
|
|
UNSAFE_componentWillMount() {
|
2021-02-13 12:15:19 +08:00
|
|
|
this.getOrganization();
|
2022-09-10 20:41:45 +08:00
|
|
|
this.getApplications();
|
2021-07-17 14:13:00 +08:00
|
|
|
this.getLdaps();
|
2021-02-13 12:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
getOrganization() {
|
|
|
|
OrganizationBackend.getOrganization("admin", this.state.organizationName)
|
2023-06-14 23:27:46 +08:00
|
|
|
.then((res) => {
|
|
|
|
if (res.status === "ok") {
|
|
|
|
const organization = res.data;
|
|
|
|
if (organization === null) {
|
|
|
|
this.props.history.push("/404");
|
|
|
|
return;
|
|
|
|
}
|
2023-06-09 21:52:30 +08:00
|
|
|
|
2023-06-14 23:27:46 +08:00
|
|
|
this.setState({
|
|
|
|
organization: organization,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Setting.showMessage("error", res.msg);
|
|
|
|
}
|
2021-02-13 12:15:19 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-09-10 20:41:45 +08:00
|
|
|
getApplications() {
|
|
|
|
ApplicationBackend.getApplicationsByOrganization("admin", this.state.organizationName)
|
2023-06-27 20:33:47 +07:00
|
|
|
.then((res) => {
|
|
|
|
if (res.status === "error") {
|
|
|
|
Setting.showMessage("error", res.msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-09-10 20:41:45 +08:00
|
|
|
this.setState({
|
2023-07-23 09:49:16 +08:00
|
|
|
applications: res.data || [],
|
2022-09-10 20:41:45 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-17 14:13:00 +08:00
|
|
|
getLdaps() {
|
|
|
|
LdapBackend.getLdaps(this.state.organizationName)
|
|
|
|
.then(res => {
|
2022-07-10 15:45:55 +08:00
|
|
|
let resdata = [];
|
2021-07-17 14:13:00 +08:00
|
|
|
if (res.status === "ok") {
|
|
|
|
if (res.data !== null) {
|
|
|
|
resdata = res.data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setState({
|
2022-08-06 23:54:56 +08:00
|
|
|
ldaps: resdata,
|
2022-07-10 15:45:55 +08:00
|
|
|
});
|
|
|
|
});
|
2021-07-17 14:13:00 +08:00
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
parseOrganizationField(key, value) {
|
|
|
|
// if ([].includes(key)) {
|
|
|
|
// value = Setting.myParseInt(value);
|
|
|
|
// }
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateOrganizationField(key, value) {
|
|
|
|
value = this.parseOrganizationField(key, value);
|
2022-08-08 23:35:24 +08:00
|
|
|
const organization = this.state.organization;
|
2021-02-13 12:15:19 +08:00
|
|
|
organization[key] = value;
|
|
|
|
this.setState({
|
|
|
|
organization: organization,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
renderOrganization() {
|
|
|
|
return (
|
|
|
|
<Card size="small" title={
|
|
|
|
<div>
|
2022-02-25 18:16:02 +08:00
|
|
|
{this.state.mode === "add" ? i18next.t("organization:New Organization") : i18next.t("organization:Edit Organization")}
|
2021-12-12 17:12:15 +08:00
|
|
|
<Button onClick={() => this.submitOrganizationEdit(false)}>{i18next.t("general:Save")}</Button>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Button style={{marginLeft: "20px"}} type="primary" onClick={() => this.submitOrganizationEdit(true)}>{i18next.t("general:Save & Exit")}</Button>
|
|
|
|
{this.state.mode === "add" ? <Button style={{marginLeft: "20px"}} onClick={() => this.deleteOrganization()}>{i18next.t("general:Cancel")}</Button> : null}
|
2021-02-13 12:15:19 +08:00
|
|
|
</div>
|
2022-08-06 23:43:09 +08:00
|
|
|
} style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner">
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "10px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} :
|
2021-02-13 12:15:19 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2021-12-23 00:40:07 +08:00
|
|
|
<Input value={this.state.organization.name} disabled={this.state.organization.name === "built-in"} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateOrganizationField("name", e.target.value);
|
2021-02-13 12:15:19 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Display name"), i18next.t("general:Display name - Tooltip"))} :
|
2021-02-13 12:15:19 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.organization.displayName} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateOrganizationField("displayName", e.target.value);
|
2021-02-13 12:15:19 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:Favicon"), i18next.t("general:Favicon - Tooltip"))} :
|
2021-04-29 20:27:07 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 1}>
|
2022-02-27 18:20:58 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:URL"), i18next.t("general:URL - Tooltip"))} :
|
2021-04-29 20:27:07 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={23} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Input prefix={<LinkOutlined />} value={this.state.organization.favicon} onChange={e => {
|
|
|
|
this.updateOrganizationField("favicon", e.target.value);
|
2021-04-29 20:27:07 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 1}>
|
2021-04-29 20:27:07 +08:00
|
|
|
{i18next.t("general:Preview")}:
|
|
|
|
</Col>
|
|
|
|
<Col span={23} >
|
|
|
|
<a target="_blank" rel="noreferrer" href={this.state.organization.favicon}>
|
2022-07-10 15:45:55 +08:00
|
|
|
<img src={this.state.organization.favicon} alt={this.state.organization.favicon} height={90} style={{marginBottom: "20px"}} />
|
2021-04-29 20:27:07 +08:00
|
|
|
</a>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("organization:Website URL"), i18next.t("organization:Website URL - Tooltip"))} :
|
2021-02-13 12:15:19 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Input prefix={<LinkOutlined />} value={this.state.organization.websiteUrl} onChange={e => {
|
|
|
|
this.updateOrganizationField("websiteUrl", e.target.value);
|
2021-02-13 12:15:19 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Password type"), i18next.t("general:Password type - Tooltip"))} :
|
2021-05-05 23:32:21 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2023-01-12 23:11:11 +08:00
|
|
|
<Select virtual={false} style={{width: "100%"}} value={this.state.organization.passwordType} onChange={(value => {this.updateOrganizationField("passwordType", value);})}
|
|
|
|
options={["plain", "salt", "md5-salt", "bcrypt", "pbkdf2-salt", "argon2id"].map(item => Setting.getOption(item, item))}
|
|
|
|
/>
|
2021-05-05 23:32:21 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Password salt"), i18next.t("general:Password salt - Tooltip"))} :
|
2021-05-05 23:40:18 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.organization.passwordSalt} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateOrganizationField("passwordSalt", e.target.value);
|
2021-05-05 23:40:18 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2023-06-17 00:01:20 +08:00
|
|
|
<Row style={{marginTop: "20px"}}>
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:Password complexity options"), i18next.t("general:Password complexity options - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Select
|
|
|
|
virtual={false}
|
|
|
|
style={{width: "100%"}}
|
|
|
|
mode="multiple"
|
|
|
|
value={this.state.organization.passwordOptions}
|
|
|
|
onChange={(value => {
|
|
|
|
this.updateOrganizationField("passwordOptions", value);
|
|
|
|
})}
|
|
|
|
options={[
|
|
|
|
{value: "AtLeast6", name: i18next.t("user:The password must have at least 6 characters")},
|
|
|
|
{value: "AtLeast8", name: i18next.t("user:The password must have at least 8 characters")},
|
|
|
|
{value: "Aa123", name: i18next.t("user:The password must contain at least one uppercase letter, one lowercase letter and one digit")},
|
|
|
|
{value: "SpecialChar", name: i18next.t("user:The password must contain at least one special character")},
|
|
|
|
{value: "NoRepeat", name: i18next.t("user:The password must not contain any repeated characters")},
|
|
|
|
].map((item) => Setting.getOption(item.name, item.value))}
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2023-02-25 15:46:54 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Supported country codes"), i18next.t("general:Supported country codes - Tooltip"))} :
|
2021-05-13 09:39:07 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2023-02-16 22:53:28 +08:00
|
|
|
<Select virtual={false} mode={"multiple"} style={{width: "100%"}} value={this.state.organization.countryCodes ?? []}
|
2023-02-25 15:25:47 +08:00
|
|
|
onChange={value => {
|
2023-02-16 22:53:28 +08:00
|
|
|
this.updateOrganizationField("countryCodes", value);
|
2023-02-25 15:25:47 +08:00
|
|
|
}}
|
|
|
|
filterOption={(input, option) => (option?.text ?? "").toLowerCase().includes(input.toLowerCase())}
|
|
|
|
>
|
|
|
|
{
|
|
|
|
Setting.getCountryCodeData().map((country) => Setting.getCountryCodeOption(country))
|
|
|
|
}
|
|
|
|
</Select>
|
2021-05-13 09:39:07 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2023-05-18 13:36:16 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:Languages"), i18next.t("general:Languages - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2023-05-31 17:36:11 +08:00
|
|
|
<Select virtual={false} mode="multiple" style={{width: "100%"}}
|
2023-05-18 13:36:16 +08:00
|
|
|
options={Setting.Countries.map((item) => {
|
|
|
|
return Setting.getOption(item.label, item.key);
|
|
|
|
})}
|
|
|
|
value={this.state.organization.languages ?? []}
|
|
|
|
onChange={(value => {
|
|
|
|
this.updateOrganizationField("languages", value);
|
|
|
|
})} >
|
|
|
|
</Select>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Default avatar"), i18next.t("general:Default avatar - Tooltip"))} :
|
2021-06-17 01:12:03 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 1}>
|
2022-02-27 18:20:58 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:URL"), i18next.t("general:URL - Tooltip"))} :
|
2021-06-17 01:12:03 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={23} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Input prefix={<LinkOutlined />} value={this.state.organization.defaultAvatar} onChange={e => {
|
|
|
|
this.updateOrganizationField("defaultAvatar", e.target.value);
|
2021-06-17 01:12:03 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 1}>
|
2021-06-17 01:12:03 +08:00
|
|
|
{i18next.t("general:Preview")}:
|
|
|
|
</Col>
|
|
|
|
<Col span={23} >
|
|
|
|
<a target="_blank" rel="noreferrer" href={this.state.organization.defaultAvatar}>
|
2022-07-10 15:45:55 +08:00
|
|
|
<img src={this.state.organization.defaultAvatar} alt={this.state.organization.defaultAvatar} height={90} style={{marginBottom: "20px"}} />
|
2021-06-17 01:12:03 +08:00
|
|
|
</a>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-09-10 20:41:45 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:Default application"), i18next.t("general:Default application - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2023-01-12 23:11:11 +08:00
|
|
|
<Select virtual={false} style={{width: "100%"}} value={this.state.organization.defaultApplication} onChange={(value => {this.updateOrganizationField("defaultApplication", value);})}
|
|
|
|
options={this.state.applications?.map((item) => Setting.getOption(item.name, item.name))
|
|
|
|
} />
|
2022-09-10 20:41:45 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-03-13 00:30:18 +08:00
|
|
|
{Setting.getLabel(i18next.t("organization:Tags"), i18next.t("organization:Tags - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Select virtual={false} mode="tags" style={{width: "100%"}} value={this.state.organization.tags} onChange={(value => {this.updateOrganizationField("tags", value);})}>
|
2022-03-13 00:30:18 +08:00
|
|
|
{
|
|
|
|
this.state.organization.tags?.map((item, index) => <Option key={index} value={item}>{item}</Option>)
|
|
|
|
}
|
|
|
|
</Select>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-11-06 21:14:53 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Master password"), i18next.t("general:Master password - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.organization.masterPassword} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateOrganizationField("masterPassword", e.target.value);
|
2021-11-06 21:14:53 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2023-10-18 11:58:25 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:Default password"), i18next.t("general:Default password - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.organization.defaultPassword} onChange={e => {
|
|
|
|
this.updateOrganizationField("defaultPassword", e.target.value);
|
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2023-11-13 13:53:41 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:Master verification code"), i18next.t("general:Master verification code - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.organization.masterVerificationCode} onChange={e => {
|
|
|
|
this.updateOrganizationField("masterVerificationCode", e.target.value);
|
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-12-10 22:27:12 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 19 : 2}>
|
2023-03-18 10:16:35 +08:00
|
|
|
{Setting.getLabel(i18next.t("organization:Init score"), i18next.t("organization:Init score - Tooltip"))} :
|
2022-12-10 22:27:12 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={4} >
|
|
|
|
<InputNumber value={this.state.organization.initScore} onChange={value => {
|
|
|
|
this.updateOrganizationField("initScore", value);
|
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 19 : 2}>
|
2021-11-06 15:52:03 +08:00
|
|
|
{Setting.getLabel(i18next.t("organization:Soft deletion"), i18next.t("organization:Soft deletion - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={1} >
|
|
|
|
<Switch checked={this.state.organization.enableSoftDeletion} onChange={checked => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateOrganizationField("enableSoftDeletion", checked);
|
2021-11-06 15:52:03 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 19 : 2}>
|
2022-04-16 15:10:03 +08:00
|
|
|
{Setting.getLabel(i18next.t("organization:Is profile public"), i18next.t("organization:Is profile public - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={1} >
|
|
|
|
<Switch checked={this.state.organization.isProfilePublic} onChange={checked => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateOrganizationField("isProfilePublic", checked);
|
2022-04-16 15:10:03 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-06-18 01:41:21 +08:00
|
|
|
{Setting.getLabel(i18next.t("organization:Account items"), i18next.t("organization:Account items - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<AccountTable
|
|
|
|
title={i18next.t("organization:Account items")}
|
|
|
|
table={this.state.organization.accountItems}
|
2022-07-10 15:45:55 +08:00
|
|
|
onUpdateTable={(value) => {this.updateOrganizationField("accountItems", value);}}
|
2022-06-18 01:41:21 +08:00
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2023-05-17 01:13:13 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:MFA items"), i18next.t("general:MFA items - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<MfaTable
|
|
|
|
title={i18next.t("general:MFA items")}
|
|
|
|
table={this.state.organization.mfaItems ?? []}
|
|
|
|
onUpdateTable={(value) => {this.updateOrganizationField("mfaItems", value);}}
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2023-02-01 22:06:40 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("theme:Theme"), i18next.t("theme:Theme - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} style={{marginTop: "5px"}}>
|
|
|
|
<Row>
|
|
|
|
<Radio.Group value={this.state.organization.themeData?.isEnabled ?? false} onChange={e => {
|
2023-02-12 18:56:56 +08:00
|
|
|
const {_, ...theme} = this.state.organization.themeData ?? {...Conf.ThemeDefault, isEnabled: false};
|
2023-02-01 22:06:40 +08:00
|
|
|
this.updateOrganizationField("themeData", {...theme, isEnabled: e.target.value});
|
|
|
|
}} >
|
|
|
|
<Radio.Button value={false}>{i18next.t("organization:Follow global theme")}</Radio.Button>
|
|
|
|
<Radio.Button value={true}>{i18next.t("theme:Customize theme")}</Radio.Button>
|
|
|
|
</Radio.Group>
|
|
|
|
</Row>
|
|
|
|
{
|
|
|
|
this.state.organization.themeData?.isEnabled ?
|
|
|
|
<Row style={{marginTop: "20px"}}>
|
|
|
|
<ThemeEditor themeData={this.state.organization.themeData} onThemeChange={(_, nextThemeData) => {
|
2023-02-12 18:56:56 +08:00
|
|
|
const {isEnabled} = this.state.organization.themeData ?? {...Conf.ThemeDefault, isEnabled: false};
|
2023-02-01 22:06:40 +08:00
|
|
|
this.updateOrganizationField("themeData", {...nextThemeData, isEnabled});
|
|
|
|
}} />
|
|
|
|
</Row> : null
|
|
|
|
}
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}}>
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-07-17 14:13:00 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:LDAPs"), i18next.t("general:LDAPs - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22}>
|
|
|
|
<LdapTable
|
|
|
|
title={i18next.t("general:LDAPs")}
|
|
|
|
table={this.state.ldaps}
|
|
|
|
organizationName={this.state.organizationName}
|
|
|
|
onUpdateTable={(value) => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.setState({ldaps: value});
|
|
|
|
}}
|
2021-07-17 14:13:00 +08:00
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2021-02-13 12:15:19 +08:00
|
|
|
</Card>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2021-02-13 12:15:19 +08:00
|
|
|
}
|
|
|
|
|
2023-10-10 21:47:38 +08:00
|
|
|
submitOrganizationEdit(exitAfterSave) {
|
2022-08-08 23:35:24 +08:00
|
|
|
const organization = Setting.deepCopy(this.state.organization);
|
2023-05-05 21:23:59 +08:00
|
|
|
organization.accountItems = organization.accountItems?.filter(accountItem => accountItem.name !== "Please select an account item");
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
OrganizationBackend.updateOrganization(this.state.organization.owner, this.state.organizationName, organization)
|
|
|
|
.then((res) => {
|
2022-11-29 20:32:47 +08:00
|
|
|
if (res.status === "ok") {
|
2022-12-02 00:06:28 +08:00
|
|
|
Setting.showMessage("success", i18next.t("general:Successfully saved"));
|
2023-02-01 22:06:40 +08:00
|
|
|
|
|
|
|
if (this.props.account.organization.name === this.state.organizationName) {
|
|
|
|
this.props.onChangeTheme(Setting.getThemeData(this.state.organization));
|
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
this.setState({
|
|
|
|
organizationName: this.state.organization.name,
|
|
|
|
});
|
2023-06-30 01:38:48 +08:00
|
|
|
window.dispatchEvent(new Event("storageOrganizationsChanged"));
|
2021-12-12 17:12:15 +08:00
|
|
|
|
2023-10-10 21:47:38 +08:00
|
|
|
if (exitAfterSave) {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.props.history.push("/organizations");
|
2021-12-12 17:12:15 +08:00
|
|
|
} else {
|
|
|
|
this.props.history.push(`/organizations/${this.state.organization.name}`);
|
|
|
|
}
|
2021-02-13 12:15:19 +08:00
|
|
|
} else {
|
2022-12-02 00:06:28 +08:00
|
|
|
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateOrganizationField("name", this.state.organizationName);
|
2021-02-13 12:15:19 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(error => {
|
2022-12-02 00:06:28 +08:00
|
|
|
Setting.showMessage("error", `${i18next.t("general:Failed to connect to server")}: ${error}`);
|
2021-02-13 12:15:19 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-02-25 18:16:02 +08:00
|
|
|
deleteOrganization() {
|
|
|
|
OrganizationBackend.deleteOrganization(this.state.organization)
|
2022-12-02 00:06:28 +08:00
|
|
|
.then((res) => {
|
|
|
|
if (res.status === "ok") {
|
|
|
|
this.props.history.push("/organizations");
|
2023-06-30 01:38:48 +08:00
|
|
|
window.dispatchEvent(new Event("storageOrganizationsChanged"));
|
2022-12-02 00:06:28 +08:00
|
|
|
} else {
|
|
|
|
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
|
|
|
|
}
|
2022-02-25 18:16:02 +08:00
|
|
|
})
|
|
|
|
.catch(error => {
|
2022-12-02 00:06:28 +08:00
|
|
|
Setting.showMessage("error", `${i18next.t("general:Failed to connect to server")}: ${error}`);
|
2022-02-25 18:16:02 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
2021-07-23 09:46:01 +08:00
|
|
|
{
|
|
|
|
this.state.organization !== null ? this.renderOrganization() : null
|
|
|
|
}
|
2022-07-10 15:45:55 +08:00
|
|
|
<div style={{marginTop: "20px", marginLeft: "40px"}}>
|
2021-12-12 17:12:15 +08:00
|
|
|
<Button size="large" onClick={() => this.submitOrganizationEdit(false)}>{i18next.t("general:Save")}</Button>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Button style={{marginLeft: "20px"}} type="primary" size="large" onClick={() => this.submitOrganizationEdit(true)}>{i18next.t("general:Save & Exit")}</Button>
|
|
|
|
{this.state.mode === "add" ? <Button style={{marginLeft: "20px"}} size="large" onClick={() => this.deleteOrganization()}>{i18next.t("general:Cancel")}</Button> : null}
|
2021-07-23 09:46:01 +08:00
|
|
|
</div>
|
2021-02-13 12:15:19 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default OrganizationEditPage;
|