diff --git a/src/forge/Issues/Component/allMenus.jsx b/src/forge/Issues/Component/allMenus.jsx index 4610249f9..ba4b3b229 100644 --- a/src/forge/Issues/Component/allMenus.jsx +++ b/src/forge/Issues/Component/allMenus.jsx @@ -11,7 +11,7 @@ const array =[ {id:6,name:"低优先级"} ] -function AllMenus({owner,projectsId,chooseFunc,update},ref){ +function AllMenus({owner,projectsId,chooseFunc,update,defaultNames,defaultIds},ref){ // 列表右侧所有筛选项的值 const [ authorList , setAuthorList ] = useState(undefined); const [ author , setAuthor ] = useState(undefined); @@ -26,6 +26,18 @@ function AllMenus({owner,projectsId,chooseFunc,update},ref){ const [ ids , setIds ] = useState({author_id:undefined,issue_priorities_id:undefined,issue_tag_ids:undefined,milestone_id:undefined,sort_by:undefined,status_id:undefined,assigner_id:undefined}); const [ names , setNames ] = useState({author_name:undefined,issue_priorities_name:undefined,issue_tag_name:undefined,milestone_name:undefined,sortby_name:undefined,status_name:undefined,assigner_name:undefined}); + useEffect(()=>{ + if(defaultNames){ + setNames(defaultNames); + } + },[defaultNames]) + + useEffect(()=>{ + if(defaultIds){ + setIds(defaultIds); + } + },[defaultIds]) + useImperativeHandle(ref, () => ({ clearChoose: () => { // 父组件按钮:清除筛选条件,将Ids\names里的字段全部改为undefined @@ -122,10 +134,10 @@ function AllMenus({owner,projectsId,chooseFunc,update},ref){ } function choose(id,name){ - let copy = {...ids,author_id:id.join(",")}; - let copyname = { ...names,author_name:name} + let copy = {...ids,author_id:id && id.length>0 ? id.join(","):undefined}; + let copyname = { ...names,author_name:name}; setIds(copy);setNames(copyname); - chooseFunc(copy); + chooseFunc(copy,copyname); } return( @@ -145,7 +157,7 @@ function AllMenus({owner,projectsId,chooseFunc,update},ref){ name={"优先级" } size={"small"} lists={prioritiesList} names={names && names.issue_priorities_name} - chooseFunc={(id,name)=>{let copy = {...ids,issue_priorities_id:id.join(",")};let copyname = { ...names,issue_priorities_name:name};setNames(copyname);setIds(copy);chooseFunc(copy)}} + chooseFunc={(id,name)=>{let copy = {...ids,issue_priorities_id:id && id.length>0 ? id.join(","):undefined};let copyname = { ...names,issue_priorities_name:name};setNames(copyname);setIds(copy);chooseFunc(copy,copyname)}} /> } setTag(value)} - chooseFunc={(id,name)=>{let copy = {...ids,issue_tag_ids:id.join(",")};let copyname = { ...names,issue_tag_name:name};setNames(copyname);setIds(copy);chooseFunc(copy)}} + chooseFunc={(id,name)=>{let copy = {...ids,issue_tag_ids:id && id.length>0 ? id.join(","):undefined};let copyname = { ...names,issue_tag_name:name};setNames(copyname);setIds(copy);chooseFunc(copy,copyname)}} /> setMillstone(value)} - chooseFunc={(id,name)=>{let copy = {...ids,milestone_id:id.join(",")};let copyname = { ...names,milestone_name:name};setNames(copyname);setIds(copy);chooseFunc(copy)}} + chooseFunc={(id,name)=>{let copy = {...ids,milestone_id:id && id.length>0 ? id.join(","):undefined};let copyname = { ...names,milestone_name:name};setNames(copyname);setIds(copy);chooseFunc(copy,copyname)}} /> setCharge(value)} - chooseFunc={(id,name)=>{let copy = {...ids,assigner_id:id.join(",")};let copyname = { ...names,assigner_name:name};setNames(copyname);setIds(copy);chooseFunc(copy)}} + double={update ? true : false } + chooseFunc={(id,name)=>{let copy = {...ids,assigner_id:id && id.length>0 ? id.join(","):undefined};let copyname = { ...names,assigner_name:name};setNames(copyname);setIds(copy);chooseFunc(copy,copyname)}} /> {let copy = {...ids,status_id:id.join(",")};let copyname = { ...names,status_name:name};setNames(copyname);setIds(copy);chooseFunc(copy)}} + chooseFunc={(id,name)=>{let copy = {...ids,status_id:id && id.length>0 ? id.join(","):undefined};let copyname = { ...names,status_name:name};setNames(copyname);setIds(copy);chooseFunc(copy,copyname)}} /> { !update && {let copy = {...ids,sort_by:id.join(",")};let copyname = { ...names,sortby_name:name};setNames(copyname);setIds(copy);chooseFunc(copy)}} + chooseFunc={(id,name)=>{let copy = {...ids,sort_by:id && id.length>0 ? id.join(","):undefined};let copyname = { ...names,sortby_name:name};setNames(copyname);setIds(copy);chooseFunc(copy,copyname)}} /> } diff --git a/src/forge/Issues/Component/datas.jsx b/src/forge/Issues/Component/datas.jsx index 210be49d2..13e640ae4 100644 --- a/src/forge/Issues/Component/datas.jsx +++ b/src/forge/Issues/Component/datas.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import { Tooltip } from 'antd'; import { getImageUrl } from 'educoder'; import issue from '../Img/issue.png'; import { Link } from "react-router-dom"; @@ -9,7 +8,8 @@ import Copy from '../Component/copy'; // issue列表显示 function Datas({checkbox ,item , projectsId,owner}){ let host = window.location.hostname === "localhost" ? "testforgeplus.trustie.net" : window.location.hostname; - + let protocol = window.location.protocol; + console.log("protocol:",protocol); function statusTag(name){ switch (name) { case "低": @@ -30,7 +30,7 @@ function Datas({checkbox ,item , projectsId,owner}){
{item.priority_name} { item.project_issues_index && - #{item.project_issues_index} + #{item.project_issues_index} }
@@ -41,7 +41,7 @@ function Datas({checkbox ,item , projectsId,owner}){ item.tags && item.tags.length>0? item.tags.map((i,k)=>{ return( - {i.name} + {i.name} ) }) :"" diff --git a/src/forge/Issues/Component/editMenus.jsx b/src/forge/Issues/Component/editMenus.jsx index 91672afaa..09290a4ad 100644 --- a/src/forge/Issues/Component/editMenus.jsx +++ b/src/forge/Issues/Component/editMenus.jsx @@ -68,7 +68,9 @@ function EditMenus({ } function chooseMenu(i){ - setVisible(false); + if(!double){ + setVisible(false); + } let l = valueId; let idStr = i && i.id ? i.id.toString() :i.name; // 分支列表没有id,只能根据name判断 diff --git a/src/forge/Issues/Component/newPanel.jsx b/src/forge/Issues/Component/newPanel.jsx index cd87ccce5..9bae37aba 100644 --- a/src/forge/Issues/Component/newPanel.jsx +++ b/src/forge/Issues/Component/newPanel.jsx @@ -12,7 +12,7 @@ function NewPanel(props,ref){ const [ attachments , setAttachments ] = useState([]); const [ receivers_login , setReceiversLogin ] = useState(undefined); - const { createFunc , title , desc , files , onCancel } = props; + const { createFunc , title , desc , files , onCancel , owner , projectsId } = props; const { form: { getFieldDecorator, validateFields , setFieldsValue } } = props; @@ -29,12 +29,24 @@ function NewPanel(props,ref){ } function UploadFunc(f){ let list = []; + let arr = []; if(files && files.length>0 ){ - let arr = files.map(i=>{return i.id}); - list = arr && arr.length>0 ? f.concat(arr) : f ; + arr = files.map(i=>{return i.id}); } + list = arr && arr.length>0 ? f.concat(arr) : f ; setFileList(list); }; + + function deleteLoad(id){ + let arr = []; + let list = files + if(list && list.length>0 ){ + arr = list.filter(i=>i.id !== id); + } + console.log(arr.map(i=>{return i.id})); + setFileList(arr.map(i=>{return i.id})); + } + function changeAtWhoLoginList(loginList){ let list = new Set(receivers_login); loginList.map(item => list.add(item)); @@ -44,6 +56,7 @@ function NewPanel(props,ref){ function sureFunc(){ validateFields((error,values)=>{ if (!error) { + console.log(fileList); createFunc(values,fileList,receivers_login,description); } }) @@ -52,6 +65,8 @@ function NewPanel(props,ref){ function cancelFunc(){ if(onCancel){ onCancel(); + }else{ + window.history.back(-1); } } return( @@ -72,6 +87,9 @@ function NewPanel(props,ref){ initValue={description} onChange={onContentChange} className="mt20" + isCanAtme = {true} + owner = {owner} + projectsId = {projectsId} changeAtWhoLoginList = {changeAtWhoLoginList} >
@@ -95,6 +113,7 @@ function NewPanel(props,ref){ attachments={attachments} showNotification={props.showNotification} canDelete={true} + deleteLoad={deleteLoad} > }
diff --git a/src/forge/Issues/Pages/details.jsx b/src/forge/Issues/Pages/details.jsx index c206ee5ab..a5d4560c8 100644 --- a/src/forge/Issues/Pages/details.jsx +++ b/src/forge/Issues/Pages/details.jsx @@ -91,8 +91,13 @@ function Details(props){ } setNames(n); data.start_date && setStartDate(moment(data.start_date).format('YYYY-MM-DD')); - console.log(data.due_date); data.due_date && setDueDate(moment(data.due_date).format('YYYY-MM-DD')); + + const {projectDetail} = props; + if(projectDetail){ + const { author, name} = projectDetail; + document.title = `${data.subject}-疑修-${author.name}/${name}`; + } } }).catch(error=>{}) } @@ -131,7 +136,16 @@ function Details(props){ const url = `/v1/${owner}/${projectsId}/issue_priorities`; axios.get(url).then(result=>{ if(result && result.data){ - setPrioritiesList(result.data.priorities); + let priorities = result.data.priorities; + let array =[]; + let colors = ["#1abcb1","#28be6c","#db3d1d","#db3d1d"]; + if(priorities && priorities.length>0){ + array = priorities.map((i,k)=>{ + let arr = {...i,color:colors[k]} + return arr; + }) + } + setPrioritiesList(array); } }) } @@ -307,6 +321,7 @@ function Details(props){ desc={details.description} files={details.attachments} createFunc={createFunc} + owner = {owner} projectsId = {projectsId} />
: diff --git a/src/forge/Issues/Pages/list.jsx b/src/forge/Issues/Pages/list.jsx index 9e96f33c4..5019f21c1 100644 --- a/src/forge/Issues/Pages/list.jsx +++ b/src/forge/Issues/Pages/list.jsx @@ -28,7 +28,8 @@ function List(props){ const [ allValue , setAllValue ] = useState([]); const [ allIds , setAllIds ] = useState([]); const [ checkAll , setCheckAll ] = useState(false); - + + const [ names , setNames ] = useState(undefined); const [ updateIds , setUpdateIds ] = useState(undefined); const [ page , setPage ] = useState(1); @@ -36,18 +37,64 @@ function List(props){ const [ total , setTotal ] = useState(undefined); const [ issueTotal , setIssueTotal ] = useState(0); + const [ clearFlag , setClearFlag ] = useState(false); + const [ has_created_issues , setHas_created_issues] = useState(false); const menuRef = useRef(null); const owner = props.match.params.owner; const projectsId = props.match.params.projectsId; const permission = props && props.projectDetail && props.projectDetail.permission; - + const { projectDetail } = props; + const states = cookie.load("states"); useEffect(()=>{ + if(projectDetail){ + const { author, name } = projectDetail; + document.title = `疑修-${author.name}/${name}`; + } + },[projectDetail]) + + useEffect(()=>{ + if((updateIds && (updateIds.author_id || updateIds.issue_priorities_id || updateIds.issue_tag_ids || updateIds.milestone_id || updateIds.sort_by || updateIds.status_id ||updateIds.assigner_id)) || value){ + setClearFlag(true); + }else{ + setClearFlag(false); + } + },[updateIds,value]) + + useEffect(()=>{ + if(states){ + setUpdateIds({...states}); + setAboutMe(states.participant_category); + setCategory(states.category); + setPage(states.page); + setLimit(states.limit); + setNames(states.names); + Init(states,states.page,states.names); + }else{ + Init(updateIds,1); + } + },[]) + + + // 自定义一个初始不更新的hook + const useUpdateEffect = (fn, inputs) => { + const didMountRef = useRef(false); + useEffect(() => { + if (didMountRef.current) fn(); + else didMountRef.current = true; + }, inputs); + }; + + // 定义处理函数 + function handleAllDisabled(){ setTotal(undefined); setLimit(defaultLimit); Init(updateIds,1); - },[aboutMe,keyword,category]) + } + + // 使用自定义hook + useUpdateEffect(handleAllDisabled, [aboutMe,keyword,category]); function getDirection(id){ if(!id) return undefined; @@ -69,18 +116,20 @@ function List(props){ } // 获取issue列表数据 - function Init(params,p){ + function Init(params,p,names){ const url = `/v1/${owner}/${projectsId}/issues`; + let getParams ={ + participant_category:aboutMe, + keyword,category, + limit, + ...params, + page:p || page, + sort_direction:getDirection(params && params.sort_by), + sort_by:getBy(params && params.sort_by) + } + console.log(getParams); axios.get(url,{ - params:{ - participant_category:aboutMe, - keyword,category, - limit, - page:p || page, - ...params, - sort_direction:getDirection(params && params.sort_by), - sort_by:getBy(params && params.sort_by) - } + params:{...getParams,names:undefined} }).then(result=>{ if(result){ setIssueList(result.data.issues); @@ -90,8 +139,9 @@ function List(props){ const ids = result.data.issues.length>0 ? result.data.issues.map(i=>{return i.id}) : []; setAllIds(ids); setIssueTotal(result.data.total_issues_count); + setHas_created_issues(result.data.has_created_issues); - let d={participant_category:aboutMe,keyword,category,limit,page,...params} + let d={...getParams,names:{...names}} let inFifteenMinutes = new Date(new Date().getTime() + 24 * 3600 * 1000); cookie.save('states', {...d},{ expires: inFifteenMinutes,path:`/` }); } @@ -109,7 +159,7 @@ function List(props){ ) function chooseAboutMe(e){ - setCategory("all"); + setCategory("opened"); setAboutMe(e.key); } @@ -120,6 +170,8 @@ function List(props){ setCategory("opened"); setTotal(undefined); setUpdateIds(undefined); + setAllValue([]); + setValue(undefined); Init(); // 清除下拉选项 menuRef.current && menuRef.current.clearChoose(); @@ -133,6 +185,9 @@ function List(props){ if(e.target.checked){ setAllValue(allIds); }else{ + if(states){ + setNames(states.names); + } setAllValue([]); } } @@ -168,6 +223,7 @@ function List(props){ status_id: updateIds && updateIds.status_id }).then(result=>{ if(result){ + setAllValue([]); setTotal(undefined); Init(); cancelUpdate(); @@ -176,9 +232,14 @@ function List(props){ } // 切换页码 - function changepage(page){ - setPage(page); - Init(updateIds,page); + function changepage(p){ + setPage(p); + Init(updateIds,p); + if (document) { // 可以排除不需要置顶的页面 + if (document.documentElement || document.body) { + document.documentElement.scrollTop = document.body.scrollTop = 0; // 切换路由时手动置顶 + } + } } // 删除issue相关 func @@ -197,14 +258,15 @@ function List(props){ }).catch(error=>{}) } - function chooseFunc(ids){ + function chooseFunc(ids,n){ + setNames(n); if(allValue && allValue.length>0){ // 将ids保存下来以便修改 setUpdateIds(ids); }else{ setUpdateIds(ids); setTotal(undefined); - Init(ids,1); + Init(ids,1,n); } } @@ -235,12 +297,16 @@ function List(props){ setValue(e.target.value)} + onChange={e=>{setValue(e.target.value);}} onSearch={()=>setKeyword(value)} style={{ width: 354 , height : 32 , marginLeft: 20 }} + allowClear /> - + { + clearFlag && + 清除筛选条件 + }
{ @@ -253,7 +319,7 @@ function List(props){
- + { allValue && allValue.length>0 ? 选择{allValue.length}个issue @@ -272,6 +338,8 @@ function List(props){ owner={owner} projectsId={projectsId} chooseFunc={chooseFunc} + defaultNames={names} + defaultIds={allValue && allValue.length>0 ? undefined : updateIds} /> { allValue && allValue.length>0 ? @@ -286,26 +354,26 @@ function List(props){
{ total === 0 && - (issueTotal === 0 ? -
- : + (!has_created_issues ?

欢迎使用疑修(Issue)

疑修用于记录与跟踪待办事项、项目bug、功能需求等。在使用之前,请您先创建一个疑修

+ : +
) } { total > 0 && - +
{issueList.map((item,key)=>{ return( } + checkbox={(permission && permission !== "reporter") && } item={item} owner={owner} projectsId={projectsId} diff --git a/src/forge/Issues/Pages/new.jsx b/src/forge/Issues/Pages/new.jsx index 53c0d9546..06bbc5a92 100644 --- a/src/forge/Issues/Pages/new.jsx +++ b/src/forge/Issues/Pages/new.jsx @@ -39,19 +39,13 @@ function New(props){ const projectsId = props.match.params.projectsId; const permission = props && props.projectDetail && props.projectDetail.permission; - - - - // 更新网页标题 - function updateDocumentTitle(){ - // if(form_type === 'feedback'){ - // document.title = `意见反馈` - // }else if(form_type === 'new'){ - // document.title = `新建疑修-${author.name}/${name}` - // }else{ - // subject && (document.title = `${subject}-疑修-${author.name}/${name}`); - // } - } + useEffect(()=>{ + const {projectDetail} = props; + if(projectDetail){ + const { author, name} = projectDetail; + document.title = `新建疑修-${author.name}/${name}` + } + },[]) // 获取状态列表 @@ -75,7 +69,16 @@ function New(props){ const url = `/v1/${owner}/${projectsId}/issue_priorities`; axios.get(url).then(result=>{ if(result && result.data){ - setPrioritiesList(result.data.priorities); + let priorities = result.data.priorities; + let array =[]; + let colors = ["#1abcb1","#28be6c","#db3d1d","#db3d1d"]; + if(priorities && priorities.length>0){ + array = priorities.map((i,k)=>{ + let arr = {...i,color:colors[k]} + return arr; + }) + } + setPrioritiesList(array); } }) } @@ -183,7 +186,8 @@ function New(props){

新建疑修

- +
{setCharegeId(ids);let copyname = { ...names,assigner_name:name};setNames(copyname);}} list={chargeList} searchFlag searchFunc={(value)=>setCharge(value)} double={5}/> diff --git a/src/forge/Issues/Pages/sign.jsx b/src/forge/Issues/Pages/sign.jsx index 93fe977a6..a9082be48 100644 --- a/src/forge/Issues/Pages/sign.jsx +++ b/src/forge/Issues/Pages/sign.jsx @@ -56,16 +56,22 @@ function Sign(props){ const menu = ( - + 按疑修数量降序排序 - + 按疑修数量升序排序 - + + 按疑修数量降序排序 + + + 按疑修数量升序排序 + + 按合并请求数量降序排序 - + 按合并请求数量升序排序 @@ -180,7 +186,7 @@ function Sign(props){
}
- 项目标记({total || 0}) + 项目标记({total || 0}) {arrayName} diff --git a/src/forge/Issues/index.jsx b/src/forge/Issues/index.jsx index 862c2f37e..c522c78de 100644 --- a/src/forge/Issues/index.jsx +++ b/src/forge/Issues/index.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React,{useEffect} from 'react'; import { Route, Switch } from "react-router-dom"; import Loadable from "react-loadable"; import Loading from "../../Loading"; @@ -22,6 +22,15 @@ const New = Loadable({ }); function Index(props){ + const pathname = props.history.location.pathname; + + useEffect(() => { + if (document) { // 可以排除不需要置顶的页面 + if (document.documentElement || document.body) { + document.documentElement.scrollTop = document.body.scrollTop = 0; // 切换路由时手动置顶 + } + } + }, [pathname]); return(
diff --git a/src/forge/Issues/index.scss b/src/forge/Issues/index.scss index 48dccfb6c..8c4012956 100644 --- a/src/forge/Issues/index.scss +++ b/src/forge/Issues/index.scss @@ -148,6 +148,8 @@ display: block; border:1px solid ; border-color: rgba(70, 106, 255, 0.01); + min-width: 30px; + text-align: center; } } } @@ -424,6 +426,7 @@ width: 100%; height: 20px; line-height: 20px; + font-weight: 600; a{ position: absolute; right: 0px; @@ -570,9 +573,11 @@ } } .descPanel{ - margin:20px 0px; + margin-top:20px; padding:20px; - background-color: #f7f8fd; + // background-color: #f7f8fd; + border:1px solid #c9d8ff; + border-radius: 2px; } // 新建页面 .explain{ diff --git a/src/forge/Settings/Index.js b/src/forge/Settings/Index.js index fad3fedc2..6b7e51fc5 100644 --- a/src/forge/Settings/Index.js +++ b/src/forge/Settings/Index.js @@ -151,13 +151,13 @@ class Index extends Component { )} > - {/* 修改仓库信息 */} - ( )} - > + > */} ( diff --git a/src/forge/Upload/attachment.js b/src/forge/Upload/attachment.js index fe21fbc1d..b668eb017 100644 --- a/src/forge/Upload/attachment.js +++ b/src/forge/Upload/attachment.js @@ -76,6 +76,7 @@ class Attachment extends Component { }; deleteAttachment = (id) => { + const { deleteLoad } = this.props; const url = `/attachments/${id}.json`; axios .delete(url, {}) @@ -86,6 +87,7 @@ class Attachment extends Component { Deleted: this.state.Deleted.concat(id), }); this.props.showNotification("附件删除成功"); + deleteLoad && deleteLoad(id); } else { this.props.showNotification(response.data.message); }