From 2e4297d770617a6bb402c7794fcfc95516bf12cc Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Mon, 24 Feb 2020 10:25:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=93=E5=BA=93=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- public/react/src/forge/Activity/activity.css | 10 +- public/react/src/forge/Main/Detail.js | 16 ++ public/react/src/forge/Settings/Branch.js | 35 +++++ .../react/src/forge/Settings/Collaborator.js | 89 +++++++++++ public/react/src/forge/Settings/Index.js | 62 ++++++++ public/react/src/forge/Settings/Setting.js | 143 ++++++++++++++++++ public/react/src/forge/Settings/setting.css | 75 +++++++++ public/react/src/forge/css/index.css | 10 ++ 9 files changed, 432 insertions(+), 10 deletions(-) create mode 100644 public/react/src/forge/Settings/Branch.js create mode 100644 public/react/src/forge/Settings/Collaborator.js create mode 100644 public/react/src/forge/Settings/Index.js create mode 100644 public/react/src/forge/Settings/Setting.js create mode 100644 public/react/src/forge/Settings/setting.css diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fe77a99f7..cb39a24f7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -329,7 +329,7 @@ class ApplicationController < ActionController::Base def current_user # User.current if Rails.env.development? - user_id = 36390 + user_id = 50207 else user_id = 130328 end diff --git a/public/react/src/forge/Activity/activity.css b/public/react/src/forge/Activity/activity.css index fc8d49f17..c9fa87e58 100644 --- a/public/react/src/forge/Activity/activity.css +++ b/public/react/src/forge/Activity/activity.css @@ -2,15 +2,7 @@ padding-bottom: 15px; border-bottom:1px solid #ddd; } -.normalBox{ - border-radius: 4px; - border:1px solid #ddd; -} -.normalBox-title{ - padding:10px; - background-color: #f4f4f4; - line-height: 18px; -} + .pageDIV{ text-align: center; margin-top: 20px; diff --git a/public/react/src/forge/Main/Detail.js b/public/react/src/forge/Main/Detail.js index 3dd0bef0d..e325415c3 100644 --- a/public/react/src/forge/Main/Detail.js +++ b/public/react/src/forge/Main/Detail.js @@ -12,6 +12,10 @@ const FileNew = Loadable({ loader: () => import('../Newfile/Index'), loading: Loading, }) +const Setting = Loadable({ + loader: () => import('../Settings/Index'), + loading: Loading, +}) const TagList = Loadable({ loader: () => import('../Order/Tags'), loading: Loading, @@ -207,6 +211,7 @@ class Detail extends Component{ const { projectDetail , watchers_count , praises_count , forked_count } = this.state; const url = this.props.history.location.pathname; + const { isManager , isDeveloper } = this.props; return(
@@ -241,6 +246,11 @@ class Detail extends Component{
  • 0 ? "active" : ""}>合并请求{projectDetail&&projectDetail.pull_requests_count===0?"":projectDetail&&projectDetail.pull_requests_count===0?projectDetail.pull_requests_count:""}
  • 0 ? "active" : ""}>版本发布
  • 0 ? "active" : ""}>动态
  • + { + (isManager || isDeveloper) && +
  • 0 ? "active" : ""}>仓库设置
  • + } +
  • 0 ? "active" : ""}>仓库设置
  • @@ -264,6 +274,12 @@ class Detail extends Component{ (props) => () } > + {/* 仓库设置 */} + () + } + > {/* 工单详情 */} { + + } + + render(){ + return( +
    +
    + 分支列表 +
    +

    请选择一个默认的分支用于合并请求和提交:

    +
    + + 更新仓库设置 +
    +
    + ) + } +} +export default Branch; \ No newline at end of file diff --git a/public/react/src/forge/Settings/Collaborator.js b/public/react/src/forge/Settings/Collaborator.js new file mode 100644 index 000000000..da501a913 --- /dev/null +++ b/public/react/src/forge/Settings/Collaborator.js @@ -0,0 +1,89 @@ +import React , { Component } from 'react'; +import { Link } from 'react-router-dom'; +import { Input , AutoComplete , Dropdown , Menu , Icon } from 'antd'; +import axios from 'axios'; + +const { Option } = AutoComplete; +const MENU_LIST = ['管理员','可读权限','可写权限']; +class Collaborator extends Component{ + constructor(props){ + super(props); + this.state={ + userDataSource:undefined + } + } + + // 选择用户 + changeInputUser=(e)=>{ + console.log(e); + const url = `/users/list.json`; + axios.get(url,{ + params:{ + search:e + } + }).then(result=>{ + if(result){ + this.setState({ + userDataSource:result.data + }) + } + }).catch(error=>{ + console.log(error); + }) + } + + changeOperaiton=(e,id)=>{ + console.log(e,id); + } + render(){ + const { userDataSource } = this.state; + + const menu =(id)=> ( + + { + MENU_LIST.map((item,key)=>{ + return( + this.changeOperaiton(e,id)}>{item} + ) + }) + } + + ) + + const source = userDataSource && userDataSource.map((item,key)=>{ + return( + + ) + }) + return( +
    +
    + 协作者 +
    +
    +
    + caicai + + + 管理员 + + + + 删除 + +
    +
    +
    + + 增加协作者 +
    +
    + ) + } +} +export default Collaborator; \ No newline at end of file diff --git a/public/react/src/forge/Settings/Index.js b/public/react/src/forge/Settings/Index.js new file mode 100644 index 000000000..2e3a82e66 --- /dev/null +++ b/public/react/src/forge/Settings/Index.js @@ -0,0 +1,62 @@ +import React , { Component } from 'react'; +import { Link , Route , Switch } from 'react-router-dom'; + +import '../css/index.css'; +import './setting.css'; + +import Loadable from 'react-loadable'; +import Loading from '../../Loading'; + +const Branch = Loadable({ + loader: () => import('./Branch'), + loading: Loading, +}) +const Setting = Loadable({ + loader: () => import('./Setting'), + loading: Loading, +}) +const Collaborator = Loadable({ + loader: () => import('./Collaborator'), + loading: Loading, +}) +class Index extends Component{ + render(){ + const { projectsId } = this.props.match.params; + console.log(this.props); + const { pathname } = this.props.history.location; + + const flag = (pathname === `/projects/${projectsId}/setting`); + return( +
    +
      +
    • 仓库
    • +
    • -1?"active":""}>协作者
    • +
    • -1?"active":""}>分支列表
    • +
    +
    + + {/* 分支列表 */} + () + } + > + {/* 协作者 */} + () + } + > + {/* 修改仓库信息 */} + () + } + > + +
    +
    + ) + } +} +export default Index; \ No newline at end of file diff --git a/public/react/src/forge/Settings/Setting.js b/public/react/src/forge/Settings/Setting.js new file mode 100644 index 000000000..330818349 --- /dev/null +++ b/public/react/src/forge/Settings/Setting.js @@ -0,0 +1,143 @@ +import React , { Component } from 'react'; +import { Form , Input , Checkbox , Select } from 'antd'; + +import axios from 'axios'; +const { TextArea } = Input; +const { Option } = Select; +class Setting extends Component{ + constructor(props){ + super(props); + this.state={ + preType:"1", + CategoryList:undefined + } + } + + componentDidMount=()=>{ + this.getCategory(); + this.getInfo(); + } + + getInfo=()=>{ + const { current_user } = this.props; + const { projectsId } = this.props.match.params; + const url = `/${current_user.login}/${projectsId}.json`; + axios.get(url).then(result=>{ + if(result){ + this.props.form.setFieldsValue({ + ...result.data + }) + } + }).catch(error=>{ + console.log(error); + }) + } + + getCategory=()=>{ + const url = `/project_categories.json` + axios.get(url).then((result)=>{ + if(result){ + let CategoryList = this.setOptionsList(result.data.project_categories) + this.setState({ + CategoryList + }) + } + }).catch((error)=>{}) + } + + setOptionsList = (data) =>{ + let list = undefined; + if(data && data.length > 0){ + list = data.map((item,key)=>{ + return( + + ) + }) + } + return list; + } + + // 更新仓库设置 + resetSetting=()=>{ + this.props.form.validateFields((err,values)=>{ + if(!err){ + const { projectsId } = this.props.match.params; + const url = `/projects/${projectsId}.json`; + axios.patch(url,{ + ...values + }).then(result=>{ + if(result){ + this.props.showNotification(`仓库信息修改成功!`) + } + }).catch(error=>{ + console.log(error); + }) + } + }) + } + + render(){ + const { getFieldDecorator } = this.props.form; + + const { preType , CategoryList } = this.state; + return( +
    +
    + 基本设置 +
    +
    + + {getFieldDecorator('name', { + rules: [{ + required: true, message: '请输入项目名称' + }], + })( + + )} + +
    + 可见性 + + {getFieldDecorator('private', { + rules: [], + })( + 将仓库设为私有 + )} + +
    + + {getFieldDecorator('description', { + rules: [], + })( +