mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 16:16:20 +00:00
RelationInputWrapper: Move publication states into a constant
This commit is contained in:
parent
535dfc9dee
commit
6ff74c9455
@ -6,6 +6,7 @@ import { RelationInput, useCMEditViewDataManager, NotAllowedInput } from '@strap
|
||||
|
||||
import { useRelation } from '../../hooks/useRelation';
|
||||
import { connect, select, normalizeRelations } from './utils';
|
||||
import { PUBLICATION_STATES } from './constants';
|
||||
|
||||
export const RelationInputWrapper = ({
|
||||
editable,
|
||||
@ -97,12 +98,12 @@ export const RelationInputWrapper = ({
|
||||
onSearch={() => handleSearch()}
|
||||
onSearchNextPage={() => handleSearchMore()}
|
||||
publicationStateTranslations={{
|
||||
draft: formatMessage({
|
||||
[PUBLICATION_STATES.DRAFT]: formatMessage({
|
||||
id: 'tbd',
|
||||
defaultMessage: 'Draft',
|
||||
}),
|
||||
|
||||
published: formatMessage({
|
||||
[PUBLICATION_STATES.PUBLISHED]: formatMessage({
|
||||
id: 'tbd',
|
||||
defaultMessage: 'Published',
|
||||
}),
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
export const PUBLICATION_STATES = {
|
||||
DRAFT: 'draft',
|
||||
PUBLISHED: 'published',
|
||||
};
|
||||
@ -1,5 +1,7 @@
|
||||
import { getRelationLink } from './getRelationLink';
|
||||
|
||||
import { PUBLICATION_STATES } from '../constants';
|
||||
|
||||
export const normalizeRelations = (
|
||||
relations,
|
||||
{ deletions = [], shouldAddLink = false, mainFieldName, targetModel }
|
||||
@ -23,7 +25,9 @@ export const normalizeRelations = (
|
||||
nextRelation.publicationState = false;
|
||||
|
||||
if (nextRelation?.publishedAt !== undefined) {
|
||||
nextRelation.publicationState = nextRelation.publishedAt ? 'published' : 'draft';
|
||||
nextRelation.publicationState = nextRelation.publishedAt
|
||||
? PUBLICATION_STATES.PUBLISHED
|
||||
: PUBLICATION_STATES.DRAFT;
|
||||
}
|
||||
|
||||
nextRelation.mainField = nextRelation[mainFieldName];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user