Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Trigger refresh after crudUpdate #3506

Merged
merged 1 commit into from
Aug 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/ra-core/src/actions/dataActions/crudUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FETCH_END, FETCH_ERROR } from '../fetchActions';
import {
NotificationSideEffect,
RedirectionSideEffect,
RefreshSideEffect,
} from '../../sideEffect';

export const crudUpdate = (
Expand All @@ -12,7 +13,8 @@ export const crudUpdate = (
data: any,
previousData: any,
basePath: string,
redirectTo: RedirectionSideEffect = 'show'
redirectTo: RedirectionSideEffect = 'show',
refresh: RefreshSideEffect = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a refresh if we have a redirect ? I think the default value should be false

Copy link
Contributor Author

@natrim natrim Aug 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as with delete, with undoable false and redirect to same page, we need refresh to happen if no redirect

fixes the same thing as #2425 but for update

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you choose to disable optimistic updates and to redirect to the same page, isn't it your responsability to set the refresh to true? This will trigger a refresh and a redirection for all default cases

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised it was accepted on delete btw

Copy link
Contributor Author

@natrim natrim Aug 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but you cannot set refresh true using provided props,
the only workaround is to create new redux action and set it there

but many ppl will not even know about it, cause they would think that refresh happens like it does if its undoable (with undoable it works with the redirect on same page) its just this one edge case that behaves differently

and same for delete where same fix was applied

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll consider this a workaround until v3 is out then

Copy link
Contributor Author

@natrim natrim Aug 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this "workaround" is already in next branch for delete

so this one should probably be put to next too as the same bug exists in next too

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably won't need them anymore soon

): CrudUpdateAction => ({
type: CRUD_UPDATE,
payload: { id, data, previousData },
Expand All @@ -27,6 +29,7 @@ export const crudUpdate = (
smart_count: 1,
},
},
refresh,
redirectTo,
basePath,
},
Expand Down Expand Up @@ -55,6 +58,7 @@ export interface CrudUpdateAction {
onSuccess: {
notification: NotificationSideEffect;
redirectTo: RedirectionSideEffect;
refresh: RefreshSideEffect;
basePath: string;
};
onFailure: {
Expand Down Expand Up @@ -97,6 +101,7 @@ export interface CrudUpdateSuccessAction {
resource: string;
notification: NotificationSideEffect;
redirectTo: RedirectionSideEffect;
refresh: RefreshSideEffect;
basePath: string;
fetchResponse: typeof UPDATE;
fetchStatus: typeof FETCH_END;
Expand Down