Merge pull request 'webhook新建页面增加两个提示弹框' (#268) from caishi/forgeplus-react:mulanoss_git_server into mulanoss_git_server

This commit is contained in:
jasder 2021-11-18 11:33:14 +08:00
commit ec5e27e479
8 changed files with 108 additions and 30 deletions

View File

@ -32,7 +32,7 @@ export function initAxiosInterceptors(props) {
// 判断网络是否连接
initOnlineOfflineListener();
var proxy = "https://code.mulanos.cn";
var proxy = "https://testforgeplus.trustie.net";
//响应前的设置
axios.interceptors.request.use(
config => {
@ -45,11 +45,11 @@ export function initAxiosInterceptors(props) {
if (`${config[0]}` !== `true`) {
if (window.location.port === "3007") {
config.url = `${proxy}${url}`;
// if (config.url.indexOf('?') === -1) {
// config.url = `${config.url}?debug=${debugType}`;
// } else {
// config.url = `${config.url}&debug=${debugType}`;
// }
if (config.url.indexOf('?') === -1) {
config.url = `${config.url}?debug=${debugType}`;
} else {
config.url = `${config.url}&debug=${debugType}`;
}
} else {
config.url = url;
}

View File

@ -1,4 +1,4 @@
import React, { useState, useCallback, memo } from 'react';
import React, { useState, useCallback, memo, useEffect } from 'react';
import { Tooltip } from 'antd';
CopyTool.defaultProps = {
@ -10,16 +10,15 @@ CopyTool.defaultProps = {
};
function CopyTool({ beforeText, afterText, className , inputId , timeOut }) {
function CopyTool({ beforeText, afterText, className , inputId , timeOut , text }) {
const [title, setTitle] = useState(() => {
return beforeText;
});
//
const copyUrl = useCallback(() => {
const copyEle = document.querySelector(`#${inputId}`); //
if (!copyEle) {
console.error("您的CopyTool未设置正确的inputId");
console.error(`您的CopyTool未设置正确的inputId${inputId}`);
return;
}
copyEle.select(); //
@ -37,12 +36,17 @@ function CopyTool({ beforeText, afterText, className , inputId , timeOut }) {
}, []);
return (
<Tooltip
placement="top"
title={title}
onVisibleChange={() => { setTitle(beforeText) }}
>
<i className={`iconfont icon-fuzhiicon ${className}`} style={{ color: '#466aff' }} onClick={copyUrl}></i>
{text?
<a className="color-blue" onClick={copyUrl}>{text}</a>
:
<i className={`iconfont icon-fuzhiicon ${className}`} style={{ color: '#466aff' }} onClick={copyUrl}></i>
}
</Tooltip>
);
}

View File

@ -561,7 +561,7 @@ function CoderDepot(props){
<a href={lesson_url} target="_blank" className="color-grey-6" style={{textDecoration:"underline",wordBreak:"break-all"}}>{lesson_url}</a>
</div>
}
{
{/* {
<div>
<Divider />
@ -580,7 +580,7 @@ function CoderDepot(props){
</span>
}
</div>
}
} */}
{/* 发布 */}
{
releaseVersions &&

View File

@ -45,19 +45,6 @@
}
}
button {
color: #333333;
background: #FAFBFC;
border: 1px solid #D0D0D0;
border-radius: 4px;
height: 32px;
}
button:hover {
background: #F3F4F6;
}
button:active {
background: #EBECF0;
}
.deleteBut{
color: #DF0002;

View File

@ -88,8 +88,7 @@
background: #FAFCFF;
border-radius: 4px 4px 0px 0px;
border: 1px solid rgba(42, 97, 255, 0.23);
height: 50px;
padding:0px 20px;
padding:5px 20px;
margin-top: 20px;
display: flex;
align-items: center;
@ -168,4 +167,19 @@
}
}
}
}
.checkModalStyle{
.ant-modal-header{
padding:8px 20px;
.ant-modal-title{
text-align: left;
}
}
.ant-modal-close{
top:0px!important;
}
input{
width: 222px;
border:none;
}
}

View File

@ -6,6 +6,7 @@ import axios from 'axios';
import PushHistory from './sub/PushHistory';
import DeleteBox from '../../Component/DeleteModal/Index';
import './Index.scss';
import CheckModal from './sub/CheckModal';
// ,"issue_assign","issue_label","issue_milestone","issue_comment","issue_only","fork",
//"pull_request_milestone","pull_request_sync","pull_request_comment","repository","pull_request_label"
@ -21,6 +22,10 @@ function New({ form , match , showNotification , history }) {
const [ data , setData ] = useState(undefined);
const [ eventFlag , setEventFlag ] = useState(false);
const [ checkVisible , setCheckVisible ] = useState(false);
const [ checkContent , setCheckContent ] = useState(1);
const { getFieldDecorator, validateFields , setFieldsValue } = form;
const { id , owner , projectsId } = match.params;
@ -169,8 +174,18 @@ function New({ form , match , showNotification , history }) {
lineHeight: '30px',
};
function OpenCheckModal(params) {
setCheckContent(params);
setCheckVisible(true);
}
return(
<div className="newPanel">
<CheckModal
visible={checkVisible}
content={checkContent}
onCancel={()=>setCheckVisible(false)}
/>
<DeleteBox
visible={visible}
onCancel={()=>setVisible(false)}
@ -185,7 +200,12 @@ function New({ form , match , showNotification , history }) {
<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>
<p className="deschead mg">
<span>当webhook被触发时我们将向以下URL发送通知包括已选择事件的详细信息更多信息可查阅
<a className="color-blue hoverLine" target="_blank" href="https://forum.trustie.net/forums/3408/detail">webhooks指南</a>
<br/><a className="color-blue" onClick={()=>OpenCheckModal(1)}>开源敏感词检测服务设置</a><a className="color-blue" onClick={()=>OpenCheckModal(2)}>PR审阅推荐服务设置</a>
</span>
</p>
<Form>
<input type="password" style={{display:"none"}} />
<Form.Item label="目标URL" colon={false}>

View File

@ -0,0 +1,53 @@
import React, { useEffect, useState } from 'react';
import { Modal } from 'antd';
import CopyTool from '../../../Component/CopyTool';
function CheckModal({visible,content,onCancel}) {
const [ type ,setType ] = useState(content);
useEffect(()=>{
setType(content);
},[content])
return(
<Modal
visible={visible}
footer={null}
title="提示"
width="480px"
onCancel={onCancel}
closable={true}
className="checkModalStyle"
>
<div>
{
type===1?
<div>
<p style={{fontWeight:"500"}}>如需使用开源敏感词检测云功能请复制以下内容至指定的输入框中</p>
<p>目标URL<input type="text" id="copy_input_check" value={"https://api.learnerhub.net/mulan"} />
<CopyTool afterText="复制成功" inputId="copy_input_check" timeOut={true} text={"复制"}/>
</p>
<p>webhook密钥默认无须密钥</p>
<p>触发webhook选中自定义事件勾选 推送创建合并请求</p>
<p>分支过滤 默认无须修改</p>
</div>
:
<div>
<p style={{fontWeight:"500"}}>如需使用PR审阅推荐云功能请复制以下内容至指定的输入框中</p>
<p>目标URL
<input type="text" id="copy_input_check" style={{width:"160px"}} value={"http://117.50.99.180:80"} />
<CopyTool afterText="复制成功" inputId="copy_input_check" timeOut={true} text={"复制"}/>
</p>
<p>webhook密钥默认无须密钥</p>
<p>触发webhook选中自定义事件勾选 合并请求</p>
<p>分支过滤 默认无须修改</p>
</div>
}
</div>
</Modal>
)
}
export default CheckModal;

View File

@ -19,7 +19,7 @@ function Index(props) {
function getInit() {
// MLh8klm46f_ceshi
const url = `http://sonar.learnerhub.net/api/issues/search?componentKeys=${owner}_${projectsId}&s=FILE_LINE&resolved=false&types=BUG&ps=${limit}&facets=owaspTop10%2CsansTop25%2Cseverities%2CsonarsourceSecurity%2Ctypes&additionalFields=_all&timeZone=Asia%2FShanghai&p=${page}`
const url = `https://sonar.learnerhub.net/api/issues/search?componentKeys=${owner}_${projectsId}&s=FILE_LINE&resolved=false&types=BUG&ps=${limit}&facets=owaspTop10%2CsansTop25%2Cseverities%2CsonarsourceSecurity%2Ctypes&additionalFields=_all&timeZone=Asia%2FShanghai&p=${page}`
axios.get(url,{
headers:{Authorization:`Basic ${Base64.encode('ecae161ce05add6121c6263f843c76d79fcd953c:')}`}
}).then(result=>{