mirror of
https://github.com/strapi/strapi.git
synced 2025-07-30 20:39:05 +00:00
console.log removed, mainValue length limited to 50 chars, componentFieldName (string) parameter reorged to componentFieldPath (array)
This commit is contained in:
parent
469ff7e100
commit
7afa200622
@ -14,7 +14,6 @@ import { Loader } from '@strapi/design-system/Loader';
|
||||
import Trash from '@strapi/icons/Trash';
|
||||
import ArrowDown from '@strapi/icons/ArrowDown';
|
||||
import ArrowUp from '@strapi/icons/ArrowUp';
|
||||
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
||||
import { useContentTypeLayout } from '../../../../hooks';
|
||||
import { getTrad } from '../../../../utils';
|
||||
import FieldComponent from '../../../FieldComponent';
|
||||
@ -60,21 +59,12 @@ const Component = ({
|
||||
}) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { getComponentLayout } = useContentTypeLayout();
|
||||
const { modifiedData } = useCMEditViewDataManager();
|
||||
const componentLayoutData = useMemo(() => {
|
||||
const layout = getComponentLayout(componentUid);
|
||||
|
||||
console.log('DZone/Component componentLayoutData', {
|
||||
componentUid,
|
||||
layout,
|
||||
name,
|
||||
index,
|
||||
modifiedData,
|
||||
});
|
||||
|
||||
return layout;
|
||||
}, [componentUid, getComponentLayout, index, name, modifiedData]);
|
||||
const mainValue = useMainValue(componentLayoutData, `${name}.${index}`);
|
||||
}, [componentUid, getComponentLayout]);
|
||||
const mainValue = useMainValue(componentLayoutData, [name, index]);
|
||||
const { icon, friendlyName } = useMemo(() => {
|
||||
const {
|
||||
info: { icon, displayName },
|
||||
|
@ -2,13 +2,15 @@ import { useMemo } from 'react';
|
||||
import { get, toString } from 'lodash';
|
||||
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
||||
|
||||
function useMainValue(schema, componentFieldName) {
|
||||
function useMainValue(schema, componentFieldPath) {
|
||||
const { modifiedData } = useCMEditViewDataManager();
|
||||
|
||||
const mainField = useMemo(() => get(schema, ['settings', 'mainField'], 'id'), [schema]);
|
||||
const displayedValue = toString(
|
||||
get(modifiedData, [...componentFieldName.split('.'), mainField], '')
|
||||
);
|
||||
let displayedValue = toString(get(modifiedData, [...componentFieldPath, mainField], ''));
|
||||
|
||||
if (displayedValue.length > 50) {
|
||||
displayedValue = `${displayedValue.substring(0, 50)}...`;
|
||||
}
|
||||
|
||||
return displayedValue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user