Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed Jun 15, 2019
1 parent 48c45ae commit bbaf62a
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 36 deletions.
6 changes: 5 additions & 1 deletion packages/ra-core/src/controller/EditController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ interface Props {
* export default App;
*/
const EditController = (props: Props) => {
useCheckMinimumRequiredProps('Edit', ['basePath', 'resource', 'children'], props);
useCheckMinimumRequiredProps(
'Edit',
['basePath', 'resource', 'children'],
props
);
const { basePath, children, id, resource, undoable } = props;
const translate = useTranslate();
const dispatch = useDispatch();
Expand Down
6 changes: 5 additions & 1 deletion packages/ra-core/src/controller/ShowController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ interface Props {
* export default App;
*/
const ShowController = (props: Props) => {
useCheckMinimumRequiredProps('Show', ['basePath', 'resource', 'children'], props);
useCheckMinimumRequiredProps(
'Show',
['basePath', 'resource', 'children'],
props
);
const { basePath, children, id, resource } = props;
const translate = useTranslate();
const version = useVersion();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { FunctionComponent, ReactNode, ReactElement } from 'react';
import { Record } from '../../types';
import useReference, { UseReferenceProps, LinkToFunctionType } from './useReference';
import useReference, {
UseReferenceProps,
LinkToFunctionType,
} from './useReference';

interface Props {
allowEmpty?: boolean;
Expand Down
18 changes: 13 additions & 5 deletions packages/ra-ui-materialui/src/field/ReferenceField.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ ReferenceFieldView.propTypes = {
* <ReferenceField label="User" source="userId" reference="users" link={false}>
* <TextField source="name" />
* </ReferenceField>
*
*
* @default
* Alternatively, you can also pass a custom function to `link`. It must take reference and record
* as arguments and return a string
*
*
* @example
* <ReferenceField label="User" source="userId" reference="users" link={(reference, record) => "/path/to/${reference}/${record}"}>
* <TextField source="name" />
* </ReferenceField>
*
*
* @default
* In previous versions of React-Admin, the prop `linkType` was used. It is now deprecated and replaced with `link`. However
* backward-compatibility is still kept
Expand Down Expand Up @@ -168,8 +168,16 @@ ReferenceField.propTypes = {
sortBy: PropTypes.string,
source: PropTypes.string.isRequired,
translateChoice: PropTypes.func,
linkType: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.func]),
link: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.func]).isRequired,
linkType: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
PropTypes.func,
]),
link: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
PropTypes.func,
]).isRequired,
};

ReferenceField.defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-ui-materialui/src/form/TabbedForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class TabbedForm extends Component {
value,
version,
...rest
} = this.props;
} = this.props;

return (
<form
Expand All @@ -115,7 +115,7 @@ export class TabbedForm extends Component {
match,
tabsWithErrors,
},
children,
children
)}
<Divider />
<CardContentInner>
Expand Down
17 changes: 11 additions & 6 deletions packages/ra-ui-materialui/src/form/TabbedFormTabs.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React, { Children, cloneElement, isValidElement } from 'react';
import PropTypes from 'prop-types';
import Tabs from '@material-ui/core/Tabs';
import compose from 'recompose/compose';

const getTabFullPath = (tab, index, baseUrl) =>
`${baseUrl}${
tab.props.path ? `/${tab.props.path}` : index > 0 ? `/${index}` : ''
}`;

const TabbedFormTabs = ({ children, classes, currentLocationPath, match, tabsWithErrors, ...rest }) => {

const TabbedFormTabs = ({
children,
classes,
currentLocationPath,
match,
tabsWithErrors,
...rest
}) => {
const validTabPaths = Children.toArray(children).map((tab, index) =>
getTabFullPath(tab, index, match.url)
);
Expand All @@ -26,7 +31,7 @@ const TabbedFormTabs = ({ children, classes, currentLocationPath, match, tabsWit
: validTabPaths[0];

return (
<Tabs value={tabValue} indicatorColor="primary" {...rest} >
<Tabs value={tabValue} indicatorColor="primary" {...rest}>
{Children.map(children, (tab, index) => {
if (!isValidElement(tab)) return null;

Expand All @@ -41,7 +46,7 @@ const TabbedFormTabs = ({ children, classes, currentLocationPath, match, tabsWit
value: tabPath,
className:
tabsWithErrors.includes(tab.props.label) &&
currentLocationPath !== tabPath
currentLocationPath !== tabPath
? classes.errorTabButton
: null,
});
Expand All @@ -58,4 +63,4 @@ TabbedFormTabs.propTypes = {
tabsWithErrors: PropTypes.arrayOf(PropTypes.string),
};

export default TabbedFormTabs;
export default TabbedFormTabs;
6 changes: 3 additions & 3 deletions packages/ra-ui-materialui/src/form/TabbedFormTabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('<TabbedFormTabs />', () => {
classes={{ errorTabButton: 'error' }}
currentLocationPath={'/posts/12'}
match={{ url: '/posts/12' }}
tabsWithErrors={['tab2']}
tabsWithErrors={['tab2']}
>
<FormTab label="tab1" />
<FormTab label="tab2" />
Expand All @@ -33,7 +33,7 @@ describe('<TabbedFormTabs />', () => {
classes={{ errorTabButton: 'error' }}
currentLocationPath={'/posts/12'}
match={{ url: '/posts/12' }}
tabsWithErrors={['tab1']}
tabsWithErrors={['tab1']}
>
<FormTab label="tab1" />
<FormTab label="tab2" />
Expand All @@ -47,4 +47,4 @@ describe('<TabbedFormTabs />', () => {
assert.equal(tab1.prop('className'), null);
assert.equal(tab2.prop('className'), null);
});
});
});
40 changes: 23 additions & 17 deletions packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ export class AutocompleteArrayInput extends React.Component {
this.updateFilter('');
} else if (!isEqual(choices, this.props.choices)) {
this.setState(({ searchText }) => ({
suggestions: this.limitSuggestions(choices.filter(suggestion =>
inputValueMatcher(
searchText,
suggestion,
this.getSuggestionText
suggestions: this.limitSuggestions(
choices.filter(suggestion =>
inputValueMatcher(
searchText,
suggestion,
this.getSuggestionText
)
)
)),
),
}));
}
}
Expand Down Expand Up @@ -192,13 +194,15 @@ export class AutocompleteArrayInput extends React.Component {
const { choices, inputValueMatcher } = this.props;

this.setState(({ searchText }) => ({
suggestions: this.limitSuggestions(choices.filter(suggestion =>
inputValueMatcher(
searchText,
suggestion,
this.getSuggestionText
suggestions: this.limitSuggestions(
choices.filter(suggestion =>
inputValueMatcher(
searchText,
suggestion,
this.getSuggestionText
)
)
)),
),
}));
};

Expand Down Expand Up @@ -418,11 +422,13 @@ export class AutocompleteArrayInput extends React.Component {
} else {
this.setState({
searchText: value,
suggestions: this.limitSuggestions(choices.filter(choice =>
this.getSuggestionText(choice)
.toLowerCase()
.includes(value.toLowerCase())
)),
suggestions: this.limitSuggestions(
choices.filter(choice =>
this.getSuggestionText(choice)
.toLowerCase()
.includes(value.toLowerCase())
)
),
});
}
}
Expand Down

0 comments on commit bbaf62a

Please sign in to comment.