107 lines
3.0 KiB
JavaScript
Raw Normal View History

2020-01-06 01:52:26 +01:00
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
2020-01-06 16:01:42 +01:00
import { Fail, Success, Pending, Remove } from '@buffetjs/icons';
2020-01-06 01:52:26 +01:00
import Wrapper from './Wrapper';
const TriggerContainer = ({ isPending, onCancel, response }) => {
2020-01-06 16:01:42 +01:00
const { statusCode, message } = response;
2020-01-06 01:52:26 +01:00
return (
<Wrapper>
<table>
<tbody>
<tr>
<td>
2020-01-15 12:17:44 +01:00
<p>
<FormattedMessage
id="Settings.webhooks.trigger.test"
defaultMessage="test-trigger"
/>
2020-01-15 12:17:44 +01:00
</p>
2020-01-06 01:52:26 +01:00
</td>
2020-01-13 10:40:10 +01:00
{isPending && (
2020-01-06 01:52:26 +01:00
<>
<td>
2020-01-06 16:01:42 +01:00
<p>
2020-01-15 12:17:44 +01:00
<Pending fill="#ffb500" width="15px" height="15px" />
<FormattedMessage
id="Settings.webhooks.trigger.pending"
defaultMessage="pending"
/>
2020-01-06 16:01:42 +01:00
</p>
</td>
<td>
<button onClick={onCancel} type="button">
<FormattedMessage
id="Settings.webhooks.trigger.cancel"
defaultMessage="cancel"
/>
2020-01-06 16:01:42 +01:00
<Remove fill="#b4b6ba" />
2020-01-06 01:52:26 +01:00
</button>
</td>
</>
2020-01-13 10:40:10 +01:00
)}
{!isPending && statusCode >= 200 && statusCode < 300 && (
2020-01-06 16:01:42 +01:00
<>
<td>
<p className="success-label">
<Success fill="#6DBB1A" width="19px" height="19px" />
<FormattedMessage
id="Settings.webhooks.trigger.success"
defaultMessage="success"
/>
2020-01-06 16:01:42 +01:00
</p>
</td>
<td>
2020-01-10 15:17:36 +01:00
<p>
<FormattedMessage
id="Settings.webhooks.trigger.success.label"
defaultMessage="success"
/>
2020-01-10 15:17:36 +01:00
</p>
2020-01-06 16:01:42 +01:00
</td>
</>
2020-01-13 10:40:10 +01:00
)}
{!isPending && statusCode >= 300 && (
2020-01-06 01:52:26 +01:00
<>
2020-01-06 16:01:42 +01:00
<td>
<p className="fail-label">
2020-01-08 14:55:37 +01:00
<Fail fill="#f64d0a" width="15px" height="15px" />
<FormattedMessage
id="Settings.error"
defaultMessage="error"
/>
&nbsp;
{statusCode}
2020-01-06 16:01:42 +01:00
</p>
</td>
<td>
2020-01-07 16:00:11 +01:00
<p title={message}>{message}</p>
2020-01-06 16:01:42 +01:00
</td>
2020-01-06 01:52:26 +01:00
</>
)}
</tr>
</tbody>
</table>
</Wrapper>
);
};
TriggerContainer.defaultProps = {
isPending: false,
onCancel: () => {},
2020-01-10 15:17:36 +01:00
response: {},
2020-01-06 01:52:26 +01:00
};
TriggerContainer.propTypes = {
isPending: PropTypes.bool,
onCancel: PropTypes.func,
response: PropTypes.object,
};
export default TriggerContainer;