Skip to content

Commit

Permalink
fix: Users role name (#777)
Browse files Browse the repository at this point in the history
* fix: Users role name

* refactor: Fix code review
  • Loading branch information
liiil825 authored Jan 31, 2019
1 parent bbb1a57 commit 0794856
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
2 changes: 2 additions & 0 deletions src/locales/zh/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"Normal Role Title Count": "终端角色({{count}})",
"Operation list": "操作列表",
"Edit info": "编辑信息",
"isv": "应用服务商",
"user": "用户",
"Set permission": "设置权限",
"Delete role": "删除角色",
"Disable": "禁用",
Expand Down
46 changes: 22 additions & 24 deletions src/portals/admin/pages/Users/ModalActions/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { Component, Fragment } from 'react';
import { observer } from 'mobx-react';
import _ from 'lodash';

Expand Down Expand Up @@ -153,8 +153,8 @@ export default class UserModalActions extends Component {
const { setRole, roles, userNames } = userStore;
const roleId = _.get(item, 'role');
const userId = _.get(item, 'user_id') || userStore.selectIds.join(',');
const names = roleId ? item.username : userNames;
const text = roleId
const names = userId ? item.username : userNames;
const text = userId
? t('Set_Role_Title', { names })
: t('Set_Role_Title_For_Multi_User', {
count: names.length,
Expand Down Expand Up @@ -186,13 +186,9 @@ export default class UserModalActions extends Component {

renderModalCreateUser() {
const { userStore, modalStore, t } = this.props;
const { isOpen } = modalStore;
const {
userDetail, roles, hideModifyUser, createOrModify
} = userStore;
const {
user_id, role, username, email
} = userDetail;
const { isOpen, item } = modalStore;
const { roles, hideModifyUser, createOrModify } = userStore;
const { user_id, username, email } = item;

const title = !user_id === 'modify' ? t('Create New User') : t('Modify User');

Expand Down Expand Up @@ -227,21 +223,23 @@ export default class UserModalActions extends Component {
/>
</div>
{!user_id && (
<div className={styles.formItem}>
<label>{t('Role')}</label>
<Select defaultValue={role} name="role">
{roles.map(({ role_id, role_name }) => (
<Select.Option key={role_id} value={role_id}>
{t(role_name)}
</Select.Option>
))}
</Select>
</div>
<Fragment>
<div className={styles.formItem}>
<label>{t('Role')}</label>
<Select name="role">
{roles.map(({ role_id, role_name }) => (
<Select.Option key={role_id} value={role_id}>
{t(role_name)}
</Select.Option>
))}
</Select>
</div>
<div className={styles.formItem}>
<label>{t('Password')}</label>
<Input name="password" type="password" maxLength={50} />
</div>
</Fragment>
)}
<div className={styles.formItem}>
<label>{t('Password')}</label>
<Input name="password" type="password" maxLength={50} />
</div>
<div className={styles.formItemText}>
<label>{t('Description')}</label>
<textarea name="description" maxLength={500} />
Expand Down
5 changes: 2 additions & 3 deletions src/portals/admin/pages/Users/columns.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import { Icon, Popover } from 'components/Base';
import _ from 'lodash';

import Status from 'components/Status';
import TimeShow from 'components/TimeShow';
import LessText from 'components/LessText';

import { roleMap } from 'config/roles';

export default (t, renderHandleMenu) => {
const columns = [
{
Expand All @@ -33,7 +32,7 @@ export default (t, renderHandleMenu) => {
{
title: t('Role'),
key: 'role',
render: item => t(roleMap[item.role])
render: item => t(_.get(item, 'role[0].role_name', ''))
},
{
title: t('Updated At'),
Expand Down

0 comments on commit 0794856

Please sign in to comment.