feat: improve user edit page to fix missing fields and page crash (#1463)

This commit is contained in:
Yaodong Yu 2023-01-11 16:15:06 +08:00 committed by GitHub
parent ce2a4bbf6e
commit ead844131e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 16 deletions

View File

@ -284,12 +284,19 @@ class UserEditPage extends React.Component {
{Setting.getLabel(i18next.t("general:Email"), i18next.t("general:Email - Tooltip"))} : {Setting.getLabel(i18next.t("general:Email"), i18next.t("general:Email - Tooltip"))} :
</Col> </Col>
<Col style={{paddingRight: "20px"}} span={11} > <Col style={{paddingRight: "20px"}} span={11} >
<Select value={this.state.user.email} {Setting.isLocalAdminUser(this.props.account) ?
options={[Setting.getItem(this.state.user.email, this.state.user.email)]} (<Input value={this.state.user.email}
disabled={disabled} disabled={disabled}
onChange={e => { onChange={e => {
this.updateUserField("email", e.target.value); this.updateUserField("email", e.target.value);
}} /> }} />) :
(<Select value={this.state.user.email}
options={[Setting.getItem(this.state.user.email, this.state.user.email)]}
disabled={disabled}
onChange={e => {
this.updateUserField("email", e.target.value);
}} />)
}
</Col> </Col>
<Col span={11} > <Col span={11} >
{/* backend auto get the current user, so admin can not edit. Just self can reset*/} {/* backend auto get the current user, so admin can not edit. Just self can reset*/}
@ -304,12 +311,18 @@ class UserEditPage extends React.Component {
{Setting.getLabel(i18next.t("general:Phone"), i18next.t("general:Phone - Tooltip"))} : {Setting.getLabel(i18next.t("general:Phone"), i18next.t("general:Phone - Tooltip"))} :
</Col> </Col>
<Col style={{paddingRight: "20px"}} span={11} > <Col style={{paddingRight: "20px"}} span={11} >
<Select value={`+${this.state.application?.organizationObj.phonePrefix} ${this.state.user.phone}`} {Setting.isLocalAdminUser(this.props.account) ?
options={[Setting.getItem(`+${this.state.application?.organizationObj.phonePrefix} ${this.state.user.phone}`, this.state.user.phone)]} <Input value={this.state.user.phone} addonBefore={`+${this.state.application?.organizationObj.phonePrefix}`}
disabled={disabled} disabled={disabled}
onChange={e => { onChange={e => {
this.updateUserField("phone", e.target.value); this.updateUserField("phone", e.target.value);
}} /> }} /> :
(<Select value={`+${this.state.application?.organizationObj.phonePrefix} ${this.state.user.phone}`}
options={[Setting.getItem(`+${this.state.application?.organizationObj.phonePrefix} ${this.state.user.phone}`, this.state.user.phone)]}
disabled={disabled}
onChange={e => {
this.updateUserField("phone", e.target.value);
}} />)}
</Col> </Col>
<Col span={11} > <Col span={11} >
{this.isSelf() ? (<ResetModal application={this.state.application} disabled={disabled} buttonText={i18next.t("user:Reset Phone...")} destType={"phone"} />) : null} {this.isSelf() ? (<ResetModal application={this.state.application} disabled={disabled} buttonText={i18next.t("user:Reset Phone...")} destType={"phone"} />) : null}

View File

@ -23,12 +23,15 @@ class PropertyTable extends React.Component {
super(props); super(props);
this.state = { this.state = {
properties: [], properties: [],
count: Object.entries(this.props.properties).length, count: this.props.properties !== null ? Object.entries(this.props.properties).length : 0,
}; };
// transfer the Object to object[] // transfer the Object to object[]
Object.entries(this.props.properties).map((item, index) => { if (this.props.properties !== null) {
this.state.properties.push({key: index, name: item[0], value: item[1]}); Object.entries(this.props.properties).map((item, index) => {
}); this.state.properties.push({key: index, name: item[0], value: item[1]});
});
}
} }
page = 1; page = 1;