Merge pull request '将功能合并至educoder forge(隐藏wiki)' (#32) from caishi/forgeplus-react:develop_educoder into develop_educoder

This commit is contained in:
jasder 2021-09-03 13:43:52 +08:00
commit b6f53575c9
72 changed files with 4540 additions and 737 deletions

509
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 2340181 */
src: url('iconfont.woff2?t=1625800786751') format('woff2'),
url('iconfont.woff?t=1625800786751') format('woff'),
url('iconfont.ttf?t=1625800786751') format('truetype');
src: url('iconfont.woff2?t=1630045103946') format('woff2'),
url('iconfont.woff?t=1630045103946') format('woff'),
url('iconfont.ttf?t=1630045103946') format('truetype');
}
.iconfont {
@ -13,6 +13,334 @@
-moz-osx-font-smoothing: grayscale;
}
.icon-xinshouzhiyin:before {
content: "\e8e4";
}
.icon-xinjianxiangmu:before {
content: "\e8e6";
}
.icon-jiaruketang1:before {
content: "\e8e9";
}
.icon-xiangmugonggao:before {
content: "\e8c2";
}
.icon-chengguo:before {
content: "\e8c3";
}
.icon-chengjiaogonggao:before {
content: "\e8c0";
}
.icon-jishuzichan:before {
content: "\e8c1";
}
.icon-feibiaogonggao:before {
content: "\e8bc";
}
.icon-zhongbiaogonggao:before {
content: "\e8bd";
}
.icon-gengzhenggonggao:before {
content: "\e8be";
}
.icon-zhaobiaogonggao:before {
content: "\e8bf";
}
.icon-wenjian6:before {
content: "\e8ba";
}
.icon-wenjianjia4:before {
content: "\e8bb";
}
.icon-quxiaoguanzhu:before {
content: "\e89a";
}
.icon-dianzan_icon:before {
content: "\e8a2";
}
.icon-wenjian5:before {
content: "\e896";
}
.icon-wenjianjia3:before {
content: "\e8a9";
}
.icon-fuzhiicon:before {
content: "\e886";
}
.icon-zhuye-fill:before {
content: "\e876";
}
.icon-daimakuicon:before {
content: "\e884";
}
.icon-xinjian2:before {
content: "\e8b0";
}
.icon-xieyiicon:before {
content: "\e870";
}
.icon-neicunicon:before {
content: "\e891";
}
.icon-zishuwenjian_icon:before {
content: "\e8a6";
}
.icon-biaoqianicon:before {
content: "\e882";
}
.icon-a-bianji:before {
content: "\e883";
}
.icon-cangkushezhiicon:before {
content: "\e885";
}
.icon-lianjieicon:before {
content: "\e887";
}
.icon-hebingqingqiuicon:before {
content: "\e888";
}
.icon-lichengbeiicon:before {
content: "\e889";
}
.icon-gongzuoliuicon:before {
content: "\e88a";
}
.icon-dongtaiicon:before {
content: "\e88b";
}
.icon-morendianzan_icon:before {
content: "\e88e";
}
.icon-muluicon:before {
content: "\e894";
}
.icon-a-shezhi:before {
content: "\e899";
}
.icon-tijiaoicon:before {
content: "\e89e";
}
.icon-morenguanzhu_ICON:before {
content: "\e89f";
}
.icon-xialaanniu1:before {
content: "\e8a4";
}
.icon-zuohuaicon:before {
content: "\e8b5";
}
.icon-master_icon:before {
content: "\e8b6";
}
.icon-morenfuke_icon:before {
content: "\e8b7";
}
.icon-a-wikiicon:before {
content: "\e8b8";
}
.icon-yixiuicon:before {
content: "\e8b9";
}
.icon-suofang:before {
content: "\e87f";
}
.icon-fangdaicon:before {
content: "\e881";
}
.icon-sousuo_icon1:before {
content: "\e873";
}
.icon-huanying_icon:before {
content: "\e878";
}
.icon-wenjianjia2:before {
content: "\e879";
}
.icon-shanchuicon1:before {
content: "\e87a";
}
.icon-qingqiuicon:before {
content: "\e871";
}
.icon-xiangyingicon:before {
content: "\e87c";
}
.icon-duoxuanxuanzhong:before {
content: "\e88f";
}
.icon-cuowuicon:before {
content: "\e890";
}
.icon-chenggongicon:before {
content: "\e892";
}
.icon-weixuanzhongxiangyingicon:before {
content: "\e893";
}
.icon-bitianicon:before {
content: "\e895";
}
.icon-weixuanzhongxiangmubiaoqianicon:before {
content: "\e897";
}
.icon-liebiaoicon:before {
content: "\e898";
}
.icon-weixuanzhongqingqiuicon:before {
content: "\e89b";
}
.icon-xiezuozheguanliicon:before {
content: "\e8a1";
}
.icon-xuanzhongfenzhiicon:before {
content: "\e8a3";
}
.icon-xuanzhongjibenshezhiicon:before {
content: "\e8a5";
}
.icon-xuanzhongxiangmubiaoqianicon:before {
content: "\e8aa";
}
.icon-a-xuanzhongwebhookicon:before {
content: "\e8af";
}
.icon-shanchu_tc_icon:before {
content: "\e88c";
}
.icon-wiki_icon:before {
content: "\e88d";
}
.icon-daorumoban_icon:before {
content: "\e86f";
}
.icon-cuowu:before {
content: "\e872";
}
.icon-gengduo_icon:before {
content: "\e874";
}
.icon-fucengguanbi_icon:before {
content: "\e875";
}
.icon-shanchuicon:before {
content: "\e877";
}
.icon-sousuo_shanchuicon:before {
content: "\e87b";
}
.icon-sousuo_icon:before {
content: "\e87d";
}
.icon-wendangyulan_icon:before {
content: "\e87e";
}
.icon-xialaanniu:before {
content: "\e880";
}
.icon-erciqueren_icon:before {
content: "\e867";
}
.icon-xuanzhongssh_icon:before {
content: "\e868";
}
.icon-weixuanzhonganquanshezhi_icon:before {
content: "\e869";
}
.icon-weixuanzhongssh_icon:before {
content: "\e86a";
}
.icon-xuanzhonganquanshezhi_icon:before {
content: "\e86b";
}
.icon-shanchu_icon:before {
content: "\e86c";
}
.icon-liebiaossh_icon:before {
content: "\e86e";
}
.icon-file-submodule:before {
content: "\e866";
}

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,580 @@
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "23655968",
"name": "新手指引",
"font_class": "xinshouzhiyin",
"unicode": "e8e4",
"unicode_decimal": 59620
},
{
"icon_id": "23655969",
"name": "新建项目",
"font_class": "xinjianxiangmu",
"unicode": "e8e6",
"unicode_decimal": 59622
},
{
"icon_id": "23658111",
"name": "加入课堂",
"font_class": "jiaruketang1",
"unicode": "e8e9",
"unicode_decimal": 59625
},
{
"icon_id": "23791639",
"name": "项目公告",
"font_class": "xiangmugonggao",
"unicode": "e8c2",
"unicode_decimal": 59586
},
{
"icon_id": "23791640",
"name": "成果",
"font_class": "chengguo",
"unicode": "e8c3",
"unicode_decimal": 59587
},
{
"icon_id": "23791410",
"name": "成交公告",
"font_class": "chengjiaogonggao",
"unicode": "e8c0",
"unicode_decimal": 59584
},
{
"icon_id": "23791411",
"name": "技术资产",
"font_class": "jishuzichan",
"unicode": "e8c1",
"unicode_decimal": 59585
},
{
"icon_id": "23790928",
"name": "废标公告",
"font_class": "feibiaogonggao",
"unicode": "e8bc",
"unicode_decimal": 59580
},
{
"icon_id": "23790929",
"name": "中标公告",
"font_class": "zhongbiaogonggao",
"unicode": "e8bd",
"unicode_decimal": 59581
},
{
"icon_id": "23790930",
"name": "更正公告",
"font_class": "gengzhenggonggao",
"unicode": "e8be",
"unicode_decimal": 59582
},
{
"icon_id": "23790931",
"name": "招标公告",
"font_class": "zhaobiaogonggao",
"unicode": "e8bf",
"unicode_decimal": 59583
},
{
"icon_id": "23732532",
"name": "文件",
"font_class": "wenjian6",
"unicode": "e8ba",
"unicode_decimal": 59578
},
{
"icon_id": "23732533",
"name": "文件夹",
"font_class": "wenjianjia4",
"unicode": "e8bb",
"unicode_decimal": 59579
},
{
"icon_id": "23642443",
"name": "取消关注",
"font_class": "quxiaoguanzhu",
"unicode": "e89a",
"unicode_decimal": 59546
},
{
"icon_id": "23642444",
"name": "点赞_icon",
"font_class": "dianzan_icon",
"unicode": "e8a2",
"unicode_decimal": 59554
},
{
"icon_id": "23639530",
"name": "文件",
"font_class": "wenjian5",
"unicode": "e896",
"unicode_decimal": 59542
},
{
"icon_id": "23639533",
"name": "文件夹",
"font_class": "wenjianjia3",
"unicode": "e8a9",
"unicode_decimal": 59561
},
{
"icon_id": "23639440",
"name": "复制icon",
"font_class": "fuzhiicon",
"unicode": "e886",
"unicode_decimal": 59526
},
{
"icon_id": "23639422",
"name": "主页-fill",
"font_class": "zhuye-fill",
"unicode": "e876",
"unicode_decimal": 59510
},
{
"icon_id": "23639423",
"name": "代码库icon",
"font_class": "daimakuicon",
"unicode": "e884",
"unicode_decimal": 59524
},
{
"icon_id": "23572260",
"name": "新建",
"font_class": "xinjian2",
"unicode": "e8b0",
"unicode_decimal": 59568
},
{
"icon_id": "23567674",
"name": "协议icon",
"font_class": "xieyiicon",
"unicode": "e870",
"unicode_decimal": 59504
},
{
"icon_id": "23567675",
"name": "内存icon",
"font_class": "neicunicon",
"unicode": "e891",
"unicode_decimal": 59537
},
{
"icon_id": "23567676",
"name": "自述文件_icon",
"font_class": "zishuwenjian_icon",
"unicode": "e8a6",
"unicode_decimal": 59558
},
{
"icon_id": "23472253",
"name": "标签icon",
"font_class": "biaoqianicon",
"unicode": "e882",
"unicode_decimal": 59522
},
{
"icon_id": "23472254",
"name": "编 辑",
"font_class": "a-bianji",
"unicode": "e883",
"unicode_decimal": 59523
},
{
"icon_id": "23472256",
"name": "仓库设置icon",
"font_class": "cangkushezhiicon",
"unicode": "e885",
"unicode_decimal": 59525
},
{
"icon_id": "23472258",
"name": "链接icon",
"font_class": "lianjieicon",
"unicode": "e887",
"unicode_decimal": 59527
},
{
"icon_id": "23472259",
"name": "合并请求icon",
"font_class": "hebingqingqiuicon",
"unicode": "e888",
"unicode_decimal": 59528
},
{
"icon_id": "23472260",
"name": "里程碑icon",
"font_class": "lichengbeiicon",
"unicode": "e889",
"unicode_decimal": 59529
},
{
"icon_id": "23472261",
"name": "工作流icon",
"font_class": "gongzuoliuicon",
"unicode": "e88a",
"unicode_decimal": 59530
},
{
"icon_id": "23472262",
"name": "动态icon",
"font_class": "dongtaiicon",
"unicode": "e88b",
"unicode_decimal": 59531
},
{
"icon_id": "23472263",
"name": "默认点赞_icon",
"font_class": "morendianzan_icon",
"unicode": "e88e",
"unicode_decimal": 59534
},
{
"icon_id": "23472265",
"name": "目录icon",
"font_class": "muluicon",
"unicode": "e894",
"unicode_decimal": 59540
},
{
"icon_id": "23472267",
"name": "设 置",
"font_class": "a-shezhi",
"unicode": "e899",
"unicode_decimal": 59545
},
{
"icon_id": "23472269",
"name": "提交icon",
"font_class": "tijiaoicon",
"unicode": "e89e",
"unicode_decimal": 59550
},
{
"icon_id": "23472270",
"name": "默认关注_ICON",
"font_class": "morenguanzhu_ICON",
"unicode": "e89f",
"unicode_decimal": 59551
},
{
"icon_id": "23472272",
"name": "下拉按钮",
"font_class": "xialaanniu1",
"unicode": "e8a4",
"unicode_decimal": 59556
},
{
"icon_id": "23472276",
"name": "左滑icon",
"font_class": "zuohuaicon",
"unicode": "e8b5",
"unicode_decimal": 59573
},
{
"icon_id": "23472277",
"name": "master_icon",
"font_class": "master_icon",
"unicode": "e8b6",
"unicode_decimal": 59574
},
{
"icon_id": "23472278",
"name": "默认复刻_icon",
"font_class": "morenfuke_icon",
"unicode": "e8b7",
"unicode_decimal": 59575
},
{
"icon_id": "23472279",
"name": "wiki icon",
"font_class": "a-wikiicon",
"unicode": "e8b8",
"unicode_decimal": 59576
},
{
"icon_id": "23472280",
"name": "易修icon",
"font_class": "yixiuicon",
"unicode": "e8b9",
"unicode_decimal": 59577
},
{
"icon_id": "23436350",
"name": "缩放",
"font_class": "suofang",
"unicode": "e87f",
"unicode_decimal": 59519
},
{
"icon_id": "23436351",
"name": "放大icon",
"font_class": "fangdaicon",
"unicode": "e881",
"unicode_decimal": 59521
},
{
"icon_id": "23384231",
"name": "搜索_icon",
"font_class": "sousuo_icon1",
"unicode": "e873",
"unicode_decimal": 59507
},
{
"icon_id": "23384232",
"name": "欢迎_icon",
"font_class": "huanying_icon",
"unicode": "e878",
"unicode_decimal": 59512
},
{
"icon_id": "23384233",
"name": "文件夹",
"font_class": "wenjianjia2",
"unicode": "e879",
"unicode_decimal": 59513
},
{
"icon_id": "23384234",
"name": "删除icon",
"font_class": "shanchuicon1",
"unicode": "e87a",
"unicode_decimal": 59514
},
{
"icon_id": "23261798",
"name": "请求icon",
"font_class": "qingqiuicon",
"unicode": "e871",
"unicode_decimal": 59505
},
{
"icon_id": "23261799",
"name": "响应icon",
"font_class": "xiangyingicon",
"unicode": "e87c",
"unicode_decimal": 59516
},
{
"icon_id": "23144143",
"name": "多选选中",
"font_class": "duoxuanxuanzhong",
"unicode": "e88f",
"unicode_decimal": 59535
},
{
"icon_id": "23144144",
"name": "错误icon",
"font_class": "cuowuicon",
"unicode": "e890",
"unicode_decimal": 59536
},
{
"icon_id": "23144146",
"name": "成功icon",
"font_class": "chenggongicon",
"unicode": "e892",
"unicode_decimal": 59538
},
{
"icon_id": "23144147",
"name": "未选中响应icon",
"font_class": "weixuanzhongxiangyingicon",
"unicode": "e893",
"unicode_decimal": 59539
},
{
"icon_id": "23144149",
"name": "必填icon",
"font_class": "bitianicon",
"unicode": "e895",
"unicode_decimal": 59541
},
{
"icon_id": "23144151",
"name": "未选中项目标签icon",
"font_class": "weixuanzhongxiangmubiaoqianicon",
"unicode": "e897",
"unicode_decimal": 59543
},
{
"icon_id": "23144152",
"name": "列表icon",
"font_class": "liebiaoicon",
"unicode": "e898",
"unicode_decimal": 59544
},
{
"icon_id": "23144155",
"name": "未选中请求icon",
"font_class": "weixuanzhongqingqiuicon",
"unicode": "e89b",
"unicode_decimal": 59547
},
{
"icon_id": "23144158",
"name": "协作者管理icon",
"font_class": "xiezuozheguanliicon",
"unicode": "e8a1",
"unicode_decimal": 59553
},
{
"icon_id": "23144160",
"name": "选中分支icon",
"font_class": "xuanzhongfenzhiicon",
"unicode": "e8a3",
"unicode_decimal": 59555
},
{
"icon_id": "23144162",
"name": "选中基本设置icon",
"font_class": "xuanzhongjibenshezhiicon",
"unicode": "e8a5",
"unicode_decimal": 59557
},
{
"icon_id": "23144165",
"name": "选中项目标签icon",
"font_class": "xuanzhongxiangmubiaoqianicon",
"unicode": "e8aa",
"unicode_decimal": 59562
},
{
"icon_id": "23144167",
"name": "选中webhook icon",
"font_class": "a-xuanzhongwebhookicon",
"unicode": "e8af",
"unicode_decimal": 59567
},
{
"icon_id": "23046290",
"name": "shanchu_tc_icon",
"font_class": "shanchu_tc_icon",
"unicode": "e88c",
"unicode_decimal": 59532
},
{
"icon_id": "23046293",
"name": "wiki_icon",
"font_class": "wiki_icon",
"unicode": "e88d",
"unicode_decimal": 59533
},
{
"icon_id": "23046244",
"name": "导入模版_icon",
"font_class": "daorumoban_icon",
"unicode": "e86f",
"unicode_decimal": 59503
},
{
"icon_id": "23046252",
"name": "错误",
"font_class": "cuowu",
"unicode": "e872",
"unicode_decimal": 59506
},
{
"icon_id": "23046255",
"name": "更多_icon",
"font_class": "gengduo_icon",
"unicode": "e874",
"unicode_decimal": 59508
},
{
"icon_id": "23046258",
"name": "复层关闭_icon",
"font_class": "fucengguanbi_icon",
"unicode": "e875",
"unicode_decimal": 59509
},
{
"icon_id": "23046268",
"name": "删除icon",
"font_class": "shanchuicon",
"unicode": "e877",
"unicode_decimal": 59511
},
{
"icon_id": "23046273",
"name": "搜索_删除icon",
"font_class": "sousuo_shanchuicon",
"unicode": "e87b",
"unicode_decimal": 59515
},
{
"icon_id": "23046275",
"name": "搜索_icon",
"font_class": "sousuo_icon",
"unicode": "e87d",
"unicode_decimal": 59517
},
{
"icon_id": "23046276",
"name": "文档预览_icon",
"font_class": "wendangyulan_icon",
"unicode": "e87e",
"unicode_decimal": 59518
},
{
"icon_id": "23046278",
"name": "下拉按钮",
"font_class": "xialaanniu",
"unicode": "e880",
"unicode_decimal": 59520
},
{
"icon_id": "22906287",
"name": "二次确认_icon",
"font_class": "erciqueren_icon",
"unicode": "e867",
"unicode_decimal": 59495
},
{
"icon_id": "22906288",
"name": "选中ssh_icon",
"font_class": "xuanzhongssh_icon",
"unicode": "e868",
"unicode_decimal": 59496
},
{
"icon_id": "22906289",
"name": "未选中安全设置_icon",
"font_class": "weixuanzhonganquanshezhi_icon",
"unicode": "e869",
"unicode_decimal": 59497
},
{
"icon_id": "22906290",
"name": "未选中ssh_icon",
"font_class": "weixuanzhongssh_icon",
"unicode": "e86a",
"unicode_decimal": 59498
},
{
"icon_id": "22906291",
"name": "选中安全设置_icon",
"font_class": "xuanzhonganquanshezhi_icon",
"unicode": "e86b",
"unicode_decimal": 59499
},
{
"icon_id": "22906292",
"name": "删除_icon",
"font_class": "shanchu_icon",
"unicode": "e86c",
"unicode_decimal": 59500
},
{
"icon_id": "22906293",
"name": "列表ssh_icon",
"font_class": "liebiaossh_icon",
"unicode": "e86e",
"unicode_decimal": 59502
},
{
"icon_id": "17575494",
"name": "file-submodule",

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -60,12 +60,13 @@ body {
.ant-progress-textno {
color: #f5222d;
}
.CodeMirror pre.CodeMirror-line{
font-size: 16px!important;
}
/* md多空格 */
.markdown-body p {
margin:10px 0px!important;
font-size: 16px !important;
line-height: 2 !important;
white-space: pre-wrap;
}
@ -87,6 +88,10 @@ body {
border-left: 1px solid rgb(221, 221, 221);
/* 某些情况下被cm盖住了 */
z-index: 99;
padding:8px 8px 50px;
}
.editormd-preview .markdown-body{
padding:0px !important;
}
/* 图片点击放大的场景,隐藏图片链接 */

View File

@ -73,11 +73,16 @@ const EducoderLogin = Loadable({
loader: () => import('./modules/login/EducoderLogin'),
loading: Loading,
})
// const Search = Loadable({
// loader: () => import('./search/SearchPage'),
// loading: Loading,
// })
// const WikiPreview = Loadable({
// loader: () => import('./forge/Wiki/Preview'),
// loading: Loading,
// })
const ProjectIndex = Loadable({
loader: () => import("./forge/Main/Index"),
loading: Loading,
});
class App extends Component {
constructor(props) {
super(props);
@ -190,9 +195,16 @@ class App extends Component {
<ConfigProvider locale={zhCN}>
<MuiThemeProvider theme={theme}>
<LoginDialog {...this.props} {...this.state} Modifyloginvalue={() => this.Modifyloginvalue()}></LoginDialog>
<SiderBar/>
<SiderBar />
<Router>
<Switch>
{/* wiki预览 */}
{/* <Route path="/projects/:owner/:projectsId/wiki/preview/:projectName/:projectId" render={
(props) => {
return (<WikiPreview {...this.props} {...props} {...this.state} />)
}
} /> */}
{/*项目*/}
<Route
path={"/projects/:owner/:projectId/devops/:opsId/detail"}
@ -224,6 +236,11 @@ class App extends Component {
</Route>
{/*404*/}
<Route path="/nopage" component={Shixunnopage} />
{/* 查询 */}
{/* <Route path="/search" component={Search} /> */}
{/* 个人主页 */}
<Route path="/users/:username"
render={

View File

@ -1,4 +1,5 @@
import moment from "moment";
import { number } from "prop-types";
// 处理整点 半点
// 取传入时间往后的第一个半点
@ -97,3 +98,40 @@ export function formatDuring(mss){
}
return days + "天" + hours + "小时" + minutes + "分";
}
/*
返回多久以前
backDate以前的某个日期
*/
export function timeAgo(backDate) {
try {
moment(backDate);
} catch (e) {
return;
}
if(typeof backDate ==='number'){
backDate=backDate*1000
}else{
backDate= moment(backDate);
}
let time = new Date() - backDate;
var days = Math.floor(time / (1000 * 60 * 60 * 24));
var hours = Math.floor((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((time % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((time % (1000 * 60 * 60)) / 1000);
if (time <= 0) {
return "刚刚";
}
if (days) {
return days + "天前";
}
if (hours) {
return hours + "小时前";
}
if (minutes) {
return minutes + "分前";
}
if (seconds) {
return seconds + "秒前";
}
}

View File

@ -27,7 +27,7 @@ export {
markdownToHTML, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll, isImageExtension,
downloadFile, sortDirections, validateLength, mdJSONParse, exportMdtoHtml
} from './TextUtil'
export { handleDateString, getNextHalfHourOfMoment, formatDuring, formatSeconds } from './DateUtil'
export { handleDateString, getNextHalfHourOfMoment, formatDuring, formatSeconds ,timeAgo} from './DateUtil'
export { configShareForIndex, configShareForPaths, configShareForShixuns, configShareForCourses, configShareForCustom } from './util/ShareUtil'

View File

@ -55,6 +55,7 @@ function AddGroup({organizeId,getGroupID}){
function addCollaborator(){
getGroupID && getGroupID(id);
setID(undefined);
}
return(

View File

@ -0,0 +1,44 @@
import React, { useState, useCallback, memo } from 'react';
import { Tooltip } from 'antd';
CopyTool.defaultProps = {
beforeText: '复制', //
afterText: '复制成功', //
className: '', //svgclass
inputId: 'copyText', //ID
};
function CopyTool({ beforeText, afterText, className,inputId }) {
const [title, setTitle] = useState(() => {
return beforeText;
});
//
const copyUrl = useCallback(() => {
let inputDom = document.getElementById(inputId);
if (!inputDom) {
console.error("您的CopyTool未设置正确的inputId");
return;
}
inputDom.select();
if (document.execCommand('copy')) {
document.execCommand('copy');
}
setTitle(afterText);
inputDom.blur();
}, []);
return (
<Tooltip
placement="top"
title={title}
onVisibleChange={() => { setTitle(beforeText) }}
>
<i className={`iconfont icon-fuzhiicon ${className}`} style={{ color: '#466aff' }} onClick={copyUrl}></i>
</Tooltip>
);
}
export default memo(CopyTool);

View File

@ -1,8 +1,8 @@
.ant-modal-mask{
z-index: 10000;
z-index: 1001;
}
.ant-modal-wrap{
z-index: 10001;
z-index: 1002;
.ant-form-explain{
position: absolute;
}

View File

@ -2,7 +2,7 @@ import React from 'react';
import { AlignCenter , AlignTop , FlexAJ } from '../Component/layout';
import { Link } from 'react-router-dom';
function Releases({owner,projectsId,releaseVersions}){
function Releases({owner,projectsId,releaseVersions , baseOperate , projectType}){
return(
<div>
@ -10,10 +10,10 @@ function Releases({owner,projectsId,releaseVersions}){
<AlignCenter><span className="font-16 color-grey-6">发行版</span>
{ releaseVersions && releaseVersions.total_count > 0 && <span className="infoCount">{releaseVersions.total_count}</span>}
</AlignCenter>
{ releaseVersions && releaseVersions.total_count > 0 ?
{ (releaseVersions && releaseVersions.total_count > 0) || projectType ===2 ?
<Link className="font-12 color-grey-9" to={`/projects/${owner}/${projectsId}/releases`}>全部</Link>
:
<Link className="font-12 color-blue" to={`/projects/${owner}/${projectsId}/releases/new`}>新建</Link>
baseOperate && <Link className="font-12 color-blue" to={`/projects/${owner}/${projectsId}/releases/new`}>新建</Link>
}
</FlexAJ>
{

View File

@ -1,45 +1,49 @@
import React , { useState } from 'react';
import React , { useState , useEffect } from 'react';
import { AutoComplete } from 'antd';
import { getImageUrl } from "educoder";
import axios from 'axios';
const Option = AutoComplete.Option;
export default ({ getUser })=>{
export default ({ getUser , placeholder, width ,value })=>{
const [ source , setSource ] = useState(undefined);
const [ searchKey , setSearchKey ] = useState(undefined);
const [ userDataSource , setUserDataSource ] = useState(undefined);
useEffect(()=>{
if(!value){
setSearchKey(undefined);
}
},[value])
useEffect(()=>{
getUserList();
},[searchKey])
function getUserList(e){
const url = `/users/list.json`;
axios.get(url, {
params: {
search: e,
search: searchKey,
},
})
.then((result) => {
}).then((result) => {
if (result) {
setUserDataSource(result.data.users);
sourceOptions(result.data.users);
}
})
.catch((error) => {
console.log(error);
});
};
function changeInputUser(value){
setSearchKey(value);
getUserList(value);
}
function selectInputUser(id, option){
setSearchKey(option.props.value);
getUserList(option.props.value);
getUser && getUser(id);
}
const source =
userDataSource && userDataSource.map((item, key) => {
function sourceOptions(userDataSource){
const s = userDataSource && userDataSource.map((item, key) => {
return (
<Option key={key} value={`${item.login}`}>
<Option
key={key}
value={`${item.user_id}`}
login={`${item.login}`}
name={item.username}
>
<img
className="user_img radius"
width="28"
@ -54,14 +58,31 @@ export default ({ getUser })=>{
</Option>
);
});
setSource(s);
}
function changeInputUser(e){
setSearchKey(e);
};
//
function selectInputUser(e, option){
setSearchKey(option.props.name);
getUser(option.props.login);
};
return(
<AutoComplete
dataSource={source}
value={searchKey}
style={{ width: 300 }}
onChange={changeInputUser}
onSelect={selectInputUser}
placeholder="搜索需要添加的用户..."
/>
<div className="addPanel">
<AutoComplete
getPopupContainer={trigger => trigger.parentNode}
dataSource={source}
value={searchKey}
style={{ width: width || 300 }}
onChange={changeInputUser}
onSelect={selectInputUser}
placeholder={placeholder || "搜索需要添加的用户..."}
allowClear
/>
</div>
)
}

View File

@ -20,13 +20,6 @@ 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(){
@ -48,7 +41,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
...values
}).then(result=>{
if(result){
onSuccess(result.data && result.data.owner);
onSuccess();
}
}).catch(error=>{})
}
@ -104,7 +97,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
</ul>
:
<ul className="descUl">
<li>仓库仅可以转移到您已经加入的组织中不可以转移到未加入的组织中</li>
<li>仓库仅可以转移到您具有管理权限的组织中</li>
<li>涉及到仓库改名操作请提前做好仓库备份并且在转移后对本地仓库的remote进行修改</li>
<li>转移仓库到组织后你和组织创建者/管理员同时拥有对该仓库的管理操作</li>
</ul>
@ -126,7 +119,6 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
{getFieldDecorator("owner_name",{
rules:[{required:true,message:"请输入目标用户名"}]
})(
// <Input placeholder="" autoComplete={"off"}/>
<SearchUser getUser={getUser} width={"100%"} placeholder="请输入目标用户" value={value}/>
)}
</Form.Item>
@ -152,20 +144,21 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
</Form.Item>
}
<Form.Item label="仓库名称:">
<Form.Item label="仓库标识:">
{getFieldDecorator("identifier",
{
rules:[
{required:true,message:"请输入仓库名称"},
{required:true,message:"请输入仓库标识"},
{
validator:checkIdentifier
}
]
}
)(
<Input placeholder="请输入仓库名称" autoComplete={"off"}/>
<Input placeholder="请输入仓库标识" autoComplete={"off"}/>
)}
</Form.Item>
<span className="color-grey-9" style={{marginLeft:"120px"}}>请输入当前项目的标识<span className="ml5 mr5 color-grey-3">{repo}</span>进行确认</span>
</Form>
</div>
</Modal>

View File

@ -0,0 +1,12 @@
.diverModal{
.descUl{
background-color: #fffae6;
border-radius: 4px;
padding:10px 15px;
color: #efc16b;
border:1px solid #efc16b;
}
.ant-form-item-required::before{
content: "";
}
}

View File

@ -63,6 +63,8 @@ function CoderDepot(props){
const [ readme , setReadme ] = useState(undefined);
const [ defaultBranch , setDefaultBranch ] = useState(undefined);
const [ editReadme , setEditReadme ] = useState(false);
const [ pullsFlag , setPullsFlag ] = useState(true);
const [ issuesFlag , setIssuesFlag ] = useState(true);
const owner = props.match.params.owner;
const projectsId = props.match.params.projectsId;
@ -70,6 +72,22 @@ function CoderDepot(props){
branchName = returnbar(branchName);
const details = props.projectDetail;
let pathname = props.history.location.pathname;
const { bannerList } = props;
useEffect(()=>{
if(bannerList && bannerList.length>0){
let a = bannerList.filter(i=>i.menu_name === "pulls");
let i = bannerList.filter(i=>i.menu_name === "issues");
if(a && a.length === 0){
setPullsFlag(false);
}
if(i && i.length === 0){
setIssuesFlag(false);
}
}
},[bannerList])
useEffect(()=>{
if(details){
@ -129,6 +147,7 @@ function CoderDepot(props){
setReadme(result.data.readme);
setEditReadme(false);
setHide(true);
console.log("dddd:",result.data.entries);
}
setTimeout(function(){setIsSpin(false);},500);
}).catch(error=>{setIsSpin(false);})
@ -282,6 +301,7 @@ function CoderDepot(props){
const mdFlag = n && n.substring(n.length-3,n.length) === ".md";
const { current_user } = props;
const baseOperate = projectDetail && projectDetail.permission && projectDetail.permission !=="Reporter";
const fileOperate = type === "dir" && projectDetail && projectDetail.type !== 2 && ((projectDetail.permission && projectDetail.permission !=="Reporter") || (current_user && current_user.admin));
return(
<WhiteBack>
@ -344,13 +364,19 @@ function CoderDepot(props){
</AlignCenter>
</AlignCenter>
<AlignCenter>
<div className="mr20 addOptionBtn">
{
projectDetail.type !== 2 &&
<a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/pulls/new`)} >+ 合并请求</a>
}
<a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/issues/new`)} >+ 任务</a>
</div>
{
baseOperate && ((projectDetail.type !== 2 && pullsFlag) || issuesFlag )&&
<div className="mr20 addOptionBtn">
{
projectDetail.type !== 2 && pullsFlag &&
<a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/pulls/new`)} >+ 合并请求</a>
}
{
issuesFlag &&
<a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/issues/new`)} >+ 任务</a>
}
</div>
}
{ fileOperate &&
<Dropdown overlay={fileMenu()} className="mr20" trigger={['click']}>
<Button type="default">文件 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-grey-9"></i></Button>
@ -363,7 +389,7 @@ function CoderDepot(props){
</AlignCenter>
</FlexAJ>
{
dirInfo || fileInfo ?
(dirInfo && dirInfo.length>0) || fileInfo ?
<div className="listtable">
{
lastCommit &&
@ -375,7 +401,9 @@ function CoderDepot(props){
{ hideBtn && <span className="ellipsis" onClick={()=>changeHide(hide)}><i className="iconfont icon-shenglvehao"></i></span> }
<span className="ml12 color-grey-9 mt3">{lastCommit && lastCommit.time_from_now}</span>
{ commitCount ? <Link to={`/projects/${owner}/${projectsId}/commits`} className="ml12 color-grey-9"><i className="iconfont icon-tijiao mr3 font-17 color-grey-9"></i>{commitCount}次提交</Link>:"" }
{ commitCount ? <Link to={`/projects/${owner}/${projectsId}/commits/branch/${turnbar(branchName || defaultBranch)}`} className="ml12 color-grey-9">
<i className="iconfont icon-tijiao mr3 font-17 color-grey-9"></i>{commitCount}次提交
</Link>:"" }
</div>
}
<ul className="listtablebody">
@ -419,7 +447,7 @@ function CoderDepot(props){
: ""
}
{
(dirInfo && dirInfo.length === 0) && (fileInfo && fileInfo.length === 0) ? <Nodata _html="暂未发现文件"/> :""
(dirInfo && dirInfo.length === 0) && !fileInfo ? <Nodata _html="暂未发现文件"/> :""
}
{/* readme文件显示(显示文件详情时不显示readme文件) */}
{ dirInfo && (readme && readme.content) ? <ReadMe ChangeFile={ChangeFile} readme={readme} operate={props && (props.isManager || props.isDeveloper) && projectDetail.type !==2 } history={props.history} /> :"" }
@ -469,7 +497,7 @@ function CoderDepot(props){
<div>
<Divider />
<p className="font-16 color-grey-6">实践课程</p>
<a href={lesson_url} target="_blank" className="color-grey-6" style={{textDecoration:"underline"}}>{lesson_url}</a>
<a href={lesson_url} target="_blank" className="color-grey-6" style={{textDecoration:"underline",wordBreak:"break-all"}}>{lesson_url}</a>
</div>
}
{/* 发布 */}
@ -477,16 +505,23 @@ function CoderDepot(props){
projectDetail && projectDetail.release_versions &&
<React.Fragment>
<Divider />
<Releases owner={owner} projectsId={projectsId} releaseVersions={projectDetail.release_versions} history={props.history}/>
<Releases
owner={owner}
projectsId={projectsId}
releaseVersions={projectDetail.release_versions}
history={props.history}
baseOperate={baseOperate}
projectType={projectDetail.type}
/>
</React.Fragment>
}
{/* 贡献者 */}
{
projectDetail && projectDetail.contributors &&
projectDetail && projectDetail.contributors && projectDetail.contributors.length >0 &&
<Contributors contributors={projectDetail && projectDetail.contributors} owner={owner} projectsId={projectsId} />
}
{/* 语言 */}
{ projectDetail && projectDetail.languages &&
{ projectDetail && projectDetail.languages && projectDetail.languages.length >0 &&
<React.Fragment>
<Divider />
<LanguagePower languages={projectDetail.languages}/>

View File

@ -17,7 +17,7 @@ export default ((props)=>{
const [ isSpin , setIsSpin ] =useState(true);
const { projectsId , owner } = props.match.params;
const { isManager , isDeveloper , projectDetail } = props;
useEffect(()=>{
getBranchs(projectsId, owner);
},[projectsId])
@ -46,7 +46,10 @@ export default ((props)=>{
</p>
</div>
<span>
<Link to={`/projects/${owner}/${projectsId}/pulls/new/${item.name}`} className="mr20 color-blue mr30">创建合并请求</Link>
{
(isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) &&
<Link to={`/projects/${owner}/${projectsId}/pulls/new/${item.name}`} className="mr20 color-blue mr30">创建合并请求</Link>
}
<Dropdown overlay={menu(item.zip_url,item.tar_url)} trigger={['click']} placement="bottomRight" className="color-green-file">
<a className="ant-dropdown-link">
<Tooltip title={`下载分支${item.name}`}><Icon type="cloud-download" className="font-18"/></Tooltip>
@ -70,6 +73,7 @@ export default ((props)=>{
<Menu.Item key={'1'}><a href={tar_url}>TAR.GZ</a></Menu.Item>
</Menu>
)
return(
<React.Fragment>
<div className="main">

View File

@ -9,6 +9,12 @@ import Nodata from '../Nodata';
import axios from 'axios';
import {Link} from "react-router-dom";
function returnbar(str){
if(str && str.length>0 && str.indexOf("%2F")>-1){
return str.replaceAll('%2F','/');
}
return str;
}
class CoderRootCommit extends Component{
constructor(props){
super(props)
@ -57,11 +63,12 @@ class CoderRootCommit extends Component{
this.setState({
isSpining:true
})
console.log(returnbar(branch));
const { projectsId , owner } = this.props.match.params;
const url = `/${owner}/${projectsId}/commits.json`;
axios.get(url,{
params:{
sha:branch,
sha:returnbar(branch),
page,
limit
}
@ -106,7 +113,7 @@ class CoderRootCommit extends Component{
const { commitDatas , dataCount , limit , page , isSpining , branchList } = this.state;
const { projectDetail, commit_class , defaultBranch } = this.props;
const { projectsId , owner , branchName } = this.props.match.params;
let branch = branchName || defaultBranch;
let branch = returnbar(branchName || defaultBranch);
return(
<React.Fragment>
<div className={"main"}>

View File

@ -102,6 +102,11 @@ class CoderRootIndex extends Component{
(props) => (<FileNew {...this.props} {...props} {...this.state} getTopCount={this.getTopCount} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/commits/branch/:branchName"
render={
() => (<CoderRootCommit {...this.props} {...this.state} commit_class="main" getTopCount={this.getTopCount} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/commits/:sha"
render={
(props) => (<Diff {...this.props} {...props} {...this.state}/>)

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { Spin, Tooltip , Button } from 'antd';
import { Spin, Tooltip, Button } from 'antd';
import { Link, Route, Switch } from 'react-router-dom';
import { Content , AlignTop } from '../Component/layout';
import { Content, AlignTop } from '../Component/layout';
import DetailBanner from './sub/DetailBanner';
import '../css/index.scss'
import './list.css';
@ -103,12 +103,12 @@ const Contribute = Loadable({
})
const CoderRootCommit = Loadable({
loader: () => import('./CoderRootCommit'),
loading: Loading,
loader: () => import('./CoderRootCommit'),
loading: Loading,
})
const CoderDepot = Loadable({
loader: () => import('./CoderDepot'),
loading: Loading,
loader: () => import('./CoderDepot'),
loading: Loading,
})
const TrendsIndex = Loadable({
@ -127,30 +127,40 @@ const Source = Loadable({
const DevIndex = Loadable({
loader: () => import('../DevOps/Index'),
loading: Loading,
})
});
const Wiki = Loadable({
loader: () => import('../Wiki/Index'),
loading: Loading,
});
const WikiEdit = Loadable({
loader: () => import('../Wiki/EditWiki'),
loading: Loading,
});
/**
* permissionManager:管理员Reporter报告人员(只有读取权限)Developer开发人员除不能设置仓库信息外
*/
function checkPathname(projectsId,owner,pathname){
function checkPathname(projectsId, owner, pathname) {
let name = "";
if(pathname && pathname !== `/projects/${owner}/${projectsId}`){
if (pathname && pathname !== `/projects/${owner}/${projectsId}`) {
let url = pathname.split(`/projects/${owner}/${projectsId}`)[1];
if(url.indexOf("/about")>-1){
name="about"
}else if(url.indexOf("/issues")>-1 ||url.indexOf("Milepost") > 0){
if (url.indexOf("/about") > -1) {
name = "about"
} else if (url.indexOf("/issues") > -1 || url.indexOf("Milepost") > 0) {
name = "issues";
}else if(url.indexOf("/pulls")>-1){
name="pulls"
}else if(url.indexOf("/milestones")>-1){
name="milestones"
}else if(url.indexOf("/activity")>-1){
name="activity"
}else if(url.indexOf("/setting")>-1){
name="setting"
}else if(url.indexOf(`/devops`)>-1){
name="devops"
}else if(url.indexOf(`/source`)>-1){
name="source"
} else if (url.indexOf("/pulls") > -1) {
name = "pulls"
} else if (url.indexOf("/milestones") > -1) {
name = "milestones"
} else if (url.indexOf("/activity") > -1) {
name = "activity"
} else if (url.indexOf("/setting") > -1) {
name = "setting"
} else if (url.indexOf(`/devops`) > -1) {
name = "devops"
} else if (url.indexOf(`/source`) > -1) {
name = "source"
} else if (url.indexOf(`/wiki`) > -1) {
name = "wiki"
}
}
return name;
@ -173,15 +183,15 @@ class Detail extends Component {
branchs: undefined,
branchList: undefined,
project: null,
firstSync:false,
secondSync:false,
open_devops:false,
forkSpin:false,
firstSync: false,
secondSync: false,
open_devops: false,
forkSpin: false,
// 默认分支
defaultBranch:undefined,
defaultBranch: undefined,
// 非本平台项目
platform:false
platform: false
}
}
@ -198,36 +208,38 @@ class Detail extends Component {
}
getProject = (num) => {
const { projectsId , owner } = this.props.match.params;
const { projectsId, owner } = this.props.match.params;
const url = `/${owner}/${projectsId}/simple.json`;
axios.get(url).then((result) => {
if (result && result.data) {
this.setState({
project: result.data,
open_devops:result.data.open_devops,
platform:result.data.platform && result.data.platform !== 'educoder'
open_devops: result.data.open_devops,
platform: result.data.platform && result.data.platform !== 'educoder'
})
if (result.data.type !== 0 && result.data.mirror_status === 1) {
console.log("--------start channel --------");
// 是镜像项目,且未完成迁移
this.canvasChannel();
if(num){
if (num) {
this.setState({
secondSync:true,
firsrtSync:false
secondSync: true,
firstSync: false
})
}else{
} else {
this.setState({
firstSync:true,
secondSync:false
firstSync: true,
secondSync: false
})
}
}else{
} else if (result.data.mirror_status === 2) {
this.deleteProjectBack();
} else {
this.getDetail();
this.setState({
firsrtSync:false,
secondSync:false
firstSync: false,
secondSync: false
})
}
}
@ -235,9 +247,9 @@ class Detail extends Component {
}
// 工作流激活后修改状态
changeOpenDevops=(flag)=>{
changeOpenDevops = (flag) => {
this.setState({
open_devops:flag
open_devops: flag
})
}
canvasChannel = () => {
@ -247,7 +259,7 @@ class Detail extends Component {
var cable = actioncable.createConsumer(`wss://${name}/cable`);
this.canvasChannel1 = cable.subscriptions.create({
channel: `MirrorProjectChannel`,
id: project && project.identifier
id: project && project.id
}, {
connected: () => {
console.log("###### channel connected! ######");
@ -255,16 +267,41 @@ class Detail extends Component {
disconnected: () => { },
received: data => {
console.log(`###### ---received data--- ######`);
console.log(data);
if (data) {
if ( data.project && data.project.mirror_status === 2) {
this.deleteProjectBack();
}
this.getDetail();
this.setState({
firstSync: false,
secondSync: false
});
cable.subscriptions.consumer.disconnect();
}
}
})
}
deleteProjectBack = () => {
const { history } = this.props;
const { projectsId, owner } = this.props.match.params;
axios.delete(`/${owner}/${projectsId}.json`).then(res => {
let hash = '/projects/mirror/new';
if (res && res.data) {
history.push({
pathname: hash,
mirror_status: 2
});
}
else {
window.location.hash = hash;
}
});
}
getDetail = () => {
const { projectsId , owner } = this.props.match.params;
const { projectsId, owner } = this.props.match.params;
this.getBanner();
const url = `/${owner}/${projectsId}/detail.json`;
axios.get(url).then((result) => {
@ -281,29 +318,29 @@ class Detail extends Component {
watchers_count: result.data.watchers_count,
praises_count: result.data.praises_count,
forked_count: result.data.forked_count,
defaultBranch:result.data.default_branch
defaultBranch: result.data.default_branch
})
}
}).catch((error) => { })
}
// 获取动态导航栏菜单
getBanner(){
const { projectsId , owner } = this.props.match.params;
getBanner() {
const { projectsId, owner } = this.props.match.params;
const url = `/${owner}/${projectsId}/menu_list.json`;
axios.get(url).then(result=>{
if(result){
axios.get(url).then(result => {
if (result) {
this.setState({
bannerList:result.data
bannerList: result.data
})
}
}).catch(error=>{})
}).catch(error => { })
}
// 关注和取消关注
focusFunc = (flag) => {
const { platform } = this.state;
if(!platform)return;
if (!platform) return;
const { project_id } = this.state;
axios({
@ -318,15 +355,15 @@ class Detail extends Component {
this.setWatchersCount(result.data.watchers_count, result.data.watched);
}
})
.catch(error => {
console.log(error);
});
.catch(error => {
console.log(error);
});
}
// 点赞和取消点赞
pariseFunc = (flag) => {
const { platform } = this.state;
if(!platform)return;
if (!platform) return;
const { project_id } = this.state;
axios({
method: flag ? 'delete' : 'post',
@ -336,9 +373,9 @@ class Detail extends Component {
this.setPraisesCount(result.data.praises_count, result.data.praised)
}
})
.catch(error => {
console.log(error);
});
.catch(error => {
console.log(error);
});
}
setWatchersCount = (count, is_watched) => {
@ -365,7 +402,7 @@ class Detail extends Component {
return;
}
this.setState({
forkSpin:true
forkSpin: true
})
const { projectsId , owner } = this.props.match.params;
const url = `/${owner}/${projectsId}/forks.json`;
@ -375,11 +412,11 @@ class Detail extends Component {
this.props.showNotification(result.data.message);
}
this.setState({
forkSpin:false
forkSpin: false
})
}).catch(error => {
this.setState({
forkSpin:false
forkSpin: false
})
})
}
@ -387,8 +424,8 @@ class Detail extends Component {
// 同步镜像
synchronismMirror = () => {
const { platform } = this.state;
if(!platform)return;
const { projectsId , owner } = this.props.match.params;
if (!platform) return;
const { projectsId, owner } = this.props.match.params;
const url = `/${owner}/${projectsId}/sync_mirror.json`;
axios.post(url).then(result => {
if (result && result.data && result.data.status === 0) {
@ -402,326 +439,344 @@ class Detail extends Component {
})
}
textFunc = (forked_from_project_id,fork_info)=>{
textFunc = (forked_from_project_id, fork_info) => {
let type = fork_info && fork_info.fork_project_user_type;
return forked_from_project_id && fork_info ?
<div className="color-grey-9 df">
<span>复刻自</span>
<Link to={`${type ==="Organization" ? "/organize":'/users'}/${fork_info.fork_project_user_login}`} className="show-user-link color-grey-6 ml5">{fork_info.fork_project_user_name}</Link>
<Link to={`${type === "Organization" ? "/organize" : '/users'}/${fork_info.fork_project_user_login}`} className="show-user-link color-grey-6 ml5">{fork_info.fork_project_user_name}</Link>
<span> / </span>
<Link to={`/projects/${fork_info.fork_project_user_login}/${fork_info.fork_project_identifier}`} className="color-grey-6 task-hide flex1" style={{maxWidth:"400px"}} title={fork_info.fork_form_name}>{fork_info.fork_form_name}</Link>
<Link to={`/projects/${fork_info.fork_project_user_login}/${fork_info.fork_project_identifier}`} className="color-grey-6 task-hide flex1" style={{ maxWidth: "400px" }} title={fork_info.fork_form_name}>{fork_info.fork_form_name}</Link>
</div> : ""
}
render() {
const { projectDetail, watchers_count, praises_count,
forked_count, firstSync , secondSync ,
isManager, watched, praised,
project , open_devops , platform , defaultBranch , bannerList , forkSpin } = this.state;
const { projectDetail, watchers_count, praises_count,
forked_count, firstSync, secondSync,
isManager, watched, praised,
project, open_devops, platform, defaultBranch, bannerList, forkSpin } = this.state;
const url = this.props.history.location.pathname;
const urlArr = url.split("/");
const urlFlag = (urlArr.length === 3);
const { projectsId , owner } = this.props.match.params;
const { projectsId, owner } = this.props.match.params;
const { current_user } = this.props;
let pathname = checkPathname(projectsId,owner,url);
let pathname = checkPathname(projectsId, owner, url);
const { state } = this.props.history.location;
const common = {
getDetail: this.getDetail,
changeOpenDevops:this.changeOpenDevops,
changeOpenDevops: this.changeOpenDevops,
defaultBranch
}
return (
<div>
<div className="detailHeader-wrapper">
<div className="normal">
<AlignTop style={{padding:"20px 0px 10px",justifyContent:"space-between"}}>
<AlignTop style={{ padding: "20px 0px 10px", justifyContent: "space-between" }}>
<div>
<AlignTop>
<div className="projectallName">
{project && project.author &&
<Link to={`${project.author.type ==="Organization" ? "/organize":'/users'}/${project.author.login}`}>{project.author.name}</Link>
<Link to={`${project.author.type === "Organization" ? "/organize" : '/users'}/${project.author.login}`}>{project.author.name}</Link>
}
<span className="ml5 mr5">/</span>
<Link to={`/projects/${owner}/${projectsId}`} className="projectN mt6">{project && project.name}</Link>
<Link to={`/projects/${owner}/${projectsId}`} className="projectN mt6">{projectDetail && projectDetail.name}</Link>
</div>
{ projectDetail && projectDetail.private && <span className="privateTag mt6">私有</span>}
{projectDetail && projectDetail.private && <span className="privateTag mt6">私有</span>}
</AlignTop>
<div className="mt8">
{
projectDetail && projectDetail.forked_from_project_id && projectDetail.fork_info ?
this.textFunc(projectDetail.forked_from_project_id,projectDetail.fork_info)
:""
this.textFunc(projectDetail.forked_from_project_id, projectDetail.fork_info)
: ""
}
{
projectDetail && projectDetail.type && projectDetail.type !== 0 ?
<span className="color-grey-9">镜像自 <a className="color-grey-6" target="_blank" href={projectDetail.mirror_url}>{projectDetail.mirror_url}</a></span>
:""
projectDetail && projectDetail.type && projectDetail.type !== 0 ?
<span className="color-grey-9">镜像自 <a className="color-grey-6" target="_blank" href={projectDetail.mirror_url}>{projectDetail.mirror_url}</a></span>
: ""
}
</div>
</div>
<div>
{
firstSync ? "":
<span className="df">
{
((current_user && current_user.admin) || isManager) && (projectDetail && projectDetail.type && projectDetail.type === 2) ?
<a className="synchronism ml30" onClick={this.synchronismMirror}>同步镜像</a> : ""
}
<Button className="detail_tag_btn">
<a className="detail_tag_btn_name" style={{cursor:platform?"pointer":"default"}} onClick={() => this.focusFunc(watched)}>
<i className={watched ? "iconfont icon-shixing color-orange font-16 mr3":"iconfont icon-kongxing color-grey-9 font-16 mr3"}></i>
<span>{watched ? '取消关注' : '关注'}</span>
</a>
firstSync ? "" :
<span className="df">
{
watchers_count > 0 ?
platform ?
<Link className="detail_tag_btn_count" style={{color:`${watched?"#2878FF":"#666"}`}} to={platform?{ pathname: `/projects/${owner}/${projectsId}/watchers`, state }:""}>
{watchers_count}
</Link>
:
<span className="detail_tag_btn_count">{watchers_count}</span>
:""
((current_user && current_user.admin) || isManager) && (projectDetail && projectDetail.type && projectDetail.type === 2) ?
<a className="synchronism ml30" onClick={this.synchronismMirror}>同步镜像</a> : ""
}
</Button>
<Button className="detail_tag_btn">
<a className="detail_tag_btn_name" style={{cursor:platform?"pointer":"default"}} onClick={() => this.pariseFunc(praised)}>
<i className={praised ? "iconfont icon-weibiaoti105 color-orange font-14 mr3":"iconfont icon-guanzhu color-grey-9 font-14 mr3"}></i>
<span>{praised ? '取消点赞' : '点赞'}</span>
</a>
{
praises_count > 0 ?
platform ?
<Link className="detail_tag_btn_count" style={{color:`${praised?"#2878FF":"#666"}`}} to={{ pathname: `/projects/${owner}/${projectsId}/stargazers`, state }}>
{praises_count}
</Link>:
<span className="detail_tag_btn_count">{praises_count}</span>
:""
}
</Button>
<Button className="detail_tag_btn" loading={forkSpin}>
<Tooltip title="复刻是fork的中文名即复制代码仓库" placement="bottom">
<a className="detail_tag_btn_name" style={{cursor:platform?"pointer":"default"}} onClick={this.forkFunc}>
<i className="iconfont icon-fork color-grey-9 mr3"></i>
<Button className="detail_tag_btn">
<a className="detail_tag_btn_name" style={{ cursor: platform ? "pointer" : "default" }} onClick={() => this.focusFunc(watched)}>
<i className={watched ? "iconfont icon-shixing color-orange font-16 mr3" : "iconfont icon-kongxing color-grey-9 font-16 mr3"}></i>
<span>{watched ? '取消关注' : '关注'}</span>
</a>
</Tooltip>
{
forked_count > 0 ?
platform ?
<Link className="detail_tag_btn_count" to={{ pathname: `/projects/${owner}/${projectsId}/fork_users`, state }}>
{forked_count}
</Link>
:
<span className="detail_tag_btn_count">{forked_count}</span>
:""
}
</Button>
</span>
{
watchers_count > 0 ?
platform ?
<Link className="detail_tag_btn_count" style={{ color: `${watched ? "#2878FF" : "#666"}` }} to={platform ? { pathname: `/projects/${owner}/${projectsId}/watchers`, state } : ""}>
{watchers_count}
</Link>
:
<span className="detail_tag_btn_count">{watchers_count}</span>
: ""
}
</Button>
<Button className="detail_tag_btn">
<a className="detail_tag_btn_name" style={{ cursor: platform ? "pointer" : "default" }} onClick={() => this.pariseFunc(praised)}>
<i className={praised ? "iconfont icon-weibiaoti105 color-orange font-14 mr3" : "iconfont icon-guanzhu color-grey-9 font-14 mr3"}></i>
<span>{praised ? '取消点赞' : '点赞'}</span>
</a>
{
praises_count > 0 ?
platform ?
<Link className="detail_tag_btn_count" style={{ color: `${praised ? "#2878FF" : "#666"}` }} to={{ pathname: `/projects/${owner}/${projectsId}/stargazers`, state }}>
{praises_count}
</Link> :
<span className="detail_tag_btn_count">{praises_count}</span>
: ""
}
</Button>
<Button className="detail_tag_btn" loading={forkSpin}>
<Tooltip title="复刻是fork的中文名即复制代码仓库" placement="bottom">
<a className="detail_tag_btn_name" style={{ cursor: platform ? "pointer" : "default" }} onClick={this.forkFunc}>
<i className="iconfont icon-fork color-grey-9 mr3"></i>
</a>
</Tooltip>
{
forked_count > 0 ?
platform ?
<Link className="detail_tag_btn_count" to={{ pathname: `/projects/${owner}/${projectsId}/fork_users`, state }}>
{forked_count}
</Link>
:
<span className="detail_tag_btn_count">{forked_count}</span>
: ""
}
</Button>
</span>
}
</div>
</AlignTop>
{
firstSync ? "" :
<DetailBanner
history={this.props.history}
list={bannerList}
owner={owner}
projectsId={projectsId}
pathname={pathname}
state={state}
projectDetail={projectDetail}
open_devops={open_devops}
platform={platform}
urlFlag={urlFlag}
isManager={isManager}
/>
<DetailBanner
history={this.props.history}
list={bannerList}
owner={owner}
projectsId={projectsId}
pathname={pathname}
state={state}
projectDetail={projectDetail}
open_devops={open_devops}
platform={platform}
urlFlag={urlFlag}
isManager={isManager}
/>
}
</div>
</div>
{
firstSync ?
<Content className="spincontent">
<Spin className="spinstyle" tip={project && `正在从 ${project.mirror_url} 迁移`} size="large" />
</Content>
:
<Spin spinning={secondSync} className="spinstyle" tip="正在同步镜像" size="large">
<Switch {...this.props}>
{/* 资源 */}
<Route path="/projects/:owner/:projectsId/source"
render={
() => (<Source {...this.props} {...this.state} {...common} />)
}
></Route>
{/* 主页 */}
<Route path="/projects/:owner/:projectsId/about"
render={
() => (<DevAbout {...this.props} {...this.state} {...common} />)
}
></Route>
{/* 工作流 */}
<Route path="/projects/:owner/:projectsId/devops"
render={
() => (<DevIndex {...this.props} {...this.state} {...common} />)
}
></Route>
{/* 标签列表 */}
<Route path="/projects/:owner/:projectsId/issues/tags"
render={
(props) => (<TagList {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 仓库设置 */}
<Route path="/projects/:owner/:projectsId/setting"
render={
(props) => (<Setting {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 任务详情 */}
<Route path="/projects/:owner/:projectsId/issues/:orderId/detail"
render={
(props) => (<OrderDetail {...this.props} {...this.state} {...props} {...common} />)
}
></Route>
{/*修改里程碑*/}
<Route path="/projects/:owner/:projectsId/milestones/:meilid/edit"
render={
(props) => (<OrderupdateMilepost {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 新建里程碑 */}
<Route path="/projects/:owner/:projectsId/milestones/new"
render={
(props) => (<OrdernewMilepost {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/*里程碑详情*/}
<Route path="/projects/:owner/:projectsId/milestones/:meilid"
render={
(props) => (<MilepostDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 里程碑 */}
<Route path="/projects/:owner/:projectsId/milestones"
render={
(props) => (<OrderMilepost {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 里程碑页面新建任务 */}
<Route path="/projects/:owner/:projectsId/issues/:milepostId/new"
render={
(props) => (<OrderNew {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 新建任务 */}
<Route path="/projects/:owner/:projectsId/issues/new"
render={
(props) => (<OrderNew {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 修改详情 */}
<Route path="/projects/:owner/:projectsId/issues/:orderId/updatedetail"
render={
(props) => (<OrderupdateDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 复制详情 */}
<Route path="/projects/:owner/:projectsId/issues/:orderId/copyetail"
render={
(props) => (<OrdercopyDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 动态 */}
<Route path="/projects/:owner/:projectsId/activity"
render={
(props) => (<TrendsIndex {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 代码Index */}
<Route path="/projects/:owner/:projectsId/issues"
render={
(props) => (<OrderIndex {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 新建合并请求 */}
<Route path="/projects/:owner/:projectsId/pulls/new/:branch"
render={
(props) => (<CreateMerge {...this.props} {...props} {...this.state} {...common} is_fork={true} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls/new"
render={
(props) => (<CreateMerge {...this.props} {...props} {...this.state} {...common} is_fork={true} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls/:mergeId/UpdateMerge"
render={
(props) => (<UpdateMerge {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls/:mergeId/Messagecount"
render={
(props) => (<MessageCount {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls/:mergeId/MergeSubmit"
render={
(props) => (<MessageCount {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Content className="spincontent">
<Spin className="spinstyle" tip={project && `正在从 ${project.mirror_url} 迁移`} size="large" />
</Content>
:
<Spin spinning={secondSync} className="spinstyle" tip="正在同步镜像" size="large">
<Switch {...this.props}>
{/* 资源 */}
<Route path="/projects/:owner/:projectsId/source"
render={
() => (<Source {...this.props} {...this.state} {...common} />)
}
></Route>
{/* 主页 */}
<Route path="/projects/:owner/:projectsId/about"
render={
() => (<DevAbout {...this.props} {...this.state} {...common} />)
}
></Route>
{/* wiki新增文件 */}
<Route path="/projects/:owner/:projectsId/wiki/add"
render={
() => (<WikiEdit {...this.props} {...this.state} {...common} />)
}
></Route>
{/* wiki编辑文件 */}
<Route path="/projects/:owner/:projectsId/wiki/edit/:wikiName"
render={
() => (<WikiEdit {...this.props} {...this.state} {...common} />)
}
></Route>
{/* wiki */}
<Route path="/projects/:owner/:projectsId/wiki"
render={
() => (<Wiki {...this.props} {...this.state} {...common} />)
}
></Route>
{/* 工作流 */}
<Route path="/projects/:owner/:projectsId/devops"
render={
() => (<DevIndex {...this.props} {...this.state} {...common} />)
}
></Route>
{/* 标签列表 */}
<Route path="/projects/:owner/:projectsId/issues/tags"
render={
(props) => (<TagList {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 仓库设置 */}
<Route path="/projects/:owner/:projectsId/setting"
render={
(props) => (<Setting {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 任务详情 */}
<Route path="/projects/:owner/:projectsId/issues/:orderId/detail"
render={
(props) => (<OrderDetail {...this.props} {...this.state} {...props} {...common} />)
}
></Route>
{/*修改里程碑*/}
<Route path="/projects/:owner/:projectsId/milestones/:meilid/edit"
render={
(props) => (<OrderupdateMilepost {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 新建里程碑 */}
<Route path="/projects/:owner/:projectsId/milestones/new"
render={
(props) => (<OrdernewMilepost {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/*里程碑详情*/}
<Route path="/projects/:owner/:projectsId/milestones/:meilid"
render={
(props) => (<MilepostDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 里程碑 */}
<Route path="/projects/:owner/:projectsId/milestones"
render={
(props) => (<OrderMilepost {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 里程碑页面新建任务 */}
<Route path="/projects/:owner/:projectsId/issues/:milepostId/new"
render={
(props) => (<OrderNew {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 新建任务 */}
<Route path="/projects/:owner/:projectsId/issues/new"
render={
(props) => (<OrderNew {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 修改详情 */}
<Route path="/projects/:owner/:projectsId/issues/:orderId/updatedetail"
render={
(props) => (<OrderupdateDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 复制详情 */}
<Route path="/projects/:owner/:projectsId/issues/:orderId/copyetail"
render={
(props) => (<OrdercopyDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 动态 */}
<Route path="/projects/:owner/:projectsId/activity"
render={
(props) => (<TrendsIndex {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 代码Index */}
<Route path="/projects/:owner/:projectsId/issues"
render={
(props) => (<OrderIndex {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 新建合并请求 */}
<Route path="/projects/:owner/:projectsId/pulls/new/:branch"
render={
(props) => (<CreateMerge {...this.props} {...props} {...this.state} {...common} is_fork={true} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls/new"
render={
(props) => (<CreateMerge {...this.props} {...props} {...this.state} {...common} is_fork={true} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls/:mergeId/UpdateMerge"
render={
(props) => (<UpdateMerge {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls/:mergeId/Messagecount"
render={
(props) => (<MessageCount {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls/:mergeId/MergeSubmit"
render={
(props) => (<MessageCount {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls"
render={
(props) => (<MergeIndexDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/watchers"
render={
(props) => (<WatchUsers {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/stargazers"
render={
(props) => (<PraiseUsers {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/fork_users"
render={
(props) => (<ForkUsers {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 贡献者列表 */}
<Route path="/projects/:owner/:projectsId/contribute"
render={
() => (<Contribute {...this.props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/pulls"
render={
(props) => (<MergeIndexDetail {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/watchers"
render={
(props) => (<WatchUsers {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/stargazers"
render={
(props) => (<PraiseUsers {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/fork_users"
render={
(props) => (<ForkUsers {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 贡献者列表 */}
<Route path="/projects/:owner/:projectsId/contribute"
render={
() => (<Contribute {...this.props} {...this.state} {...common} />)
}
></Route>
{/* 代码库----详情页面 */}
<Route path="/projects/:owner/:projectsId/commits/branch/:branchName"
render={
(props) => (<CoderRootCommit {...this.props} {...props} {...this.state} {...common}/>)
}
></Route>
<Route path="/projects/:owner/:projectsId/tree/:branchName"
render={
(props) => (<CoderDepot {...this.props} {...props} {...this.state} {...common}/>)
}
></Route>
<Route path="/projects/:owner/:projectsId/:subIndex"
render={
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state} {...common}/>)
}
></Route>
<Route path="/projects/:owner/:projectsId"
render={
(props) => (<CoderDepot {...this.props} {...props} {...this.state} {...common}/>)
}
></Route>
</Switch>
</Spin>
{/* 代码库----详情页面 */}
<Route path="/projects/:owner/:projectsId/commits/branch/:branchName"
render={
(props) => (<CoderRootCommit {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/tree/:branchName"
render={
(props) => (<CoderDepot {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/:subIndex"
render={
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId"
render={
(props) => (<CoderDepot {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
</Switch>
</Spin>
}
</div>
)

View File

@ -276,15 +276,18 @@ class Index extends Component {
</span>
</span>
</div>
<Button type={"primary"} size={"large"}>
<Link to={`/projects/deposit/new`}>新建项目</Link>
</Button>
<Button type={"primary"} size={"large"}>
<Link to={`/projects/deposit/new`}>
<i class="iconfont icon-xinjianxiangmu"></i>
<a>新建项目</a>
</Link>
<a>
<i class="iconfont icon-jiaruketang1"></i>
<AddProjectModal showNotification={this.props.showNotification}/>
</Button>
<Button type={"primary"} size={"large"} style={{backgroundColor:"rgb(47, 163, 79)",borderColor:"rgb(47, 163, 79)"}}>
<a href={`https://data.educoder.net/api/attachments/1955244?disposition=inline`} target="_blank">新手指引</a>
</Button>
</a>
<a href={`https://data.educoder.net/api/attachments/1955244?disposition=inline`} target="_blank">
<i class="iconfont icon-xinshouzhiyin"></i>
新手指引
</a>
</div>
</div>
{

View File

@ -43,13 +43,26 @@
margin-top: -6px;
margin-bottom: 2px!important;
}
.bannerBox .ant-btn{
margin-top: 30px;
height: 40px;
font-size: 16px;
width: 120px;
.bannerBox > a{
display: inline-block;
width: 104px;
height: 30px;
line-height: 28px;
text-align: center;
border-radius: 4px;
margin-right: 40px;
border: 1px solid #666;
margin-right: 30px;
margin-top: 30px;
color: #fff;
cursor: pointer;
}
.bannerBox > a > i{
font-size: 14px!important;
display: inline-block;
margin-right: 10px;
}
.bannerBox > a > a{
color: #fff!important;
}
.ProjectListIndex{
width: 1200px;

View File

@ -22,9 +22,9 @@ function DetailBanner({ history,list , owner , projectsId , isManager , url , pa
menuName && menuName.length> 0 && projectDetail ?
<ul className="headerMenu-wrapper">
{
menuName.map((item,key)=>{
Array.isArray(menuName)&& menuName.map((item,key)=>{
return(
<React.Fragment>
<React.Fragment key={item.menu_name}>
{
item.menu_name === "home" &&
<li className={pathname==="about" ? "active" : ""}>
@ -65,6 +65,15 @@ function DetailBanner({ history,list , owner , projectsId , isManager , url , pa
</Link>
</li>:""
}
{/* {
item.menu_name === "wiki" &&
<li className={pathname === "wiki" ? "active" : ""}>
<Link to={{ pathname: `/projects/${owner}/${projectsId}/wiki`, state }}>
<i className={pathname==="wiki" ? "iconfont icon-wiki_icon color-grey-3 mr5 font-14":"iconfont icon-wiki_icon color-grey-6 font-14 mr5"}></i>
<span>Wiki</span>
</Link>
</li>
} */}
{
item.menu_name === "devops" && platform ?
<li className={pathname==="devops" ? "active" : ""}>

View File

@ -49,7 +49,7 @@ class MergeItem extends Component {
};
render() {
const { issues, project_name, project_author_name , user_admin_or_member} = this.props;
const { issues, project_name, project_author_name , user_admin_or_developer} = this.props;
const { projectsId , owner } = this.props.match.params;
const { current_user } = this.props;
const renderList = () => {
@ -183,7 +183,7 @@ class MergeItem extends Component {
) : (
""
)}
{user_admin_or_member ? (
{user_admin_or_developer && item.pull_request_status === 0 ? (
<div
className="milepostleft"
style={{

View File

@ -102,7 +102,7 @@ class MergeSubmit extends Component{
<span className="f-wrap-alignCenter">
<Link to={`/users/${item.login}`} className="show-user-link">
<img src={getImageUrl(`/${item.image_url}`)} alt="" width="28px" height="28px" className="mr3 radius"/>
<label className="hide-1" style={{maxWidth:"75px",'vertical-align':'middle'}}>{text}</label>
<label className="hide-1" style={{maxWidth:"75px",verticalAlign:'middle'}}>{text}</label>
</Link>
</span>
),

View File

@ -4,7 +4,7 @@ import "./merge.css";
import "../Order/order.css";
import "../Order/index.scss";
import NoneData from "./no_data";
import OrderItem from "./MergeItem";
import MergeItem from "./MergeItem";
import './Index.scss';
import axios from "axios";
@ -159,14 +159,10 @@ class merge extends Component {
<Menu.Item key={"all"} onClick={(e) => this.getOption(e, id, name)}>
{name}
</Menu.Item>
{array &&
array.length > 0 &&
array.map((item, key) => {
{array && array.length > 0 && array.map((item, key) => {
return (
<Menu.Item
key={item.id}
onClick={(e) => this.getOption(e, id, item.name)}
>
((!item.permission) || (item.permission && item.permission !== "Reporter")) &&
<Menu.Item key={item.id} onClick={(e) => this.getOption(e, id, item.name)}>
{item.name}
</Menu.Item>
);
@ -259,7 +255,7 @@ class merge extends Component {
/>
</div>
{
data && data.user_admin_or_member &&
data && data.user_admin_or_developer &&
<a className="topWrapper_btn ml10" onClick={() => this.checkOperation()}>
+&nbsp;新建合并请求
</a>
@ -391,7 +387,7 @@ class merge extends Component {
<Spin spinning={isSpin}>
{data && data.search_count && data.search_count > 0 ? (
<div>
<OrderItem
<MergeItem
issues={issues}
search_count={search_count}
page={select_params.page}
@ -400,8 +396,8 @@ class merge extends Component {
project_author_name={data.project_author_name}
{...this.props}
{...this.state}
user_admin_or_member={data && data.user_admin_or_member}
></OrderItem>
user_admin_or_developer={data && data.user_admin_or_developer}
></MergeItem>
</div>
):""}
{search_count > select_params.limit ? (

View File

@ -264,7 +264,7 @@ class MergeForm extends Component {
},
],
initialValue: title,
})(<Input placeholder="标题" />)}
})(<Input placeholder="标题" maxLength={50} />)}
</Form.Item>
<MDEditor
placeholder={"请输入合并请求的描述..."}
@ -346,19 +346,21 @@ class MergeForm extends Component {
</Select>
)}
</Form.Item>
<Form.Item name="checkbox-group" label="其他">
<Checkbox.Group>
<div>
<Checkbox value="A">必须审查代码</Checkbox>
</div>
<div>
<Checkbox value="B">合并后删除提交分支</Checkbox>
</div>
<div>
<Checkbox value="C">合并后关闭提到的任务</Checkbox>
</div>
</Checkbox.Group>
</Form.Item>
{/* <Form.Item label="">
{getFieldDecorator("checkbox-group")(
<Checkbox.Group>
<div>
<Checkbox value="A">必须审查代码</Checkbox>
</div>
<div>
<Checkbox value="B">合并后删除提交分支</Checkbox>
</div>
<div>
<Checkbox value="C">合并后关闭提到的任务</Checkbox>
</div>
</Checkbox.Group>
)}
</Form.Item> */}
</div>
</div>
</div>

View File

@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Input , Form , Select , Checkbox , Button , Spin , AutoComplete } from 'antd';
import { Input , Form , Select , Checkbox , Button , Spin , AutoComplete, Modal } from 'antd';
import { Base64 } from 'js-base64';
import '../css/index.scss';
@ -62,6 +62,8 @@ class Index extends Component {
this.getGitignore();
// 获取开源许可证
this.getLicenses();
//判断是否为删除新建项目失败后返回,并执行对应逻辑
this.isDeleteProjectBack();
}
componentDidUpdate=(prevPros)=>{
if(prevPros && this.props && !this.props.checkIfLogin()){
@ -73,6 +75,7 @@ class Index extends Component {
getOwner=()=>{
const { OIdentifier } = this.props.match.params;
const { user_id } = this.props && this.props.current_user;
const url = `/owners.json`;
axios.get(url).then(result=>{
if(result && result.data){
@ -81,16 +84,13 @@ class Index extends Component {
OwnerList: owner,
})
if(OIdentifier){
owner = owner.filter(item=>item.name === OIdentifier);
this.props.form.setFieldsValue({
user_id:OIdentifier
})
owner = owner.filter(item=>item.login === OIdentifier);
}else if(user_id){
owner = owner.filter(item=>item.id === user_id);
this.props.form.setFieldsValue({
user_id:owner && owner[0].name
})
}
this.props.form.setFieldsValue({
user_id:owner && owner[0].name
})
owner && this.setState({
owners_id:owner[0].id,
owners_name:owner[0].name
@ -148,6 +148,31 @@ class Index extends Component {
}).catch((error) => { })
}
isDeleteProjectBack = () => {
let mirror_status = this.props.history.location.mirror_status;
if (mirror_status === 2 && sessionStorage.newProjectValue) {
Modal.warning({
title: '警告',
content: '镜像项目创建失败!请按操作规范重新创建项目!',
});
let newProjectValue = JSON.parse(sessionStorage.newProjectValue);
if (newProjectValue) {
this.setState({
project_language_id: newProjectValue.project_language_id,
project_category_id: newProjectValue.project_category_id,
license_id: newProjectValue.license_id,
ignore_id: newProjectValue.ignore_id
});
delete newProjectValue.project_language_id;
delete newProjectValue.project_category_id;
delete newProjectValue.license_id;
delete newProjectValue.ignore_id;
this.props.form.setFieldsValue(newProjectValue);
}
}
}
// 设置option
setOptionsList = (data, _head, name) => {
if (data && data.length > 0) {
@ -176,6 +201,8 @@ class Index extends Component {
const { project_language_id, project_category_id, license_id, ignore_id , owners_id , owners_name } = this.state;
const decoderPass = Base64.encode(values.password);
const url = (projectsType && projectsType === "mirror") ? "/projects/migrate.json" : "/projects.json";
// 新建项目的时候,暂存数据,如果失败,返回的时候可以重新赋值
sessionStorage.newProjectValue=JSON.stringify({...values,project_language_id,project_category_id,license_id,ignore_id});
axios.post(url, {
...values,
auth_password:decoderPass,
@ -185,14 +212,12 @@ class Index extends Component {
ignore_id,
user_id:owners_id
}).then((result) => {
if (result) {
if (result.data.id) {
this.setState({
isSpin: false
})
this.props.showNotification(`${projectsType && projectsType === "mirror" ? "镜像" : "托管"}项目创建成功!`);
this.props.history.push(`/projects/${result.data.login}/${result.data.identifier}`);
}
if (result && result.data.id) {
this.setState({
isSpin: false
})
projectsType && projectsType !== "mirror" && this.props.showNotification(`托管项目创建成功!`);
this.props.history.push(`/projects/${result.data.login}/${result.data.identifier}`);
}
}).catch((error) => {
this.setState({
@ -342,7 +367,9 @@ class Index extends Component {
{
projectsType && projectsType === "mirror" &&
<React.Fragment>
<p className="mt10 mb10 color-grey-3 pointer" onClick={this.changeMirrorCheck}>需要授权验证<i className={mirrorCheck?"iconfont icon-xiajiantou font-13 ml10 color-grey-8":"iconfont icon-youjiantou font-13 ml10 color-grey-8"}></i></p>
<p className="mt10 mb10 color-grey-3 pointer" onClick={this.changeMirrorCheck}>
需要授权验证<i className={mirrorCheck?"iconfont icon-xiajiantou font-13 ml10 color-grey-8":"iconfont icon-youjiantou font-13 ml10 color-grey-8"}></i>
<span className="ml20 font-12 color-red">如果源项目为公有仓库禁止填写用户名密码如果源项目为私有仓库则必须填写正确的用户名和密码!</span></p>
{
mirrorCheck &&
<div className="df mb20" style={{alignItems:'center'}}>

View File

@ -22,6 +22,7 @@ function Index(props){
const username = props.match.params.username;
const pathname = props.history.location.pathname;
const user = props.user;
const undo_messages = props.undo_messages;
const [ menu , setMenu ] = useState("notify");
const [ messagesCount , setMessagesCount ] = useState(0);
@ -72,7 +73,7 @@ function Index(props){
if(type==="apply"){
setApplyCount(applyCount-count);
}else if(type==="undo"){
setTransferCount(applyCount-count);
setTransferCount(transferCount-count);
}else{
setMessagesCount(0);
c = messagesCount;

View File

@ -14,8 +14,24 @@ function Notify(props){
const [ isSpin , setIsSpin ] = useState(true);
useEffect(()=>{
props && props.deleteEvent("notify",0);
},[])
if(username){
getList();
}
},[username,page])
function getList(){
const url = `/users/${username}/applied_messages.json`;
Axios.get(url,{
params:{
page,per_page:limit
}
}).then(result=>{
if(result){
setList(result.data.applied_messages);
setTotal(result.data.total_count);
}
}).catch(error=>{})
}
useEffect(()=>{
if(username){

View File

@ -14,6 +14,7 @@ function UndoEvent(props){
const [ total , setTotal ] = useState(0);
const [ isSpin , setIsSpin ] = useState(true);
useEffect(()=>{
if(username){
setIsSpin(true);
@ -69,15 +70,14 @@ function UndoEvent(props){
list.map((i,k)=>{
return(
<li>
<Link to={`/users/${i.user && i.user.login}`}><img src={getImageUrl(`/${i.user && i.user.image_url}`)} alt="" className="notifyImg"/></Link>
<Link to={`/users/${i.user && i.user.login}`}><img src={getImageUrl(i.user && i.user.image_url)} alt="" className="notifyImg"/></Link>
<div className="notifyFlex">
<p className="notifyInfos">
<Link to={`/users/${i.login}`} className="font-15 mr20">{i.user && i.user.name}</Link>
<span className="color-grey-9">{i.time_ago}</span>
</p>
<FlexAJ>
<p className="color-grey-6">请求将仓库<Link to={`/projects/${i.project && i.project.owner && i.project.owner.login}/${i.project && i.project.identifier}`}>{i.project && i.project.name}</Link>
转移给<Link to={`/users/${i.owner && i.owner.login}`}>{i.owner && i.owner.name}</Link>是否接受</p>
<p>请求将仓库转移给{i.owner && i.owner.name},是否接受</p>
{
i.status === "common" &&
<span>
@ -93,7 +93,7 @@ function UndoEvent(props){
i.status === "canceled" && <span className="color-grey-9">对方已取消转移</span>
}
{
i.status === "accepted" && <span className="color-grey-9">已接受</span>
i.status === "accept" && <span className="color-grey-9">已接受</span>
}
{
i.status === "refused" && <span className="color-grey-9">已拒绝</span>

View File

@ -154,10 +154,10 @@ class Milepost extends Component {
const { projectsId , owner } = this.props.match.params;
const menu = (
<Menu className="orderCondition" onClick={this.arrayList}>
<Menu.Item key={'created_on'} value="desc">到期日从近到远</Menu.Item>
<Menu.Item key={'created_on'} value="asc">到期日从远到近</Menu.Item>
<Menu.Item key={'percent'} value="desc">完成度从低到高</Menu.Item>
<Menu.Item key={'percent'} value="asc">完成度从高到低</Menu.Item>
<Menu.Item key={'effective_date'} value="desc">到期日从后到先</Menu.Item>
<Menu.Item key={'effective_date'} value="asc">到期日从先到后</Menu.Item>
<Menu.Item key={'percent'} value="asc">完成度从低到高</Menu.Item>
<Menu.Item key={'percent'} value="desc">完成度从高到低</Menu.Item>
<Menu.Item key={'issues_count'} value="desc">任务从多到少</Menu.Item>
<Menu.Item key={'issues_count'} value="asc">任务从少到多</Menu.Item>
</Menu>

View File

@ -180,8 +180,8 @@ class UpdateMilepost extends Component {
<Row type="flex" justify="space-between">
<Col>
<Group size="small" onChange={e => onTypeChange(e.target.value)} value={type}>
<Button value="month">月份</Button>
<Button value="year"></Button>
<Button value="month">日期</Button>
<Button value="year"></Button>
</Group>
</Col>
<Col>

View File

@ -102,7 +102,7 @@ class NewMilepost extends Component {
required: true, message: '请输入标题'
}],
})(
<Input placeholder="标题" autoComplete="off"/>
<Input placeholder="标题" autoComplete="off" maxLength="30" />
)}
</Form.Item>
</div>
@ -113,7 +113,7 @@ class NewMilepost extends Component {
required: true, message: '请输入描述内容'
}],
})(
<TextArea placeholder="请输入描述内容..." style={{ height: "150px" }} />
<TextArea placeholder="请输入描述内容..." style={{ height: "150px" }} maxLength={500} />
)}
</Form.Item>

View File

@ -92,10 +92,10 @@ class order_form extends Component {
const url = `/${owner}/${projectsId}/issues/new.json`;
axios.get(url).then((result) => {
if (result) {
if (result && result.data) {
this.setState({
issue_chosen: result.data.issue_chosen,
branches: result.data.branches,
branches: result.data.issue_chosen.branches,
isSpin:false
});

View File

@ -23,6 +23,7 @@ export default ((props)=>{
const [ page , setPage ] = useState(1);
let defaultBranch = props.defaultBranch;
useEffect(()=>{
if(defaultBranch){
setBranch(defaultBranch);
@ -76,6 +77,8 @@ export default ((props)=>{
.then((result) => {
if (result) {
props.showNotification(`分支设置成功!`);
const { getDetail } = props;
getDetail && getDetail();
}
})
.catch((error) => {
@ -95,7 +98,7 @@ export default ((props)=>{
return(
<WhiteBack>
<Title>分支设置</Title>
<Title><span className="font-18">分支设置</span></Title>
<Div>
<div className="pb20" style={{borderBottom:"1px dashed #eee"}}>
<p className="color-grey-3 mb10 font-18">默认分支</p>

View File

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState , useRef } from "react";
import {WhiteBack} from '../Component/layout';
import AddMember from '../Component/AddMember';
import AddGroup from '../Component/AddGroup';
@ -8,9 +8,11 @@ import Group from './CollaboratorGroup';
function Collaborator(props){
const [ nav , setNav] = useState("1");
const [ newId , setNewId] = useState(undefined);
const [ addOperation , setAddOperation] = useState(true);
const [ newGroupId , setNewGroupId] = useState(undefined);
const {projectsId ,owner} = props.match.params;
const author = props && props.projectDetail && props.projectDetail.author;
function getID(id){
@ -19,6 +21,7 @@ function Collaborator(props){
function getGroupID(id){
setNewGroupId(id);
}
return (
<WhiteBack>
@ -27,15 +30,17 @@ function Collaborator(props){
author && author.type === "Organization" ?
<span>
<span style={{cursor:"pointer"}} className={nav === "1" ? "font-18 text-black color-blue":"font-18 text-black"} onClick={()=>{setNav("1");setNewId(undefined)}}>协作者管理</span>
<span style={{cursor:"pointer"}} className={nav === "2" ? "font-18 text-black ml30 color-blue":"font-18 text-black ml30"} onClick={()=>{setNav("2");setNewId(undefined)}}>团队管理</span>
<span style={{cursor:"pointer"}} className={nav === "2" ? "font-18 text-black ml30 color-blue":"font-18 text-black ml30"} onClick={()=>{setNav("2");setNewId(undefined);setNewGroupId(undefined)}}>团队管理</span>
</span>
:
<span className="font-18 text-black">协作者管理</span>
}
{
nav === "1" ?
nav === "1" &&
<AddMember getID={getID} login showNotification={props.showNotification}/>
:
}
{
(nav !== "1" && addOperation) &&
<AddGroup getGroupID={getGroupID} organizeId={owner}/>
}
</div>
@ -44,7 +49,7 @@ function Collaborator(props){
nav === "1" ?
<Member newId={newId} projectsId={projectsId} owner={owner} project_id={props.project_id} author={props.projectDetail && props.projectDetail.author} showNotification={props.showNotification}/>
:
<Group owner={owner} projectsId={projectsId} newGroupId={newGroupId}/>
<Group setAddOperation={setAddOperation} owner={owner} projectsId={projectsId} newGroupId={newGroupId}/>
}
</div>
</WhiteBack>

View File

@ -10,7 +10,7 @@ const roles = {
read: "报告者",
};
const limit = 15;
function CollaboratorGroup({ newGroupId, owner, projectsId }) {
function CollaboratorGroup({ newGroupId, owner, projectsId , setAddOperation }) {
const [list, setList] = useState(undefined);
const [isSpin, setIsSpin] = useState(true);
const [page, setPage] = useState(1);
@ -34,6 +34,7 @@ function CollaboratorGroup({ newGroupId, owner, projectsId }) {
setList(result.data.teams);
setTotal(result.data.total_count);
setIsSpin(false);
setAddOperation(result.data.can_add);
}
})
.catch((error) => {});
@ -47,16 +48,15 @@ function CollaboratorGroup({ newGroupId, owner, projectsId }) {
//
function addGroup(id) {
const url = `/${owner}/${projectsId}/teams.json`;
axios
.post(url, {
team_id: id,
})
.then((result) => {
if (result && result.data) {
getData();
}
})
.catch((error) => {});
axios.post(url, {
team_id: id,
})
.then((result) => {
if (result && result.data) {
getData();
}
})
.catch((error) => {});
}
//
@ -77,7 +77,11 @@ function CollaboratorGroup({ newGroupId, owner, projectsId }) {
title: "团队名",
dataIndex: "name",
render: (value, item) => {
return <Link to={`/organize/${owner}/group/${item.id}`}>{value}</Link>;
if(item.is_admin || item.is_member){
return <Link to={`/organize/${owner}/group/${item.id}`}>{value}</Link>;
}else{
return <span>{value}</span>;
}
},
},
{

View File

@ -58,8 +58,12 @@ function CollaboratorMember({projectsId,owner,project_id,author,showNotification
})
.then((result) => {
if (result) {
setListData(result.data.members);
setTotal(result.data.total_count);
if(page > 1 && ( listData && listData.length === 1)){
setPage(page-1);
}else{
setListData(result.data.members);
setTotal(result.data.total_count);
}
setIsSpin(false);
}
})

View File

@ -80,7 +80,7 @@ export default Form.create()(
[],
<Input type="password" />
)}
<p className="font-12 mt10 pb15" style={{borderBottom:"1px solid #eee"}}>推送创建删除分支事件白名单支持匹配符如果为空或者 *所有分支的事件均被触发<br/>语法参见 <Link to="github.com/gobwas/glob" className="color-blue" target="_blank">github.com/gobwas/glob</Link> 示例 Master, ${'{master,release*}'}</p>
<p className="font-12 mt10 pb15" style={{borderBottom:"1px solid #eee"}}>推送创建删除分支事件白名单支持匹配符如果为空或者 *所有分支的事件均被触发<br/>语法参见 <a href="http://github.com/gobwas/glob" className="color-blue" target="_blank">github.com/gobwas/glob</a> 示例 Master, ${'{master,release*}'}</p>
{helper(
"",
"active",

View File

@ -2,6 +2,7 @@ import React, { Component } from "react";
import { Form, Input, Checkbox, Select , Spin } from "antd";
import Title from '../Component/Title';
import {WhiteBack} from '../Component/layout';
import DivertModal from '../Divert/DivertModal';
import axios from "axios";
import "./setting.scss";
const { TextArea } = Input;
@ -12,6 +13,7 @@ const menu = [
{name:"代码库",index:"code"},
{name:"易修 (Issue)",index:"issues"},
{name:"合并请求",index:"pulls"},
// {name:"Wiki",index:"wiki"},
{name:"工作流(beta版)",index:"devops"},
// {name:"资源库",index:"resources"},
{name:"里程碑",index:"versions"},
@ -28,7 +30,8 @@ class Setting extends Component {
project_units:['home',"activity","code"],
divertVisible:false,
is_transfering:undefined,
projectName:undefined
projectName:undefined,
permission:undefined
};
}
@ -78,7 +81,9 @@ class Setting extends Component {
projectName:result.data.project_name,
private_check: result.data.private,
loading:false,
project_units:units
project_units:units,
is_transfering:result.data.is_transfering,
permission:result.data.permission
});
}
})
@ -192,16 +197,57 @@ class Setting extends Component {
});
};
// 转移仓库
DivertProject=()=>{
this.setState({
divertVisible:true
})
}
// 取消仓库转移
CancelDivertProject=()=>{
this.props.confirm({
content: "是否确认取消将此项目转移给他人?",
onOk: () => {
const { projectsId , owner } = this.props.match.params;
const url = `/${owner}/${projectsId}/applied_transfer_projects/cancel.json`;
axios.post(url).then(result=>{
if(result && result.data){
this.setState({
is_transfering:false
})
}
}).catch(error=>{})
},
});
}
// 确定转移仓库
onSuccess=()=>{
this.setState({
is_transfering:true,
divertVisible:false
})
}
render() {
const { getFieldDecorator } = this.props.form;
const { projectDetail } = this.props;
const { projectsId , owner } = this.props.match.params;
const { CategoryList, LanguageList, private_check ,loading } = this.state;
let mirror = projectDetail && projectDetail.mirror;
let type = projectDetail && projectDetail.type;
const forked_from_project_id = this.props && this.props.projectDetail && this.props.projectDetail.forked_from_project_id;
const { CategoryList, LanguageList, private_check ,loading , divertVisible , permission , is_transfering } = this.state;
return (
<div>
<DivertModal
owner={owner}
repo={projectsId}
visible={divertVisible}
onSuccess={this.onSuccess}
onCancel={()=>{this.setState({divertVisible:false})}}
/>
<Spin spinning={loading}>
<WhiteBack>
<Title>基本设置</Title>
@ -293,23 +339,41 @@ class Setting extends Component {
{/* 镜像设置部分,暂无接口,先不显示 */}
{/* <Mirror /> */}
</WhiteBack>
<WhiteBack className="dangerousBox mb20">
<div>
<div className="dangerousTitle">危险操作区</div>
<div className="flex-a-center padding15-10">
{
permission && (permission === "Admin" || permission === "Owner")?
<WhiteBack className="dangerousBox mb20">
<div>
<p className="font-bd font-16">删除本仓库</p>
<p className="mt10">
删除仓库是永久性的,
无法撤消且删除后与仓库关联的项目/任务/合并请求/版本发布等均会被删除
</p>
<div className="dangerousTitle">危险操作区</div>
<div className="flex-a-center padding15-10" style={{borderBottom:"1px solid #f9edbe"}}>
<div>
<p className="font-bd font-16">转移仓库</p>
<p className="mt10">
将此仓库转移给其他用户或组织
</p>
</div>
{
is_transfering ?
<a onClick={this.CancelDivertProject} className="red_deleteBtn">取消转移</a>
:
<a onClick={this.DivertProject} className="red_deleteBtn">转移</a>
}
</div>
<div className="flex-a-center padding15-10">
<div>
<p className="font-bd font-16">删除本仓库</p>
<p className="mt10">
删除仓库是永久性的,
无法撤消且删除后与仓库关联的项目/任务/合并请求/版本发布等均会被删除
</p>
</div>
<a onClick={this.deleteProject} className="red_deleteBtn">
删除本仓库
</a>
</div>
</div>
<a onClick={this.deleteProject} className="red_deleteBtn">
删除本仓库
</a>
</div>
</div>
</WhiteBack>
</WhiteBack>
:""
}
</Spin>
</div>
);

View File

@ -0,0 +1,337 @@
import React , { forwardRef, useEffect, useState } from 'react';
import { Form , Input , Button , Select , Radio , Checkbox } from 'antd';
import { Banner } from '../../Component/layout';
import { Link } from 'react-router-dom';
import axios from 'axios';
import PushHistory from './sub/PushHistory';
import DeleteBox from '../../Component/DeleteModal/Index';
import './Index.scss';
// ,"issue_assign","issue_label","issue_milestone","issue_comment","issue_only","fork",
//"pull_request_milestone","pull_request_sync","pull_request_comment","repository","pull_request_label"
const eventArray = [
"create","delete","push","pull_request_assign","pull_request_review","pull_request_only"
]
function New({ form , match , showNotification , history }) {
const [ httpValue , setHttpValue ] = useState("POST");
const [ posthttpValue , setPostHttpValue ] = useState("json");
const [ condition , setCondition ] = useState("push");
const [ event , setEvent ] = useState(["push"]);
const [ visible , setVisible ] = useState(false);
const [ data , setData ] = useState(undefined);
const [ eventFlag , setEventFlag ] = useState(false);
const { getFieldDecorator, validateFields , setFieldsValue } = form;
const { id , owner , projectsId } = match.params;
function compareArray(params) {
if(params && params.length > 0){
if(params.length === 1 && params[0] === "push"){
setEvent(['push']);
return "push";
}else if(params.length === eventArray.length){
setEvent(eventArray);
return "all";
}else{
setEvent([]);
return "forevent";
}
}
}
useEffect(()=>{
if(id){
Init();
}else{
let e = compareArray(event);
setCondition(e);
setFieldsValue({
url:"",
secret:"",
http_method:httpValue,
content_type:posthttpValue,
eventCondition:condition,
event:event,
branch_filter:"*",
active:true
})
}
},[id])
function Init() {
const url = `/${owner}/${projectsId}/webhooks/${id}/edit.json`;
axios.get(url).then(result=>{
if(result){
let e = compareArray(result.data.events);
setFieldsValue({
...result.data,
eventCondition:e,
active:result.data.is_active
})
setData(result.data);
setHttpValue(result.data.http_method);
setCondition(e);
setEvent(result.data.events);
}
}).catch(error=>{})
}
function changeHTTP(value) {
setHttpValue(value);
}
function changeCondition(e) {
setCondition(e.target.value);
if(e.target.value === "push"){
setEvent(["push"])
}else if(e.target.value === "all"){
setEvent(eventArray)
}else{
setEvent([])
}
}
function submit() {
validateFields((error,values)=>{
if(!error){
if(values.eventCondition === "forevent" && event.length === 0){
setEventFlag(true);
return;
}
let e = values.eventCondition === "push" ? ['push'] : values.eventCondition === "all" ? eventArray : event;
if(id){
//
const url = `/${owner}/${projectsId}/webhooks/${id}.json`;
axios.patch(url,{
webhook:{
...values,
events:e
}
}).then(result=>{
if(result){
showNotification("webhook更新成功");
history.push(`/projects/${owner}/${projectsId}/setting/webhooks`);
}
}).catch(error=>{})
}else{
//
const url = `/${owner}/${projectsId}/webhooks.json`;
axios.post(url,{
webhook:{
...values,
events:e
}
}).then(result=>{
if(result && result.data && result.data.id){
showNotification("webhook新建成功");
history.push(`/projects/${owner}/${projectsId}/setting/webhooks`);
}
}).catch(error=>{})
}
}
})
}
function checkAddr(rule, value, callback) {
let reg = /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
if(!value){
callback();
}
if (!reg.test(value)){
callback("请输入有效的URL");
}
callback();
}
function deleteFunc() {
if(id){
setVisible(true);
}
}
function onSuccess() {
if(id){
const url = `/${owner}/${projectsId}/webhooks/${id}.json`;
axios.delete(url).then(result=>{
if(result){
showNotification("webhook删除成功");
history.push(`/projects/${owner}/${projectsId}/setting/webhooks`);
}
}).catch(error=>{})
}
}
const radioStyle = {
display: 'block',
height: '30px',
lineHeight: '30px',
};
return(
<div className="newPanel">
<DeleteBox
visible={visible}
onCancel={()=>setVisible(false)}
onSuccess={onSuccess}
title="删除Webhook"
content="您确定要删除此Webhook吗"
subTitle={`删除后未来事件将不会推送至此Webhook地址${data && data.url}`}
/>
<Banner>
<Link to={`/projects/${owner}/${projectsId}/setting/webhooks`} className="color-blue">Webhooks</Link>
<i className="iconfont icon-youjiantou ml5 mr5 font-12"></i>
<span>{id ? "更新" : "添加"}Webhook</span>
</Banner>
<div>
<p className="deschead mg"><span>当webhook被触发时我们将向以下URL发送通知包括已选择事件的详细信息更多信息可查阅<a className="color-blue hoverLine" target="_blank" href="https://forum.trustie.net/forums/3408/detail">webhooks指南</a></span></p>
<Form>
<input type="password" style={{display:"none"}} />
<Form.Item label="目标URL" colon={false}>
{getFieldDecorator("url",{
rules:[
{required:true,message:"请输入目标URL"},
{
validator:checkAddr
}
]
})(
<Input placeholder="请输入目标URL" size="large" autocomplete='off'/>
)}
</Form.Item>
<Form.Item label="Webhook密钥" colon={false}>
{getFieldDecorator("secret",{
rules:[]
})(
<Input.Password placeholder="请输入Webhook密钥" autocomplete='new-password' size="large" maxLength={"50"}/>
)}
</Form.Item>
<Form.Item label="Http请求方法" colon={false}>
{getFieldDecorator("http_method",{
rules:[]
})(
<Select onSelect={changeHTTP} size="large">
<Select.Option value="GET">GET</Select.Option>
<Select.Option value="POST">POST</Select.Option>
</Select>
)}
</Form.Item>
<Form.Item
label="POST请求类型"
colon={false}
style={{display:httpValue === "POST" ?"block":"none"}}
>
{getFieldDecorator("content_type",{
rules:[]
})(
<Select size="large">
<Select.Option value="json">application/json</Select.Option>
<Select.Option value="form">application/x-www-form-urlencoded</Select.Option>
</Select>
)}
</Form.Item>
<Form.Item label="您希望哪些事件触发此webhook" colon={false} className="topLine">
{getFieldDecorator("eventCondition",{
rules:[]
})(
<Radio.Group onChange={changeCondition}>
<Radio style={radioStyle} value="push">只是push事件</Radio>
<Radio style={radioStyle} value="all">所有事件</Radio>
<Radio style={radioStyle} value="forevent">自定义事件</Radio>
</Radio.Group>
)}
</Form.Item>
<div className="eventCb"
style={{display:condition === "forevent" ?"block":"none"}}
>
<Checkbox.Group value={event} onChange={(e)=>{setEvent(e)}}>
<p className="color-grey-3 mb10">代码库事件</p>
<div className="colSpan">
<span>
<Checkbox value="push">推送</Checkbox>
<span>git推送到存储库</span>
</span>
{/* <span>
<Checkbox value="repository">代码库</Checkbox>
<span>创建或删除代码库</span>
</span> */}
<span>
<Checkbox value="create">创建</Checkbox>
<span>创建分支或标签</span>
</span>
<span>
<Checkbox value="delete">删除</Checkbox>
<span>删除分支或标签</span>
</span>
</div>
<p className="color-grey-3 mt10 mb10">合并请求事件</p>
<div className="colSpan">
<span>
<Checkbox value="pull_request_only">合并请求</Checkbox>
<span>合并请求被打开被关闭被重新打开或被编辑</span>
</span>
<span>
<Checkbox value="pull_request_assign">合并请求分配</Checkbox>
<span>合并请求被分配或取消分配</span>
</span>
{/* <span>
<Checkbox value="pull_request_milestone">合并请求收入里程碑</Checkbox>
<span>合并请求被记录或取消记录于里程碑中</span>
</span> */}
{/* <span>
<Checkbox value="pull_request_comment">合并请求被评论</Checkbox>
<span>合并请求评论被创建编辑或删除</span>
</span> */}
{/* <span>
<Checkbox value="pull_request_label">合并请求标签</Checkbox>
<span>合并请求的标签被更新或清除</span>
</span> */}
<span>
<Checkbox value="pull_request_review">合并请求审查</Checkbox>
<span>合并请求被批准拒绝或提出审查意见审查人员的修改审查线程已解决或未解决</span>
</span>
{/* <span>
<Checkbox value="pull_request_sync">合并请求被同步</Checkbox>
<span>合并请求被同步</span>
</span> */}
</div>
</Checkbox.Group>
{ eventFlag && <span style={{color:"#DF0002"}}>请选择自定义事件</span>}
</div>
<Form.Item
label="分支过滤"
className="topLine"
help={<span>推送创建删除分支事件的分支白名单使用 glob 模式匹配指定若为空或 *则将报告所有分支的事件语法文档见<a href="http://github.com/gobwas/glob" target="_blank" className="hoverLine color-blue">github.com/gobwas/glob</a>示例master,{'{'}master,release*{'}'}</span>}
colon={false}
style={{marginTop:'15px'}}
>
{getFieldDecorator("branch_filter",{
rules:[]
})(
<Input size="large"/>
)}
</Form.Item>
<Form.Item
className="topLine bottomLine"
colon={false}
style={{height:"110px",paddingBottom:"0px"}}
>
{getFieldDecorator("active",{
valuePropName:"checked"
})(
<Checkbox>激活<span className="subCbDesc">激活后触发事件的信息将发送到此Webhook地址</span></Checkbox>
)}
</Form.Item>
<Button type="primary" onClick={submit} className="ml20" style={{width:id?"":"100px"}}>{id ? "更新Webhook":"添加"}</Button>
{
id && <Button type="danger" className="ml20" onClick={deleteFunc}>删除</Button>
}
</Form>
</div>
{ id && <PushHistory id={id} owner={owner} projectsId={projectsId} showNotification={showNotification}/> }
</div>
)
}
export default Form.create()(forwardRef(New));

View File

@ -445,7 +445,7 @@ class NewTags extends Component {
message: "请填写标签名字",
},
],
})(<Input placeholder="标签名字" maxLength="20" />)}
})(<Input placeholder="名称10字以内" maxLength="10" />)}
</Form.Item>
<Form.Item className="inputcount">
@ -507,8 +507,8 @@ class NewTags extends Component {
>
<div className="dialogdiv">
<Input
placeholder="标签名字"
maxLength="20"
placeholder="称,10以内"
maxLength="10"
className="inptwidth"
value={this.state.name}
onChange={this.changmodelname}

View File

@ -24,21 +24,32 @@ export default Form.create()(
const [check_box, setCheckBox] = useState(false);
const [switch_box, setSwtichBox] = useState([]);
const [onwers, setOnwers] = useState(false);
const [auth, setAuth] = useState("");
const [ descNum , setDescNum ] = useState(0);
const [switch_box_code, setSwtichBoxCode] = useState(false);
const [switch_box_pull, setSwtichBoxPull] = useState(false);
const [switch_box_issue, setSwtichBoxIssue] = useState(false);
const [switch_box_release, setSwtichBoxRelease] = useState(false);
const [switch_box_wiki, setSwtichBoxWiki] = useState(false);
const { getFieldDecorator, validateFields, setFieldsValue } = form;
const { OIdentifier, groupId } = match.params;
useEffect(()=>{
setFieldsValue({
authorize:"read",
includes_all_project:0
})
},[])
useEffect(() => {
if (GroupDetail) {
setOnwers(GroupDetail.authorize === "owner");
setAuth(GroupDetail.authorize);
setCheckBox(GroupDetail.can_create_org_project)
setSwtichBox(GroupDetail.units)
setFieldsValue({
...GroupDetail
...GroupDetail,
includes_all_project:GroupDetail.includes_all_project ? 1 :0
})
setDescNum(GroupDetail.description ? GroupDetail.description.length : 0);
}
@ -50,6 +61,7 @@ export default Form.create()(
setSwtichBoxPull(switch_checked("pulls"))
setSwtichBoxIssue(switch_checked("issues"))
setSwtichBoxRelease(switch_checked("releases"))
setSwtichBoxWiki(switch_checked("wiki"))
}
}, [switch_box])
@ -68,11 +80,13 @@ export default Form.create()(
setIsSpin(true)
validateFields((error, values) => {
if (!error) {
values.unit_types = switch_box
// values.unit_types = switch_box
values.unit_types = ['code','pulls','issues','releases','wiki'];
if (groupId) { //
const url = `/organizations/${OIdentifier}/teams/${groupId}.json`;
axios.put(url, {
...values
...values,
includes_all_project:values.includes_all_project === 1?true:false
}).then(result => {
if (result && result.data) {
showNotification("基本设置更新成功!");
@ -82,7 +96,8 @@ export default Form.create()(
} else {
const url = `/organizations/${OIdentifier}/teams.json`;
axios.post(url, {
...values
...values,
includes_all_project:values.includes_all_project === 1?true:false
}).then(result => {
if (result && result.data) {
showNotification("团队创建成功!");
@ -132,6 +147,11 @@ export default Form.create()(
setSwtichBoxRelease(checked)
}
function switch_wiki_types(checked, event) {
switch_unit_types(checked, "wiki");
setSwtichBoxWiki(checked);
}
function cancelEdit(){
if(groupId){
history.push(`/organize/${OIdentifier}/group/${groupId}`);
@ -140,6 +160,9 @@ export default Form.create()(
}
}
function changeAuth(params) {
setAuth(params.target.value)
}
function checkname(rule, value, callback){
if(!value){
@ -192,8 +215,8 @@ export default Form.create()(
"includes_all_project",
[],
<Radio.Group>
<Radio value={false} style={addStyle}>指定项目<span className="color-grey-8 ml10">(团队成员将只能访问添加到团队的项目 选择此项 <span className="color-grey-3">将不会</span> 自动删除已经添加的项目)</span></Radio>
<Radio value={true} style={OptionStyle}>所有项目<span className="color-grey-8 ml10">(团队可以访问所有项目选择此选项将 <span className="color-grey-3">添加所有现有的</span> 项目到指定团队)</span></Radio>
<Radio value={0} style={addStyle}>指定项目<span className="color-grey-8 ml10">(团队成员将只能访问添加到团队的项目 选择此项 <span className="color-grey-3">将不会</span> 自动删除已经添加的项目)</span></Radio>
<Radio value={1} style={OptionStyle}>所有项目<span className="color-grey-8 ml10">(团队可以访问所有项目选择此选项将 <span className="color-grey-3">添加所有现有的</span> 项目到指定团队)</span></Radio>
</Radio.Group>, false, 0,onwers ? "hide":""
)}
{helper(
@ -202,37 +225,42 @@ export default Form.create()(
[],
<Checkbox checked={check_box} onChange={change_check_box_status} style={OptionStyle}>新建项目<span className="color-grey-8 ml10">(成员可以在组织中新建项目创建者将自动获得新建的项目的管理员权限)</span></Checkbox>, false, 20,onwers ? "hide":""
)}
{/* {helper(
{helper(
'版本库权限:',
"authorize",
[],
<Radio.Group>
<Radio.Group onChange={changeAuth}>
<Radio value="read" style={addStyle}>读取权限<span className="color-grey-8 ml10">(成员可以查看和克隆团队项目)</span></Radio>
<Radio value="write" style={addStyle}>写入权限<span className="color-grey-8 ml10">(成员可以查看和推送提交到团队项目)</span></Radio>
<Radio value="admin" style={OptionStyle}>管理员权限<span className="color-grey-8 ml10">(成员可以拉取和推送到团队项目同时可以添加协作者)</span></Radio>
</Radio.Group>, false, 20,onwers ? "hide":""
)} */}
)}
</Form>
{/* <p className="required">访</p>
<AlignCenter className="mb10">
<Switch checked={switch_box_code} onClick={switch_code_types} />
<span className="ml30 color-grey-3">代码库<span className="color-grey-8 ml15">(查看源码文件提交和分支)</span></span>
</AlignCenter>
<AlignCenter className="mb10">
<Switch checked={switch_box_issue} onClick={switch_issue_types} />
<span className="ml30 color-grey-3">任务<span className="color-grey-8 ml15">(组织 bug 报告任务和里程碑)</span></span>
</AlignCenter>
<AlignCenter className="mb10">
<Switch checked={switch_box_pull} onClick={switch_pull_types} />
<span className="ml30 color-grey-3">合并请求<span className="color-grey-8 ml15">(启用合并请求和代码评审)</span></span>
</AlignCenter>
<AlignCenter className="mb20">
<Switch checked={switch_box_release} onClick={switch_releas_types} />
<span className="ml30 color-grey-3">版本发布<span className="color-grey-8 ml15">(跟踪项目版本和下载)</span></span>
</AlignCenter>
*/}
{/* <div className={(auth!=="owner" && auth !=="admin") ? "" :"hide"}>
<p className="required">允许访问项目单元</p>
<AlignCenter className="mb10">
<Switch checked={switch_box_code} onClick={switch_code_types} />
<span className="ml30 color-grey-3">代码库<span className="color-grey-8 ml15">(查看源码文件提交和分支)</span></span>
</AlignCenter>
<AlignCenter className="mb10">
<Switch checked={switch_box_issue} onClick={switch_issue_types} />
<span className="ml30 color-grey-3">任务<span className="color-grey-8 ml15">(组织 bug 报告任务和里程碑)</span></span>
</AlignCenter>
<AlignCenter className="mb10">
<Switch checked={switch_box_pull} onClick={switch_pull_types} />
<span className="ml30 color-grey-3">合并请求<span className="color-grey-8 ml15">(启用合并请求和代码评审)</span></span>
</AlignCenter>
<AlignCenter className="mb10">
<Switch checked={switch_box_release} onClick={switch_releas_types} />
<span className="ml30 color-grey-3">版本发布<span className="color-grey-8 ml15">(跟踪项目版本和下载)</span></span>
</AlignCenter>
<AlignCenter className="mb20">
<Switch checked={switch_box_wiki} onClick={switch_wiki_types} />
<span className="ml30 color-grey-3">wiki<span className="color-grey-8 ml15">(编辑此仓库的相关文档说明)</span></span>
</AlignCenter>
</div> */}
<Button type={"primary"} onClick={saveGroupFrom}>{groupId ? "更新团队设置" : "新建团队"}</Button>
<Cancel className="ml30" onClick={() => cancelEdit()}><span className="pl30 pr30">取消</span></Cancel>
<Cancel className="ml30" onClick={() => cancelEdit()}><span>取消</span></Cancel>
</Div>
</WhiteBack>
</Spin>

View File

@ -368,5 +368,5 @@
}
}
.hide{
display: hidden;
display: none;
}

View File

@ -75,7 +75,7 @@ function List(props){
<Search placeholder="输入仓库名称进行搜索" onSearch={onSearch}/>
</div>
<p>
{ organizeDetail && organizeDetail.is_admin ?
{ organizeDetail && organizeDetail.can_create_project ?
<Sort menu={menu_new}>
<a className="addBtn mr30">+&nbsp;新建项目</a>
</Sort>

View File

@ -97,7 +97,12 @@ function RightBox({ OIdentifier , history , admin }) {
return(
<div className="teammembers" key={key}>
<div>
<Link to={`/organize/${OIdentifier}/group/${item.id}`}><ColorListName>{item.name}</ColorListName></Link>
{
(item.is_admin || item.is_member) ?
<Link to={`/organize/${OIdentifier}/group/${item.id}`}><ColorListName>{item.name}</ColorListName></Link>
:
<ColorListName>{item.name}</ColorListName>
}
<Align>
<Span>{item.num_users}名成员</Span>
<Span>{item.num_projects}个仓库</Span>

View File

@ -168,7 +168,7 @@ export default Form.create()(
'权限:',
"repo_admin_change_team_access",
[],
<Checkbox style={radioStyle}>仓库管理员可以添加或移除团队的访问权限</Checkbox>,false,true
<Checkbox style={radioStyle}>项目管理员可以添加或移除团队的访问权限</Checkbox>,false,true
)}
<Divider/>
{helper(

View File

@ -75,7 +75,12 @@ function TeamGroupItems({organizeDetail,limit, count , history}){
return(
<div key={key}>
<p className="g-head">
<Link to={`/organize/${organizeDetail.name}/group/${item.id}`} className="color-grey-3 font-16">{item.nickname}</Link>
{
(item.is_admin || item.is_member) ?
<Link to={`/organize/${organizeDetail.name}/group/${item.id}`} className="color-grey-3 font-16">{item.nickname}</Link>
:
<span className="color-grey-3 font-16">{item.nickname}</span>
}
<span>
{ item.is_admin && item.authorize!=="owner" && <Popconfirm title={`确定解散团队${item.name}?`} okText="是" cancelText="否" onConfirm={()=>disMissGroup(item.id)}><a className="color-red">解散团队</a></Popconfirm>}
{ item.is_member && <LeaveTeam className="ml15" teamID={item.id} onOk={outTeam}/>}

View File

@ -58,6 +58,9 @@ class version extends Component {
renderList = (releases) => {
const { projectsId , owner } = this.props.match.params;
const { isManager , isDeveloper } = this.props;
const type = this.props.projectDetail && this.props.projectDetail.type;
if (releases && releases.length > 0) {
return (
releases.map((item, key) => {
@ -74,7 +77,10 @@ class version extends Component {
<div className="versionInfo_right">
<span className="versionName">
<span className="task-hide">{item.name}</span>
<Link to={`/projects/${owner}/${projectsId}/releases/${item.version_id}/update`} className="color-blue ml3 font-12">编辑</Link>
{
(isManager || isDeveloper) && type !==2 &&
<Link to={`/projects/${owner}/${projectsId}/releases/${item.version_id}/update`} className="color-blue ml3 font-12">编辑</Link>
}
</span>
<span className="color-grey-3">
<i className={`${item.bodyshow ? "iconfont icon-sanjiaoxing-down color-grey-8 mr3 font-14":"iconfont icon-triangle color-grey-8 mr3 font-14"}`} onClick={()=>this.showBody(key,item.bodyshow)}></i>
@ -100,14 +106,14 @@ class version extends Component {
render() {
const { projectsId ,owner } = this.props.match.params;
const { data , releases , isSpin } = this.state
const { data , releases , isSpin } = this.state;
const type = this.props.projectDetail && this.props.projectDetail.type;
return (
<div className="main" style={{padding:"0px"}}>
<div className="topWrapper" style={{padding:"15px 20px"}}>
<span className="font-18 color-grey-3">版本发布</span>
{
data && data.user_permission ?
data && data.user_permission && type !== 2 ?
<Link to={`/projects/${owner}/${projectsId}/releases/new`} className="topWrapper_btn_new">+ 发布新版</Link>
: ''
}

223
src/forge/Wiki/EditWiki.jsx Normal file
View File

@ -0,0 +1,223 @@
import React, { useEffect, useCallback, useState } from 'react';
import { Button, Checkbox, Form, Icon, Radio, Input, message } from 'antd';
import MDEditor from "../../modules/tpm/challengesnew/tpm-md-editor";
import DelModal from './components/ModalFun';
import { weekModal, monthModal } from './components/config';
import { getWiki, wikiPages, addWiki, updateWiki } from './api';
import './Index.scss';
export default Form.create()(({ form, history, showNotification, projectDetail, match, project }) => {
// const permission = projectDetail && projectDetail.permission !== "Reporter";
const permission = projectDetail && projectDetail.permission && projectDetail.permission !== "Reporter";
const { getFieldDecorator, validateFields, setFieldsValue } = form;
const [fileArrInit, setFileArrInit] = useState(null);
let projectsId = match.params.projectsId;
let owner = match.params.owner;
let wikiName = history.location.pathname.split('/').pop();
if (wikiName === 'add') {
wikiName = '';
}
const [content, setContent] = useState(undefined);
const [modal, setModal] = useState(false);
const [modalType, setModalType] = useState();
useEffect(() => {
wikiName && project && getWiki({
owner,
repo: projectsId,
pagename: wikiName,
projectId: project.id
}).then(res => {
if (res && res.data) {
setContent(res.data.md_content);
setFieldsValue({
name: res.data.name,
content: res.data.md_content,
});
}
});
}, [owner, wikiName]);
// wiki
useEffect(() => {
project && wikiPages({
owner: owner,
repo: projectsId,
projectId: project.id
}).then(res => {
if (res && res.message === "200" && Array.isArray(res.data)) {
setFileArrInit(res.data);
} else {
setFileArrInit([]);
}
});
}, [project]);
const helper = useCallback(
(label, name, rules, widget, initialValue, rightComponent) => (
<Form.Item label={label} className="mb0">
{getFieldDecorator(name, { rules, initialValue, validateFirst: true, })(widget)}
{rightComponent}
</Form.Item>
), []);
function onContentChange(value) {
setContent(value);
setFieldsValue({
content: value
});
};
// wiki
function saveFile() {
validateFields((err, values) => {
if (!err) {
let regEn = /[\[\]`\/:*?''<>|%-+_]/g;
if (regEn.test(values.name)) {
message.error('文件名不能有特殊字符');
return;
}
if (wikiName) {
updateWiki({
owner,
repo: projectsId,
projectId: project.id,
pagename: wikiName,
...values,
commit_message: '',
}).then(res => dealRes(res));
} else {
if (Array.isArray(fileArrInit)) {
for (const item of fileArrInit) {
if (item.name === values.name) {
message.error('不能与已有文件标题相同');
return false;
}
}
}
addWiki({
owner,
repo: projectsId,
projectId: project.id,
pagename: values.name,
...values,
commit_message: '',
}).then(res => dealRes(res));
}
}
})
}
function dealRes(res) {
if (res && res.message === "200") {
showNotification("操作成功");
goBack();
} else if (res && res.message === "500") {
message.error('请检查格式是否正确或文件名是否重复');
} else {
showNotification(res.message || "操作失败");
}
}
function goBack() {
history.push(`/projects/${owner}/${projectsId}/wiki`);
}
function changeModal(e) {
setModal(e.target.checked);
if (!e.target.checked) {
setModalType();
}
}
function changeModalType(e) {
let value = e.target.value;
if (!content) {
setModalContent(value);
return;
}
DelModal({
title: '添加模版',
contentTitle: `您确定要添加“${value}”模板吗`,
content: `此操作会将“${value}”模板替换编辑栏内所有内容,请确认以防文件的丢失`,
okText: '确认添加',
onOk: () => {
setModalType(value);
setModal(true);
setModalContent(value);
}
});
}
function setModalContent(value) {
if (value === '周报') {
setContent(weekModal);
setFieldsValue({
content: weekModal
});
} else if (value === '月报') {
setContent(monthModal);
setFieldsValue({
content: monthModal
});
}
}
return (
<div className="wiki-main">
<div className="wiki-head">
<span className="head-title"><span className="back-wiki" onClick={goBack}>Wiki</span> <Icon type="right" /> 编辑页面</span>
</div>
<div >
<h4 className="mt20 mb0">标题</h4>
{helper(
"",
"name",
[
{ required: true, message: "请输入标题" },
// { pattern: /[^`\[\]\/:*?''<>|%-+_]/g, message: '' }
],
<Input
placeholder={"请输入标题"}
className="contact-input"
maxLength={50}
/>
)}
<Form.Item className="mb0">
<MDEditor
placeholder={"请输入wiki内容"}
height={500}
mdID={"order-new-description"}
initValue={content}
onChange={onContentChange}
className="mt20"
></MDEditor>
{getFieldDecorator('content', {
rules: [{ required: true, message: "请输入wiki内容" }],
validateFirst: true
})(<Input style={{ display: 'none' }} />)}
</Form.Item>
<Checkbox checked={modal} onChange={changeModal}>添加模版</Checkbox>
<Radio.Group onChange={changeModalType} value={modalType}>
<Radio value='周报'>周报</Radio>
<Radio value='月报'>月报</Radio>
</Radio.Group>
</div>
{permission && <Button className="mt25" type="primary" onClick={saveFile}>保存</Button>}
</div>
)
})

283
src/forge/Wiki/Index.jsx Normal file
View File

@ -0,0 +1,283 @@
import React, { useEffect, useCallback, useState } from 'react';
import { Button, Dropdown, Icon, Input, Menu, Tooltip, Select, Upload, message, Spin } from 'antd';
import { getImageUrl, timeAgo } from 'educoder';
import cookie from 'react-cookies';
import CopyTool from '../Component/CopyTool';
import DelModal from './components/ModalFun';
import Welcome from './Welcome';
import { wikiPages, getWiki, deleteWiki } from './api';
import { httpUrl, TokenKey } from './fetch';
import './Index.scss';
import { isArray } from 'lodash';
const Search = Input.Search;
const InputGroup = Input.Group;
const { Option } = Select;
export default (props) => {
const { match, history, showNotification, project, projectDetail } = props;
const permission = projectDetail && projectDetail.permission && projectDetail.permission !== "Reporter";
let projectsId = match.params.projectsId;
let owner = match.params.owner;
const [fileArrInit, setFileArrInit] = useState(null);
const [checkItem, setCheckItem] = useState({});
const [itemDetail, setItemDetail] = useState({});
const [fileArr, setFileArr] = useState([]);
const [reload, setReload] = useState();
const [urlType, setUrlType] = useState('HTTPS');
// wiki
useEffect(() => {
project && wikiPages({
owner: owner,
repo: projectsId,
projectId: project.id
}).then(res => {
if (res && res.message === "200" && isArray(res.data)) {
setFileArr(res.data);
setFileArrInit(res.data);
if (res.data.length) {
setCheckItem(res.data[0]);
};
} else {
setFileArr([]);
setFileArrInit([]);
}
});
}, [project, reload])
// wiki
useEffect(() => {
project && checkItem.name && getWiki({
owner: owner,
repo: projectsId,
pagename: checkItem.name,
projectId: project.id
}).then(res => {
if (res && res.message === "200") {
setItemDetail(res.data);
} else {
showNotification("加载失败")
}
});
}, [project, checkItem]);
function changeSearchValue(e) {
let value = e.target.value;
let newFileArr = [];
for (const item of fileArrInit) {
if (item.name.indexOf(value) > -1) {
newFileArr.push(item);
}
}
setFileArr(newFileArr);
}
// wiki
function deleteFileModal(e, item) {
e.stopPropagation();
DelModal({
title: '删除页面',
contentTitle: `您确定要删除“${item.name}”此页面吗?`,
content: '此操作将删除该页面,请进行确认以防文件的丢失',
onOk: () => {
deleteWiki({
owner: owner,
repo: projectsId,
pagename: item.name,
projectId: project.id
}).then(res => {
if (res && res.message === "200") {
message.success('删除成功');
setReload(Math.random());
} else {
message.error('删除失败');
}
});
}
});
}
function goUser(login) {
window.location.href = `/users/${login}`;
}
function addFile() {
history.push(`/projects/${owner}/${projectsId}/wiki/add`);
}
function goEdit() {
history.push(`/projects/${owner}/${projectsId}/wiki/edit/${encodeURI(checkItem.name)}`);
}
function preview() {
window.open(`/projects/${owner}/${projectsId}/wiki/preview/${encodeURI(project.name)}/${project.id}`);
}
// MarkdownHtmlPdf
const menu = (
<Menu >
<Menu.Item key="1" onClick={() => { downloadWiki('markdown') }}>
Markdown
</Menu.Item>
<Menu.Item key="2" onClick={() => { downloadWiki('html') }}>
HTML
</Menu.Item>
<Menu.Item key="3" onClick={() => { downloadWiki('pdf') }}>
PDF
</Menu.Item>
</Menu>
);
function downloadWiki(type) {
window.open(`${httpUrl}/api/wikiExport/wikiExport-wrapper?repoName=${projectsId}&owner=${owner}&type=${type}&projectName=${project.name}&projectId=${project.id}`);
}
function beforeUpload(file) {
if (!['md', 'txt'].includes(file.name.split('.').pop())) {
message.error('只能上传md、txt文件');
return false;
}
let regEn = /[\[\]`\/:*?''<>|%-+_]/g;
if (regEn.test(file.name)) {
message.error('文件名不能有特殊字符');
return;
}
for (const item of fileArrInit) {
if (item.name === file.name) {
message.error('不能上传与已有文件相同文件名的文件');
return false;
}
}
const isLt100M = file.size / 1024 / 1024 < 100;
if (!isLt100M) {
showNotification(`文件大小必须小于${100}MB!`);
}
return isLt100M;
}
const uploadProps = {
name: 'multipartFile',
withCredentials: true,
action: `${httpUrl}/api/wikiExport/uploadWiki/${owner}/${projectsId}/${project && project.id}`, //?token=${sessionStorage.taskToken}
showUploadList: false,
headers: {
Authorization: cookie.load(TokenKey) || sessionStorage.taskToken,
},
beforeUpload: beforeUpload,
onChange(info) {
if (info.file.status === 'uploading') {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
if (info.file.response.message === '200') {
message.success(`${info.file.name} 上传成功`);
setReload(Math.random());
} else if (info.file.response.message === '500') {
let data = JSON.parse(info.file.response.data);
message.error(data && data.message ? data.message : '文件上传失败');
} else {
message.error('文件上传失败');
}
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 上传失败`);
}
},
};
return (
< Spin spinning={!fileArrInit} className="opacitySpin">
{fileArrInit && fileArrInit.length ?
<div className="wiki-main">
<div className="wiki-head">
<span className="head-title">
{
permission ?
<Button type="default" onClick={addFile}><Icon type="plus" />新增页面</Button>
: "Wiki文档"
}
</span>
<div>
{
permission &&
<Upload {...uploadProps}>
<Tooltip placement="top" title={'支持导入txt、markdown格式文件'}>
<Button type="default" className="ml10"><Icon type="plus" />导入模板</Button>
</Tooltip>
</Upload>
}
<Dropdown overlay={menu}>
<Button type="default" className="ml10">导出<Icon type="caret-down" /></Button>
</Dropdown>
<Button type="default" className="ml10" onClick={preview}>预览</Button>
</div>
</div>
<div className="wiki-body">
<div className="wiki-nav-parent">
<div className="wiki-nav">
<Search
// allowClear
placeholder="输入关键字搜索文件"
className="wiki-search"
onChange={changeSearchValue}
/>
{
fileArr.map(item => {
return <div className="wiki-nav-title-parent" key={item.name}>
<div className={`wiki-nav-title ${item.name === checkItem.name ? 'active' : ''}`} onClick={() => { setCheckItem(item) }}>
<div className="nav-title-left">
<i className="iconfont icon-wenjianjia2 mr3"></i>
<span className="nav-title-left-text">{item.name}</span>
</div>
{permission && <i className="iconfont icon-shanchuicon1 delete-title-icon color-grey-6" onClick={(e) => { deleteFileModal(e, item) }}></i>}
</div>
</div>
})
}
</div>
{checkItem.wiki_clone_link && <InputGroup className="copy-url" compact>
<Select dropdownClassName="wiki-url-type" defaultValue="HTTPS" onChange={(v) => { setUrlType(v) }}>
<Option value="HTTPS">HTTPS</Option>
<Option value="SSH">SSH</Option>
</Select>
<Input id="wikiUrl" value={urlType === 'HTTPS' ? checkItem.wiki_clone_link.https : checkItem.wiki_clone_link.ssh} />
<CopyTool className="copy-wiki" inputId="wikiUrl" />
</InputGroup>}
</div>
<div className="wiki-content">
<div className="wiki-content-head">
<div className="wiki-content-head-left">
<h3 className="wiki-detail-title">{checkItem.name}</h3>
<span className="user-box mr10" onClick={() => { checkItem.commit && goUser(checkItem.commit.author.name) }}>
{itemDetail.image_url && <img alt="头像" className="head-log-small" src={getImageUrl(`/${itemDetail.image_url}`)} />}
<span >{itemDetail.userName}</span>
</span>
<span className="time-ago">上次修改于{checkItem.commit && timeAgo(checkItem.commit.author.when)}</span>
</div>
{permission && <Button type="primary" onClick={goEdit}>编辑</Button>}
</div>
<div className="wiki-content-detail editor-content-panel markdown-body" dangerouslySetInnerHTML={{ __html: itemDetail && itemDetail.simple_content }} ></div>
</div>
</div>
</div >
:
<Welcome {...props} reloadList={setReload} />
}
</Spin>
)
}

381
src/forge/Wiki/Index.scss Normal file
View File

@ -0,0 +1,381 @@
$wikiColor: #466aff;
$primaryBtnHover: #6482ff;
body {
width: 100% !important;
}
.ant-spin-nested-loading > div > .ant-spin.opacitySpin{
max-height: 100vh;
background: rgba(255,255,255,1);
}
.wiki-main {
width: 1200px;
min-height: 400px;
margin: 20px auto;
.ant-btn-primary {
background-color: $wikiColor;
border-color: $wikiColor;
&:hover,
&:focus,
&:active {
background-color: $primaryBtnHover;
}
}
.ant-btn-default:hover,
.ant-btn-default:active,
.ant-btn-default:focus {
background: #f3f4f6;
color: #333;
border-color: #d0d0d0;
}
.wiki-head {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
height: 64px;
background: #fafcff;
box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.13);
border-radius: 4px;
border-bottom-left-radius: 0;
.ant-btn .anticon {
margin: 0 -3px 0 0;
}
}
.head-title {
font-size: 20px;
color: #05101a;
line-height: 30px;
font-weight: 500;
.anticon-right {
color: #666;
font-size: 0.9rem;
}
}
.back-wiki {
color: $wikiColor;
cursor: pointer;
&:hover {
color: $primaryBtnHover;
}
}
.head-log-middle {
width: 3rem;
height: 3rem;
margin-right: 0.35rem;
border-radius: 50%;
}
.head-log-small {
width: 1.25rem;
height: 1.25rem;
margin-right: 0.35rem;
border-radius: 50%;
}
.user-box {
font-size: 12px;
font-family: "PingFangSC-Medium";
color: $wikiColor;
cursor: pointer;
&:hover {
color: $primaryBtnHover;
}
.head-log-small {
position: relative;
top: -2px;
}
}
.time-ago {
font-size: 12px;
color: #333;
letter-spacing: 0;
line-height: 17px;
font-weight: 400;
font-family: "PingFangSC-Regular";
}
.has-error .ant-form-explain,
.has-error .ant-form-split {
position: absolute;
}
.wiki-nav {
max-height: 60vh;
.wiki-search {
padding: 0 14px;
.ant-input {
padding-left: 30px;
}
.ant-input-suffix {
left: 26px;
right: auto;
}
&:hover .ant-input,
&:focus .ant-input {
border-color: $wikiColor !important;
}
}
}
.wiki-nav-parent {
width: 260px;
flex: none;
}
.ant-form-item-children .ant-input:hover {
border-color: $wikiColor !important;
}
.ant-checkbox-checked .ant-checkbox-inner {
background-color: $wikiColor;
border-color: $wikiColor;
}
.ant-radio-checked .ant-radio-inner,
.ant-radio-checked::after {
border-color: $wikiColor;
}
.ant-radio-inner::after {
background-color: $wikiColor;
}
.ant-radio-group {
display: block;
margin: 10px 0 0 30px;
}
.ant-radio-wrapper:hover .ant-radio,
.ant-radio:hover .ant-radio-inner,
.ant-radio-input:focus + .ant-radio-inner {
border-color: $wikiColor;
}
}
#wikiUrl:focus {
border-right: 1px solid #d9d9d9 !important;
}
.wiki-body {
display: flex;
}
.wiki-content {
flex: auto;
width: 75%;
}
.wiki-content-detail {
padding: 0 20px;
word-break: break-all;
}
.ant-input-group.ant-input-group-compact.copy-url {
display: flex;
margin-top: 20px;
.ant-select-selection__rendered {
margin: 0 14px 0 5px;
width: 3rem;
font-size: 12px;
}
.ant-select-arrow {
right: 4px;
}
.ant-input {
font-size: 12px;
font-family: "PingFangSC-Regular";
color: #666;
letter-spacing: 0;
font-weight: 400;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-break: break-all;
}
.copy-wiki {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0 5px;
background: #fff;
font-size: 1rem !important;
border: 1px solid #d9d9d9;
border-left: 0;
color: $wikiColor;
cursor: pointer;
}
}
.wiki-url-type {
.ant-select-dropdown-menu-item {
font-size: 12px;
}
}
.wiki-nav {
min-height: 300px;
padding: 20px 0;
background: #ffffff;
border: 1px solid rgba(153, 153, 153, 0.22);
overflow-y: scroll;
flex: none;
color: #333;
}
.wiki-nav-title {
display: flex;
justify-content: space-between;
align-items: center;
height: 50px;
padding: 0 10px 0 10px;
font-size: 14px;
letter-spacing: 0;
font-weight: 400;
font-family: "PingFangSC-Regular";
border-bottom: 1px solid #eee;
line-height: 16px;
cursor: pointer;
.delete-title-icon {
display: none;
}
&:hover {
background-color: #fbfbfb;
.delete-title-icon {
display: inline-block;
}
}
}
.wiki-nav-title-parent {
padding: 0 14px;
&:hover {
background: #fbfbfb;
}
}
.wiki-nav-title.active {
color: $wikiColor;
}
.wiki-content-head {
margin: 20px 0 20px 20px;
padding: 0 20px 20px 0;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #eee;
}
.wiki-content-head-left {
width: 90%;
}
.nav-title-left {
display: inline-flex;
max-width: 90%;
svg {
margin-right: 0.5rem;
flex: none;
}
.nav-title-left-text {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
.wiki-detail-title {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
// 预览页面样式文件
.wiki-preview {
overflow-y: scroll;
height: 100%;
.wiki-body {
width: 90%;
}
.ant-btn-primary {
background-color: $wikiColor;
border-color: $wikiColor;
&:hover,
&:focus,
&:active {
background-color: $primaryBtnHover;
}
}
.preview-head {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 12rem 0 2rem;
width: 100%;
height: 80px;
background: rgb(39, 47, 76);
color: #fff;
}
.preview-head-left {
display: inline-flex;
align-items: center;
font-size: 24px;
cursor: pointer;
.icon-wendangyulan_icon {
font-size: 24px !important;
font-weight: 700;
}
}
.preview-head-right {
display: flex;
.copy-url {
margin-top: 0;
}
.copy-desc {
width: 6rem;
padding-top: 1px;
}
}
.wiki-nav-title {
padding: 0 10px 0 40px;
}
.wiki-nav-title.active {
background-color: #f3f4f6;
}
.wiki-content-head {
padding: 10px 20px 10px 20px;
}
.wiki-nav {
padding: 20px 0;
width: 20vw;
border-bottom: 0;
height: 80vh;
}
.wiki-content-detail {
padding: 0 40px;
img {
max-width: 100%;
}
}
.ant-btn:hover {
background: #f3f4f6;
color: #333;
border-color: #d0d0d0;
}
}

146
src/forge/Wiki/Preview.jsx Normal file
View File

@ -0,0 +1,146 @@
import React, { useEffect, useCallback, useState } from 'react';
import { Input, Button, Select, Dropdown, Icon, Menu, message } from 'antd';
import CopyTool from '../Component/CopyTool';
import { wikiPages, getWiki, } from './api';
import { httpUrl } from './fetch';
import './Index.scss';
const InputGroup = Input.Group;
const { Option } = Select;
export default (props) => {
const { match, history, showNotification, project, projectDetail } = props;
const permission = projectDetail && projectDetail.permission && projectDetail.permission !== "Reporter";
let projectsId = match.params.projectsId;
let owner = match.params.owner;
let projectName = match.params.projectName;
let projectId = match.params.projectId;
console.log('projectName:');
console.log(projectName);
const [checkItem, setCheckItem] = useState({});
const [itemDetail, setItemDetail] = useState({});
const [fileArr, setFileArr] = useState([]);
const [urlType, setUrlType] = useState('HTTPS');
useEffect(() => {
projectsId && wikiPages({
owner: owner,
repo: projectsId,
projectId: projectId,
}).then(res => {
if (res && res.message === "200") {
setFileArr(res.data);
if (res.data.length) {
setCheckItem(res.data[0]);
};
} else {
showNotification("加载失败")
}
});
}, [project])
useEffect(() => {
projectsId && checkItem.name && getWiki({
owner: owner,
repo: projectsId,
pagename: checkItem.name,
projectId: projectId,
}).then(res => {
if (res && res.message === "200") {
setItemDetail(res.data);
} else {
showNotification("加载失败")
}
});
}, [project, checkItem]);
function goEdit() {
history.push(`/projects/${owner}/${projectsId}/wiki/edit/${checkItem.name}`);
}
function goBack() {
history.push(`/projects/${owner}/${projectsId}/wiki`);
}
// MarkdownHtmlPdf
const menu = (
<Menu >
<Menu.Item key="1" onClick={() => { downloadWiki('markdown') }}>
Markdown
</Menu.Item>
<Menu.Item key="2" onClick={() => { downloadWiki('html') }}>
HTML
</Menu.Item>
<Menu.Item key="3" onClick={() => { downloadWiki('pdf') }}>
PDF
</Menu.Item>
</Menu>
);
function downloadWiki(type) {
window.open(`${httpUrl}/api/wikiExport/wikiExport-wrapper?repoName=${projectsId}&owner=${owner}&type=${type}&projectName=${projectName}&projectId=${projectId}`);
}
return (
<div className="wiki-preview">
<div className="preview-head">
<div className="preview-head-left" onClick={goBack}>
<i className="iconfont icon-wendangyulan_icon mr3"></i>
<span className="ml10">{projectName}</span>
</div>
<div className="preview-head-right">
<span className="copy-desc">克隆地址</span>
{
checkItem.wiki_clone_link && <InputGroup className="copy-url" compact>
<Select dropdownClassName="wiki-url-type" defaultValue="HTTPS" onChange={(v) => { console.log(v); setUrlType(v) }}>
<Option value="HTTPS">HTTPS</Option>
<Option value="SSH">SSH</Option>
</Select>
<Input id="wikiUrl" value={urlType === 'HTTPS' ? checkItem.wiki_clone_link.https : checkItem.wiki_clone_link.ssh} />
<CopyTool className="copy-wiki" inputId="wikiUrl"/>
</InputGroup>
}
<Dropdown overlay={menu}>
<Button className="ml10">导出<Icon type="caret-down" /></Button>
</Dropdown>
</div>
</div>
<div className="wiki-body">
<div className="wiki-nav">
{
fileArr.map(item => {
return <div className={`${item.name === checkItem.name ? 'active' : ''} wiki-nav-title`} key={item.name} onClick={() => { setCheckItem(item) }}>
<span className="nav-title-left" >
<i className="iconfont icon-wenjianjia2 mr3"></i>
<span className="nav-title-left-text">{item.name}</span>
</span>
</div>
})
}
</div>
<div className="wiki-content">
<div className="wiki-content-head">
<h3>{checkItem.name}</h3>
{permission && <Button type="primary" onClick={goEdit}>编辑</Button>}
</div>
<div className="wiki-content-detail editor-content-panel markdown-body" dangerouslySetInnerHTML={{ __html: itemDetail && itemDetail.simple_content }} ></div>
</div>
</div>
</div>
)
}

View File

@ -0,0 +1,50 @@
import React from 'react';
import { Button } from 'antd';
// import { addWiki } from '../api';
import './index.scss';
export default ({ project, isManager, history, showNotification, match, reloadList }) => {
let projectsId = match.params.projectsId;
let owner = match.params.owner;
// function addFile() {
// addWiki({
// owner,
// repo: projectsId,
// pagename: 'Home',
// name: 'Home',
// content: 'Welcome to the wiki!',
// commit_message: '',
// }).then(res => {
// if (res.message === "200") {
// reloadList(Math.random());
// showNotification("");
// } else {
// showNotification("");
// }
// });
// }
function addFile() {
history.push(`/projects/${owner}/${projectsId}/wiki/add`);
}
return (
<div className="welcome-main">
<i className="iconfont icon-huanying_icon" ></i>
<p className="welcome-title">欢迎使用&nbsp;
<span className="wiki-title">
{project && project.name}
</span>
&nbsp;Wiki</p>
<p className="welcome-content">Wiki主要是您项目的产品设计文档描述注释等等</p>
<div className="wiki-line"></div>
{
isManager ? <Button type="primary" onClick={addFile}>创建Wiki文档</Button>
: <p className="welcome-des">该项目暂时没有创建Wiki</p>
}
</div>
)
}

View File

@ -0,0 +1,55 @@
.welcome-main {
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
width: 1200px;
min-height: 400px;
padding: 20px;
margin: 20px auto;
background: rgba(250, 252, 255, 1);
font-family: "PingFangSC-Medium";
border-radius: 4px;
border: 1px solid rgba(42, 97, 255, 0.23);
.icon-huanying_icon {
font-size: 48px !important;
font-weight: 700;
}
.welcome-title {
display: inline-flex;
align-items: center;
margin: 10px 0;
font-size: 26px;
color: #333333;
font-weight: 500;
}
.wiki-title {
display: inline-block;
max-width: 20em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.welcome-content {
font-size: 14px;
color: #333333;
font-weight: 400;
}
.wiki-line {
margin: 50px 0 40px;
width: 400px;
height: 1px;
background: #eeeeee;
}
.welcome-des {
font-size: 16px;
color: #333333;
font-weight: 500;
}
}

48
src/forge/Wiki/api.js Normal file
View File

@ -0,0 +1,48 @@
import fetch from './fetch';
// import { notification } from 'antd';
// 获取wiki列表
export function wikiPages(params) {
return fetch({
url: '/api/wiki/wikiPages',
method: 'get',
params
});
}
// 获取单个wiki
export function getWiki(params) {
return fetch({
url: '/api/wiki/getWiki',
method: 'get',
params
});
}
//新增wiki
export function addWiki(data) {
return fetch({
url: '/api/wiki/createWiki',
method: 'post',
data: data
});
}
//更新wiki
export function updateWiki(data) {
return fetch({
url: '/api/wiki/updateWiki',
method: 'PUT',
data: data
});
}
//删除wiki
export function deleteWiki(data) {
return fetch({
url: '/api/wiki/deleteWiki',
method: 'DELETE',
data,
});
}

View File

@ -0,0 +1,244 @@
import * as React from 'react';
import classNames from 'classnames';
import { Icon, Tree } from 'antd';
import omit from 'omit.js';
import debounce from 'lodash/debounce';
import { conductExpandParent, convertTreeToEntities } from 'rc-tree/lib/util';
import { polyfill } from 'react-lifecycles-compat';
import { ConfigConsumer } from '../../../../../node_modules/antd/lib/config-provider';
import {
calcRangeKeys,
getFullKeyList,
convertDirectoryKeysToNodes,
getFullKeyListByTreeData,
} from '../../../../../node_modules/antd/lib/tree/util';
import { FolderSvg, FolderExpandSvg, FileSvg } from '../../Svg';
import './index.scss';
function getIcon(props) {
// console.log(props);
// console.log(props.expanded);
const { isLeaf, expanded ,selected} = props;
if (isLeaf) {
return <FileSvg color={selected ? "#2A61FF" : "#666"}/>;
}
return expanded ? <FolderExpandSvg color={"#666"}/> : <FolderSvg color={"#666"} />
// return <FolderSvg color={expanded ? "#2A61FF" : "#666"} />
}
class DirectoryTree extends React.Component {
static defaultProps = {
showIcon: true,
expandAction: 'click',
};
static getDerivedStateFromProps(nextProps) {
const newState = {};
if ('expandedKeys' in nextProps) {
newState.expandedKeys = nextProps.expandedKeys;
}
if ('selectedKeys' in nextProps) {
newState.selectedKeys = nextProps.selectedKeys;
}
return newState;
}
// state: DirectoryTreeState;
// tree: Tree;
// onDebounceExpand: (event: React.MouseEvent<HTMLElement>, node: AntTreeNode) => void;
// Shift click usage
// lastSelectedKey?: string;
// cachedSelectedKeys?: string[];
constructor(props) {
super(props);
const {
defaultExpandAll,
defaultExpandParent,
expandedKeys,
defaultExpandedKeys,
children,
} = props;
const { keyEntities } = convertTreeToEntities(children);
// Selected keys
this.state = {
selectedKeys: props.selectedKeys || props.defaultSelectedKeys || [],
};
// Expanded keys
if (defaultExpandAll) {
if (props.treeData) {
this.state.expandedKeys = getFullKeyListByTreeData(props.treeData);
} else {
this.state.expandedKeys = getFullKeyList(props.children);
}
} else if (defaultExpandParent) {
this.state.expandedKeys = conductExpandParent(
expandedKeys || defaultExpandedKeys,
keyEntities,
);
} else {
this.state.expandedKeys = expandedKeys || defaultExpandedKeys;
}
this.onDebounceExpand = debounce(this.expandFolderNode, 200, {
leading: true,
});
}
onExpand = (expandedKeys, info) => {
const { onExpand } = this.props;
this.setUncontrolledState({ expandedKeys });
// Call origin function
if (onExpand) {
return onExpand(expandedKeys, info);
}
return undefined;
};
onClick = (event, node) => {
const { onClick, expandAction } = this.props;
// Expand the tree
if (expandAction === 'click') {
this.onDebounceExpand(event, node);
}
if (onClick) {
onClick(event, node);
}
};
onDoubleClick = (event, node) => {
const { onDoubleClick, expandAction } = this.props;
// Expand the tree
if (expandAction === 'doubleClick') {
this.onDebounceExpand(event, node);
}
if (onDoubleClick) {
onDoubleClick(event, node);
}
};
onSelect = (keys, event) => {
const { onSelect, multiple, children } = this.props;
const { expandedKeys = [] } = this.state;
const { node, nativeEvent } = event;
const { eventKey = '' } = node.props;
const newState = {};
// We need wrap this event since some value is not same
const newEvent = {
...event,
selected: true, // Directory selected always true
};
// Windows / Mac single pick
const ctrlPick = nativeEvent.ctrlKey || nativeEvent.metaKey;
const shiftPick = nativeEvent.shiftKey;
// Generate new selected keys
let newSelectedKeys;
if (multiple && ctrlPick) {
// Control click
newSelectedKeys = keys;
this.lastSelectedKey = eventKey;
this.cachedSelectedKeys = newSelectedKeys;
newEvent.selectedNodes = convertDirectoryKeysToNodes(children, newSelectedKeys);
} else if (multiple && shiftPick) {
// Shift click
newSelectedKeys = Array.from(
new Set([
...(this.cachedSelectedKeys || []),
...calcRangeKeys(children, expandedKeys, eventKey, this.lastSelectedKey),
]),
);
newEvent.selectedNodes = convertDirectoryKeysToNodes(children, newSelectedKeys);
} else {
// Single click
newSelectedKeys = [eventKey];
this.lastSelectedKey = eventKey;
this.cachedSelectedKeys = newSelectedKeys;
newEvent.selectedNodes = [event.node];
}
newState.selectedKeys = newSelectedKeys;
if (onSelect) {
onSelect(newSelectedKeys, newEvent);
}
this.setUncontrolledState(newState);
};
setTreeRef = (node) => {
this.tree = node;
};
expandFolderNode = (event, node) => {
const { isLeaf } = node.props;
if (isLeaf || event.shiftKey || event.metaKey || event.ctrlKey) {
return;
}
// Get internal rc-tree
const internalTree = this.tree.tree;
// Call internal rc-tree expand function
// https://github.com/ant-design/ant-design/issues/12567
internalTree.onNodeExpand(event, node);
};
setUncontrolledState = (state) => {
const newState = omit(state, Object.keys(this.props));
if (Object.keys(newState).length) {
this.setState(newState);
}
};
renderDirectoryTree = ({ getPrefixCls }) => {
const { prefixCls: customizePrefixCls, className, ...props } = this.props;
const { expandedKeys, selectedKeys } = this.state;
const prefixCls = getPrefixCls('tree', customizePrefixCls);
const connectClassName = classNames(`${prefixCls}-directory`, className);
return (
<Tree
icon={getIcon}
ref={this.setTreeRef}
{...props}
prefixCls={prefixCls}
className={connectClassName}
expandedKeys={expandedKeys}
selectedKeys={selectedKeys}
onSelect={this.onSelect}
onClick={this.onClick}
onDoubleClick={this.onDoubleClick}
onExpand={this.onExpand}
/>
);
};
render() {
return <ConfigConsumer>{this.renderDirectoryTree}</ConfigConsumer>;
}
}
polyfill(DirectoryTree);
export default DirectoryTree;

View File

@ -0,0 +1,61 @@
.hide-file-icon.ant-tree.ant-tree-directory {
li span.ant-tree-switcher {
display: none !important;
}
// li[role="treeitem"]:hover > span.ant-tree-switcher,
// li.ant-tree-treenode-selected > span.ant-tree-switcher {
// z-index: 1000;
// display: inline-block !important;
// }
.ant-tree-node-content-wrapper{
display: inline-flex;
width: 100%;
}
.tree-title-icon{
display: none;
}
.ant-tree-node-content-wrapper:hover .tree-title-icon{
transition: all 0.3s;
display: inline-block;
}
&.ant-tree.ant-tree-directory
> li.ant-tree-treenode-selected
> span.ant-tree-node-content-wrapper::before,
&.ant-tree.ant-tree-directory
.ant-tree-child-tree
> li.ant-tree-treenode-selected
> span.ant-tree-node-content-wrapper::before {
background: #fff;
margin-top: -3px;
}
&.ant-tree.ant-tree-directory > li span.ant-tree-node-content-wrapper::before,
&.ant-tree.ant-tree-directory
.ant-tree-child-tree
> li
span.ant-tree-node-content-wrapper::before {
margin-top: -3px;
}
> li span.ant-tree-node-content-wrapper.ant-tree-node-selected,
.ant-tree-child-tree
> li
span.ant-tree-node-content-wrapper.ant-tree-node-selected {
color: #2a61ff;
}
.ant-tree-title{
display: inline-flex;
justify-content:space-between;
flex: auto;
}
}

View File

@ -0,0 +1,40 @@
import React, { useState } from 'react';
import * as ReactDOM from 'react-dom';
import LoginDialog from '../../../../modules/login/LoginDialog';
// 使
export default function Login(props) {
const div = document.createElement('div');
document.body.appendChild(div);
function destroy() {
const unmountResult = ReactDOM.unmountComponentAtNode(div);
if (unmountResult && div.parentNode) {
div.parentNode.removeChild(div);
}
}
function render() {
setTimeout(() => {
ReactDOM.render(
<MyLoginDialog afterClose={destroy} />
,
div,
);
});
}
render();
}
function MyLoginDialog({afterClose}) {
const [isRender, setIsRender] = useState(true);
return (
<LoginDialog
isRender={isRender}
Modifyloginvalue={() => {setIsRender(false);afterClose()}}
/>
)
}

View File

@ -0,0 +1,117 @@
/* eslint-disable react/jsx-no-duplicate-props */
import React, { useState } from 'react';
import * as ReactDOM from 'react-dom';
import { Modal, Button } from 'antd';
import './index.scss';
InitModal.defaultProps = {
okText: '确认', //
cancelText: '取消', //
className: '', //
inputId: 'copyText', //ID
};
// 使
export default function DelModal(props) {
renderModal({ ...props, type: 'delete' })
}
// 使
export function Confirm(props) {
renderModal({ ...props, type: 'confirm' })
}
function renderModal(props) {
const { type, afterClose } = props;
const div = document.createElement('div');
document.body.appendChild(div);
function destroy() {
afterClose && afterClose();
const unmountResult = ReactDOM.unmountComponentAtNode(div);
if (unmountResult && div.parentNode) {
div.parentNode.removeChild(div);
}
}
function modalType(type) {
if (type === 'delete') {
return <InitModal
title="删除"
contentTitle="确定要删除吗?"
okText="确认删除"
{...props}
afterClose={destroy}
contentTitle={<React.Fragment>
<i className="red-circle iconfont icon-shanchu_tc_icon mr3"></i>
{props.contentTitle}
</React.Fragment>}
/>
} else if (type === 'confirm') {
return <InitModal title="选择" afterClose={destroy} {...props} />
} else {
return <InitModal title="选择" afterClose={destroy} {...props} />
}
}
function render() {
setTimeout(() => {
ReactDOM.render(
modalType(type),
div,
);
});
}
render();
}
//
function InitModal({
onCancel,
onOk,
title,
contentTitle,
content,
okText,
cancelText,
afterClose,
className,
}) {
const [visible, setVisible] = useState(true);
function onCancelModal() {
setVisible(false);
onCancel && onCancel()
}
function onSuccess() {
setVisible(false);
onOk && onOk();
}
return (
<Modal
visible={visible}
onCancel={onCancelModal}
afterClose={afterClose}
title={title}
className={`myself-modal ${className}`}
centered
footer={[
<Button type="default" key="back" onClick={onCancelModal}>
{cancelText}
</Button>,
<Button className="foot-submit" key="submit" onClick={onSuccess}>
{okText}
</Button>,
]}
>
<div>
{contentTitle && <p className="content-title">{contentTitle}</p>}
<p className="content-descibe">{content}</p>
</div>
</Modal>
)
}

View File

@ -0,0 +1,63 @@
.myself-modal {
.ant-modal-header {
padding: 9px 24px;
background: #f8f8f8;
border-bottom: 1px solid #eee;
}
.ant-modal-title {
text-align: left;
}
.ant-modal-close {
top: 0px !important;
}
.ant-modal-close-x {
font-size: 24px;
}
.ant-modal-body {
text-align: center;
}
.content-title {
display: flex;
justify-content: center;
align-items: center;
margin: 2rem 0 1rem !important;
font-size: 16px;
color: #333;
letter-spacing: 0;
line-height: 29px;
font-weight: 400;
}
.red-circle {
align-self: flex-start;
color: #ca0002;
font-size: 1.5rem !important;
}
.content-descibe {
font-size: 14px;
color: #666;
line-height: 33px;
font-weight: 400;
}
.ant-modal-footer {
padding: 2rem 0;
text-align: center;
border: 0;
.ant-btn {
width: 6rem;
}
}
.foot-submit {
margin-left: 3rem;
color: #df0002;
&:hover {
border-color: #df0002;
}
}
.ant-btn-default:hover,
.ant-btn-default:active,
.ant-btn-default:focus {
background: #f3f4f6;
color: #333;
border-color: #d0d0d0;
}
}

View File

@ -0,0 +1,29 @@
import { httpUrl } from '../fetch';
export const editorConfig = {
placeholder: '请输入',
uploadImgServer: httpUrl + '/busiAttachments/upload',
uploadFileName: 'file',
uploadImgHeaders: {
'X-Requested-With': 'XMLHttpRequest'
},
excludeMenus: [
'list',
'todo',
'emoticon',
'video'
],
uploadImgHooks: {
// 图片上传并返回了结果,想要自己把图片插入到编辑器中
customInsert: function (insertImgFn, result) {
// insertImgFn 可把图片插入到编辑器,传入图片 src ,执行函数即可
if (result && result.data && result.data.id) {
insertImgFn(`${httpUrl}/busiAttachments/view/${result.data.id}`);
}
}
},
}
export const weekModal="| 工作项目 | 本周工作计划 | 本周完成情况 |下周计划 | 待协同事项 |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n| | | | | |\n| | | | | |\n| | | | | |\n| | | | | |\n\n 备注:";
export const monthModal="|工作项目 | 工作内容 | 项目进度情况 | 问题列表及解决方案| 下月工作计划 | 遗留未解决的问题 |\n| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |\n| | | | | | |\n| | | | | | |\n| | | | | | |\n| | | | | | |\n\n 月度总结:";

106
src/forge/Wiki/fetch.js Normal file
View File

@ -0,0 +1,106 @@
import { notification ,message} from 'antd';
import axios from 'axios';
import cookie from 'react-cookies';
import Login from './components/Login';
let actionUrl = '';
if (window.location.href.indexOf('localhost') > -1) {
// actionUrl = 'http://117.50.100.12:8008';
// actionUrl = 'http://192.168.31.74:8081';
actionUrl = "https://test-search.trustie.net";
} else if(window.location.href.indexOf('testforgeplus')>-1){
actionUrl = "https://test-search.trustie.net";
// actionUrl = 'https://testforgeplus.trustie.net';
axios.defaults.withCredentials = true;
}else if (window.location.href.indexOf('forgeplus') > -1) {
actionUrl = "https://wiki-api.trustie.net";
axios.defaults.withCredentials = true;
}
export const httpUrl = actionUrl;
export const TokenKey = 'autologin_trustie';
// 创建axios实例
const service = axios.create({
baseURL: httpUrl,
timeout: 10000, // 请求超时时间
});
// request拦截器
service.interceptors.request.use(config => {
if (cookie.load(TokenKey)) {
console.log(cookie.load(TokenKey));
config.headers['Authorization'] = cookie.load(TokenKey); // 让每个请求携带自定义token 请根据实际情况自行修改
}
if (window.location.port === "3007") {
// 模拟token为登录用户
const taskToken = sessionStorage.taskToken;
if (config.url.indexOf('?') === -1) {
config.url = `${config.url}?token=${taskToken}`;
} else {
config.url = `${config.url}&token=${taskToken}`;
}
}
return config;
}, error => {
// Do something with request error
console.log(error); // for debug
// Promise.reject(error);
});
// respone拦截器
service.interceptors.response.use(
response => {
const res = response||{};
if (res.status === 400) {
message.error(res.data.message || '操作失败');
return Promise.reject('error');
}
if (res.status === 401) {
message.error(res.data.message || '登录信息已过期');
return Promise.reject('error');
}
if (res.status === 403) {
message.error(res.data.message || '无权限!');
return Promise.reject('error');
}
if (res.status === 40001) {
notification.open({
message: "提示",
description: '账户或密码错误!',
});
return Promise.reject('error');
}
if (response.status !== 200 && res.status !== 200) {
notification.open({
message: "提示",
description: res.message,
});
} else {
return response.data;
}
},
error => {
console.log(error);
let res = error.response||{};
if (res.status === 400) {
message.error(res.data.message || '操作失败');
return Promise.reject('error');
}
if (res.status === 401) {
message.error(res.data.message || '登录信息已过期');
Login();
return Promise.reject('error');
}
if (res.status === 403) {
message.error(res.data.message || '无权限!');
return Promise.reject('error');
}
notification.open({
message: "提示",
description: error.message,
});
return Promise.reject(error);
}
);
export default service;

View File

@ -105,6 +105,7 @@ $flex:flex;
word-break: break-all;
text-align: justify;
font-size: 16px;
text-align: center;
}
.focusBox,.infoBox{
width: 100%!important;

View File

@ -194,7 +194,7 @@ class Infos extends Component {
render() {
const { current_user } = this.props;
const { username } = this.props.match.params;
const { user, isSpin, route_type , undo_events , menuKey } = this.state;
const { user, isSpin, route_type , undo_events , menuKey , project_type } = this.state;
return (
<div className="newMain clearfix">
<Spin spinning={isSpin}>
@ -276,6 +276,97 @@ class Infos extends Component {
}
</div>
</div>
{current_user && user && user.login === current_user.login ? (
<div className="bgcF">
<div className="list-l-Menu">
<li className={project_type && project_type === "notice" ? "active" : ""}>
<p onClick={() => this.undo_link()}>
<span className="font-16 color-grey-3">
<i className="iconfont icon-dahuizhongzuo3x font-15 mr5"></i>
待办事项
</span>
<span className="text-yellow font-16">
{user.undo_events}
</span>
</p>
</li>
</div>
</div>
):""}
<div className="bgcF">
<ul className="list-l-Menu">
<li className="MenuTitle" onClick={() => this.change_project_type(undefined)}>
<i className="iconfont icon-xiangmuleixing font-15 mr5"></i>
项目类型
<i className="iconfont icon-youjiantou font-15 mr20 color-grey-9 pull-right"></i>
</li>
<li className={project_type && project_type === "common" ? "active" : ""} onClick={() => this.change_project_type("common")}>
<p>
<span className="font-16">开源托管项目</span>
<span className="color-blue">
{user && user.common_projects_count}
</span>
</p>
</li>
<li className={project_type && project_type === "mirror" ? "active" : ""} onClick={() => this.change_project_type("mirror")}>
<p>
<span className="font-16">开源镜像项目</span>
<span className="color-blue">
{user && user.mirror_projects_count}
</span>
</p>
</li>
<li className={project_type && project_type === "sync_mirror" ? "active" : ""} onClick={() => this.change_project_type("sync_mirror")}>
<p>
<span className="font-16">镜像托管项目</span>
<span className="color-blue">
{user && user.sync_mirror_projects_count}
</span>
</p>
</li>
</ul>
</div>
{
current_user && current_user.login && current_user.login === username &&
<div className="bgcF">
<ul className="list-l-Menu">
<li className="MenuTitle">
<i className="iconfont icon-gongzuoliu font-15 mr5"></i>
DevOps工作流
<i className="iconfont icon-youjiantou font-15 mr20 color-grey-9 pull-right"></i>
</li>
<li className={project_type && project_type === "CIService" ? "active" : ""} onClick={() => this.change_devops_type("CIService")}>
<p>
<span className="font-16 color-grey-3">CI服务</span>
</p>
</li>
{/* <li className={project_type && project_type === "CDService" ? "active" : ""} onClick={() => this.change_devops_type("CDService")}>
<p>
<span className="font-16">CD服务</span>
<span className="color-blue">
{user && user.common_projects_count}
</span>
</p>
</li> */}
</ul>
</div>
}
<div className="bgcF">
<div className="list-l-Menu">
<li className={project_type && project_type === "organizes" ? "active" : ""}>
<p onClick={() => this.organize_link()} >
<span className="font-16 color-grey-3">
<i className="iconfont icon-itsm-liuchengguanli font-15 mr5"></i>
组织
</span>
<span className="color-blue font-16">
{user && user.user_org_count}
</span>
</p>
</li>
</div>
</div>
</div>
<div className="list-right">
{ !route_type && menuKey &&

View File

@ -5,6 +5,7 @@ import Search from '../Component/Search';
import Item from './Team-item';
import Nodata from '../Nodata';
import axios from 'axios';
import { Link } from 'react-router-dom';
const limit = 15;
function Team(props){
@ -14,7 +15,7 @@ function Team(props){
const [ sort_direction , setSort_direction ] = useState("asc");
const [ sort_by ,setSort_by ] = useState("created_at");
const [ search ,setSearch ] = useState(undefined);
const { checkIfLogin , showLoginDialog } = props;
const { username } = props.match.params;
useEffect(()=>{
if(username){
@ -47,14 +48,6 @@ function Team(props){
</Menu>
)
function newFunc() {
const { checkIfLogin , showLoginDialog } = props;
if(checkIfLogin()){
props.history.push(`/organize/new`);
}else{
showLoginDialog && showLoginDialog();
}
}
return(
<div>
<div className="headerbox">
@ -62,7 +55,10 @@ function Team(props){
<Search value={search} onChange={(e)=>setSearch(e.target.value)} placeholder="请输入组织名称关键字进行搜索" onSearch={onSearch}/>
</div>
<p>
<a onClick={newFunc}><i className="iconfont icon-xinjian1 mr3 font-14"></i>新建组织</a>
{
checkIfLogin() &&
<Link to={`/organize/new`}><i className="iconfont icon-xinjian1 mr3 font-14"></i>新建组织</Link>
}
<Dropdown overlay={menu}>
<a>排序<i className="iconfont icon-sanjiaoxing-down ml3 font-14"></i></a>
</Dropdown>

View File

@ -1,16 +0,0 @@
import React, { Component } from "react";
import Nodata from "../Nodata";
class UndoEvents extends Component {
render() {
return (
<div className="pd20">
<div className="grid-item pb20 bbt">
<h3>待办事项</h3>
</div>
<Nodata _html={`暂时没有数据~`} />
</div>
);
}
}
export default UndoEvents;

View File

@ -41,9 +41,6 @@
z-index: 1000 !important;
}
.markdown-body p {
margin: 0 !important
}
.markdown-body img{
cursor: pointer;
}