Skip to content

Commit

Permalink
fix: able to use default channel to send webhook message now
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed May 10, 2023
1 parent 1d32544 commit 34b9633
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
13 changes: 13 additions & 0 deletions web/src/components/WebhooksTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ const WebhooksTable = () => {
>
状态
</Table.HeaderCell>
<Table.HeaderCell
style={{ cursor: 'pointer' }}
onClick={() => {
sortWebhook('channel');
}}
>
通道
</Table.HeaderCell>
<Table.HeaderCell
style={{ cursor: 'pointer' }}
onClick={() => {
Expand All @@ -220,6 +228,11 @@ const WebhooksTable = () => {
<Table.Cell>{webhook.id}</Table.Cell>
<Table.Cell>{webhook.name}</Table.Cell>
<Table.Cell>{renderStatus(webhook.status)}</Table.Cell>
<Table.Cell>
<Label>
{webhook.channel ? webhook.channel : '默认通道'}
</Label>
</Table.Cell>
<Table.Cell>
{renderTimestamp(webhook.created_time)}
</Table.Cell>
Expand Down
14 changes: 13 additions & 1 deletion web/src/pages/Webhook/EditWebhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const EditWebhook = () => {
' "content": "内容:$content",\n' +
' "url": "https://example.com/$title"\n' +
'}',
channel: '',
channel: 'default',
};

const [inputs, setInputs] = useState(originInputs);
Expand All @@ -39,6 +39,9 @@ const EditWebhook = () => {
let res = await API.get(`/api/webhook/${webhookId}`);
const { success, message, data } = res.data;
if (success) {
if (data.channel === '') {
data.channel = 'default';
}
setInputs(data);
} else {
showError(message);
Expand All @@ -53,6 +56,12 @@ const EditWebhook = () => {
}
let channels = await loadUserChannels();
if (channels) {
channels.unshift({
key: 'default',
text: '默认通道',
value: 'default',
description: '使用默认通道',
});
setChannels(channels);
}
};
Expand All @@ -71,6 +80,9 @@ const EditWebhook = () => {
}
let res = undefined;
let localInputs = { ...inputs };
if (localInputs.channel === 'default') {
localInputs.channel = '';
}
if (isEditing) {
res = await API.put(`/api/webhook/`, {
...localInputs,
Expand Down

0 comments on commit 34b9633

Please sign in to comment.