forked from Gitlink/forgeplus-react
项目仓库中,建木/softbot创建的webhook允许用户进入详情页查看
This commit is contained in:
parent
f0d5862f14
commit
f78619bc1b
|
|
@ -1,8 +1,8 @@
|
|||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 2340181 */
|
||||
src: url('iconfont.woff2?t=1680167204025') format('woff2'),
|
||||
url('iconfont.woff?t=1680167204025') format('woff'),
|
||||
url('iconfont.ttf?t=1680167204025') format('truetype');
|
||||
src: url('iconfont.woff2?t=1680498859493') format('woff2'),
|
||||
url('iconfont.woff?t=1680498859493') format('woff'),
|
||||
url('iconfont.ttf?t=1680498859493') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
|
|
@ -13,6 +13,10 @@
|
|||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-a-zu37:before {
|
||||
content: "\e961";
|
||||
}
|
||||
|
||||
.icon-guanzhuicon:before {
|
||||
content: "\e95b";
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -5,6 +5,13 @@
|
|||
"css_prefix_text": "icon-",
|
||||
"description": "",
|
||||
"glyphs": [
|
||||
{
|
||||
"icon_id": "34875122",
|
||||
"name": "组 37",
|
||||
"font_class": "a-zu37",
|
||||
"unicode": "e961",
|
||||
"unicode_decimal": 59745
|
||||
},
|
||||
{
|
||||
"icon_id": "34819652",
|
||||
"name": "关注icon",
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -86,12 +86,13 @@ function Index(props) {
|
|||
}
|
||||
|
||||
function gotoEditWebhook(webhook){
|
||||
if(webhook.isJianMu){
|
||||
setEditId(webhook.id);
|
||||
setEditVisible(true);
|
||||
}else{
|
||||
props.history.push(`/${owner}/${projectsId}/settings/webhooks/${webhook.id}`);
|
||||
}
|
||||
props.history.push(`/${owner}/${projectsId}/settings/webhooks/${webhook.id}`);
|
||||
// if(webhook.isJianMu){
|
||||
// setEditId(webhook.id);
|
||||
// setEditVisible(true);
|
||||
// }else{
|
||||
// props.history.push(`/${owner}/${projectsId}/settings/webhooks/${webhook.id}`);
|
||||
// }
|
||||
}
|
||||
|
||||
return(
|
||||
|
|
@ -104,7 +105,7 @@ function Index(props) {
|
|||
content="您确定要删除此Webhook吗?"
|
||||
subTitle={deleteWebHookModSubTitle}
|
||||
/>
|
||||
<Modal
|
||||
{/* <Modal
|
||||
visible={editVisible}
|
||||
onCancel={()=>{setEditVisible(false)}}
|
||||
title="请谨慎编辑此Webhook"
|
||||
|
|
@ -115,7 +116,7 @@ function Index(props) {
|
|||
>
|
||||
<AlignCenter className="editWebhookModalTitle font-20 mb10"><i className="iconfont icon-shanchu_tc_icon mr10 font-36" style={{color: '#ca0002'}}></i>您确定要编辑此Webhook吗?</AlignCenter>
|
||||
<p className="task-hide-2" style={{WebkitLineClamp:5}}>该Webhook由流水线创建, 编辑此Webhook后, 将大概率导致本仓库相关流水线失效。确定要修改此Webhook?</p>
|
||||
</Modal>
|
||||
</Modal> */}
|
||||
<Banner>
|
||||
<span>Webhooks(网络钩子)</span>
|
||||
<Button type="primary" size="large" onClick={addFunc}>添加Webhook</Button>
|
||||
|
|
@ -128,15 +129,15 @@ function Index(props) {
|
|||
{data.map((i,k)=>{
|
||||
return(
|
||||
<List.Item key={k}>
|
||||
<i className={`iconfont mr12 font-17 ${i.isJianMu ? 'icon-gongzuoliuicon color-grey-6' : 'icon-a-xuanzhongwebhookicon color-grey-d'}`}></i>
|
||||
<i className={`iconfont mr12 font-17 ${i.isJianMu ? 'icon-gongzuoliuicon color-grey-6' : i.type === "softbot" ? 'icon-a-zu37 color-grey-6' : 'icon-a-xuanzhongwebhookicon color-grey-d'}`}></i>
|
||||
<span className="webName">{i.isJianMu ? <Tooltip title="该Webhook由流水线创建,请勿编辑或删除以防流水线失效"><span className="webName spanBox">{i.url}</span></Tooltip> : i.url}</span>
|
||||
{!i.isJianMu && i.type !== "softbot" && <span>
|
||||
<Button ghost type={"primary"} onClick={()=>{gotoEditWebhook(i)}}>编辑</Button>
|
||||
<Button ghost className="ml20" type="danger" onClick={()=>{deleteFunc(i)}}>删除</Button>
|
||||
</span>}
|
||||
{(i.isJianMu || i.type === "softbot") && <span>
|
||||
<Popover content={`该webhook由${i.isJianMu ? '流水线' : 'softbot'}创建,不可编辑或删除,更改配置将导致流水线失效`} title="无法编辑此Webhook" overlayClassName="disabledButPopover"><Button type={"primary"} disabled>编辑</Button></Popover>
|
||||
<Popover content={`该webhook由${i.isJianMu ? '流水线' : 'softbot'}创建,不可编辑或删除,更改配置将导致流水线失效`} title="无法删除此Webhook" overlayClassName="disabledButPopover"><Button className="ml20" type="danger" disabled>删除</Button></Popover>
|
||||
<Popover content={`该webhook由${i.isJianMu ? '流水线创建,不可编辑或删除,更改配置将导致流水线失效' : '已安装的Bot创建,请勿编辑或删除以防Bot失效'}`} title="无法编辑此Webhook" overlayClassName="disabledButPopover"><Button ghost type={"primary"} onClick={()=>{gotoEditWebhook(i)}}>查看</Button></Popover>
|
||||
<Popover content={`该webhook由${i.isJianMu ? '流水线创建,不可编辑或删除,更改配置将导致流水线失效' : '已安装的Bot创建,请勿编辑或删除以防Bot失效'}`} title="无法删除此Webhook" overlayClassName="disabledButPopover"><Button className="ml20" type="danger" disabled>删除</Button></Popover>
|
||||
</span>}
|
||||
</List.Item>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
const [ visible , setVisible ] = useState(false);
|
||||
const [ data , setData ] = useState(undefined);
|
||||
const [ eventFlag , setEventFlag ] = useState(false);
|
||||
const [ unEdit, setUnEdit] = useState(false);
|
||||
|
||||
const { getFieldDecorator, validateFields , setFieldsValue } = form;
|
||||
const { id , owner , projectsId } = match.params;
|
||||
|
|
@ -69,6 +70,10 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
const url = `/${owner}/${projectsId}/webhooks/${id}/edit.json`;
|
||||
axios.get(url).then(result=>{
|
||||
if(result){
|
||||
const reg1 = new RegExp("https://(.*?)jianmuhub.com(.*?)");
|
||||
const reg2 = new RegExp("https://jianmu.gitlink.org.cn(.*?)");
|
||||
const {url, type} = result.data;
|
||||
setUnEdit(reg1.test(url) || reg2.test(url) || type === "softbot")
|
||||
let e = compareArray(result.data.events);
|
||||
setFieldsValue({
|
||||
...result.data,
|
||||
|
|
@ -190,7 +195,7 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
<span>
|
||||
<Link to={`/${owner}/${projectsId}/settings/webhooks`} className="color-blue">Webhooks</Link>
|
||||
<i className="iconfont icon-youjiantou ml5 mr5 font-12"></i>
|
||||
<span>{id ? "更新" : "添加"}Webhook</span>
|
||||
<span>{ unEdit ? '查看' : id ? "更新" : "添加"}Webhook</span>
|
||||
</span>
|
||||
</Banner>
|
||||
<div>
|
||||
|
|
@ -206,21 +211,21 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
}
|
||||
]
|
||||
})(
|
||||
<Input placeholder="请输入目标URL" maxLength="200" size="large" autocomplete='off'/>
|
||||
<Input placeholder="请输入目标URL" maxLength="200" size="large" autocomplete='off' disabled = {unEdit}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item label="Webhook密钥" colon={false}>
|
||||
{getFieldDecorator("secret",{
|
||||
rules:[]
|
||||
})(
|
||||
<Input.Password placeholder="请输入Webhook密钥" autocomplete='new-password' size="large" maxLength={"200"}/>
|
||||
<Input.Password placeholder="请输入Webhook密钥" autocomplete='new-password' size="large" maxLength={"200"} disabled = {unEdit}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item label="Http请求方法" colon={false}>
|
||||
{getFieldDecorator("http_method",{
|
||||
rules:[]
|
||||
})(
|
||||
<Select onSelect={changeHTTP} size="large">
|
||||
<Select onSelect={changeHTTP} size="large" disabled = {unEdit}>
|
||||
<Select.Option value="GET">GET</Select.Option>
|
||||
<Select.Option value="POST">POST</Select.Option>
|
||||
</Select>
|
||||
|
|
@ -234,7 +239,7 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
{getFieldDecorator("content_type",{
|
||||
rules:[]
|
||||
})(
|
||||
<Select size="large">
|
||||
<Select size="large" disabled = {unEdit}>
|
||||
<Select.Option value="json">application/json</Select.Option>
|
||||
<Select.Option value="form">application/x-www-form-urlencoded</Select.Option>
|
||||
</Select>
|
||||
|
|
@ -244,7 +249,7 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
{getFieldDecorator("eventCondition",{
|
||||
rules:[]
|
||||
})(
|
||||
<Radio.Group onChange={changeCondition}>
|
||||
<Radio.Group onChange={changeCondition} disabled = {unEdit}>
|
||||
<Radio style={radioStyle} value="push">只是push事件</Radio>
|
||||
<Radio style={radioStyle} value="all">所有事件</Radio>
|
||||
<Radio style={radioStyle} value="forevent">自定义事件</Radio>
|
||||
|
|
@ -254,7 +259,7 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
<div className="eventCb"
|
||||
style={{display:condition === "forevent" ?"block":"none"}}
|
||||
>
|
||||
<Checkbox.Group value={event} onChange={(e)=>{setEvent(e)}}>
|
||||
<Checkbox.Group value={event} onChange={(e)=>{setEvent(e)}} disabled = {unEdit}>
|
||||
<p className="color-grey-3 mb10">代码库事件</p>
|
||||
<div className="colSpan">
|
||||
<span>
|
||||
|
|
@ -318,7 +323,7 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
{getFieldDecorator("branch_filter",{
|
||||
rules:[]
|
||||
})(
|
||||
<Input size="large"/>
|
||||
<Input size="large" disabled = {unEdit}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
|
|
@ -329,13 +334,13 @@ function New({ form , match , showNotification , history, projectDetail }) {
|
|||
{getFieldDecorator("active",{
|
||||
valuePropName:"checked"
|
||||
})(
|
||||
<Checkbox>激活<span className="subCbDesc">激活后触发事件的信息将发送到此Webhook地址</span></Checkbox>
|
||||
<Checkbox disabled = {unEdit}>激活<span className="subCbDesc">激活后触发事件的信息将发送到此Webhook地址</span></Checkbox>
|
||||
)}
|
||||
</Form.Item>
|
||||
|
||||
<Button type="primary" onClick={submit} className="ml20" style={{width:id?"":"100px"}}>{id ? "更新Webhook":"添加"}</Button>
|
||||
<Button type="primary" onClick={submit} className="ml20" style={{width:id?"":"100px"}} disabled = {unEdit}>{id ? "更新Webhook":"添加"}</Button>
|
||||
{
|
||||
id && <Button type="danger" className="ml20" onClick={deleteFunc}>删除</Button>
|
||||
id && <Button type="danger" className="ml20" onClick={deleteFunc} disabled = {unEdit}>删除</Button>
|
||||
}
|
||||
</Form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue