Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,44 @@ import { crudGetMany, crudGetMatching } from './dataActions';

export const CRUD_GET_MANY_ACCUMULATE = 'RA/CRUD_GET_MANY_ACCUMULATE';

export const crudGetManyAccumulate = (resource, ids) => ({
export interface CrudGetManyAccumulateAction {
readonly type: typeof CRUD_GET_MANY_ACCUMULATE;
readonly payload: {
resource: string;
ids: [];
};
readonly meta: {
accumulate: any;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the metas, we need to be a bit smarter. As each meta has a special signification (and triggers a particular side effect), we probably need a subtype for accumulate, to be reused everywhere the accumulate meta is present.

};
}

export const crudGetManyAccumulate = (
resource: string,
ids: []
): CrudGetManyAccumulateAction => ({
type: CRUD_GET_MANY_ACCUMULATE,
payload: { resource, ids },
meta: { accumulate: crudGetMany },
});

export const CRUD_GET_MATCHING_ACCUMULATE = 'RA/CRUD_GET_MATCHING_ACCUMULATE';

export interface CrudGetMatchingAccumulateAction {
readonly type: typeof CRUD_GET_MATCHING_ACCUMULATE;
readonly meta: {
accumulate: () => any;
accumulateValues?: () => boolean;
accumulateKey?: string;
};
}

export const crudGetMatchingAccumulate = (
reference,
relatedTo,
pagination,
sort,
filter
) => {
reference: string,
relatedTo: string,
pagination: object,
sort: object,
filter: object
): CrudGetMatchingAccumulateAction => {
const action = crudGetMatching(
reference,
relatedTo,
Expand All @@ -32,7 +55,7 @@ export const crudGetMatchingAccumulate = (
accumulateValues: () => true,
accumulateKey: JSON.stringify({
resource: reference,
relatedTo: relatedTo,
relatedTo,
...action.payload,
}),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
export const USER_CHECK_SUCCESS = 'RA/USER_CHECK_SUCCESS';
export const USER_LOGIN = 'RA/USER_LOGIN';
export const USER_LOGIN_LOADING = 'RA/USER_LOGIN_LOADING';
export const USER_LOGIN_FAILURE = 'RA/USER_LOGIN_FAILURE';
export const USER_LOGIN_SUCCESS = 'RA/USER_LOGIN_SUCCESS';

export const userLogin = (payload, pathName) => ({
export interface UserLoginAction {
readonly type: typeof USER_LOGIN;
readonly payload: object;
readonly meta: { auth: boolean; pathName: string };
}

export const userLogin = (
payload: object,
pathName: string
): UserLoginAction => ({
type: USER_LOGIN,
payload,
meta: { auth: true, pathName },
});

export const USER_CHECK = 'RA/USER_CHECK';
export const USER_CHECK_SUCCESS = 'RA/USER_CHECK_SUCCESS';

export interface UserCheckAction {
readonly type: typeof USER_CHECK;
readonly payload: object;
readonly meta: { auth: boolean; pathName: string };
}

export const userCheck = (payload, pathName, routeParams) => ({
export const userCheck = (
payload: object,
pathName: string,
routeParams
): UserCheckAction => ({
type: USER_CHECK,
payload: {
...payload,
Expand All @@ -23,17 +42,21 @@ export const userCheck = (payload, pathName, routeParams) => ({

export const USER_LOGOUT = 'RA/USER_LOGOUT';

export interface UserLogoutAction {
readonly type: typeof USER_LOGOUT;
readonly payload: { redirectTo?: string };
readonly meta: { auth: boolean };
}

/**
* Action to trigger logout of the current user. The entire redux state will be cleared
* thanks to the resettableAppReducer in Admin.
* @see: Admin.js
* @param redirectTo Path to direct to after logout
* @return {{type: string, payload: {redirectTo: string}, meta: {auth: boolean}}}
*/
export const userLogout = redirectTo => ({
export const userLogout = (redirectTo?: string): UserLogoutAction => ({
type: USER_LOGOUT,
payload: {
redirectTo,
},
payload: { redirectTo },
meta: { auth: true },
});
20 changes: 0 additions & 20 deletions packages/ra-core/src/actions/fetchActions.js

This file was deleted.

31 changes: 31 additions & 0 deletions packages/ra-core/src/actions/fetchActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const FETCH_START = 'RA/FETCH_START';

export interface FetchStartAction {
readonly type: typeof FETCH_START;
}

export const fetchStart = (): FetchStartAction => ({ type: FETCH_START });

export const FETCH_END = 'RA/FETCH_END';

export interface FetchEndAction {
readonly type: typeof FETCH_END;
}

export const fetchEnd = (): FetchEndAction => ({ type: FETCH_END });

export const FETCH_ERROR = 'RA/FETCH_ERROR';

export interface FetchErrorAction {
readonly type: typeof FETCH_ERROR;
}

export const fetchError = (): FetchErrorAction => ({ type: FETCH_ERROR });

export const FETCH_CANCEL = 'RA/FETCH_CANCEL';

export interface FetchCancelAction {
readonly type: typeof FETCH_CANCEL;
}

export const fetchCancel = (): FetchCancelAction => ({ type: FETCH_CANCEL });
21 changes: 0 additions & 21 deletions packages/ra-core/src/actions/filterActions.js

This file was deleted.

51 changes: 51 additions & 0 deletions packages/ra-core/src/actions/filterActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
export const CRUD_SHOW_FILTER = 'RA/CRUD_SHOW_FILTER';

export interface ShowFilterAction {
readonly type: typeof CRUD_SHOW_FILTER;
readonly payload: { field: string };
readonly meta: { resource: string };
}

export const showFilter = (
resource: string,
field: string
): ShowFilterAction => ({
type: CRUD_SHOW_FILTER,
payload: { field },
meta: { resource },
});

export const CRUD_HIDE_FILTER = 'RA/CRUD_HIDE_FILTER';

export interface HideFilterAction {
readonly type: typeof CRUD_HIDE_FILTER;
readonly payload: { field: string };
readonly meta: { resource: string };
}

export const hideFilter = (
resource: string,
field: string
): HideFilterAction => ({
type: CRUD_HIDE_FILTER,
payload: { field },
meta: { resource },
});

export const CRUD_SET_FILTER = 'RA/CRUD_SET_FILTER';

export interface SetFilterAction {
readonly type: typeof CRUD_SET_FILTER;
readonly payload: { field: string; value: any };
readonly meta: { resource: string };
}

export const setFilter = (
resource: string,
field: string,
value: any
): SetFilterAction => ({
type: CRUD_SET_FILTER,
payload: { field, value },
meta: { resource },
});
18 changes: 0 additions & 18 deletions packages/ra-core/src/actions/formActions.js

This file was deleted.

38 changes: 38 additions & 0 deletions packages/ra-core/src/actions/formActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export const INITIALIZE_FORM = 'RA/INITIALIZE_FORM';

export interface InitializeFormAction {
readonly type: typeof INITIALIZE_FORM;
readonly payload: any;
}

export const initializeForm = (initialValues: any): InitializeFormAction => ({
type: INITIALIZE_FORM,
payload: initialValues,
});

export const RESET_FORM = 'RA/RESET_FORM';

export interface ResetFormAction {
readonly type: typeof RESET_FORM;
}

export const resetForm = (): ResetFormAction => ({ type: RESET_FORM });

export const BEFORE_LOCATION_CHANGE = 'RA/BEFORE_LOCATION_CHANGE';

export interface BeforeLocationChangeAction {
readonly type: typeof BEFORE_LOCATION_CHANGE;
readonly payload: any;
readonly meta: any;
}
export const beforeLocationChange = ({
payload,
meta,
}: {
payload: any;
meta: any;
}): BeforeLocationChangeAction => ({
type: BEFORE_LOCATION_CHANGE,
payload,
meta,
});
21 changes: 0 additions & 21 deletions packages/ra-core/src/actions/listActions.js

This file was deleted.

48 changes: 48 additions & 0 deletions packages/ra-core/src/actions/listActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export const CRUD_CHANGE_LIST_PARAMS = 'RA/CRUD_CHANGE_LIST_PARAMS';

export interface ChangeListParamsAction {
readonly type: typeof CRUD_CHANGE_LIST_PARAMS;
readonly payload: any;
readonly meta: { resource: string };
}
export const changeListParams = (
resource: string,
params: any
): ChangeListParamsAction => ({
type: CRUD_CHANGE_LIST_PARAMS,
payload: params,
meta: { resource },
});

export const SET_LIST_SELECTED_IDS = 'RA/SET_LIST_SELECTED_IDS';

export interface SetListLelectedIdsAction {
readonly type: typeof SET_LIST_SELECTED_IDS;
readonly payload: [];
readonly meta: { resource: string };
}
export const setListSelectedIds = (
resource: string,
ids: []
): SetListLelectedIdsAction => ({
type: SET_LIST_SELECTED_IDS,
payload: ids,
meta: { resource },
});

export const TOGGLE_LIST_ITEM = 'RA/TOGGLE_LIST_ITEM';

export interface ToggleListItemAction {
readonly type: typeof TOGGLE_LIST_ITEM;
readonly payload: any;
readonly meta: { resource: string };
}

export const toggleListItem = (
resource: string,
id: any
): ToggleListItemAction => ({
type: TOGGLE_LIST_ITEM,
payload: id,
meta: { resource },
});
Loading