Skip to content

Commit

Permalink
change doc according to changing notification type
Browse files Browse the repository at this point in the history
  • Loading branch information
JinParc committed Dec 20, 2022
1 parent 6bc8549 commit 6a402d8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions docs/Actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const ApproveButton = () => {
},
onError: (error) => {
// failure side effects go here
notify(`Comment approval error: ${error.message}`, { type: 'warning' });
notify(`Comment approval error: ${error.message}`, { type: 'error' });
},
}
);
Expand Down Expand Up @@ -410,7 +410,7 @@ const ApproveButton = () => {
notify('Comment approved');
},
onError: (error) => {
notify(`Comment approval error: ${error.message}`, { type: 'warning' });
notify(`Comment approval error: ${error.message}`, { type: 'error' });
},
}
);
Expand Down Expand Up @@ -462,7 +462,7 @@ const ApproveButton = () => {
- notify('Comment approved');
+ notify('Comment approved', { undoable: true });
},
onError: (error) => notify(`Error: ${error.message}`, { type: 'warning' }),
onError: (error) => notify(`Error: ${error.message}`, { type: 'error' }),
}
);
return <Button label="Approve" onClick={() => approve()} disabled={isLoading} />;
Expand Down Expand Up @@ -504,7 +504,7 @@ const ApproveButton = () => {
redirect('/comments');
})
.catch((e) => {
notify('Error: comment not approved', { type: 'warning' })
notify('Error: comment not approved', { type: 'error' })
})
.finally(() => {
setLoading(false);
Expand Down
2 changes: 1 addition & 1 deletion docs/Create.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ The default `onError` function is:

```jsx
(error) => {
notify(typeof error === 'string' ? error : error.message || 'ra.notification.http_error', { type: 'warning' });
notify(typeof error === 'string' ? error : error.message || 'ra.notification.http_error', { type: 'error' });
}
```

Expand Down
6 changes: 3 additions & 3 deletions docs/Datagrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const CustomResetViewsButton = () => {
notify('Posts updated');
unselectAll();
},
onError: error => notify('Error: posts not updated', { type: 'warning' }),
onError: error => notify('Error: posts not updated', { type: 'error' }),
}
);

Expand Down Expand Up @@ -283,7 +283,7 @@ const CustomResetViewsButton = () => {
notify('Posts updated');
unselectAll();
},
onError: error => notify('Error: posts not updated', { type: 'warning' }),
onError: error => notify('Error: posts not updated', { type: 'error' }),
}
);
const handleClick = () => setOpen(true);
Expand Down Expand Up @@ -349,7 +349,7 @@ const CustomResetViewsButton = () => {
+ notify('Posts updated', { undoable: true }); // the last argument forces the display of 'undo' in the notification
unselectAll();
},
onError: error => notify('Error: posts not updated', { type: 'warning' }),
onError: error => notify('Error: posts not updated', { type: 'error' }),
+ mutationMode: 'undoable'
}
);
Expand Down
2 changes: 1 addition & 1 deletion docs/Edit.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ The default `onError` function is:

```jsx
(error) => {
notify(typeof error === 'string' ? error : error.message || 'ra.notification.http_error', { type: 'warning' });
notify(typeof error === 'string' ? error : error.message || 'ra.notification.http_error', { type: 'error' });
if (mutationMode === 'undoable' || mutationMode === 'pessimistic') {
refresh();
}
Expand Down
2 changes: 1 addition & 1 deletion docs/List.md
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ const PostList = () => {
const redirect = useRedirect();

const onError = (error) => {
notify(`Could not load list: ${error.message}`, { type: 'warning' });
notify(`Could not load list: ${error.message}`, { type: 'error' });
redirect('/dashboard');
};

Expand Down
4 changes: 2 additions & 2 deletions docs/Show.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const PostShow = props => {
const redirect = useRedirect();

const onError = (error) => {
notify(`Could not load post: ${error.message}`, { type: 'warning' });
notify(`Could not load post: ${error.message}`, { type: 'error' });
redirect('/posts');
refresh();
};
Expand All @@ -205,7 +205,7 @@ The default `onError` function is:

```jsx
(error) => {
notify('ra.notification.item_doesnt_exist', { type: 'warning' });
notify('ra.notification.item_doesnt_exist', { type: 'error' });
redirect('list', resource);
refresh();
}
Expand Down
4 changes: 2 additions & 2 deletions docs/ShowBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const PostShow = props => {
const redirect = useRedirect();

const onError = (error) => {
notify(`Could not load post: ${error.message}`, { type: 'warning' });
notify(`Could not load post: ${error.message}`, { type: 'error' });
redirect('/posts');
refresh();
};
Expand All @@ -101,7 +101,7 @@ The default `onError` function is:

```jsx
(error) => {
notify('ra.notification.item_doesnt_exist', { type: 'warning' });
notify('ra.notification.item_doesnt_exist', { type: 'error' });
redirect('list', resource);
refresh();
}
Expand Down
2 changes: 1 addition & 1 deletion docs/useNotify.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Here are more examples of `useNotify` calls:
// notify an error
notify(`This is an error`, { type: 'error' });
// notify a warning
notify(`This is a warning`, { type: 'warning' });
notify(`This is a warning`, { type: 'error' });
// pass translation arguments
notify('item.created', { type: 'info', messageArgs: { resource: 'post' } });
// send an undoable notification
Expand Down
2 changes: 1 addition & 1 deletion docs/useRefresh.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const DeleteCommentButton = () => {
notify('Comment deleted');
},
onError: (error) => {
notify(`Comment deletion error: ${error.message}`, { type: 'warning' });
notify(`Comment deletion error: ${error.message}`, { type: 'error' });
},
}
);
Expand Down
4 changes: 2 additions & 2 deletions docs/useShowController.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const PostShow = props => {
const redirect = useRedirect();

const onError = (error) => {
notify(`Could not load post: ${error.message}`, { type: 'warning' });
notify(`Could not load post: ${error.message}`, { type: 'error' });
redirect('/posts');
refresh();
};
Expand Down Expand Up @@ -111,7 +111,7 @@ The default `onError` function is:

```js
(error) => {
notify('ra.notification.item_doesnt_exist', { type: 'warning' });
notify('ra.notification.item_doesnt_exist', { type: 'error' });
redirect('list', resource);
refresh();
}
Expand Down

0 comments on commit 6a402d8

Please sign in to comment.