2020-01-06 01:52:26 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
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 { useGlobalContext } from 'strapi-helper-plugin';
|
|
|
|
|
|
|
|
import Wrapper from './Wrapper';
|
|
|
|
|
|
|
|
const TriggerContainer = ({ isPending, onCancel, response }) => {
|
|
|
|
const { formatMessage } = useGlobalContext();
|
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>
|
|
|
|
<p>Test-trigger</p>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
{isPending ? (
|
|
|
|
<>
|
|
|
|
<td>
|
2020-01-06 16:01:42 +01:00
|
|
|
<p>
|
|
|
|
<Pending fill="#6DBB1A" width="14px" height="15px" />
|
|
|
|
<span>Pending...</span>
|
|
|
|
</p>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<button onClick={onCancel} type="button">
|
2020-01-06 01:52:26 +01:00
|
|
|
{formatMessage({ id: `Settings.webhooks.trigger.cancel` })}
|
2020-01-06 16:01:42 +01:00
|
|
|
<Remove fill="#b4b6ba" />
|
2020-01-06 01:52:26 +01:00
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</>
|
2020-01-06 16:01:42 +01:00
|
|
|
) : statusCode >= 200 && statusCode < 300 ? (
|
|
|
|
<>
|
|
|
|
<td>
|
|
|
|
<p className="success-label">
|
|
|
|
<Success fill="#6DBB1A" width="19px" height="19px" />
|
|
|
|
<span>Success!</span>
|
|
|
|
</p>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<p>Trigger succeded</p>
|
|
|
|
</td>
|
|
|
|
</>
|
2020-01-06 01:52:26 +01:00
|
|
|
) : (
|
|
|
|
<>
|
2020-01-06 16:01:42 +01:00
|
|
|
<td>
|
|
|
|
<p className="fail-label">
|
|
|
|
<Fail fill="#f64d0a" width="14px" height="15px" />
|
|
|
|
<span>Error {statusCode}</span>
|
|
|
|
</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: () => {},
|
|
|
|
};
|
|
|
|
|
|
|
|
TriggerContainer.propTypes = {
|
|
|
|
isPending: PropTypes.bool,
|
|
|
|
onCancel: PropTypes.func,
|
|
|
|
response: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TriggerContainer;
|