RelationInputWrapper: Move relations to display into a constant

This commit is contained in:
Gustav Hansen 2022-09-07 18:35:23 +02:00
parent ddfaeed2af
commit 1fddf048db
2 changed files with 8 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import { useCMEditViewDataManager, NotAllowedInput } from '@strapi/helper-plugin
import { RelationInput } from '../RelationInput'; import { RelationInput } from '../RelationInput';
import { useRelation } from '../../hooks/useRelation'; import { useRelation } from '../../hooks/useRelation';
import { connect, select, normalizeRelations } from './utils'; import { connect, select, normalizeRelations } from './utils';
import { PUBLICATION_STATES } from './constants'; import { PUBLICATION_STATES, RELATIONS_TO_DISPLAY, SEARCH_RESULTS_TO_DISPLAY } from './constants';
import { getTrad } from '../../utils'; import { getTrad } from '../../utils';
export const RelationInputWrapper = ({ export const RelationInputWrapper = ({
@ -37,7 +37,7 @@ export const RelationInputWrapper = ({
}, },
pageParams: { pageParams: {
...defaultParams, ...defaultParams,
pageSize: 10, pageSize: RELATIONS_TO_DISPLAY,
}, },
}, },
@ -46,7 +46,7 @@ export const RelationInputWrapper = ({
pageParams: { pageParams: {
...defaultParams, ...defaultParams,
entityId: isCreatingEntry ? undefined : initialData.id, entityId: isCreatingEntry ? undefined : initialData.id,
pageSize: 10, pageSize: SEARCH_RESULTS_TO_DISPLAY,
}, },
}, },
}); });
@ -131,7 +131,7 @@ export const RelationInputWrapper = ({
}) })
} }
name={name} name={name}
numberOfRelationsToDisplay={5} numberOfRelationsToDisplay={RELATIONS_TO_DISPLAY}
onRelationAdd={(relation) => handleRelationAdd(relation)} onRelationAdd={(relation) => handleRelationAdd(relation)}
onRelationRemove={(relation) => handleRelationRemove(relation)} onRelationRemove={(relation) => handleRelationRemove(relation)}
onRelationLoadMore={() => handleRelationLoadMore()} onRelationLoadMore={() => handleRelationLoadMore()}

View File

@ -2,3 +2,7 @@ export const PUBLICATION_STATES = {
DRAFT: 'draft', DRAFT: 'draft',
PUBLISHED: 'published', PUBLISHED: 'published',
}; };
export const RELATIONS_TO_DISPLAY = 5;
export const SEARCH_RESULTS_TO_DISPLAY = 10;