Merge pull request #14400 from strapi/relations/proptypes-fix

[RelationInput] fix proptypes
This commit is contained in:
Gustav Hansen 2022-09-13 16:08:20 +02:00 committed by GitHub
commit 5710491285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 14 deletions

View File

@ -156,7 +156,7 @@ const RelationInput = ({
inputId={id}
isSearchable
isClear
loadingMessage={() => loadingMessage}
loadingMessage={loadingMessage}
onChange={(relation) => {
setValue(null);
onRelationAdd(relation);

View File

@ -50,5 +50,5 @@ Relation.propTypes = {
search: PropTypes.node,
loadMore: PropTypes.node,
size: PropTypes.number.isRequired,
totalNumberOfRelations: PropTypes.string,
totalNumberOfRelations: PropTypes.number,
};

View File

@ -19,34 +19,34 @@ const ShadowBox = styled(Box)`
&:before {
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
content: ${({ overflow }) =>
overflow === 'top-bottom' || overflow === 'top' ? "''" : undefined};
content: ${({ overflowDirection }) =>
overflowDirection === 'top-bottom' || overflowDirection === 'top' ? "''" : undefined};
background: linear-gradient(rgba(33, 33, 52, 0.1) 0%, rgba(0, 0, 0, 0) 100%);
top: 0;
}
&:after {
/* TODO: as for DS Table component we would need this to be handled by the DS theme */
content: ${({ overflow }) =>
overflow === 'top-bottom' || overflow === 'bottom' ? "''" : undefined};
content: ${({ overflowDirection }) =>
overflowDirection === 'top-bottom' || overflowDirection === 'bottom' ? "''" : undefined};
background: linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(33, 33, 52, 0.1) 100%);
bottom: 0;
}
`;
export const RelationList = ({ children, ...props }) => {
export const RelationList = ({ children, overflow, ...props }) => {
return (
<ShadowBox {...props}>
<ShadowBox overflowDirection={overflow} {...props}>
<Stack spacing={1}>{children}</Stack>
</ShadowBox>
);
};
RelationList.defaultProps = {
overflow: undefined,
overflow: '',
};
RelationList.propTypes = {
children: PropTypes.node.isRequired,
overflow: PropTypes.oneOf(['top-bottom', 'bottom', 'top']),
overflow: PropTypes.oneOf(['top-bottom', 'bottom', 'top', '']),
};

View File

@ -18,7 +18,7 @@ const setup = (props) =>
describe('Content-Manager || RelationInput || Option', () => {
it('should render custom Option with published state title', () => {
setup({ options: [{ mainField: 'relation 1', publicationState: 'published' }] });
setup({ options: [{ id: 1, mainField: 'relation 1', publicationState: 'published' }] });
act(() => {
fireEvent.mouseDown(screen.getByRole('button'));
@ -29,7 +29,7 @@ describe('Content-Manager || RelationInput || Option', () => {
});
it('should render custom Option with draft state title', () => {
setup({ options: [{ mainField: 'relation 1', publicationState: 'draft' }] });
setup({ options: [{ id: 1, mainField: 'relation 1', publicationState: 'draft' }] });
act(() => {
fireEvent.mouseDown(screen.getByRole('button'));

View File

@ -63,7 +63,7 @@ const setup = (props) =>
name="some-relation-1"
label="Some Relation"
labelLoadMore="Load more"
loadingMessage="Relations are loading"
loadingMessage={() => 'Relations are loading'}
numberOfRelationsToDisplay={5}
onRelationAdd={() => jest.fn()}
onSearchOpen={() => jest.fn()}
@ -79,6 +79,7 @@ const setup = (props) =>
}}
relations={FIXTURES_RELATIONS}
searchResults={FIXTURES_SEARCH}
size={8}
{...props}
/>
</IntlProvider>

View File

@ -584,7 +584,6 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] =
>
<div
class="c16"
overflow=""
>
<div
class="c4 c5"