Add isEnabled to webhook.

This commit is contained in:
Yang Luo
2021-12-26 21:02:56 +08:00
parent 0c665edcbc
commit 9943e3c316
13 changed files with 95 additions and 25 deletions

View File

@ -146,6 +146,10 @@ func GetRecordsByField(record *Record) []*Record {
func SendWebhooks(record *Record) error { func SendWebhooks(record *Record) error {
webhooks := getWebhooksByOrganization(record.Organization) webhooks := getWebhooksByOrganization(record.Organization)
for _, webhook := range webhooks { for _, webhook := range webhooks {
if !webhook.IsEnabled {
continue
}
matched := false matched := false
for _, event := range webhook.Events { for _, event := range webhook.Events {
if record.Action == event { if record.Action == event {

View File

@ -38,6 +38,7 @@ type Webhook struct {
ContentType string `xorm:"varchar(100)" json:"contentType"` ContentType string `xorm:"varchar(100)" json:"contentType"`
Headers []*Header `xorm:"mediumtext" json:"headers"` Headers []*Header `xorm:"mediumtext" json:"headers"`
Events []string `xorm:"varchar(100)" json:"events"` Events []string `xorm:"varchar(100)" json:"events"`
IsEnabled bool `json:"isEnabled"`
} }
func GetWebhookCount(owner, field, value string) int { func GetWebhookCount(owner, field, value string) int {

View File

@ -250,7 +250,7 @@ class SyncerEditPage extends React.Component {
</Row> </Row>
<Row style={{marginTop: '20px'}} > <Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 19 : 2}> <Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 19 : 2}>
{Setting.getLabel(i18next.t("syncer:Is enabled"), i18next.t("syncer:Is enabled - Tooltip"))} : {Setting.getLabel(i18next.t("general:Is enabled"), i18next.t("general:Is enabled - Tooltip"))} :
</Col> </Col>
<Col span={1} > <Col span={1} >
<Switch checked={this.state.syncer.isEnabled} onChange={checked => { <Switch checked={this.state.syncer.isEnabled} onChange={checked => {

View File

@ -192,7 +192,7 @@ class SyncerListPage extends BaseListPage {
...this.getColumnSearchProps('syncInterval'), ...this.getColumnSearchProps('syncInterval'),
}, },
{ {
title: i18next.t("syncer:Is enabled"), title: i18next.t("general:Is enabled"),
dataIndex: 'isEnabled', dataIndex: 'isEnabled',
key: 'isEnabled', key: 'isEnabled',
width: '120px', width: '120px',

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import React from "react"; import React from "react";
import {Button, Card, Col, Input, Row, Select} from 'antd'; import {Button, Card, Col, Input, Row, Select, Switch} from 'antd';
import {LinkOutlined} from "@ant-design/icons"; import {LinkOutlined} from "@ant-design/icons";
import * as WebhookBackend from "./backend/WebhookBackend"; import * as WebhookBackend from "./backend/WebhookBackend";
import * as OrganizationBackend from "./backend/OrganizationBackend"; import * as OrganizationBackend from "./backend/OrganizationBackend";
@ -181,6 +181,16 @@ class WebhookEditPage extends React.Component {
</Select> </Select>
</Col> </Col>
</Row> </Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 19 : 2}>
{Setting.getLabel(i18next.t("general:Is enabled"), i18next.t("general:Is enabled - Tooltip"))} :
</Col>
<Col span={1} >
<Switch checked={this.state.webhook.isEnabled} onChange={checked => {
this.updateWebhookField('isEnabled', checked);
}} />
</Col>
</Row>
</Card> </Card>
) )
} }

View File

@ -14,7 +14,7 @@
import React from "react"; import React from "react";
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import {Button, Popconfirm, Table} from 'antd'; import {Button, Popconfirm, Switch, Table} from 'antd';
import moment from "moment"; import moment from "moment";
import * as Setting from "./Setting"; import * as Setting from "./Setting";
import * as WebhookBackend from "./backend/WebhookBackend"; import * as WebhookBackend from "./backend/WebhookBackend";
@ -34,6 +34,7 @@ class WebhookListPage extends BaseListPage {
contentType: "application/json", contentType: "application/json",
headers: [], headers: [],
events: ["signup", "login", "logout", "update-user"], events: ["signup", "login", "logout", "update-user"],
isEnabled: true,
} }
} }
@ -156,6 +157,18 @@ class WebhookListPage extends BaseListPage {
return Setting.getTags(text); return Setting.getTags(text);
} }
}, },
{
title: i18next.t("general:Is enabled"),
dataIndex: 'isEnabled',
key: 'isEnabled',
width: '120px',
sorter: true,
render: (text, record, index) => {
return (
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
)
}
},
{ {
title: i18next.t("general:Action"), title: i18next.t("general:Action"),
dataIndex: '', dataIndex: '',

View File

@ -87,6 +87,8 @@
"Home - Tooltip": "Application homepage", "Home - Tooltip": "Application homepage",
"ID": "ID", "ID": "ID",
"ID - Tooltip": "random string", "ID - Tooltip": "random string",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"LDAPs": "LDAPs", "LDAPs": "LDAPs",
"LDAPs - Tooltip": "LDAPs - Tooltip", "LDAPs - Tooltip": "LDAPs - Tooltip",
"Logo - Tooltip": "App's image tag", "Logo - Tooltip": "App's image tag",
@ -335,8 +337,6 @@
"Database type": "Database type", "Database type": "Database type",
"Database type - Tooltip": "Database type - Tooltip", "Database type - Tooltip": "Database type - Tooltip",
"Edit Syncer": "Edit Syncer", "Edit Syncer": "Edit Syncer",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"Is hashed": "Is hashed", "Is hashed": "Is hashed",
"Sync interval": "Sync interval", "Sync interval": "Sync interval",
"Sync interval - Tooltip": "Sync interval - Tooltip", "Sync interval - Tooltip": "Sync interval - Tooltip",
@ -417,7 +417,13 @@
"Edit Webhook": "Edit Webhook", "Edit Webhook": "Edit Webhook",
"Events": "Events", "Events": "Events",
"Events - Tooltip": "Events - Tooltip", "Events - Tooltip": "Events - Tooltip",
"Headers": "Headers",
"Headers - Tooltip": "Headers - Tooltip",
"Method": "Method",
"Method - Tooltip": "Method - Tooltip",
"Name": "Name",
"URL": "URL", "URL": "URL",
"URL - Tooltip": "URL - Tooltip" "URL - Tooltip": "URL - Tooltip",
"Value": "Value"
} }
} }

View File

@ -87,6 +87,8 @@
"Home - Tooltip": "Home - Tooltip", "Home - Tooltip": "Home - Tooltip",
"ID": "ID", "ID": "ID",
"ID - Tooltip": "ID - Tooltip", "ID - Tooltip": "ID - Tooltip",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"LDAPs": "LDAPs", "LDAPs": "LDAPs",
"LDAPs - Tooltip": "LDAPs - Tooltip", "LDAPs - Tooltip": "LDAPs - Tooltip",
"Logo - Tooltip": "Logo - Tooltip", "Logo - Tooltip": "Logo - Tooltip",
@ -335,8 +337,6 @@
"Database type": "Database type", "Database type": "Database type",
"Database type - Tooltip": "Database type - Tooltip", "Database type - Tooltip": "Database type - Tooltip",
"Edit Syncer": "Edit Syncer", "Edit Syncer": "Edit Syncer",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"Is hashed": "Is hashed", "Is hashed": "Is hashed",
"Sync interval": "Sync interval", "Sync interval": "Sync interval",
"Sync interval - Tooltip": "Sync interval - Tooltip", "Sync interval - Tooltip": "Sync interval - Tooltip",
@ -417,7 +417,13 @@
"Edit Webhook": "Edit Webhook", "Edit Webhook": "Edit Webhook",
"Events": "Events", "Events": "Events",
"Events - Tooltip": "Events - Tooltip", "Events - Tooltip": "Events - Tooltip",
"Headers": "Headers",
"Headers - Tooltip": "Headers - Tooltip",
"Method": "Method",
"Method - Tooltip": "Method - Tooltip",
"Name": "Name",
"URL": "URL", "URL": "URL",
"URL - Tooltip": "URL - Tooltip" "URL - Tooltip": "URL - Tooltip",
"Value": "Value"
} }
} }

View File

@ -87,6 +87,8 @@
"Home - Tooltip": "Application homepage", "Home - Tooltip": "Application homepage",
"ID": "ID", "ID": "ID",
"ID - Tooltip": "random string", "ID - Tooltip": "random string",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"LDAPs": "LDAPs", "LDAPs": "LDAPs",
"LDAPs - Tooltip": "LDAPs - Tooltip", "LDAPs - Tooltip": "LDAPs - Tooltip",
"Logo - Tooltip": "App's image tag", "Logo - Tooltip": "App's image tag",
@ -335,8 +337,6 @@
"Database type": "Database type", "Database type": "Database type",
"Database type - Tooltip": "Database type - Tooltip", "Database type - Tooltip": "Database type - Tooltip",
"Edit Syncer": "Edit Syncer", "Edit Syncer": "Edit Syncer",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"Is hashed": "Is hashed", "Is hashed": "Is hashed",
"Sync interval": "Sync interval", "Sync interval": "Sync interval",
"Sync interval - Tooltip": "Sync interval - Tooltip", "Sync interval - Tooltip": "Sync interval - Tooltip",
@ -417,7 +417,13 @@
"Edit Webhook": "Edit Webhook", "Edit Webhook": "Edit Webhook",
"Events": "Events", "Events": "Events",
"Events - Tooltip": "Events - Tooltip", "Events - Tooltip": "Events - Tooltip",
"Headers": "Headers",
"Headers - Tooltip": "Headers - Tooltip",
"Method": "Method",
"Method - Tooltip": "Method - Tooltip",
"Name": "Name",
"URL": "URL", "URL": "URL",
"URL - Tooltip": "URL - Tooltip" "URL - Tooltip": "URL - Tooltip",
"Value": "Value"
} }
} }

View File

@ -87,6 +87,8 @@
"Home - Tooltip": "Application homepage", "Home - Tooltip": "Application homepage",
"ID": "ID", "ID": "ID",
"ID - Tooltip": "random string", "ID - Tooltip": "random string",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"LDAPs": "LDAPs", "LDAPs": "LDAPs",
"LDAPs - Tooltip": "LDAPs - Tooltip", "LDAPs - Tooltip": "LDAPs - Tooltip",
"Logo - Tooltip": "App's image tag", "Logo - Tooltip": "App's image tag",
@ -335,8 +337,6 @@
"Database type": "Database type", "Database type": "Database type",
"Database type - Tooltip": "Database type - Tooltip", "Database type - Tooltip": "Database type - Tooltip",
"Edit Syncer": "Edit Syncer", "Edit Syncer": "Edit Syncer",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"Is hashed": "Is hashed", "Is hashed": "Is hashed",
"Sync interval": "Sync interval", "Sync interval": "Sync interval",
"Sync interval - Tooltip": "Sync interval - Tooltip", "Sync interval - Tooltip": "Sync interval - Tooltip",
@ -417,7 +417,13 @@
"Edit Webhook": "Edit Webhook", "Edit Webhook": "Edit Webhook",
"Events": "Events", "Events": "Events",
"Events - Tooltip": "Events - Tooltip", "Events - Tooltip": "Events - Tooltip",
"Headers": "Headers",
"Headers - Tooltip": "Headers - Tooltip",
"Method": "Method",
"Method - Tooltip": "Method - Tooltip",
"Name": "Name",
"URL": "URL", "URL": "URL",
"URL - Tooltip": "URL - Tooltip" "URL - Tooltip": "URL - Tooltip",
"Value": "Value"
} }
} }

View File

@ -87,6 +87,8 @@
"Home - Tooltip": "Application homepage", "Home - Tooltip": "Application homepage",
"ID": "ID", "ID": "ID",
"ID - Tooltip": "random string", "ID - Tooltip": "random string",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"LDAPs": "LDAPs", "LDAPs": "LDAPs",
"LDAPs - Tooltip": "LDAPs - Tooltip", "LDAPs - Tooltip": "LDAPs - Tooltip",
"Logo - Tooltip": "App's image tag", "Logo - Tooltip": "App's image tag",
@ -335,8 +337,6 @@
"Database type": "Database type", "Database type": "Database type",
"Database type - Tooltip": "Database type - Tooltip", "Database type - Tooltip": "Database type - Tooltip",
"Edit Syncer": "Edit Syncer", "Edit Syncer": "Edit Syncer",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"Is hashed": "Is hashed", "Is hashed": "Is hashed",
"Sync interval": "Sync interval", "Sync interval": "Sync interval",
"Sync interval - Tooltip": "Sync interval - Tooltip", "Sync interval - Tooltip": "Sync interval - Tooltip",
@ -417,7 +417,13 @@
"Edit Webhook": "Edit Webhook", "Edit Webhook": "Edit Webhook",
"Events": "Events", "Events": "Events",
"Events - Tooltip": "Events - Tooltip", "Events - Tooltip": "Events - Tooltip",
"Headers": "Headers",
"Headers - Tooltip": "Headers - Tooltip",
"Method": "Method",
"Method - Tooltip": "Method - Tooltip",
"Name": "Name",
"URL": "URL", "URL": "URL",
"URL - Tooltip": "URL - Tooltip" "URL - Tooltip": "URL - Tooltip",
"Value": "Value"
} }
} }

View File

@ -87,6 +87,8 @@
"Home - Tooltip": "Application homepage", "Home - Tooltip": "Application homepage",
"ID": "ID", "ID": "ID",
"ID - Tooltip": "random string", "ID - Tooltip": "random string",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"LDAPs": "LDAPs", "LDAPs": "LDAPs",
"LDAPs - Tooltip": "LDAPs - Tooltip", "LDAPs - Tooltip": "LDAPs - Tooltip",
"Logo - Tooltip": "App's image tag", "Logo - Tooltip": "App's image tag",
@ -335,8 +337,6 @@
"Database type": "Database type", "Database type": "Database type",
"Database type - Tooltip": "Database type - Tooltip", "Database type - Tooltip": "Database type - Tooltip",
"Edit Syncer": "Edit Syncer", "Edit Syncer": "Edit Syncer",
"Is enabled": "Is enabled",
"Is enabled - Tooltip": "Is enabled - Tooltip",
"Is hashed": "Is hashed", "Is hashed": "Is hashed",
"Sync interval": "Sync interval", "Sync interval": "Sync interval",
"Sync interval - Tooltip": "Sync interval - Tooltip", "Sync interval - Tooltip": "Sync interval - Tooltip",
@ -417,7 +417,13 @@
"Edit Webhook": "Edit Webhook", "Edit Webhook": "Edit Webhook",
"Events": "Events", "Events": "Events",
"Events - Tooltip": "Events - Tooltip", "Events - Tooltip": "Events - Tooltip",
"Headers": "Headers",
"Headers - Tooltip": "Headers - Tooltip",
"Method": "Method",
"Method - Tooltip": "Method - Tooltip",
"Name": "Name",
"URL": "URL", "URL": "URL",
"URL - Tooltip": "URL - Tooltip" "URL - Tooltip": "URL - Tooltip",
"Value": "Value"
} }
} }

View File

@ -87,6 +87,8 @@
"Home - Tooltip": "应用的首页", "Home - Tooltip": "应用的首页",
"ID": "ID", "ID": "ID",
"ID - Tooltip": "唯一的随机字符串", "ID - Tooltip": "唯一的随机字符串",
"Is enabled": "已启用",
"Is enabled - Tooltip": "是否启用",
"LDAPs": "LDAPs", "LDAPs": "LDAPs",
"LDAPs - Tooltip": "LDAPs", "LDAPs - Tooltip": "LDAPs",
"Logo - Tooltip": "应用程序向外展示的图标", "Logo - Tooltip": "应用程序向外展示的图标",
@ -335,8 +337,6 @@
"Database type": "数据库类型", "Database type": "数据库类型",
"Database type - Tooltip": "数据库类型", "Database type - Tooltip": "数据库类型",
"Edit Syncer": "修改同步器", "Edit Syncer": "修改同步器",
"Is enabled": "已启用",
"Is enabled - Tooltip": "是否启用",
"Is hashed": "是否参与哈希计算", "Is hashed": "是否参与哈希计算",
"Sync interval": "同步间隔", "Sync interval": "同步间隔",
"Sync interval - Tooltip": "单位为分钟", "Sync interval - Tooltip": "单位为分钟",
@ -417,7 +417,13 @@
"Edit Webhook": "修改Webhook", "Edit Webhook": "修改Webhook",
"Events": "事件", "Events": "事件",
"Events - Tooltip": "事件", "Events - Tooltip": "事件",
"Headers": "协议头",
"Headers - Tooltip": "HTTP协议头键值对",
"Method": "方法",
"Method - Tooltip": "HTTP方法",
"Name": "名称",
"URL": "URL", "URL": "URL",
"URL - Tooltip": "URL" "URL - Tooltip": "URL",
"Value": "值"
} }
} }