From d7f3c766b4ce23f2f2d1c91c57dbd4fd18a11e12 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 19 Mar 2021 15:46:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Main/Detail.js | 97 +++++----------- src/forge/Main/sub/DetailBanner.jsx | 165 +++++++++++++++++----------- src/forge/Merge/merge.js | 4 +- src/forge/Order/index.scss | 3 +- src/forge/Order/order.js | 4 +- src/forge/Settings/Index.js | 2 +- src/forge/Settings/Setting.js | 101 ++++++++++++----- 7 files changed, 210 insertions(+), 166 deletions(-) diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 07de51c3e..43194996e 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import { Spin, Tooltip } from 'antd'; import { Link, Route, Switch } from 'react-router-dom'; import { Content } from '../Component/layout'; +import DetailBanner from './sub/DetailBanner'; import '../css/index.scss' import './list.css'; @@ -257,6 +258,7 @@ class Detail extends Component { getDetail = () => { const { projectsId , owner } = this.props.match.params; + this.getBanner(); const url = `/${owner}/${projectsId}/detail.json`; axios.get(url).then((result) => { if (result && result.data) { @@ -278,6 +280,19 @@ class Detail extends Component { }).catch((error) => { }) } + // 获取动态导航栏菜单 + getBanner(){ + const { projectsId , owner } = this.props.match.params; + const url = `/${owner}/${projectsId}/menu_list.json`; + axios.get(url).then(result=>{ + if(result){ + this.setState({ + bannerList:result.data + }) + } + }).catch(error=>{}) + } + // 关注和取消关注 focusFunc = (flag) => { const { platform } = this.state; @@ -374,7 +389,7 @@ class Detail extends Component { const { projectDetail, watchers_count, praises_count, forked_count, firstSync , secondSync , isManager, watched, praised, - project , open_devops , platform , defaultBranch } = this.state; + project , open_devops , platform , defaultBranch , bannerList } = this.state; const url = this.props.history.location.pathname; const urlArr = url.split("/"); const urlFlag = (urlArr.length === 3); @@ -494,79 +509,25 @@ class Detail extends Component { { firstSync ? "" : -
- -
+ } { firstSync ? - - + : diff --git a/src/forge/Main/sub/DetailBanner.jsx b/src/forge/Main/sub/DetailBanner.jsx index c80999c10..a31973061 100644 --- a/src/forge/Main/sub/DetailBanner.jsx +++ b/src/forge/Main/sub/DetailBanner.jsx @@ -1,72 +1,107 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; +import { Skeleton } from 'antd'; import { Link } from 'react-router-dom'; -function DetailBanner({ isManager , url , pathname , owner , projectsId , state , urlFlag , projectDetail , platform ,open_devops }){ +function DetailBanner({ list , owner , projectsId , isManager , url , pathname , state , urlFlag , projectDetail , platform ,open_devops }){ + const [ menuName , setMenuName ] = useState(undefined); + useEffect(()=>{ + if(list){ + setMenuName(list); + } + },[list]); return(
-
    -
  • - - - 主页 - -
  • -
  • - - - 代码库 - -
  • -
  • - - - 易修 (Issue) - {projectDetail && projectDetail.issues_count ? {projectDetail.issues_count} : ""} - -
  • - { - projectDetail && parseInt(projectDetail.type) !== 2 && platform && -
  • - - - 合并请求 - {projectDetail && projectDetail.pull_requests_count ? {projectDetail.pull_requests_count} : ""} - -
  • - } - { - platform && -
  • - - 工作流(beta版) - {projectDetail && projectDetail.ops_count ? {projectDetail.ops_count} : ""} - -
  • - } - -
  • - - - 里程碑 - {projectDetail && projectDetail.versions_count ? {projectDetail.versions_count} :""} - -
  • -
  • - - - 动态 - -
  • - { - isManager && platform && -
  • 0 ? "active" : ""}> - - 0 ? "iconfont icon-cangku color-grey-3 mr5 font-14":"iconfont icon-cangku color-grey-6 font-14 mr5"}> - 仓库设置 - -
  • - } -
+ { + menuName && projectDetail ? +
    + { + menuName.map((item,key)=>{ + return( + + { + item.menu_name === "home" && +
  • + + + 主页 + +
  • + } + { + item.menu_name === "code" && +
  • + + + 代码库 + +
  • + } + { + item.menu_name === "issues" && +
  • + + + 易修 (Issue) + {projectDetail && projectDetail.issues_count ? {projectDetail.issues_count} : ""} + +
  • + } + { + item.menu_name === "pulls" && projectDetail && parseInt(projectDetail.type) !== 2 && platform ? +
  • + + + 合并请求 + {projectDetail && projectDetail.pull_requests_count ? {projectDetail.pull_requests_count} : ""} + +
  • :"" + } + { + item.menu_name === "devops" && platform ? +
  • + + 工作流(beta版) + {projectDetail && projectDetail.ops_count ? {projectDetail.ops_count} : ""} + +
  • + :"" + } + { + item.menu_name === "versions" && +
  • + + + 里程碑 + {projectDetail && projectDetail.versions_count ? {projectDetail.versions_count} :""} + +
  • + } + { + item.menu_name === "activity" && +
  • + + + 动态 + +
  • + } +
    + ) + }) + } + { + isManager && platform ? +
  • + + 0 ? "iconfont icon-cangku color-grey-3 mr5 font-14":"iconfont icon-cangku color-grey-6 font-14 mr5"}> + 仓库设置 + +
  • :"" + } +
+ : + + }
) } diff --git a/src/forge/Merge/merge.js b/src/forge/Merge/merge.js index 5b50f6ba0..be1ec97c4 100644 --- a/src/forge/Merge/merge.js +++ b/src/forge/Merge/merge.js @@ -272,8 +272,8 @@ class merge extends Component { ); return ( -
-
+
+
+
+
  • @@ -568,6 +569,7 @@ class order extends Component {
+
diff --git a/src/forge/Settings/Index.js b/src/forge/Settings/Index.js index 23b4b03df..17ae87614 100644 --- a/src/forge/Settings/Index.js +++ b/src/forge/Settings/Index.js @@ -82,7 +82,7 @@ class Index extends Component { >

- + 项目标签

diff --git a/src/forge/Settings/Setting.js b/src/forge/Settings/Setting.js index 263db31e1..dda9a9f81 100644 --- a/src/forge/Settings/Setting.js +++ b/src/forge/Settings/Setting.js @@ -2,11 +2,20 @@ import React, { Component } from "react"; import { Form, Input, Checkbox, Select , Spin } from "antd"; import Title from '../Component/Title'; import {WhiteBack} from '../Component/layout'; - import axios from "axios"; import "./setting.scss"; const { TextArea } = Input; const { Option } = Select; + +const menu = [ + {name:"主页",index:"home"}, + {name:"代码库",index:"code"}, + {name:"易修 (Issue)",index:"issues"}, + {name:"合并请求",index:"pulls"}, + {name:"工作流(beta版)",index:"devops"}, + {name:"里程碑",index:"versions"}, + {name:"动态",index:"activity"}, +] class Setting extends Component { constructor(props) { super(props); @@ -14,7 +23,8 @@ class Setting extends Component { CategoryList: undefined, LanguageList: undefined, private_check: undefined, - loading:true + loading:true, + project_units:['home',"activity"] }; } @@ -51,12 +61,18 @@ class Setting extends Component { .get(url) .then((result) => { if (result) { + const { project_units } = this.state; + let units = result.data.project_units; + units.push(...project_units); + this.props.form.setFieldsValue({ ...result.data, + project_units:units }); this.setState({ private_check: result.data.private, - loading:false + loading:false, + project_units:units }); } }) @@ -104,36 +120,46 @@ class Setting extends Component { loading:true }) const { projectsId , owner } = this.props.match.params; + const navUrl = `/${owner}/${projectsId}/project_units.json`; - const { private_check } = this.state; - const url = `/${owner}/${projectsId}.json`; - axios - .put(url, { - name: values.project_name, - description: values.project_description, - private: private_check, - ...values, - }) - .then((result) => { - if (result) { - this.props.showNotification(`仓库信息修改成功!`); - const { getDetail } = this.props; - getDetail && getDetail(); - this.setState({ - loading:false - }) - } - }) - .catch((error) => { - console.log(error); - this.setState({ - loading:false - }) - }); + let unit = values.project_units.filter(item => (item !== "home" && item!== "activity")); + axios.post(navUrl, { + unit_types:unit + }).then((result) => { + if (result) { + this.update(values); + } + }).catch(error=>{}) } }); }; + update=(values)=>{ + const { projectsId , owner } = this.props.match.params; + const { private_check } = this.state; + const url = `/${owner}/${projectsId}.json`; + axios.put(url, { + name: values.project_name, + description: values.project_description, + private: private_check, + ...values, + }).then((result) => { + if (result) { + this.props.showNotification(`仓库信息修改成功!`); + const { getDetail } = this.props; + getDetail && getDetail(); + this.setState({ + loading:false + }) + } + }).catch((error) => { + console.log(error); + this.setState({ + loading:false + }) + }); + } + // 删除本仓库 deleteProject = () => { this.props.confirm({ @@ -224,6 +250,25 @@ class Setting extends Component { ], })()} + + {getFieldDecorator("project_units", { + rules: [], + })( + + { + menu.map((item,key)=>{ + return( + {item.name} + ) + }) + } + + )} +

更新仓库设置