Skip to content

Commit

Permalink
Regression: Webhook Integration Creation + string error toast msg (#2…
Browse files Browse the repository at this point in the history
…6008)

## Issue(s)
While creating an webhook integration, it was missing the **v1/**. Also, the toast was not properly displaying error messages

## Before:

![image](https://user-images.githubusercontent.com/1761174/175665990-c3e820c2-e9af-44ff-b0da-03b6a803f930.png)

![image](https://user-images.githubusercontent.com/1761174/175666183-d8d6999c-8ffd-43e9-835b-61ba76853d6b.png)


## After:

![image](https://user-images.githubusercontent.com/1761174/175665664-72b99178-e720-41a6-aec0-d0d06a25dfc2.png)


## Steps to test or reproduce
Try creating an Integration Webhook in Admin > Integrations. 
The payload will be sent to: http://localhost:3000/api/integrations.create

Edit a user, and set it's email the same email as an existing user: the toast message will not display the correct message



Co-authored-by: Debdut Chakraborty <[email protected]>
  • Loading branch information
dudanogueira and debdutdeb authored Jun 27, 2022
1 parent cf921ac commit c8f93fa
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/client/hooks/useEndpointAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const useEndpointAction = <TMethod extends Method, TPath extends PathFor<

return data;
} catch (error) {
dispatchToastMessage({ type: 'error', message: String(error) });
dispatchToastMessage({ type: 'error', message: error });
throw error;
}
}, [dispatchToastMessage, params, sendData, successMessage]);
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/account/security/TwoFactorEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const TwoFactorEmail = (props) => {

const isEnabled = user && user.services && user.services.email2fa && user.services.email2fa.enabled;

const enable2faAction = useEndpointAction('POST', 'users.2fa.enableEmail', undefined, t('Two-factor_authentication_enabled'));
const disable2faAction = useEndpointAction('POST', 'users.2fa.disableEmail', undefined, t('Two-factor_authentication_disabled'));
const enable2faAction = useEndpointAction('POST', '/v1/users.2fa.enableEmail', undefined, t('Two-factor_authentication_enabled'));
const disable2faAction = useEndpointAction('POST', '/v1/users.2fa.disableEmail', undefined, t('Two-factor_authentication_disabled'));

const handleEnable = useCallback(async () => {
await enable2faAction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function EditIncomingWebhook({ data, onChange, ...props }) {
const setModal = useSetModal();

const deleteQuery = useMemo(() => ({ type: 'webhook-incoming', integrationId: data._id }), [data._id]);
const deleteIntegration = useEndpointAction('POST', 'integrations.remove', deleteQuery);
const deleteIntegration = useEndpointAction('POST', '/v1/integrations.remove', deleteQuery);
const saveIntegration = useMethod('updateIncomingIntegration');

const router = useRoute('admin-integrations');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function EditOutgoingWebhook({ data, onChange, setSaveAction, ...props }) {
const router = useRoute('admin-integrations');

const deleteQuery = useMemo(() => ({ type: 'webhook-outgoing', integrationId: data._id }), [data._id]);
const deleteIntegration = useEndpointAction('POST', 'integrations.remove', deleteQuery);
const deleteIntegration = useEndpointAction('POST', '/v1/integrations.remove', deleteQuery);

const handleDeleteIntegration = useCallback(() => {
const closeModal = () => setModal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function NewIncomingWebhook(props) {
const { values: formValues, handlers: formHandlers, reset } = useForm(initialState);

const params = useMemo(() => ({ ...formValues, type: 'webhook-incoming' }), [formValues]);
const saveAction = useEndpointAction('POST', 'integrations.create', params, t('Integration_added'));
const saveAction = useEndpointAction('POST', '/v1/integrations.create', params, t('Integration_added'));

const handleSave = useCallback(async () => {
const result = await saveAction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function NewOutgoingWebhook({ data = defaultData, onChange, setSa
}),
[formValues, triggerWords, urls],
);
const saveIntegration = useEndpointAction('POST', 'integrations.create', params, t('Integration_added'));
const saveIntegration = useEndpointAction('POST', '/v1/integrations.create', params, t('Integration_added'));

const handleSave = useCallback(async () => {
const result = await saveIntegration();
Expand Down

0 comments on commit c8f93fa

Please sign in to comment.