forked from Gitlink/forgeplus-react
merge undo
This commit is contained in:
parent
63d7045444
commit
605d5a047d
|
@ -1,24 +1,27 @@
|
||||||
import React , { useState } from 'react';
|
import React , { useState , useEffect } from 'react';
|
||||||
import { AutoComplete } from 'antd';
|
import { AutoComplete } from 'antd';
|
||||||
import { getImageUrl } from "educoder";
|
import { getImageUrl } from "educoder";
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const Option = AutoComplete.Option;
|
const Option = AutoComplete.Option;
|
||||||
|
|
||||||
export default ({ getUser })=>{
|
export default ({ getUser , placeholder, width })=>{
|
||||||
|
const [ source , setSource ] = useState(undefined);
|
||||||
const [ searchKey , setSearchKey ] = useState(undefined);
|
const [ searchKey , setSearchKey ] = useState(undefined);
|
||||||
const [ userDataSource , setUserDataSource ] = useState(undefined);
|
|
||||||
|
useEffect(()=>{
|
||||||
|
getUserList();
|
||||||
|
},[searchKey])
|
||||||
|
|
||||||
function getUserList(e){
|
function getUserList(e){
|
||||||
const url = `/users/list.json`;
|
const url = `/users/list.json`;
|
||||||
axios.get(url, {
|
axios.get(url, {
|
||||||
params: {
|
params: {
|
||||||
search: e,
|
search: searchKey,
|
||||||
},
|
},
|
||||||
})
|
}).then((result) => {
|
||||||
.then((result) => {
|
|
||||||
if (result) {
|
if (result) {
|
||||||
setUserDataSource(result.data.users);
|
sourceOptions(result.data.users);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
@ -26,20 +29,15 @@ export default ({ getUser })=>{
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function changeInputUser(value){
|
function sourceOptions(userDataSource){
|
||||||
setSearchKey(value);
|
const s = userDataSource && userDataSource.map((item, key) => {
|
||||||
getUserList(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectInputUser(id, option){
|
|
||||||
setSearchKey(option.props.value);
|
|
||||||
getUserList(option.props.value);
|
|
||||||
getUser && getUser(id);
|
|
||||||
}
|
|
||||||
const source =
|
|
||||||
userDataSource && userDataSource.map((item, key) => {
|
|
||||||
return (
|
return (
|
||||||
<Option key={key} value={`${item.login}`}>
|
<Option
|
||||||
|
key={key}
|
||||||
|
value={`${item.user_id}`}
|
||||||
|
login={`${item.login}`}
|
||||||
|
name={item.username}
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
className="user_img radius"
|
className="user_img radius"
|
||||||
width="28"
|
width="28"
|
||||||
|
@ -54,14 +52,31 @@ export default ({ getUser })=>{
|
||||||
</Option>
|
</Option>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
setSource(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeInputUser(e){
|
||||||
|
setSearchKey(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 选择用户
|
||||||
|
function selectInputUser(e, option){
|
||||||
|
setSearchKey(option.props.name);
|
||||||
|
getUser(option.props.login);
|
||||||
|
};
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
<div className="addPanel">
|
||||||
<AutoComplete
|
<AutoComplete
|
||||||
|
getPopupContainer={trigger => trigger.parentNode}
|
||||||
dataSource={source}
|
dataSource={source}
|
||||||
value={searchKey}
|
value={searchKey}
|
||||||
style={{ width: 300 }}
|
style={{ width: width || 300 }}
|
||||||
onChange={changeInputUser}
|
onChange={changeInputUser}
|
||||||
onSelect={selectInputUser}
|
onSelect={selectInputUser}
|
||||||
placeholder="搜索需要添加的用户..."
|
placeholder={placeholder || "搜索需要添加的用户..."}
|
||||||
|
allowClear
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -305,12 +305,12 @@ function CoderDepot(props){
|
||||||
<a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/issues/new`)} >+ 任务</a>
|
<a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/issues/new`)} >+ 任务</a>
|
||||||
</div>
|
</div>
|
||||||
{ type === "dir" && projectDetail.type !== 2 &&
|
{ type === "dir" && projectDetail.type !== 2 &&
|
||||||
<Dropdown overlay={fileMenu} className="mr20">
|
<Dropdown overlay={fileMenu} className="mr20" trigger={['click']}>
|
||||||
<Button type="default">文件 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-grey-9"></i></Button>
|
<Button type="default">文件 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-grey-9"></i></Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
}
|
}
|
||||||
|
|
||||||
<Dropdown overlay={downloadMenu} placement="bottomRight">
|
<Dropdown overlay={downloadMenu} placement="bottomRight" trigger={['click']}>
|
||||||
<Button type={'primary'}>下载 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-white"></i></Button>
|
<Button type={'primary'}>下载 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-white"></i></Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</AlignCenter>
|
</AlignCenter>
|
||||||
|
|
|
@ -83,10 +83,9 @@ function Detail(props){
|
||||||
img={detail.avatar_url}
|
img={detail.avatar_url}
|
||||||
rightBtn={
|
rightBtn={
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{flag && !buttonflag && detail.is_admin ? <AlignCenter className="color-blue">
|
{flag && !buttonflag && detail.is_admin ?
|
||||||
<Link to={`/organize/${OIdentifier}/setting`} className="color-blue">设置</Link>
|
<Link to={`/organize/${OIdentifier}/setting`} className="color-blue ml10 font-14">设置<i className="iconfont icon-shezhi2 ml3 fr"></i></Link>
|
||||||
<i className="iconfont icon-shezhi2 ml3"></i>
|
:""}
|
||||||
</AlignCenter> :""}
|
|
||||||
{buttonflag &&
|
{buttonflag &&
|
||||||
<span className="subNavs">
|
<span className="subNavs">
|
||||||
<Link to={`/organize/${OIdentifier}/member`} className={pathname ===`/organize/${OIdentifier}/member` ? "active":""}><span>组织成员</span>{detail.num_users && <lable>{detail.num_users}</lable>}</Link>
|
<Link to={`/organize/${OIdentifier}/member`} className={pathname ===`/organize/${OIdentifier}/member` ? "active":""}><span>组织成员</span>{detail.num_users && <lable>{detail.num_users}</lable>}</Link>
|
||||||
|
@ -95,6 +94,18 @@ function Detail(props){
|
||||||
}
|
}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
|
bottomInfos={
|
||||||
|
!buttonflag && <div>
|
||||||
|
{
|
||||||
|
detail.location &&
|
||||||
|
<span className="color-grey-6"><i className="iconfont icon-weizhi mr3 font-16 color-grey-6"></i>{detail.location}</span>
|
||||||
|
}
|
||||||
|
{
|
||||||
|
detail.website &&
|
||||||
|
<a href={detail.website} target="_blank" className="ml20 color-grey-6"><i className="iconfont icon-lianjie mr3 font-14"></i>{detail.website}</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
<Switch {...props}>
|
<Switch {...props}>
|
||||||
|
|
Loading…
Reference in New Issue