U 无权限的操作按钮现已不再显示 #203

pull/220/head
vapao 2020-09-28 11:17:22 +08:00
parent dc1975c52c
commit 87576ebe4e
18 changed files with 190 additions and 187 deletions

View File

@ -0,0 +1,39 @@
/**
* Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
* Copyright (c) <spug.dev@gmail.com>
* Released under the AGPL-3.0 License.
*/
import React from 'react';
import { Link } from 'react-router-dom';
import { Divider, Button } from 'antd';
import { hasPermission } from 'libs';
function canVisible(auth) {
return !auth || hasPermission(auth)
}
class Action extends React.Component {
static Link(props) {
return <Link {...props}/>
}
static Button(props) {
return <Button type="link" {...props} style={{padding: 0}}/>
}
render() {
const children = [];
this.props.children.forEach((el, index) => {
if (canVisible(el.props.auth)) {
if (children.length !== 0) children.push(<Divider key={index} type="vertical"/>);
children.push(el)
}
})
return <span>
{children}
</span>
}
}
export default Action

View File

@ -13,5 +13,5 @@ export default function AuthButton(props) {
if (props.auth && !hasPermission(props.auth)) { if (props.auth && !hasPermission(props.auth)) {
disabled = true; disabled = true;
} }
return <Button {...props} disabled={disabled}>{props.children}</Button> return disabled ? null : <Button {...props}>{props.children}</Button>
} }

View File

@ -1,17 +0,0 @@
/**
* Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
* Copyright (c) <spug.dev@gmail.com>
* Released under the AGPL-3.0 License.
*/
import React from 'react';
import {Link} from 'react-router-dom';
import { hasPermission } from 'libs';
export default function AuthLink(props) {
let disabled = props.disabled;
if (props.auth && !hasPermission(props.auth)) {
disabled = true;
}
return <Link {...props} disabled={disabled}>{props.children}</Link>
}

View File

@ -8,10 +8,10 @@ import SearchForm from './SearchForm';
import LinkButton from './LinkButton'; import LinkButton from './LinkButton';
import AuthButton from './AuthButton'; import AuthButton from './AuthButton';
import AuthFragment from './AuthFragment'; import AuthFragment from './AuthFragment';
import AuthLink from './AuthLink';
import AuthCard from './AuthCard'; import AuthCard from './AuthCard';
import AuthDiv from './AuthDiv'; import AuthDiv from './AuthDiv';
import ACEditor from './ACEditor'; import ACEditor from './ACEditor';
import Action from './Action';
export { export {
StatisticsCard, StatisticsCard,
@ -19,8 +19,8 @@ export {
SearchForm, SearchForm,
LinkButton, LinkButton,
AuthButton, AuthButton,
AuthLink,
AuthCard, AuthCard,
AuthDiv, AuthDiv,
ACEditor, ACEditor,
Action,
} }

View File

@ -15,6 +15,6 @@ code {
} }
/* Common CSS style */ /* Common CSS style */
.span-button { .none {
padding: 0; display: none;
} }

View File

@ -5,11 +5,11 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, message } from 'antd'; import { Table, Modal, message } from 'antd';
import ComForm from './Form'; import ComForm from './Form';
import http from 'libs/http'; import {http, hasPermission} from 'libs';
import store from './store'; import store from './store';
import { LinkButton } from "components"; import { Action } from "components";
@observer @observer
class ComTable extends React.Component { class ComTable extends React.Component {
@ -42,12 +42,12 @@ class ComTable extends React.Component {
ellipsis: true ellipsis: true
}, { }, {
title: '操作', title: '操作',
className: hasPermission('alarm.contact.edit|alarm.contact.del') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="alarm.contact.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="alarm.contact.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="alarm.contact.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="alarm.contact.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> </Action>
</span>
) )
}]; }];

View File

@ -5,12 +5,12 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, message } from 'antd'; import { Table, Modal, message } from 'antd';
import ComForm from './Form'; import ComForm from './Form';
import http from 'libs/http'; import {http, hasPermission} from 'libs';
import store from './store'; import store from './store';
import contactStore from '../contact/store'; import contactStore from '../contact/store';
import { LinkButton } from "components"; import { Action } from "components";
import lds from 'lodash'; import lds from 'lodash';
@observer @observer
@ -58,12 +58,12 @@ class ComTable extends React.Component {
ellipsis: true ellipsis: true
}, { }, {
title: '操作', title: '操作',
className: hasPermission('alarm.group.edit|alarm.group.del') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="alarm.group.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="alarm.group.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="alarm.group.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="alarm.group.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> </Action>
</span>
) )
}]; }];

View File

@ -5,10 +5,10 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, message } from 'antd'; import { Table, Modal, message } from 'antd';
import http from 'libs/http'; import { http, hasPermission } from 'libs';
import store from './store'; import store from './store';
import { LinkButton, AuthLink } from 'components'; import { Action } from 'components';
@observer @observer
class ComTable extends React.Component { class ComTable extends React.Component {
@ -33,16 +33,14 @@ class ComTable extends React.Component {
ellipsis: true ellipsis: true
}, { }, {
title: '操作', title: '操作',
className: hasPermission('config.app.edit|config.app.del|config.app.view_config') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="config.app.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="config.app.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="config.app.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="config.app.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> <Action.Button auth="config.app.view_config" onClick={() => store.showRel(info)}>依赖</Action.Button>
<Divider type="vertical"/> <Action.Link auth="config.app.view_config" to={`/config/setting/app/${info.id}`}>配置</Action.Link>
<LinkButton auth="config.app.view_config" onClick={() => store.showRel(info)}>依赖</LinkButton> </Action>
<Divider type="vertical"/>
<AuthLink auth="config.app.view_config" to={`/config/setting/app/${info.id}`}>配置</AuthLink>
</span>
) )
}]; }];

View File

@ -5,11 +5,11 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, message } from 'antd'; import { Table, Modal, message } from 'antd';
import ComForm from './Form'; import ComForm from './Form';
import http from 'libs/http'; import {http, hasPermission} from 'libs';
import store from './store'; import store from './store';
import { LinkButton } from "components"; import { Action } from "components";
@observer @observer
class ComTable extends React.Component { class ComTable extends React.Component {
@ -34,12 +34,12 @@ class ComTable extends React.Component {
ellipsis: true ellipsis: true
}, { }, {
title: '操作', title: '操作',
className: hasPermission('config.env.edit|config.env.del') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="config.env.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="config.env.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="config.env.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="config.env.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> </Action>
</span>
) )
}]; }];

View File

@ -5,11 +5,11 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, message } from 'antd'; import { Table, Modal, message } from 'antd';
import ComForm from './Form'; import ComForm from './Form';
import http from 'libs/http'; import { http, hasPermission } from 'libs';
import store from './store'; import store from './store';
import { LinkButton, AuthLink } from "components"; import { Action } from "components";
@observer @observer
class ComTable extends React.Component { class ComTable extends React.Component {
@ -34,14 +34,13 @@ class ComTable extends React.Component {
ellipsis: true ellipsis: true
}, { }, {
title: '操作', title: '操作',
className: hasPermission('config.src.edit|config.src.del|config.src.view_config') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="config.src.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="config.src.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="config.src.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="config.src.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> <Action.Link auth="config.src.view_config" to={`/config/setting/src/${info.id}`}>配置</Action.Link>
<Divider type="vertical"/> </Action>
<AuthLink auth="config.src.view_config" to={`/config/setting/src/${info.id}`}>配置</AuthLink>
</span>
) )
}]; }];

View File

@ -5,10 +5,10 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, Tooltip, Icon, message } from 'antd'; import { Table, Modal, Tooltip, Icon, message } from 'antd';
import { LinkButton } from 'components'; import { Action } from 'components';
import ComForm from './Form'; import ComForm from './Form';
import http from 'libs/http'; import { http, hasPermission } from 'libs';
import store from './store'; import store from './store';
@observer @observer
@ -31,7 +31,6 @@ class TableView extends React.Component {
}, { }, {
title: 'Value', title: 'Value',
dataIndex: 'value', dataIndex: 'value',
ellipsis: true
}, { }, {
title: '修改人', title: '修改人',
width: 120, width: 120,
@ -43,12 +42,13 @@ class TableView extends React.Component {
}, { }, {
title: '操作', title: '操作',
width: 120, width: 120,
className: hasPermission(`config.${store.type}.edit_config`) ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth={`config.${store.type}.edit_config`} onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth={`config.${store.type}.edit_config`} onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth={`config.${store.type}.edit_config`}
<LinkButton auth={`config.${store.type}.edit_config`} onClick={() => this.handleDelete(info)}>删除</LinkButton> onClick={() => this.handleDelete(info)}>删除</Action.Button>
</span> </Action>
) )
}]; }];

View File

@ -6,10 +6,10 @@
import React from 'react'; import React from 'react';
import { toJS } from 'mobx'; import { toJS } from 'mobx';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, Tag, Icon, message } from 'antd'; import { Table, Modal, Tag, Icon, message } from 'antd';
import http from 'libs/http'; import { http, hasPermission } from 'libs';
import store from './store'; import store from './store';
import { LinkButton } from "components"; import { Action } from "components";
import CloneConfirm from './CloneConfirm'; import CloneConfirm from './CloneConfirm';
import envStore from 'pages/config/environment/store'; import envStore from 'pages/config/environment/store';
import lds from 'lodash'; import lds from 'lodash';
@ -45,16 +45,14 @@ class ComTable extends React.Component {
ellipsis: true ellipsis: true
}, { }, {
title: '操作', title: '操作',
className: hasPermission('deploy.app.edit|deploy.app.del') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="deploy.app.edit" onClick={e => store.showExtForm(e, info.id)}>新建发布</LinkButton> <Action.Button auth="deploy.app.edit" onClick={e => store.showExtForm(e, info.id)}>新建发布</Action.Button>
<Divider type="vertical"/> <Action.Button auth="deploy.app.edit" onClick={e => this.handleClone(e, info.id)}>克隆发布</Action.Button>
<LinkButton auth="deploy.app.edit" onClick={e => this.handleClone(e, info.id)}>克隆发布</LinkButton> <Action.Button auth="deploy.app.edit" onClick={e => store.showForm(e, info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="deploy.app.del" onClick={e => this.handleDelete(e, info)}>删除</Action.Button>
<LinkButton auth="deploy.app.edit" onClick={e => store.showForm(e, info)}>编辑</LinkButton> </Action>
<Divider type="vertical"/>
<LinkButton auth="deploy.app.del" onClick={e => this.handleDelete(e, info)}>删除</LinkButton>
</span>
) )
}]; }];
@ -127,15 +125,15 @@ class ComTable extends React.Component {
render: value => value ? <Tag color="green">开启</Tag> : <Tag color="red"></Tag> render: value => value ? <Tag color="green">开启</Tag> : <Tag color="red"></Tag>
}, { }, {
title: '操作', title: '操作',
className: hasPermission('deploy.app.config|deploy.app.edit') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="deploy.app.config" <Action.Button
onClick={e => store.showExtForm(e, record.id, info, false, true)}>查看</LinkButton> auth="deploy.app.config"
<Divider type="vertical"/> onClick={e => store.showExtForm(e, record.id, info, false, true)}>查看</Action.Button>
<LinkButton auth="deploy.app.edit" onClick={e => store.showExtForm(e, record.id, info)}>编辑</LinkButton> <Action.Button auth="deploy.app.edit" onClick={e => store.showExtForm(e, record.id, info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="deploy.app.edit" onClick={() => this.handleDeployDelete(info)}>删除</Action.Button>
<LinkButton auth="deploy.app.edit" onClick={() => this.handleDeployDelete(info)}>删除</LinkButton> </Action>
</span>
) )
}]; }];

View File

@ -5,10 +5,10 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, Icon, Popover, Tag, message } from 'antd'; import { Table, Modal, Icon, Popover, Tag, message } from 'antd';
import http from 'libs/http'; import { http, hasPermission } from 'libs';
import { Action } from "components";
import store from './store'; import store from './store';
import { LinkButton, AuthLink } from "components";
@observer @observer
class ComTable extends React.Component { class ComTable extends React.Component {
@ -82,54 +82,54 @@ class ComTable extends React.Component {
sorter: (a, b) => a['created_at'].localeCompare(b['created_at']) sorter: (a, b) => a['created_at'].localeCompare(b['created_at'])
}, { }, {
title: '操作', title: '操作',
className: hasPermission('deploy.request.do|deploy.request.edit|deploy.request.approve|deploy.request.del') ? null : 'none',
render: info => { render: info => {
switch (info.status) { switch (info.status) {
case '-3': case '-3':
return <React.Fragment> return <Action>
<AuthLink auth="deploy.request.do" to={`/deploy/do/ext${info['app_extend']}/${info.id}/1`}>查看</AuthLink> <Action.Link
<Divider type="vertical"/> auth="deploy.request.do"
<AuthLink auth="deploy.request.do" to={`/deploy/do/ext${info['app_extend']}/${info.id}`}>发布</AuthLink> to={`/deploy/do/ext${info['app_extend']}/${info.id}/1`}>查看</Action.Link>
<Divider type="vertical"/> <Action.Link auth="deploy.request.do" to={`/deploy/do/ext${info['app_extend']}/${info.id}`}>发布</Action.Link>
<LinkButton <Action.Button
auth="deploy.request.do" auth="deploy.request.do"
disabled={info.type === '2'} disabled={info.type === '2'}
loading={this.state.loading} loading={this.state.loading}
onClick={() => this.handleRollback(info)}>回滚</LinkButton> onClick={() => this.handleRollback(info)}>回滚</Action.Button>
</React.Fragment>; </Action>;
case '3': case '3':
return <React.Fragment> return <Action>
<AuthLink auth="deploy.request.do" to={`/deploy/do/ext${info['app_extend']}/${info.id}/1`}>查看</AuthLink> <Action.Link
<Divider type="vertical"/> auth="deploy.request.do"
<LinkButton to={`/deploy/do/ext${info['app_extend']}/${info.id}/1`}>查看</Action.Link>
<Action.Button
auth="deploy.request.do" auth="deploy.request.do"
disabled={info.type === '2'} disabled={info.type === '2'}
loading={this.state.loading} loading={this.state.loading}
onClick={() => this.handleRollback(info)}>回滚</LinkButton> onClick={() => this.handleRollback(info)}>回滚</Action.Button>
</React.Fragment>; </Action>;
case '-1': case '-1':
return <React.Fragment> return <Action>
<LinkButton auth="deploy.request.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="deploy.request.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="deploy.request.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="deploy.request.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> </Action>;
</React.Fragment>;
case '0': case '0':
return <React.Fragment> return <Action>
<LinkButton auth="deploy.request.approve" onClick={() => store.showApprove(info)}>审核</LinkButton> <Action.Button auth="deploy.request.approve" onClick={() => store.showApprove(info)}>审核</Action.Button>
<Divider type="vertical"/> <Action.Button auth="deploy.request.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<LinkButton auth="deploy.request.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="deploy.request.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<Divider type="vertical"/> </Action>;
<LinkButton auth="deploy.request.del" onClick={() => this.handleDelete(info)}>删除</LinkButton>
</React.Fragment>;
case '1': case '1':
return <React.Fragment> return <Action>
<AuthLink auth="deploy.request.do" to={`/deploy/do/ext${info['app_extend']}/${info.id}`}>发布</AuthLink> <Action.Link auth="deploy.request.do" to={`/deploy/do/ext${info['app_extend']}/${info.id}`}>发布</Action.Link>
<Divider type="vertical"/> <Action.Button auth="deploy.request.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="deploy.request.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> </Action>;
</React.Fragment>;
case '2': case '2':
return ( return <Action>
<AuthLink auth="deploy.request.do" to={`/deploy/do/ext${info['app_extend']}/${info.id}/1`}>查看</AuthLink> <Action.Link
); auth="deploy.request.do"
to={`/deploy/do/ext${info['app_extend']}/${info.id}/1`}>查看</Action.Link>
</Action>;
default: default:
return null return null
} }

View File

@ -5,11 +5,11 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, message } from 'antd'; import { Table, Modal, message } from 'antd';
import ComForm from './Form'; import ComForm from './Form';
import http from 'libs/http'; import {http,hasPermission } from 'libs';
import { Action } from "components";
import store from './store'; import store from './store';
import { LinkButton } from "components";
@observer @observer
class ComTable extends React.Component { class ComTable extends React.Component {
@ -33,12 +33,12 @@ class ComTable extends React.Component {
ellipsis: true ellipsis: true
}, { }, {
title: '操作', title: '操作',
className: hasPermission('exec.template.edit|exec.template.del') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="exec.template.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="exec.template.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="exec.template.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="exec.template.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> </Action>
</span>
) )
}]; }];

View File

@ -5,11 +5,11 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, message } from 'antd'; import { Table, Modal, message } from 'antd';
import { LinkButton } from 'components'; import { Action } from 'components';
import ComForm from './Form'; import ComForm from './Form';
import ComImport from './Import'; import ComImport from './Import';
import http from 'libs/http'; import { http, hasPermission} from 'libs';
import store from './store'; import store from './store';
@observer @observer
@ -19,11 +19,6 @@ class ComTable extends React.Component {
} }
columns = [{ columns = [{
title: '序号',
key: 'series',
render: (_, __, index) => index + 1,
width: 80
}, {
title: '类别', title: '类别',
dataIndex: 'zone', dataIndex: 'zone',
}, { }, {
@ -36,7 +31,8 @@ class ComTable extends React.Component {
sorter: (a, b) => a.name.localeCompare(b.name) sorter: (a, b) => a.name.localeCompare(b.name)
}, { }, {
title: '端口', title: '端口',
dataIndex: 'port' dataIndex: 'port',
width: 100,
}, { }, {
title: '备注', title: '备注',
dataIndex: 'desc', dataIndex: 'desc',
@ -44,14 +40,13 @@ class ComTable extends React.Component {
}, { }, {
title: '操作', title: '操作',
width: 200, width: 200,
className: hasPermission('host.host.edit|host.host.del|host.host.console') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="host.host.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="host.host.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<Divider type="vertical"/> <Action.Button auth="host.host.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<LinkButton auth="host.host.del" onClick={() => this.handleDelete(info)}>删除</LinkButton> <Action.Button auth="host.host.console" onClick={() => this.handleConsole(info)}>Console</Action.Button>
<Divider type="vertical"/> </Action>
<LinkButton auth="host.host.console" onClick={() => this.handleConsole(info)}>Console</LinkButton>
</span>
) )
}]; }];

View File

@ -5,10 +5,10 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, Tag, message } from 'antd'; import { Table, Modal, Tag, message } from 'antd';
import { LinkButton } from 'components'; import { Action } from 'components';
import ComForm from './Form'; import ComForm from './Form';
import http from 'libs/http'; import {http, hasPermission} from 'libs';
import store from './store'; import store from './store';
import hostStore from '../host/store'; import hostStore from '../host/store';
import lds from 'lodash'; import lds from 'lodash';
@ -82,14 +82,13 @@ class ComTable extends React.Component {
sorter: (a, b) => a.latest_run_time.localeCompare(b.latest_run_time) sorter: (a, b) => a.latest_run_time.localeCompare(b.latest_run_time)
}, { }, {
title: '操作', title: '操作',
className: hasPermission('monitor.monitor.edit|monitor.monitor.del') ? null : 'none',
render: info => ( render: info => (
<span> <Action>
<LinkButton auth="monitor.monitor.edit" onClick={() => this.handleActive(info)}>{info['is_active'] ? '禁用' : '启用'}</LinkButton> <Action.Button auth="monitor.monitor.edit" onClick={() => this.handleActive(info)}>{info['is_active'] ? '禁用' : '启用'}</Action.Button>
<Divider type="vertical"/> <Action.Button auth="monitor.monitor.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<LinkButton auth="monitor.monitor.edit" onClick={() => store.showForm(info)}>编辑</LinkButton> <Action.Button auth="monitor.monitor.del" onClick={() => this.handleDelete(info)}>删除</Action.Button>
<Divider type="vertical"/> </Action>
<LinkButton auth="monitor.monitor.del" onClick={() => this.handleDelete(info)}>删除</LinkButton>
</span>
), ),
width: 180 width: 180
}]; }];

View File

@ -5,11 +5,11 @@
*/ */
import React from 'react'; import React from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Table, Divider, Modal, Tag, Dropdown, Icon, Menu, message } from 'antd'; import { Table, Modal, Tag, Dropdown, Icon, Menu, message } from 'antd';
import ComForm from './Form'; import ComForm from './Form';
import http from 'libs/http'; import {http} from 'libs';
import store from './store'; import store from './store';
import { LinkButton } from "components"; import { LinkButton, Action } from "components";
import Info from './Info'; import Info from './Info';
import Record from './Record'; import Record from './Record';
@ -40,11 +40,6 @@ class ComTable extends React.Component {
); );
columns = [{ columns = [{
title: '序号',
key: 'series',
render: (_, __, index) => index + 1,
width: 80,
}, {
title: '任务名称', title: '任务名称',
dataIndex: 'name', dataIndex: 'name',
}, { }, {
@ -75,17 +70,15 @@ class ComTable extends React.Component {
title: '操作', title: '操作',
width: 180, width: 180,
render: info => ( render: info => (
<span> <Action>
<LinkButton disabled={!info['latest_run_time']} onClick={() => store.showInfo(info)}>详情</LinkButton> <Action.Button disabled={!info['latest_run_time']} onClick={() => store.showInfo(info)}>详情</Action.Button>
<Divider type="vertical"/> <Action.Button auth="schedule.schedule.edit" onClick={() => store.showForm(info)}>编辑</Action.Button>
<LinkButton auth="schedule.schedule.edit" onClick={() => store.showForm(info)}>编辑</LinkButton>
<Divider type="vertical"/>
<Dropdown overlay={() => this.moreMenus(info)} trigger={['click']}> <Dropdown overlay={() => this.moreMenus(info)} trigger={['click']}>
<LinkButton> <LinkButton>
更多 <Icon type="down"/> 更多 <Icon type="down"/>
</LinkButton> </LinkButton>
</Dropdown> </Dropdown>
</span> </Action>
) )
}]; }];

View File

@ -50,14 +50,13 @@ class ComTable extends React.Component {
title: '操作', title: '操作',
render: info => ( render: info => (
<span> <span>
<LinkButton className="span-button" <LinkButton onClick={() => this.handleActive(info)}>{info['is_active'] ? '禁用' : '启用'}</LinkButton>
onClick={() => this.handleActive(info)}>{info['is_active'] ? '禁用' : '启用'}</LinkButton>
<Divider type="vertical"/> <Divider type="vertical"/>
<LinkButton className="span-button" onClick={() => store.showForm(info)}>编辑</LinkButton> <LinkButton onClick={() => store.showForm(info)}>编辑</LinkButton>
<Divider type="vertical"/> <Divider type="vertical"/>
<LinkButton disabled={info['type'] === 'ldap'} className="span-button" onClick={() => this.handleReset(info)}>重置密码</LinkButton> <LinkButton disabled={info['type'] === 'ldap'} onClick={() => this.handleReset(info)}>重置密码</LinkButton>
<Divider type="vertical"/> <Divider type="vertical"/>
<LinkButton className="span-button" onClick={() => this.handleDelete(info)}>删除</LinkButton> <LinkButton onClick={() => this.handleDelete(info)}>删除</LinkButton>
</span> </span>
) )
}]; }];