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

[BC Break] Rename duplicate types to allow type emission from react-admin #5257

Merged
merged 3 commits into from
Sep 15, 2020
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
6 changes: 3 additions & 3 deletions packages/ra-core/src/actions/accumulateActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { crudGetMany, crudGetMatching } from './dataActions';
import { Pagination, Sort, Identifier } from '../types';
import { PaginationPayload, SortPayload, Identifier } from '../types';

export const CRUD_GET_MANY_ACCUMULATE = 'RA/CRUD_GET_MANY_ACCUMULATE';

Expand Down Expand Up @@ -37,8 +37,8 @@ export interface CrudGetMatchingAccumulateAction {
export const crudGetMatchingAccumulate = (
reference: string,
relatedTo: string,
pagination: Pagination,
sort: Sort,
pagination: PaginationPayload,
sort: SortPayload,
filter: object
): CrudGetMatchingAccumulateAction => {
const action = crudGetMatching(
Expand Down
8 changes: 4 additions & 4 deletions packages/ra-core/src/actions/dataActions/crudGetAll.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Record, Pagination, Sort } from '../../types';
import { Record, PaginationPayload, SortPayload } from '../../types';
import { GET_LIST } from '../../core';
import { FETCH_END, FETCH_ERROR } from '../fetchActions';
import { NotificationSideEffect, CallbackSideEffect } from '../../sideEffect';

export const crudGetAll = (
resource: string,
sort: Sort,
sort: SortPayload,
filter: object,
maxResults: number,
callback?: CallbackSideEffect
Expand All @@ -28,8 +28,8 @@ export const crudGetAll = (
});

interface RequestPayload {
pagination: Pagination;
sort: Sort;
pagination: PaginationPayload;
sort: SortPayload;
filter: object;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/ra-core/src/actions/dataActions/crudGetList.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Record, Pagination, Sort } from '../../types';
import { Record, PaginationPayload, SortPayload } from '../../types';
import { GET_LIST } from '../../core';
import { FETCH_END, FETCH_ERROR } from '../fetchActions';
import { NotificationSideEffect } from '../../sideEffect';

export const crudGetList = (
resource: string,
pagination: Pagination,
sort: Sort,
pagination: PaginationPayload,
sort: SortPayload,
filter: object
): CrudGetListAction => ({
type: CRUD_GET_LIST,
Expand All @@ -24,8 +24,8 @@ export const crudGetList = (
});

interface RequestPayload {
pagination: Pagination;
sort: Sort;
pagination: PaginationPayload;
sort: SortPayload;
filter: object;
}

Expand Down
15 changes: 10 additions & 5 deletions packages/ra-core/src/actions/dataActions/crudGetManyReference.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Identifier, Record, Pagination, Sort } from '../../types';
import {
Identifier,
Record,
PaginationPayload,
SortPayload,
} from '../../types';
import { GET_MANY_REFERENCE } from '../../core';
import { FETCH_END, FETCH_ERROR } from '../fetchActions';
import { NotificationSideEffect } from '../../sideEffect';
Expand All @@ -8,8 +13,8 @@ export const crudGetManyReference = (
target: string,
id: Identifier,
relatedTo: string,
pagination: Pagination,
sort: Sort,
pagination: PaginationPayload,
sort: SortPayload,
filter: object,
source: string
): CrudGetManyReferenceAction => ({
Expand All @@ -32,8 +37,8 @@ interface RequestPayload {
source: string;
target: string;
id: Identifier;
pagination: Pagination;
sort: Sort;
pagination: PaginationPayload;
sort: SortPayload;
filter: object;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/ra-core/src/actions/dataActions/crudGetMatching.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Record, Pagination, Sort } from '../../types';
import { Record, PaginationPayload, SortPayload } from '../../types';
import { GET_LIST } from '../../core';
import { FETCH_END, FETCH_ERROR } from '../fetchActions';
import { NotificationSideEffect } from '../../sideEffect';

export const crudGetMatching = (
reference: string,
relatedTo: string,
pagination: Pagination,
sort: Sort,
pagination: PaginationPayload,
sort: SortPayload,
filter: object
): CrudGetMatchingAction => ({
type: CRUD_GET_MATCHING,
Expand All @@ -26,8 +26,8 @@ export const crudGetMatching = (
});

interface RequestPayload {
pagination: Pagination;
sort: Sort;
pagination: PaginationPayload;
sort: SortPayload;
filter: object;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ra-core/src/actions/notificationActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ interface NotificationOptions {
undoable?: boolean;
}

export interface Notification {
export interface NotificationPayload {
readonly message: string;
readonly type: NotificationType;
readonly notificationOptions?: NotificationOptions;
}

export interface ShowNotificationAction {
readonly type: typeof SHOW_NOTIFICATION;
readonly payload: Notification;
readonly payload: NotificationPayload;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FunctionComponent, ReactElement } from 'react';

import useReferenceArrayFieldController from './useReferenceArrayFieldController';
import { ListControllerProps } from '../useListController';
import { Record, Sort } from '../../types';
import { Record, SortPayload } from '../../types';

interface Props {
basePath: string;
Expand All @@ -12,7 +12,7 @@ interface Props {
record?: Record;
reference: string;
resource: string;
sort?: Sort;
sort?: SortPayload;
source: string;
children: (params: ListControllerProps) => ReactElement<any>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactElement, FunctionComponent } from 'react';

import { Record, Sort } from '../../types';
import { Record, SortPayload } from '../../types';
import useReferenceManyFieldController from './useReferenceManyFieldController';
import { ListControllerProps } from '../useListController';

Expand All @@ -13,7 +13,7 @@ interface Props {
record?: Record;
reference: string;
resource: string;
sort?: Sort;
sort?: SortPayload;
source: string;
target: string;
total?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import get from 'lodash/get';
import isEqual from 'lodash/isEqual';

import { useSafeSetState, removeEmpty } from '../../util';
import { Record, RecordMap, Identifier, Sort } from '../../types';
import { Record, RecordMap, Identifier, SortPayload } from '../../types';
import { useGetMany } from '../../dataProvider';
import { ListControllerProps } from '../useListController';
import { useNotify } from '../../sideEffect';
Expand All @@ -19,7 +19,7 @@ interface Option {
record?: Record;
reference: string;
resource: string;
sort?: Sort;
sort?: SortPayload;
source: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import isEqual from 'lodash/isEqual';
import { useSafeSetState, removeEmpty } from '../../util';
import { useGetManyReference } from '../../dataProvider';
import { useNotify } from '../../sideEffect';
import { Record, Sort, RecordMap } from '../../types';
import { Record, SortPayload, RecordMap } from '../../types';
import { ListControllerProps } from '../useListController';
import usePaginationState from '../usePaginationState';
import useSelectionState from '../useSelectionState';
Expand All @@ -22,7 +22,7 @@ interface Options {
record?: Record;
reference: string;
resource: string;
sort?: Sort;
sort?: SortPayload;
source?: string;
target: string;
total?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from 'react';
import debounce from 'lodash/debounce';

import { Record, Sort, Pagination } from '../../types';
import { Record, SortPayload, PaginationPayload } from '../../types';
import useReferenceArrayInputController from './useReferenceArrayInputController';

interface ChildrenFuncParams {
Expand All @@ -15,8 +15,8 @@ interface ChildrenFuncParams {
loaded: boolean;
loading: boolean;
setFilter: (filter: any) => void;
setPagination: (pagination: Pagination) => void;
setSort: (sort: Sort) => void;
setPagination: (pagination: PaginationPayload) => void;
setSort: (sort: SortPayload) => void;
warning?: string;
}

Expand All @@ -32,7 +32,7 @@ interface Props {
record?: Record;
reference: string;
resource: string;
sort?: Sort;
sort?: SortPayload;
source: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ReactElement,
} from 'react';

import { Sort, Record } from '../../types';
import { SortPayload, Record } from '../../types';
import useReferenceInputController, {
ReferenceInputValue,
} from './useReferenceInputController';
Expand All @@ -22,7 +22,7 @@ interface Props {
reference: string;
referenceSource?: (resource: string, source: string) => string;
resource: string;
sort?: Sort;
sort?: SortPayload;
source: string;
onChange: () => void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ import {
getPossibleReferenceValues,
getReferenceResource,
} from '../../reducer';
import { Pagination, Sort, Record, Filter } from '../../types';
import {
PaginationPayload,
SortPayload,
Record,
FilterPayload,
} from '../../types';
import { useDeepCompareEffect } from '../../util/hooks';

interface UseMatchingReferencesOption {
reference: string;
referenceSource: (resource: string, source: string) => string;
resource: string;
source: string;
filter: Filter;
pagination: Pagination;
sort: Sort;
filter: FilterPayload;
pagination: PaginationPayload;
sort: SortPayload;
id: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { useMemo, useState, useEffect, useRef } from 'react';
import { useSelector } from 'react-redux';
import isEqual from 'lodash/isEqual';
import difference from 'lodash/difference';
import { Pagination, Record, Sort, ReduxState } from '../../types';
import {
PaginationPayload,
Record,
SortPayload,
ReduxState,
} from '../../types';
import { useGetMany } from '../../dataProvider';
import { FieldInputProps } from 'react-final-form';
import useGetMatching from '../../dataProvider/useGetMatching';
Expand Down Expand Up @@ -206,8 +211,8 @@ interface ReferenceArrayInputProps {
loading: boolean;
loaded: boolean;
setFilter: (filter: any) => void;
setPagination: (pagination: Pagination) => void;
setSort: (sort: Sort) => void;
setPagination: (pagination: PaginationPayload) => void;
setSort: (sort: SortPayload) => void;
}

interface Option {
Expand All @@ -220,7 +225,7 @@ interface Option {
record?: Record;
reference: string;
resource: string;
sort?: Sort;
sort?: SortPayload;
source: string;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getStatusForInput as getDataStatus } from './referenceDataStatus';
import useTranslate from '../../i18n/useTranslate';
import { Sort, Record, Pagination } from '../../types';
import { SortPayload, Record, PaginationPayload } from '../../types';
import useReference from '../useReference';
import useGetMatchingReferences from './useGetMatchingReferences';
import usePaginationState from '../usePaginationState';
Expand All @@ -15,12 +15,12 @@ export interface ReferenceInputValue {
choices: Record[];
error?: string;
loading: boolean;
pagination: Pagination;
pagination: PaginationPayload;
setFilter: (filter: string) => void;
filter: any;
setPagination: (pagination: Pagination) => void;
setSort: (sort: Sort) => void;
sort: Sort;
setPagination: (pagination: PaginationPayload) => void;
setSort: (sort: SortPayload) => void;
sort: SortPayload;
warning?: string;
}

Expand All @@ -34,7 +34,7 @@ interface Option {
reference: string;
referenceSource?: typeof defaultReferenceSource;
resource: string;
sort?: Sort;
sort?: SortPayload;
source: string;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/ra-core/src/controller/useFilterState.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useRef, useState, useCallback } from 'react';
import debounce from 'lodash/debounce';
import isEqual from 'lodash/isEqual';
import { Filter } from '../types';
import { FilterPayload } from '../types';

interface UseFilterStateOptions {
filterToQuery?: (v: string) => Filter;
permanentFilter?: Filter;
filterToQuery?: (v: string) => FilterPayload;
permanentFilter?: FilterPayload;
debounceTime?: number;
}

Expand All @@ -15,7 +15,7 @@ interface UseFilterStateOptions {
* @property {setFilter} setFilter: Update the filter with the given string
*/
interface UseFilterStateProps {
filter: Filter;
filter: FilterPayload;
setFilter: (v: string) => void;
}

Expand Down
Loading