mirror of https://github.com/portainer/portainer
fix(app/edge-stack): UI notification on creation error (#325)
parent
154ca9f1b1
commit
cab667c23b
|
@ -10,8 +10,13 @@ import {
|
|||
import { notifyError } from '@/portainer/services/notifications';
|
||||
|
||||
/**
|
||||
* @deprecated use withGlobalError
|
||||
* `onError` and other callbacks are not supported on react-query v5
|
||||
* @deprecated for `useQuery` ONLY. Use `withGlobalError`.
|
||||
*
|
||||
* `onError` and other callbacks are not supported on `useQuery` in react-query v5
|
||||
*
|
||||
* Using `withError` is fine for mutations (`useMutation`)
|
||||
*
|
||||
* see https://tkdodo.eu/blog/breaking-react-querys-api-on-purpose
|
||||
*/
|
||||
export function withError(fallbackMessage?: string, title = 'Failure') {
|
||||
return {
|
||||
|
|
|
@ -6,6 +6,7 @@ import { TemplateViewModel } from '@/react/portainer/templates/app-templates/vie
|
|||
import { CustomTemplate } from '@/react/portainer/templates/custom-templates/types';
|
||||
import { notifySuccess } from '@/portainer/services/notifications';
|
||||
import { transformAutoUpdateViewModel } from '@/react/portainer/gitops/AutoUpdateFieldset/utils';
|
||||
import { mutationOptions, withError } from '@/react-tools/react-query';
|
||||
|
||||
import {
|
||||
BasePayload,
|
||||
|
@ -49,12 +50,18 @@ export function useCreate({
|
|||
),
|
||||
});
|
||||
|
||||
mutation.mutate(getPayload(method, values), {
|
||||
onSuccess: () => {
|
||||
notifySuccess('Success', 'Edge stack created');
|
||||
router.stateService.go('^');
|
||||
},
|
||||
});
|
||||
mutation.mutate(
|
||||
getPayload(method, values),
|
||||
mutationOptions(
|
||||
{
|
||||
onSuccess: () => {
|
||||
notifySuccess('Success', 'Edge stack created');
|
||||
router.stateService.go('^');
|
||||
},
|
||||
},
|
||||
withError('unable to create edge stack')
|
||||
)
|
||||
);
|
||||
|
||||
function getPayload(
|
||||
method: 'string' | 'file' | 'git',
|
||||
|
|
Loading…
Reference in New Issue