Skip to content

Commit

Permalink
Add base react-admin props to components (#25) (#27)
Browse files Browse the repository at this point in the history
* Add base react-admin props to components (#25)

Co-authored-by: Marcin Pycio <[email protected]>

* Build and bump version

Co-authored-by: Marcin Pycio <[email protected]>
Co-authored-by: Marcin Pycio <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2020
1 parent 18ae41d commit f98a41b
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-admin-amplify",
"version": "1.2.2",
"version": "1.2.3",
"description": "AWS Amplify data provider for react-admin.",
"repository": {
"type": "git",
Expand Down
13 changes: 10 additions & 3 deletions src/components/AmplifyAdmin.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Admin } from "react-admin";
import { Admin, AdminProps } from "react-admin";
import { buildAuthProvider, buildDataProvider } from "../providers";
import { Operations } from "../providers/DataProvider";

Expand All @@ -13,10 +13,17 @@ const defaultOptions: AmplifyAdminOptions = {
authGroups: [],
};

export const AmplifyAdmin: React.FC<{
type Props = {
operations: Operations;
options?: AmplifyAdminOptions;
}> = ({ children, operations, options = defaultOptions, ...propsRest }) => {
} & Omit<AdminProps, "authProvider" | "dataProvider">;

export const AmplifyAdmin: React.FC<Props> = ({
children,
operations,
options = defaultOptions,
...propsRest
}) => {
const optionsBag = { ...defaultOptions, ...options };
const { authGroups, storageBucket, storageRegion } = optionsBag;

Expand Down
4 changes: 2 additions & 2 deletions src/components/AmplifyFileField.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import { FileField } from "react-admin";
import { FileField, FileFieldProps } from "react-admin";
import { useStorageField } from "../hooks/useStorageField";

type Props = {
source?: string;
record?: any;
storageOptions?: any;
};
} & FileFieldProps;

export const AmplifyFileField: React.FC<Props> = ({
source,
Expand Down
9 changes: 7 additions & 2 deletions src/components/AmplifyFileInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {
FileInputOptions,
FileInputProps,
} from "ra-ui-materialui/lib/input/FileInput";
import React from "react";
import { FileInput } from "react-admin";
import { FileInput, InputProps } from "react-admin";
import { useStorageInput } from "../hooks/useStorageInput";
import { AmplifyFileField } from "./AmplifyFileField";

Expand All @@ -8,7 +12,8 @@ type Props = {
multiple?: boolean;
options?: any;
storageOptions?: any;
};
} & FileInputProps &
InputProps<FileInputOptions>;

export const AmplifyFileInput: React.FC<Props> = ({
options = {},
Expand Down
13 changes: 10 additions & 3 deletions src/components/AmplifyFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from "react";
import { Filter } from "react-admin";
import { Filter, FilterProps } from "react-admin";

interface Keys {
[index: string]: {
Expand Down Expand Up @@ -62,10 +62,17 @@ function getKeys(filters: React.ReactNodeArray): Keys {
return keys;
}

export const AmplifyFilter: React.FC<{
type Props = {
defaultQuery: string;
setQuery?: React.Dispatch<string>;
}> = ({ children, defaultQuery, setQuery = null, ...propsRest }) => {
} & FilterProps;

export const AmplifyFilter: React.FC<Props> = ({
children,
defaultQuery,
setQuery = null,
...propsRest
}) => {
let filters;

if (children !== null && typeof children === "object") {
Expand Down
4 changes: 2 additions & 2 deletions src/components/AmplifyImageField.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import { ImageField } from "react-admin";
import { ImageField, ImageFieldProps } from "react-admin";
import { useStorageField } from "../hooks/useStorageField";

type Props = {
source?: string;
record?: any;
storageOptions?: any;
};
} & ImageFieldProps;

export const AmplifyImageField: React.FC<Props> = ({
source,
Expand Down
9 changes: 7 additions & 2 deletions src/components/AmplifyImageInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {
FileInputOptions,
FileInputProps,
} from "ra-ui-materialui/lib/input/FileInput";
import React from "react";
import { ImageInput } from "react-admin";
import { ImageInput, InputProps } from "react-admin";
import { useStorageInput } from "../hooks/useStorageInput";
import { AmplifyImageField } from "./AmplifyImageField";

Expand All @@ -8,7 +12,8 @@ type Props = {
multiple?: boolean;
options?: any;
storageOptions?: any;
};
} & FileInputProps &
InputProps<FileInputOptions>;

export const AmplifyImageInput: React.FC<Props> = ({
options = {},
Expand Down
1 change: 0 additions & 1 deletion src/typings.d.ts

This file was deleted.

0 comments on commit f98a41b

Please sign in to comment.