forked from Gitlink/forgeplus-react
清空弹窗里的内容
This commit is contained in:
parent
ae34240bfb
commit
79d8f4e5ad
|
@ -5,10 +5,16 @@ import axios from 'axios';
|
|||
|
||||
const Option = AutoComplete.Option;
|
||||
|
||||
export default ({ getUser , placeholder, width })=>{
|
||||
export default ({ getUser , placeholder, width ,value })=>{
|
||||
const [ source , setSource ] = useState(undefined);
|
||||
const [ searchKey , setSearchKey ] = useState(undefined);
|
||||
|
||||
useEffect(()=>{
|
||||
if(!value){
|
||||
setSearchKey(undefined);
|
||||
}
|
||||
},[value])
|
||||
|
||||
useEffect(()=>{
|
||||
getUserList();
|
||||
},[searchKey])
|
||||
|
|
|
@ -8,6 +8,8 @@ const { Option } = Select;
|
|||
function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
||||
const { getFieldDecorator, validateFields , setFieldsValue } = form;
|
||||
const [ cate , setCate ] = useState(0);
|
||||
const [ value , setValue ] = useState(undefined);
|
||||
|
||||
const [ organizations , setOrganizations ] = useState(undefined);
|
||||
|
||||
useEffect(()=>{
|
||||
|
@ -18,6 +20,13 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
if(owner && repo && visible===true){
|
||||
getTeam();
|
||||
}
|
||||
if(!visible){
|
||||
setFieldsValue({
|
||||
owner_name:undefined,
|
||||
identifier:undefined
|
||||
})
|
||||
setValue(undefined)
|
||||
}
|
||||
},[repo,owner,visible])
|
||||
|
||||
function getTeam(){
|
||||
|
@ -69,6 +78,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
};
|
||||
|
||||
function getUser(id){
|
||||
setValue(id);
|
||||
setFieldsValue({
|
||||
owner_name:id
|
||||
})
|
||||
|
@ -117,7 +127,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
rules:[{required:true,message:"请输入目标用户名"}]
|
||||
})(
|
||||
// <Input placeholder="请输入目标用户" autoComplete={"off"}/>
|
||||
<SearchUser getUser={getUser} width={"100%"} placeholder="请输入目标用户"/>
|
||||
<SearchUser getUser={getUser} width={"100%"} placeholder="请输入目标用户" value={value}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ class Infos extends Component {
|
|||
const { current_user } = this.props;
|
||||
const { username } = this.props.match.params;
|
||||
const { pathname } = this.props.location;
|
||||
const { notice } = this.state;
|
||||
|
||||
let url = `/users/${username || (current_user && current_user.login)}.json`;
|
||||
axios
|
||||
|
@ -83,12 +84,13 @@ class Infos extends Component {
|
|||
.then((result) => {
|
||||
let e = result.data && result.data.undo_events;
|
||||
let p = result.data && result.data.undo_messages;
|
||||
let notice = p !== 0 ? pathname === `/users/${username}/notice` :false;
|
||||
let n = notice || pathname === `/users/${username}/notice` ;
|
||||
this.setState({
|
||||
user: result.data,
|
||||
isSpin: false,
|
||||
undo_events:notice ? (e-p) : e,
|
||||
undo_messages:notice ? result.data && result.data.undo_messages : 0
|
||||
undo_events:n ? (e-p) : e,
|
||||
undo_messages:0,
|
||||
notice:n
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -122,12 +124,15 @@ class Infos extends Component {
|
|||
}
|
||||
|
||||
undo_link = () => {
|
||||
const {user} = this.state
|
||||
const {user } = this.state;
|
||||
this.setState({
|
||||
route_type: undefined,
|
||||
project_type:"notice",
|
||||
notice:true
|
||||
},()=>{
|
||||
this.props.history.push(`/users/${user && user.login}/notice`);
|
||||
this.fetchUser();
|
||||
})
|
||||
this.props.history.push(`/users/${user && user.login}/notice`)
|
||||
}
|
||||
|
||||
route_link = (type) => {
|
||||
|
|
Loading…
Reference in New Issue