fix: slack webhooks PUT call
This commit is contained in:
parent
11344e2d9c
commit
c55647f5ad
3 changed files with 21 additions and 14 deletions
|
|
@ -1,20 +1,22 @@
|
|||
import React from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { edit, save, init } from 'Duck/integrations/slack'
|
||||
import { edit, save, init, update } from 'Duck/integrations/slack'
|
||||
import { Form, Input, Button, Message } from 'UI'
|
||||
import { confirm } from 'UI/Confirmation';
|
||||
import { remove } from 'Duck/integrations/slack'
|
||||
|
||||
class SlackAddForm extends React.PureComponent {
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.init({});
|
||||
}
|
||||
|
||||
save = () => {
|
||||
this.props.save(this.props.instance).then(function() {
|
||||
|
||||
})
|
||||
const instance = this.props.instance;
|
||||
if(instance.exists()) {
|
||||
this.props.update(this.props.instance)
|
||||
} else {
|
||||
this.props.save(this.props.instance)
|
||||
}
|
||||
}
|
||||
|
||||
remove = async (id) => {
|
||||
|
|
@ -102,4 +104,4 @@ export default connect(state => ({
|
|||
instance: state.getIn(['slack', 'instance']),
|
||||
saving: state.getIn(['slack', 'saveRequest', 'loading']),
|
||||
errors: state.getIn([ 'slack', 'saveRequest', 'errors' ]),
|
||||
}), { edit, save, init, remove })(SlackAddForm)
|
||||
}), { edit, save, init, remove, update })(SlackAddForm)
|
||||
|
|
@ -24,15 +24,11 @@ function SlackChannelList(props) {
|
|||
className="border-t px-5 py-2 flex items-center justify-between cursor-pointer"
|
||||
onClick={() => onEdit(c)}
|
||||
>
|
||||
<div className="flex-grow-0" style={{ maxWidth: '80%'}}>
|
||||
<div className="flex-grow-0" style={{ maxWidth: '90%'}}>
|
||||
<div>{c.name}</div>
|
||||
<TextEllipsis
|
||||
text={
|
||||
<div className="test-xs color-gray-medium text-">
|
||||
{c.endpoint}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<div className="truncate test-xs color-gray-medium">
|
||||
{c.endpoint}
|
||||
</div>
|
||||
</div>
|
||||
{/* <div className="flex-shrink-0">
|
||||
<Button plain onClick={() => remove(c.webhookId) }>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import Config from 'Types/integrations/slackConfig';
|
|||
import { createItemInListUpdater } from '../funcTools/tools';
|
||||
|
||||
const SAVE = new RequestTypes('slack/SAVE');
|
||||
const UPDATE = new RequestTypes('slack/UPDATE');
|
||||
const REMOVE = new RequestTypes('slack/REMOVE');
|
||||
const FETCH_LIST = new RequestTypes('slack/FETCH_LIST');
|
||||
const EDIT = 'slack/EDIT';
|
||||
|
|
@ -20,6 +21,7 @@ const reducer = (state = initialState, action = {}) => {
|
|||
switch (action.type) {
|
||||
case FETCH_LIST.SUCCESS:
|
||||
return state.set('list', List(action.data).map(Config));
|
||||
case UPDATE.SUCCESS:
|
||||
case SAVE.SUCCESS:
|
||||
const config = Config(action.data);
|
||||
return state
|
||||
|
|
@ -57,6 +59,13 @@ export function save(instance) {
|
|||
};
|
||||
}
|
||||
|
||||
export function update(instance) {
|
||||
return {
|
||||
types: UPDATE.toArray(),
|
||||
call: client => client.put(`/integrations/slack/${instance.webhookId}`, instance.toData()),
|
||||
};
|
||||
}
|
||||
|
||||
export function edit(instance) {
|
||||
return {
|
||||
type: EDIT,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue