Skip to content

Commit

Permalink
Merge pull request #6200 from marmelab/export-actions-props-interfaces
Browse files Browse the repository at this point in the history
[TypeScript] Fix view action component types aren't exported
  • Loading branch information
fzaninotto authored Apr 22, 2021
2 parents 7aee34e + 33c9cdb commit 8f122fd
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
14 changes: 9 additions & 5 deletions packages/ra-ui-materialui/src/detail/CreateActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { useCreateContext, useResourceDefinition } from 'ra-core';
* </Create>
* );
*/
const CreateActions = ({ className, ...rest }: CreateActionsProps) => {
export const CreateActions = ({ className, ...rest }: CreateActionsProps) => {
const { basePath } = useCreateContext(rest);
const { hasList } = useResourceDefinition(rest);
return (
Expand All @@ -48,18 +48,22 @@ const sanitizeRestProps = ({
...rest
}) => rest;

interface CreateActionsProps {
export interface CreateActionsProps {
basePath?: string;
className?: string;
hasShow?: boolean;
hasCreate?: boolean;
hasEdit?: boolean;
hasList?: boolean;
hasShow?: boolean;
resource?: string;
}

CreateActions.propTypes = {
basePath: PropTypes.string,
className: PropTypes.string,
hasCreate: PropTypes.bool,
hasEdit: PropTypes.bool,
hasShow: PropTypes.bool,
hasList: PropTypes.bool,
resource: PropTypes.string,
};

export default CreateActions;
11 changes: 7 additions & 4 deletions packages/ra-ui-materialui/src/detail/EditActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import TopToolbar from '../layout/TopToolbar';
* </Edit>
* );
*/
const EditActions = ({ className, ...rest }: EditActionsProps) => {
export const EditActions = ({ className, ...rest }: EditActionsProps) => {
const { basePath, record } = useEditContext(rest);
const { hasShow } = useResourceDefinition(rest);

Expand All @@ -54,17 +54,20 @@ export interface EditActionsProps {
basePath?: string;
className?: string;
data?: Record;
hasShow?: boolean;
hasCreate?: boolean;
hasEdit?: boolean;
hasList?: boolean;
hasShow?: boolean;
resource?: string;
}

EditActions.propTypes = {
basePath: PropTypes.string,
className: PropTypes.string,
data: PropTypes.object,
hasCreate: PropTypes.bool,
hasEdit: PropTypes.bool,
hasShow: PropTypes.bool,
hasList: PropTypes.bool,
resource: PropTypes.string,
};

export default EditActions;
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/detail/EditView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useEditContext,
} from 'ra-core';

import DefaultActions from './EditActions';
import { EditActions as DefaultActions } from './EditActions';
import TitleForRecord from '../layout/TitleForRecord';
import { EditProps } from '../types';

Expand Down
8 changes: 5 additions & 3 deletions packages/ra-ui-materialui/src/detail/ShowActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const sanitizeRestProps = ({
* </Show>
* );
*/
const ShowActions = ({ className, ...rest }: ShowActionsProps) => {
export const ShowActions = ({ className, ...rest }: ShowActionsProps) => {
const { basePath, record } = useShowContext(rest);
const { hasEdit } = useResourceDefinition(rest);
return (
Expand All @@ -53,7 +53,9 @@ export interface ShowActionsProps {
basePath?: string;
className?: string;
data?: Record;
hasCreate?: boolean;
hasEdit?: boolean;
hasShow?: boolean;
hasList?: boolean;
resource?: string;
}
Expand All @@ -62,9 +64,9 @@ ShowActions.propTypes = {
basePath: PropTypes.string,
className: PropTypes.string,
data: PropTypes.object,
hasCreate: PropTypes.bool,
hasEdit: PropTypes.bool,
hasShow: PropTypes.bool,
hasList: PropTypes.bool,
resource: PropTypes.string,
};

export default ShowActions;
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/detail/ShowView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useShowContext,
} from 'ra-core';

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

Expand Down
11 changes: 4 additions & 7 deletions packages/ra-ui-materialui/src/detail/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
import { Create } from './Create';
import { CreateView } from './CreateView';
import CreateActions from './CreateActions';
import { Edit } from './Edit';
import { EditView } from './EditView';
import EditActions, { EditActionsProps } from './EditActions';
import EditGuesser from './EditGuesser';
import { Show } from './Show';
import { ShowView } from './ShowView';
import ShowActions, { ShowActionsProps } from './ShowActions';
import ShowGuesser from './ShowGuesser';
import SimpleShowLayout, { SimpleShowLayoutProps } from './SimpleShowLayout';

export * from './CreateActions';
export * from './EditActions';
export * from './ShowActions';
export * from './TabbedShowLayout';
export * from './TabbedShowLayoutTabs';
export * from './Tab';

export {
Create,
CreateView,
CreateActions,
Edit,
EditView,
EditActions,
EditGuesser,
Show,
ShowView,
ShowActions,
ShowGuesser,
SimpleShowLayout,
};

export type { EditActionsProps, SimpleShowLayoutProps, ShowActionsProps };
export type { SimpleShowLayoutProps };

0 comments on commit 8f122fd

Please sign in to comment.