From d147960fc787a8dd1b562cb27c29399084383a7c Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Mon, 6 Jul 2020 16:26:18 +0800 Subject: [PATCH] change some bug --- src/forge/Merge/merge_form.js | 14 +- src/forge/New/Index.js | 1 + src/forge/Order/newMilepost.js | 19 +- src/forge/Order/order_form.js | 21 +- src/forge/Settings/Collaborator.js | 21 +- src/forge/Settings/Setting.js | 20 +- src/forge/Settings/new_tags.js | 19 +- src/forge/comments/new.js | 605 ----------------------------- 8 files changed, 74 insertions(+), 646 deletions(-) delete mode 100644 src/forge/comments/new.js diff --git a/src/forge/Merge/merge_form.js b/src/forge/Merge/merge_form.js index 38fc4ad5..a214b30f 100644 --- a/src/forge/Merge/merge_form.js +++ b/src/forge/Merge/merge_form.js @@ -29,16 +29,22 @@ class MergeForm extends Component { } componentDidMount = () => { - this.check_is_login(); + // this.check_is_login(); this.get_default_selects(); this.set_defatul(); }; - check_is_login =() =>{ - if(!this.props.checkIfLogin()){ + componentDidUpdate=(prevPros)=>{ + if(prevPros && this.props && !this.props.checkIfLogin()){ this.props.history.push("/403") return } - }; + } + // check_is_login =() =>{ + // if(!this.props.checkIfLogin()){ + // this.props.history.push("/403") + // return + // } + // }; get_default_selects = () => { const { projectsId } = this.props.match.params; this.setState({ isSpin: true }); diff --git a/src/forge/New/Index.js b/src/forge/New/Index.js index 52128888..8916fbbe 100644 --- a/src/forge/New/Index.js +++ b/src/forge/New/Index.js @@ -50,6 +50,7 @@ class Index extends Component { this.getGitignore(); // 获取开源许可证 this.getLicenses(); + } componentDidUpdate=(prevPros)=>{ if(prevPros && this.props && !this.props.checkIfLogin()){ diff --git a/src/forge/Order/newMilepost.js b/src/forge/Order/newMilepost.js index 00d398e5..ad260f92 100644 --- a/src/forge/Order/newMilepost.js +++ b/src/forge/Order/newMilepost.js @@ -16,16 +16,21 @@ class NewMilepost extends Component { isSpin: false } } - - componentDidMount = () => { - this.check_is_login(); - }; - check_is_login =() =>{ - if(!this.props.checkIfLogin()){ + componentDidUpdate=(prevPros)=>{ + if(prevPros && this.props && !this.props.checkIfLogin()){ this.props.history.push("/403") return } - }; + } + // componentDidMount = () => { + // this.check_is_login(); + // }; + // check_is_login =() =>{ + // if(!this.props.checkIfLogin()){ + // this.props.history.push("/403") + // return + // } + // }; onPanelChange = (time, mode) => { this.setState({ diff --git a/src/forge/Order/order_form.js b/src/forge/Order/order_form.js index b69d8ac3..d2b1c185 100644 --- a/src/forge/Order/order_form.js +++ b/src/forge/Order/order_form.js @@ -36,18 +36,23 @@ class order_form extends Component { show_token: false, }; } - - componentDidMount = () => { - this.check_is_login() - this.getSelectList(); - this.get_detail(); - }; - check_is_login =() =>{ - if(!this.props.checkIfLogin()){ + componentDidUpdate=(prevPros)=>{ + if(prevPros && this.props && !this.props.checkIfLogin()){ this.props.history.push("/403") return } } + componentDidMount = () => { + // this.check_is_login() + this.getSelectList(); + this.get_detail(); + }; + // check_is_login =() =>{ + // if(!this.props.checkIfLogin()){ + // this.props.history.push("/403") + // return + // } + // } get_detail = () => { const { form_type } = this.props; if (form_type === "new") { diff --git a/src/forge/Settings/Collaborator.js b/src/forge/Settings/Collaborator.js index 1a539630..6623f0ac 100644 --- a/src/forge/Settings/Collaborator.js +++ b/src/forge/Settings/Collaborator.js @@ -54,20 +54,25 @@ class Collaborator extends Component { roleName: undefined, }; } - + componentDidUpdate=(prevPros)=>{ + if(prevPros && this.props && !this.props.checkIfLogin()){ + this.props.history.push("/403") + return + } + } componentDidMount = () => { - this.check_is_login() + // this.check_is_login() if (this.props.project_id) { this.getMember(); } }; - check_is_login =() =>{ - if(!this.props.checkIfLogin()){ - this.props.history.push("/403") - return - } - }; + // check_is_login =() =>{ + // if(!this.props.checkIfLogin()){ + // this.props.history.push("/403") + // return + // } + // }; componentDidUpdate = (prevState) => { if ( diff --git a/src/forge/Settings/Setting.js b/src/forge/Settings/Setting.js index e7e101e8..3374329c 100644 --- a/src/forge/Settings/Setting.js +++ b/src/forge/Settings/Setting.js @@ -18,18 +18,24 @@ class Setting extends Component { }; } + componentDidUpdate=(prevPros)=>{ + if(prevPros && this.props && !this.props.checkIfLogin()){ + this.props.history.push("/403") + return + } + } componentDidMount = () => { - this.check_is_login() + // this.check_is_login() this.getCategory(); this.getLanguage(); this.getInfo(); }; - check_is_login =() =>{ - if(!this.props.checkIfLogin()){ - this.props.history.push("/403") - return - } - }; + // check_is_login =() =>{ + // if(!this.props.checkIfLogin()){ + // this.props.history.push("/403") + // return + // } + // }; getLanguage = () => { const url = `/project_languages.json`; axios diff --git a/src/forge/Settings/new_tags.js b/src/forge/Settings/new_tags.js index 40dcf27b..b6727c49 100644 --- a/src/forge/Settings/new_tags.js +++ b/src/forge/Settings/new_tags.js @@ -49,17 +49,22 @@ class NewTags extends Component { isSpin: false, }; } - - componentDidMount = () => { - this.check_is_login(); - this.getList(); - }; - check_is_login =() =>{ - if(!this.props.checkIfLogin()){ + componentDidUpdate=(prevPros)=>{ + if(prevPros && this.props && !this.props.checkIfLogin()){ this.props.history.push("/403") return } + } + componentDidMount = () => { + // this.check_is_login(); + this.getList(); }; + // check_is_login =() =>{ + // if(!this.props.checkIfLogin()){ + // this.props.history.push("/403") + // return + // } + // }; getList = (page, order_name, order_type) => { const { projectsId } = this.props.match.params; diff --git a/src/forge/comments/new.js b/src/forge/comments/new.js deleted file mode 100644 index d37423b1..00000000 --- a/src/forge/comments/new.js +++ /dev/null @@ -1,605 +0,0 @@ -import React, { Component } from "react"; -import { Link } from "react-router-dom"; -import axios from "axios"; -import { getImageUrl } from "educoder"; -import Attachments from "../Upload/attachment"; -import MDEditor from "../../modules/tpm/challengesnew/tpm-md-editor"; -import RenderHtml from "../../components/render-html"; -import "./order.css"; -import { Popconfirm , Tooltip , Spin } from 'antd'; - -class comments extends Component { - - componentDidMount = () => { - this.getjournalslist(); - }; - - handleok = () => { - this.setState({ - isShow: false, - }); - }; - handleCancel = () => { - this.setState({ - isShow: false, - }); - }; - - imgshow = () => { - this.setState({ - isShow: true, - }); - }; - - //添加评论 - addjournals = () => { - const { quillValue } = this.state; - this.setState({ - journal_spin: true, - }); - if (!quillValue) { - this.setState({ - quillFlag: true, - journal_spin: false, - }); - return; - } - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - const { data, page, limit, fileList } = this.state; - const url = `/issues/${data.id}/journals.json`; - axios - .post(url, { - ...values, - content: quillValue, - issue_id: data.id, - attachment_ids: fileList, - }) - .then((result) => { - if (result) { - this.props.showNotification("评论成功!"); - this.props.form.setFieldsValue({ - content: "", - }); - this.setState({ - showFiles: false, - quillValue: "", - quillFlag: false, - journal_spin: false, - }); - this.getjournalslist(page, limit); - } - }) - .catch((error) => { - this.setState({ - journal_spin: false, - }); - console.log(error); - }); - } else { - this.setState({ - journal_spin: false, - }); - } - }); - }; - //获取评论信息 - getjournalslist = (page, limit) => { - const { data } = this.state; - const url = `/issues/${data.id}/journals.json`; - let id = data.id; - axios - .get(url, { - params: { - id, - page, - limit, - }, - }) - .then((result) => { - if (result) { - this.setState({ - journalsdata: result.data, - search_count: result.data.journals_count, - isSpin: false, - fileList: undefined, - }); - } - }) - .catch((error) => { - console.log(error); - }); - }; - - //修改评论 - updatedetail = (id) => { - const { page, limit, countvalue } = this.state; - const { orderId } = this.props.match.params; - this.setState({ - edit_spin: true, - }); - const url = `/issues/${orderId}/journals/${id}.json`; - axios - .put(url, { - issue_id: orderId, - id: id, - content: countvalue, - }) - .then((result) => { - if (result) { - this.setState({ - isedit: undefined, - edit_spin: false, - }); - this.getjournalslist(page, limit); - } - }) - .catch((error) => { - this.setState({ - edit_spin: false, - }); - console.log(error); - }); - }; - // 获取上传后的文件id数组 - UploadFunc = (fileList) => { - this.setState({ - fileList, - }); - }; - - //删除评论 - deleteorder = (id) => { - const { orderId } = this.props.match.params; - const { page, limit } = this.state; - const url = `/issues/${orderId}/journals/${id}.json`; - axios - .delete(url, { - data: { - issue_id: orderId, - id: id, - }, - }) - .then((result) => { - if (result) { - this.getjournalslist(page, limit); - } - }) - .catch((error) => { - console.log(error); - }); - }; - - editdetail = (count, status) => { - this.setState({ - countvalue: this.stringJson(count), - isedit: status, - }); - }; - - renderJournalList = (list) => { - if (list && list.length > 0) { - return list.map((item, key) => { - return ( -
- {item.detail}: - - {item.old_value && item.old_value.length > 0 ? "更新为" : "新增"} - - - {item.value && item.value.length > 0 ? ( - item.detail === "标签" ? ( - - {item.value[0].name} - - ) : ( - item.value - ) - ) : ( - "无" - )} - -
- ); - }); - } else { - return ( -
- 没有评论~ -
- ); - } - }; - - // 翻页 - ChangePage = (page) => { - this.setState({ - page, - isSpin: true, - }); - const { limit } = this.state; - this.getjournalslist(page, limit); - }; - - // 判断是否重新上传文件 - changeIsComplete = (flag) => { - this.setState({ - showFiles: flag, - }); - }; - // 新建评论 - onContentChange = (value) => { - if (value) { - this.setState({ - quillValue: value, - quillFlag: false, - }); - } - }; - // 编辑评论 - onEditContentChange = (value) => { - if (value) { - this.setState({ - countvalue: value, - }); - } - }; - - handleShowImage = (value) => { - this.setState({ - imageUrl: value, - visible: true, - }); - }; - setVisible = (flag) => { - this.setState({ - visible: flag, - }); - }; - - stringJson = (value) => { - let _value = null; - - try { - _value = JSON.parse(value); - } catch (e) { - _value = value; - } - return _value; - }; - - commentCtx = (v) => { - return ; - }; - - render() { - const { - journalsdata, - isedit, - quillFlag, - countvalue, - edit_spin, - } = this.state; - const { current_user } = this.props; - - const renderList = () => { - if ( - journalsdata && - journalsdata.issue_journals && - journalsdata.issue_journals.length > 0 - ) { - return ( -
- {journalsdata.issue_journals.map((item, key) => { - return ( -
  • - {key > 0 && ( -
    - )} -
    - - - - -
    -
    -

    - {item.user_name} - 评论于 - - {item.created_at} - -

    -
    - - this.editdetail(item.content, item.id) - } - className="detail_edit_action" - > - 编辑 - - this.deleteorder(item.id)} - > - 删除 - -
    -
    -
    -
    - {item.content ? ( - this.commentCtx(item.content) - ) : ( -
    - {this.renderJournalList(item.journal_details)} -
    - )} - {item && - item.attachments && - item.attachments.length > 0 ? ( - - ) : ( - "" - )} -
    - -
    -
    -
    -
    -
    -
    -
  • - ); - })} -
    - ); - } - }; - - return ( -
    -
    - //
    - // {visible && } - //
    - //
    - //

    - // { - // data ? - // 【{data.issue_classify === "issue" ? (data.tracker ? data.tracker : "缺陷") : "合并请求"}】 - // : - // "" - // } - // {data && data.subject} - - //

    - //

    - // {data && data.issue_status === "关闭" ? "关闭中" : "开启中"} - // - // 由 {data && data.author_name} 于 {data && data.created_at}创建{data && data.journals_count && data.journals_count > 0 ? ` · ${data.journals_count} 条评论` : ""} - // - // { - // data && data.user_permission ? - // - // 复制 - // this.deletedetail(orderId)}> - // 删除 - // - - // 编辑 - // - // : - // "" - // } - //

    - - //
    - //
    - //
    - //
    - // - //
    - //
    - // {data && data.description && (data.description.length > 0) ? this.commentCtx(data.description) : 没有描述} - //
    - // { - // data && data.attachments && data.attachments.length > 0 ? - // - // : - // "" - // } - //
    - //
    - //
    - // - //
      - // {renderList()} - //
    - //
    - - // {Paginations} - // { - // current_user && current_user.login ? - // - //
    - //
    - // - //
    - //
    - // - //

    - // {quillFlag && 请输入评论内容} - //

    - //
    - // - //

    - // - // 评论 - // { - // data && data.user_permission ? - // this.closedetail(data && data.issue_status === "关闭" ? 2 : 5)}>{data && data.issue_status === "关闭" ? "重新开启" : "关闭"} - // : - // "" - // } - // - - //

    - //
    - //
    - //
    - // : - //
    登录并参与到对话中
    - // } - - //
    - //
    - //

    - // 分支 - // { - // data && data.branch_name ? data.branch_name : "--" - // } - //

    - //

    - // 标签 - // { - // data && data.issue_tags ? {data.issue_tags[0].name} : "--" - // } - //

    - //

    - // 里程碑 - // { - // data && data.version ? data.version : "--" - // } - //

    - //

    - // 当前状态 - // { - // data && data.issue_status ? data.issue_status : "--" - // } - //

    - //

    - // 分类 - // { - // data && data.tracker ? data.tracker : "--" - // } - //

    - //

    - // 指派给 - // {data && data.assign_user_name ? data.assign_user_name : "--"} - //

    - //

    - // 优先级 - // {data && data.priority ? data.priority : "--"} - //

    - //

    - // 完成度 - // {data && data.done_ratio ? data.done_ratio : "--"} - //

    - - //
    - //
    - //
    - // - // - // - //
    - ); - } -} - -export default comments;