Merge remote-tracking branch 'upstream/gitlink_server' into gitlink_server

This commit is contained in:
黄心宇 2024-01-13 10:12:39 +08:00
commit 3981445969
13 changed files with 131 additions and 77 deletions

View File

@ -0,0 +1,9 @@
import React, { } from 'react';
import './index.scss';
function HomePage(props) {
return (
<div>云际计算社区首页自定义</div>
)
}
export default HomePage;

View File

@ -85,6 +85,11 @@ const Help = Loadable({
loading: Loading,
});
const HomePageByJCC = Loadable({
loader : () => import("./Pages/JCC/homePage"),
loading : Loading,
});
function Index(props){
const [ data , setData ] = useState(undefined);
const [ adminUrl , setAdminUrl ] = useState(undefined);
@ -251,8 +256,10 @@ function Index(props){
<Route
path="/zone/:deptId"
render={(p) => (
deptId==="CCF-ODC"?<HeaderPageCCF {...props} {...p} data={data} id={id} temp={ temp } />:
temp === tempEnum.zone ? <HeaderPage {...props} {...p} data={data} id={id} temp={ temp }/> : <HeaderPageZone1 {...props} {...p} data={data} id={id} temp={ temp }/>
deptId==="CCF-ODC" ? <HeaderPageCCF {...props} {...p} data={data} id={id} temp={ temp } />:
deptId === "JCC" ? <HomePageByJCC {...props} {...p} data={data} id={id}/>:
temp === tempEnum.zone ? <HeaderPage {...props} {...p} data={data} id={id} temp={ temp }/>:
<HeaderPageZone1 {...props} {...p} data={data} id={id} temp={ temp }/>
)}
></Route>
</Switch>

View File

@ -3,7 +3,7 @@ import CopyTool from '../../Component/CopyTool';
import { truncateCommitId } from '../../common/util';
import { Link } from 'react-router-dom';
import { getImageUrl , turnbar } from 'educoder';
import { Button, Dropdown , Input, Menu , message, Modal, Select, Spin, Table, Tooltip } from 'antd';
import { Button, Dropdown , Input, Menu , message, Modal, Select, Spin, Table, Tooltip , Radio } from 'antd';
import Modals from '../../Component/PublicModal/Index';
import './Index.scss';
@ -29,26 +29,13 @@ function Index(props) {
const [total, setTotal] = useState(0);
const [pageSize, setPageSize] = useState(10);
const [ chooseStatus , setChooseStatus ] = useState("all");
const { projectsId , owner } = props.match.params;
const { isManager , isDeveloper , projectDetail , defaultBranch, getDetail } = props;
useEffect(()=>{
// getList();
const url = `/v1/${owner}/${projectsId}/branches.json`;
Axios.get(url,{
params:{
keyword: name,
page: current,
limit: pageSize
}
}).then(result=>{
if(result){
const {branches, total_count} = result.data;
setTotal(total_count)
setList(branches);
}
setIsSpin(false);
}).catch(error=>{setIsSpin(false);})
},[name, reload, pageSize, current])
getList(chooseStatus);
},[name, reload, pageSize, current,chooseStatus])
useEffect(()=>{
if(projectDetail && document.title.indexOf('所有分支-') === -1){
@ -96,7 +83,7 @@ function Index(props) {
</Link>
:
<React.Fragment>
<img style={{borderRadius:"50%"}} src={getImageUrl(`/${ txt.committer.image_url}`)} alt="" className='branchLastUpdateUserImage'/>
<img style={{borderRadius:"50%"}} src={getImageUrl(`/${ txt && txt.committer && txt.committer.image_url}`)} alt="" className='branchLastUpdateUserImage'/>
<span style={{fontWeight:"500"}}>{txt && txt.committer && txt.committer.name}</span>
</React.Fragment>
}
@ -141,10 +128,12 @@ function Index(props) {
dataIndex: "name",
key: 6,
align: "center",
width: "320px",
width: "300px",
className: "branchActionColumn",
render: (txt, item) => {
render: (txt, item,key) => {
console.log("-----:",item.is_deleted);
return (
item.is_deleted ? <div style={{textAlign:"right"}}><Button onClick={()=>restoreBranch(item.branch_id,item.name)}>恢复分支</Button></div>:
<div className="treeabout">
{
(isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) &&
@ -165,11 +154,32 @@ function Index(props) {
}
];
function getList() {
const url = `/${owner}/${projectsId}/branches_slice.json`;
Axios.get(url).then(result=>{
function restoreBranch(id,name){
const url = `/v1/${owner}/${projectsId}/branches/restore.json`;
Axios.post(url,{
branch_id:id,branch_name:name
}).then(result=>{
message.success('恢复分支成功');
let copyList = list;
copyList = copyList.filter(i=>i.branch_id !== id);
setList([...copyList]);
})
}
function getList(state) {
const url = `/v1/${owner}/${projectsId}/branches.json`;
Axios.get(url,{
params:{
keyword: name,
page: current,
limit: pageSize,
state:chooseStatus==="deleted" ?chooseStatus:undefined
}
}).then(result=>{
if(result){
setList(result.data);
const {branches, total_count} = result.data;
setTotal(total_count)
setList(branches);
}
setIsSpin(false);
}).catch(error=>{setIsSpin(false);})
@ -275,7 +285,14 @@ function Index(props) {
<Spin spinning={isSpin}>
<div style={{paddingTop:"10px",minHeight:"400px",paddingBottom:"30px"}}>
<div className='branchListActionBox'>
<Input.Search placeholder='请输入分支名称' style={{width: '354px'}} className='searchBranch' onSearch={(value)=>{setCurrent(1);setName(value)}} allowClear/>
<div>
<Input.Search placeholder='请输入分支名称' style={{width: '354px'}} className='searchBranch' onSearch={(value)=>{setCurrent(1);setName(value)}} allowClear/>
<Radio.Group value={chooseStatus} buttonStyle="solid" onChange={(v)=>{setChooseStatus(v.target.value)}} style={{marginLeft:"25px"}}>
<Radio.Button value="all">代码库分支</Radio.Button>
<Radio.Button value="deleted">已删除分支</Radio.Button>
</Radio.Group>
</div>
<div>
{isManager && <Link to={`/${owner}/${projectsId}/settings/branches`} className="btn-83" style={{width: '102px'}}><i className="iconfont icon-xuanzhongjibenshezhiicon font-14 mr5"></i>分支设置</Link>}
{(isManager || isDeveloper) && (projectDetail && projectDetail.type!==2) && <Button type='primary' onClick={addBranchBtn}>+ 新建分支</Button>}

View File

@ -136,12 +136,12 @@
margin-right: 5px;
}
}
.treeabout{
flex:1;
text-align: right;
}
}
}
.treeabout{
display: flex;
justify-content: space-between;
}
.treecopy{
flex:1;
display: flex;

View File

@ -68,8 +68,12 @@ export default Form.create()(
if(!value){
callback();
}
if(value && !value.match(/^[a-zA-Z0-9][a-zA-Z0-9_-]{3,19}$/)){
callback("只能使用以字母、数字开头包含字母、数字、下划线、横杠等长度4到20个字符");
let reg = /^[a-zA-Z0-9]+([-_.][a-zA-Z0-9]+)*$/
if(value && !value.match(reg)){
callback("只能以数字或字母开头仅支持横杠、下划线、点三种符号不允许符号连续排列长度4-50个字符");
}
if(value && (value.length<4 || value.length>50)){
callback("只能以数字或字母开头仅支持横杠、下划线、点三种符号不允许符号连续排列长度4-50个字符12");
}
callback();
}
@ -90,7 +94,7 @@ export default Form.create()(
],
<Input
addonBefore={port ? `${hostname}:${port}/`:`https://${hostname}/`}
placeholder="组织账号" maxLength={100}
placeholder="组织账号" maxLength={50}
/>
)}
{helper(

View File

@ -18,7 +18,7 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
let wikiName = ''
let key = '';
if (!pathname.endsWith('/wiki/add')) {
wikiName = decodeURI(pathname.split('/')[4]);
wikiName = pathname.split('/')[4];
key = pathname.split('/')[5];
}else{
key = search.split('=').pop();
@ -116,12 +116,6 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
};
validateFields((err, values) => {
if (!err) {
let regEn = /[\\/:*?"<>|[\]-]/g;
if (regEn.test(values.title)) {
message.error('文件名不能有特殊字符: \\ / : * ? \" < > | [ \] -');
setOperateFlag(false);
return;
}
const {md_content, title} = values;
if (wikiName && search!== "?copy") {
updateWiki({
@ -130,7 +124,7 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
projectId: project.id,
pageName: wikiName,
title,
commit_message: '',
message: '',
content_base64: Base64.encode(md_content)
}).then(res => dealRes(res, title));
} else {
@ -223,7 +217,7 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
projectId: project.id,
pageName: '_Sidebar',
title: '_Sidebar',
commit_message: '',
message: '',
content_base64: Base64.encode(content)
}).then(res => {
if (res && res.message === "200") {
@ -333,7 +327,7 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
"title",
[
{ required: true, message: "请输入标题" },
// { pattern: /[^`\[\]\/:*?''<>|%-+_]/g, message: '' }
{ pattern: /^(?!-).*$/, message: '不能以-开头' }
],
<Input
placeholder={"请输入标题"}

View File

@ -115,7 +115,7 @@ export default (props) => {
project && checkItem.name && getWiki({
owner: owner,
repo: projectsId,
pageName: checkItem.name,
pageName: checkItem.sub_url,
projectId: project.id
}).then(res => {
if (res && res.message === "200") {
@ -190,11 +190,6 @@ export default (props) => {
setAddMenuError("不能仅输入空格");
return;
}
const regEn = /[\\/:*?"<>|[\]-]/g;
if (regEn.test(menuName)) {
setAddMenuError("不能有特殊字符: \\ / : * ? \" < > | [ \] -");
return;
}
//
const oneMenuList = fileList.filter(item=>!item.title.trim().startsWith('[[')).map(i=>i.title.trim())
if(oneMenuList.includes(`- ${menuName}`)){
@ -215,7 +210,7 @@ export default (props) => {
projectId: project.id,
pageName: '_Sidebar',
title: '_Sidebar',
commit_message: '',
message: '',
content_base64: Base64.encode(treeToMd(sidebarList))
}).then(res => {
if (res && res.message === "200") {
@ -233,7 +228,7 @@ export default (props) => {
}
function goEdit(params) {
history.push(`/${owner}/${projectsId}/wiki/${encodeURI(checkItem.name)}/${checkItem.key}/edit${params}`);
history.push(`/${owner}/${projectsId}/wiki/${encodeURI(checkItem.sub_url)}/${checkItem.key}/edit${params}`);
}
function preview() {

View File

@ -63,7 +63,7 @@ export default (props) => {
projectsId && checkItem.name && getWiki({
owner: owner,
repo: projectsId,
pageName: checkItem.name,
pageName: checkItem.sub_url,
projectId: projectId,
}).then(res => {
if (res && res.message === "200") {

View File

@ -116,13 +116,16 @@ export function markdownToTree(markdownText){
lines.map((item, index) =>{
const title = item.trim();
const isFile = title.startsWith('[[') && title.endsWith(']]');
const titleStr = isFile ? title.substring(2, title.length - 2) : title.substring(2, title.length)
const node = {
// 带空格+[[]]或者- 标识
title: item,
children: [],
key: undefined,
// 纯内容
titleStr: isFile ? title.substring(2, title.length - 2) : title.substring(2, title.length),
titleStr,
// 编码后的title,获取wiki内容用title_sub
title_sub: encodeURIComponent(titleStr),
// 是否是wiki文件
isFile: isFile
}

View File

@ -163,7 +163,7 @@ export default function Sidebar(props) {
const {node, children, key} = item;
if(isFile){
//
deleteWiki({owner: owner, repo: projectsId, projectId: project.id, pageName: title}).then(res => {
deleteWiki({owner: owner, repo: projectsId, projectId: project.id, pageName: item.title_sub}).then(res => {
if(res && res.message === "204"){
// key
const menuListByDel = findSameKeyByDel(menuList, key);
@ -267,7 +267,7 @@ export default function Sidebar(props) {
projectId: project.id,
pageName: '_Sidebar',
title: '_Sidebar',
commit_message: '',
message: '',
content_base64: Base64.encode(content)
}).then(res => {
if (res && res.message === "200") {
@ -303,20 +303,18 @@ export default function Sidebar(props) {
e.stopPropagation();
setVisible(item);
setIsEditName(type);
let title = item.title.trim();
const isFile = title.startsWith('[[') && title.endsWith(']]');
title = isFile ? title.substring(2,title.length-2) : title.substring(2, title.length);
const {titleStr, title_sub} = item;
type === 2 && getWiki({
owner: owner,
repo: projectsId,
pageName: title,
pageName: title_sub,
projectId: project.id
}).then(res => {
if (res && res.message === "200") {
setWikiContent(res.data.md_content);
}
})
setMenuName(title);
setMenuName(titleStr);
}
//
@ -329,9 +327,8 @@ export default function Sidebar(props) {
setAddMenuError("不能仅输入空格");
return;
}
const regEn = /[\\/:*?"<>|[\]-]/g;
if (regEn.test(menuName)) {
setAddMenuError('不能有特殊字符: \\ / : * ? \" < > | [ \] -');
if (isEditName === 2 && /^-/.test(menuName)) {
setAddMenuError('不能以-开头');
return;
}
if(!isEditName){
@ -356,14 +353,15 @@ export default function Sidebar(props) {
}else{
// isEditName 1 2
const titleToJudge = isEditName === 2 ? `[[${menuName}]]` : `- ${menuName}`;
const {title, key} = visible;
if(title.trim() === titleToJudge){
const {key, titleStr, title_sub} = visible;
//
if(titleStr === menuName){
setAddMenuError("请修改名称");
return
}
//
const list = findBrotherNodesByKey(menuList, key) || [];
if(list.map(item=>item.title.trim()).includes(titleToJudge)){
if(list.map(item=>item.titleStr).includes(menuName)){
setAddMenuError("不能与同级目录名称相同");
return
}
@ -381,17 +379,16 @@ export default function Sidebar(props) {
})
if(isEditName === 2){
// -> wiki
const oldTitle = title.substring(title.indexOf('[[')+2, title.indexOf(']]'))
updateWiki({
owner,
repo: projectsId,
projectId: project.id,
//
pageName: oldTitle,
pageName: title_sub,
//
title: menuName,
content_base64: wikiContent,
commit_message: '',
message: '',
}).then(res=>{
if(res && res.message === '200'){
// wikisidebar

View File

@ -59,10 +59,8 @@ export default function UploadWiki(props) {
message.error('只能上传md、txt文件');
return false;
}
let regEn = /[\\/:*?"<>|[\]-]/g;
if (regEn.test(file.name)) {
message.error('文件名不能有特殊字符: \\ / : * ? \" < > | [ \] -');
if (/^-/.test(file.name)) {
message.error('文件名不能以-开头');
return false;
}
@ -86,7 +84,7 @@ export default function UploadWiki(props) {
projectId: project.id,
pageName: '_Sidebar',
title: '_Sidebar',
commit_message: '',
message: '',
content_base64: Base64.encode(treeToMd(sidebarList))
}).then(res => {
if (res && res.message === "200") {

View File

@ -90,6 +90,26 @@ function Calendar({ userLogin , time , chooseTime }) {
}
function Init(data,max,flag) {
let piecesList = [];
let number = 1;
if(max>500){
number = 6;
}else if(max<=500 && max>200){
number = 5;
}else if(max<=200 && max>100){
number = 4;
}else if(max<=100 && max>=30){
number = 3;
}else if(max<30 && max>=10){
number = 2;
}else{
number = 1;
}
for(var i=number;i>0;i--){
let gt = {gt: parseInt(max/number*(i-1)+1,0), lte: parseInt(max/number*i,0)};
piecesList.push(gt);
}
var huan_val = document.getElementById("Calendar");
var myEcharts = echarts.init(huan_val);
let option = {
@ -111,7 +131,17 @@ function Calendar({ userLogin , time , chooseTime }) {
inRange:{
color:flag ? ['#fafafa', '#216e39'] :['#fff','#fff']
},
show:flag
show:flag,
pieces: [
// {gt: parseInt(max/5*4,0), lte: max},
// {gt: parseInt(max/5*3,0), lte: parseInt(max/5*4,0)},
// {gt: parseInt(max/5*2,0), lte: parseInt(max/5*3,0)},
// {gt: parseInt(max/5*1,0), lte: parseInt(max/5*2,0)},
// {gt: 1, lte: parseInt(max/5*1,0)},
...piecesList,
{max: 1,label:"0"}
],
itemGap:25
},
calendar: {
top: 50,