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

More TS fixes #5298

Merged
merged 7 commits into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
18 changes: 9 additions & 9 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"fetch-mock": "~6.3.0",
"json-graphql-server": "~2.1.3",
"proxy-polyfill": "^0.3.0",
"ra-data-fakerest": "^3.0.0",
"ra-data-graphql-simple": "^3.0.0",
"ra-data-simple-rest": "^3.0.0",
"ra-i18n-polyglot": "^3.0.0",
"ra-input-rich-text": "^3.0.0",
"ra-language-english": "^3.0.0",
"ra-language-french": "^3.0.0",
"ra-data-fakerest": "^3.9.0-beta.1",
"ra-data-graphql-simple": "^3.9.0-beta.1",
"ra-data-simple-rest": "^3.9.0-beta.1",
"ra-i18n-polyglot": "^3.9.0-beta.1",
"ra-input-rich-text": "^3.9.0-beta.1",
"ra-language-english": "^3.9.0-beta.1",
"ra-language-french": "^3.9.0-beta.1",
"react": "^16.9.0",
"react-admin": "^3.0.0",
"react-admin": "next",
"react-app-polyfill": "^1.0.4",
"react-dom": "^16.9.0",
"react-redux": "^7.1.0",
Expand Down Expand Up @@ -54,4 +54,4 @@
"source-map-explorer": "^2.0.0",
"typescript": "^4.0.2"
}
}
}
12 changes: 6 additions & 6 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
"@babel/polyfill": "^7.10.4",
"@material-ui/core": "^4.10.0",
"@material-ui/icons": "^4.9.1",
"ra-data-fakerest": "^3.0.0",
"ra-i18n-polyglot": "^3.0.0",
"ra-input-rich-text": "^3.0.0",
"ra-language-english": "^3.0.0",
"ra-language-french": "^3.0.0",
"ra-data-fakerest": "^3.9.0-beta.1",
"ra-i18n-polyglot": "^3.9.0-beta.1",
"ra-input-rich-text": "^3.9.0-beta.1",
"ra-language-english": "^3.9.0-beta.1",
"ra-language-french": "^3.9.0-beta.1",
"react": "^16.9.0",
"react-admin": "^3.0.0",
"react-admin": "next",
"react-dom": "^16.9.0"
}
}
6 changes: 3 additions & 3 deletions examples/tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"private": true,
"dependencies": {
"@material-ui/core": "^4.10.0",
"ra-data-json-server": "^3.0.0",
"ra-data-json-server": "^3.9.0-beta.1",
"react": "^16.9.0",
"react-admin": "^3.0.0",
"react-admin": "next",
"react-dom": "^16.9.0",
"react-scripts": "^3.0.0"
},
Expand All @@ -21,4 +21,4 @@
"not ie <= 11",
"not op_mini all"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ interface ReferenceArrayInputProps {
}

interface Option {
basePath: string;
basePath?: string;
filter?: any;
filterToQuery?: (filter: any) => any;
input: FieldInputProps<any, HTMLElement>;
options?: any;
perPage?: number;
record?: Record;
reference: string;
resource: string;
resource?: string;
sort?: SortPayload;
source: string;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/controller/useShowController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ShowProps {
hasShow?: boolean;
hasList?: boolean;
id: Identifier;
resource: string;
resource?: string;
[key: string]: any;
}

Expand Down
15 changes: 11 additions & 4 deletions packages/ra-core/src/dataProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import Query from './Query';
import cacheDataProviderProxy from './cacheDataProviderProxy';
import undoableEventEmitter from './undoableEventEmitter';
import useDataProvider from './useDataProvider';
import useMutation from './useMutation';
import useQuery from './useQuery';
import useQueryWithStore from './useQueryWithStore';
import useMutation, { UseMutationValue } from './useMutation';
import useQuery, { UseQueryValue } from './useQuery';
import useQueryWithStore, { QueryOptions } from './useQueryWithStore';
import withDataProvider from './withDataProvider';
import useGetOne from './useGetOne';
import useGetOne, { UseGetOneHookValue } from './useGetOne';
import useGetList from './useGetList';
import useGetMany from './useGetMany';
import useGetManyReference from './useGetManyReference';
Expand All @@ -24,6 +24,13 @@ import useDeleteMany from './useDeleteMany';
import useRefreshWhenVisible from './useRefreshWhenVisible';
import useIsAutomaticRefreshEnabled from './useIsAutomaticRefreshEnabled';

export type {
QueryOptions,
UseMutationValue,
UseQueryValue,
UseGetOneHookValue,
};

export {
cacheDataProviderProxy,
convertLegacyDataProvider,
Expand Down
2 changes: 2 additions & 0 deletions packages/ra-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,14 @@ export type LoginComponent = ComponentType<LoginComponentProps>;
export type DashboardComponent = ComponentType<WithPermissionsChildrenParams>;

export interface LayoutProps {
appBar?: ComponentType;
dashboard?: DashboardComponent;
logout?: ReactNode;
menu?: ComponentType<{
logout?: ReactNode;
hasDashboard?: boolean;
}>;
sideBar?: ComponentType;
theme?: ThemeOptions;
title?: TitleComponent;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-data-fakerest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
"rimraf": "^2.6.3"
},
"peerDependencies": {
"ra-core": "^3.0.0"
"ra-core": "^3.9.0-beta.1"
Copy link
Member

Choose a reason for hiding this comment

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

we will need to pass over all these before the stable release

}
}
2 changes: 1 addition & 1 deletion packages/ra-data-graphql-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"peerDependencies": {
"graphql": "^14.1.1",
"ra-core": "^3.0.0"
"ra-core": "^3.9.0-beta.1"
},
"devDependencies": {
"cross-env": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-data-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"peerDependencies": {
"graphql": "^14.1.1",
"ra-core": "^3.0.0"
"ra-core": "^3.9.0-beta.1"
},
"devDependencies": {
"cross-env": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-data-simple-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"rimraf": "^2.6.3"
},
"peerDependencies": {
"ra-core": "^3.0.0"
"ra-core": "^3.9.0-beta.1"
}
}
4 changes: 2 additions & 2 deletions packages/ra-input-rich-text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"watch": "tsc --outDir esm --module es2015 --watch"
},
"peerDependencies": {
"ra-core": "^3.0.0",
"ra-ui-materialui": "^4.3.3",
"ra-core": "^3.9.0-beta.1",
"ra-ui-materialui": "^3.9.0-beta.1",
"react": "^16.9.0",
"react-dom": "^16.9.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@material-ui/styles": "^4.3.3",
"final-form": "^4.18.5",
"final-form-arrays": "^3.0.1",
"ra-core": "^3.0.0",
"ra-core": "^3.9.0-beta.1",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-final-form": "^6.3.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/ra-ui-materialui/src/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ButtonProps as MuiButtonProps } from '@material-ui/core/Button';
import { Theme } from '@material-ui/core';
import classnames from 'classnames';
import { Record, RedirectionSideEffect, useTranslate } from 'ra-core';
import { LocationDescriptor } from 'history';

/**
* A generic Button with side icon. Only the icon is displayed on small screens.
Expand Down Expand Up @@ -133,7 +134,7 @@ interface Props {
className?: string;
color?: MuiPropTypes.Color;
component?: ReactNode;
to?: string | { pathname: string; search: string };
to?: string | LocationDescriptor;
disabled?: boolean;
label?: string;
size?: 'small' | 'medium' | 'large';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ interface Props {
undoable?: boolean;
}

type DeleteWithConfirmButtonProps = Props & ButtonProps;
export type DeleteWithConfirmButtonProps = Props & ButtonProps;

DeleteWithConfirmButton.propTypes = {
basePath: PropTypes.string,
Expand Down
19 changes: 15 additions & 4 deletions packages/ra-ui-materialui/src/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import BulkDeleteButton from './BulkDeleteButton';
import BulkDeleteWithConfirmButton from './BulkDeleteWithConfirmButton';
import BulkDeleteWithUndoButton from './BulkDeleteWithUndoButton';
import BulkExportButton from './BulkExportButton';
import Button from './Button';
import Button, { ButtonProps } from './Button';
import CloneButton from './CloneButton';
import CreateButton from './CreateButton';
import DeleteButton from './DeleteButton';
import DeleteWithConfirmButton from './DeleteWithConfirmButton';
import DeleteWithUndoButton from './DeleteWithUndoButton';
import DeleteButton, { DeleteButtonProps } from './DeleteButton';
import DeleteWithConfirmButton, {
DeleteWithConfirmButtonProps,
} from './DeleteWithConfirmButton';
import DeleteWithUndoButton, {
DeleteWithUndoButtonProps,
} from './DeleteWithUndoButton';
import EditButton from './EditButton';
import ExportButton from './ExportButton';
import ListButton from './ListButton';
Expand All @@ -17,6 +21,13 @@ import SortButton from './SortButton';
import RefreshButton from './RefreshButton';
import RefreshIconButton from './RefreshIconButton';

export type {
ButtonProps,
DeleteButtonProps,
DeleteWithConfirmButtonProps,
DeleteWithUndoButtonProps,
};

export {
BulkDeleteButton,
BulkDeleteWithConfirmButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import PropTypes from 'prop-types';
import Card from '@material-ui/core/Card';
import { makeStyles } from '@material-ui/core/styles';
import classnames from 'classnames';
import { useShowController } from 'ra-core';
import { ShowControllerProps, useShowController } from 'ra-core';

import DefaultActions from './ShowActions';
import TitleForRecord from '../layout/TitleForRecord';
import { ShowProps } from '../types';

/**
* Page component for the Show view
Expand Down Expand Up @@ -52,7 +53,9 @@ import TitleForRecord from '../layout/TitleForRecord';
* );
* export default App;
*/
const Show = props => <ShowView {...props} {...useShowController(props)} />;
const Show = (props: ShowProps) => (
<ShowView {...props} {...useShowController(props)} />
);

Show.propTypes = {
actions: PropTypes.element,
Expand All @@ -69,7 +72,11 @@ Show.propTypes = {
title: PropTypes.node,
};

export const ShowView = props => {
interface ShowViewProps
extends ShowProps,
Omit<ShowControllerProps, 'resource'> {}

export const ShowView = (props: ShowViewProps) => {
const {
actions,
aside,
Expand Down Expand Up @@ -207,6 +214,6 @@ const sanitizeRestProps = ({
permissions,
translate,
...rest
}) => rest;
}: any) => rest;

export default Show;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { Record } from 'ra-core';

import { EditButton } from '../button';
import TopToolbar from '../layout/TopToolbar';
Expand All @@ -12,7 +13,7 @@ const sanitizeRestProps = ({
hasList,
resource,
...rest
}) => rest;
}: any) => rest;

/**
* Action Toolbar for the Show view
Expand All @@ -39,12 +40,27 @@ const sanitizeRestProps = ({
* </Show>
* );
*/
const ShowActions = ({ basePath, className, data, hasEdit, ...rest }) => (
const ShowActions = ({
basePath,
className,
data,
hasEdit,
...rest
}: ShowActionsProps) => (
<TopToolbar className={className} {...sanitizeRestProps(rest)}>
{hasEdit && <EditButton basePath={basePath} record={data} />}
</TopToolbar>
);

export interface ShowActionsProps {
basePath?: string;
className?: string;
data?: Record;
hasEdit?: boolean;
hasList?: boolean;
resource?: string;
}

ShowActions.propTypes = {
basePath: PropTypes.string,
className: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import { Children, isValidElement, cloneElement } from 'react';
import { Children, isValidElement, cloneElement, ReactNode } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Record } from 'ra-core';

import CardContentInner from '../layout/CardContentInner';
import Labeled from '../input/Labeled';
Expand All @@ -16,7 +17,7 @@ const sanitizeRestProps = ({
initialValues,
translate,
...rest
}) => rest;
}: any) => rest;

/**
* Simple Layout for a Show view, showing fields in one column.
Expand Down Expand Up @@ -58,14 +59,14 @@ const SimpleShowLayout = ({
resource,
version,
...rest
}) => (
}: SimpleShowLayoutProps) => (
<CardContentInner
className={className}
key={version}
{...sanitizeRestProps(rest)}
>
{Children.map(children, field =>
field && isValidElement(field) ? (
field && isValidElement<any>(field) ? (
<div
key={field.props.source}
className={classnames(
Expand Down Expand Up @@ -99,6 +100,15 @@ const SimpleShowLayout = ({
</CardContentInner>
);

export interface SimpleShowLayoutProps {
basePath?: string;
className?: string;
children: ReactNode;
record?: Record;
resource?: string;
version?: number;
}

SimpleShowLayout.propTypes = {
basePath: PropTypes.string,
className: PropTypes.string,
Expand Down
Loading