mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 00:29:51 +00:00
Remove useless code
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
138ba1c2de
commit
cf3d87d69a
@ -9,7 +9,6 @@ import { get } from 'lodash';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import List from '../List';
|
import List from '../List';
|
||||||
import useDataManager from '../../hooks/useDataManager';
|
import useDataManager from '../../hooks/useDataManager';
|
||||||
// import convertAttrObjToArray from '../../utils/convertAttrObjToArray';
|
|
||||||
import Td from '../Td';
|
import Td from '../Td';
|
||||||
|
|
||||||
function ComponentList({
|
function ComponentList({
|
||||||
@ -35,7 +34,6 @@ function ComponentList({
|
|||||||
<List
|
<List
|
||||||
customRowComponent={customRowComponent}
|
customRowComponent={customRowComponent}
|
||||||
dzName={dzName}
|
dzName={dzName}
|
||||||
// items={convertAttrObjToArray(attributes)}
|
|
||||||
items={attributes}
|
items={attributes}
|
||||||
targetUid={component}
|
targetUid={component}
|
||||||
mainTypeName={mainTypeName}
|
mainTypeName={mainTypeName}
|
||||||
|
|||||||
@ -22,9 +22,6 @@ import makeUnique from '../../utils/makeUnique';
|
|||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
import FormModal from '../FormModal';
|
import FormModal from '../FormModal';
|
||||||
import createDataObject from './utils/createDataObject';
|
import createDataObject from './utils/createDataObject';
|
||||||
// import createModifiedDataSchema, {
|
|
||||||
// orderAllDataAttributesWithImmutable,
|
|
||||||
// } from './utils/createModifiedDataSchema';
|
|
||||||
import createModifiedDataSchema from './utils/createModifiedDataSchema';
|
import createModifiedDataSchema from './utils/createModifiedDataSchema';
|
||||||
import retrieveSpecificInfoFromComponents from './utils/retrieveSpecificInfoFromComponents';
|
import retrieveSpecificInfoFromComponents from './utils/retrieveSpecificInfoFromComponents';
|
||||||
import retrieveComponentsFromSchema from './utils/retrieveComponentsFromSchema';
|
import retrieveComponentsFromSchema from './utils/retrieveComponentsFromSchema';
|
||||||
@ -121,17 +118,9 @@ const DataManagerProvider = ({
|
|||||||
const formattedComponents = formatSchemas(components);
|
const formattedComponents = formatSchemas(components);
|
||||||
const contentTypes = createDataObject(contentTypesArray);
|
const contentTypes = createDataObject(contentTypesArray);
|
||||||
const formattedContentTypes = formatSchemas(contentTypes);
|
const formattedContentTypes = formatSchemas(contentTypes);
|
||||||
// const orderedComponents = orderAllDataAttributesWithImmutable({
|
|
||||||
// components,
|
|
||||||
// });
|
|
||||||
// const orderedContenTypes = orderAllDataAttributesWithImmutable({
|
|
||||||
// components: contentTypes,
|
|
||||||
// });
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: GET_DATA_SUCCEEDED,
|
type: GET_DATA_SUCCEEDED,
|
||||||
// components: orderedComponents.get('components'),
|
|
||||||
// contentTypes: orderedContenTypes.get('components'),
|
|
||||||
components: formattedComponents,
|
components: formattedComponents,
|
||||||
contentTypes: formattedContentTypes,
|
contentTypes: formattedContentTypes,
|
||||||
reservedNames,
|
reservedNames,
|
||||||
@ -415,15 +404,12 @@ const DataManagerProvider = ({
|
|||||||
isInContentTypeView
|
isInContentTypeView
|
||||||
);
|
);
|
||||||
|
|
||||||
// const dataShape = orderAllDataAttributesWithImmutable(newSchemaToSet, isInContentTypeView);
|
|
||||||
|
|
||||||
const hasJustCreatedSchema =
|
const hasJustCreatedSchema =
|
||||||
get(schemaToSet, 'isTemporary', false) &&
|
get(schemaToSet, 'isTemporary', false) &&
|
||||||
size(get(schemaToSet, 'schema.attributes', [])) === 0;
|
size(get(schemaToSet, 'schema.attributes', [])) === 0;
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: SET_MODIFIED_DATA,
|
type: SET_MODIFIED_DATA,
|
||||||
// schemaToSet: dataShape,
|
|
||||||
schemaToSet: newSchemaToSet,
|
schemaToSet: newSchemaToSet,
|
||||||
hasJustCreatedSchema,
|
hasJustCreatedSchema,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,3 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Creates an object of content types from an array
|
||||||
|
* @params {Object[]} arr array of content types
|
||||||
|
* @returns {Object} an object of content types
|
||||||
|
*/
|
||||||
const createDataObject = arr =>
|
const createDataObject = arr =>
|
||||||
arr.reduce((acc, current) => {
|
arr.reduce((acc, current) => {
|
||||||
acc[current.uid] = current;
|
acc[current.uid] = current;
|
||||||
|
|||||||
@ -1,6 +1,13 @@
|
|||||||
// import { fromJS, OrderedMap } from 'immutable';
|
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @params {Object} contentTypeSchema
|
||||||
|
* @params {Object[]} retrievedComponents array of components that are used in the content type
|
||||||
|
* @params {Object} allComponentsSchema All app's components
|
||||||
|
* @params {Boolean} isInContentTypeView
|
||||||
|
* @returns {Object} The modifiedData to set in the reducer
|
||||||
|
*/
|
||||||
const createModifiedDataSchema = (
|
const createModifiedDataSchema = (
|
||||||
contentTypeSchema,
|
contentTypeSchema,
|
||||||
retrievedComponents,
|
retrievedComponents,
|
||||||
@ -23,52 +30,4 @@ const createModifiedDataSchema = (
|
|||||||
return schema;
|
return schema;
|
||||||
};
|
};
|
||||||
|
|
||||||
// const orderAllDataAttributesWithImmutable = (allDataSchema, isInContentTypeView) => {
|
|
||||||
// const attributesPath = ['schema', 'attributes'];
|
|
||||||
// const componentsSchema = allDataSchema.components;
|
|
||||||
// const componentsWithImmutableSchema = Object.keys(componentsSchema).reduce((acc, current) => {
|
|
||||||
// const currentSchema = get(componentsSchema, [current], {});
|
|
||||||
|
|
||||||
// const currentAttributes = get(currentSchema, attributesPath, {});
|
|
||||||
|
|
||||||
// const fromJSAttributes = Object.keys(currentAttributes).reduce((acc, current) => {
|
|
||||||
// acc[current] = fromJS(currentAttributes[current]);
|
|
||||||
|
|
||||||
// return acc;
|
|
||||||
// }, {});
|
|
||||||
|
|
||||||
// // TODO refacto
|
|
||||||
// const currentImmutableSchemas = fromJS(currentSchema).setIn(
|
|
||||||
// ['schema', 'attributes'],
|
|
||||||
// fromJS(OrderedMap(fromJSAttributes))
|
|
||||||
// );
|
|
||||||
|
|
||||||
// acc[current] = fromJS(currentImmutableSchemas);
|
|
||||||
|
|
||||||
// return acc;
|
|
||||||
// }, {});
|
|
||||||
// const keyName = isInContentTypeView ? 'contentType' : 'component';
|
|
||||||
// const mainSchema = get(allDataSchema, [keyName], {});
|
|
||||||
// const mainImmutableSchema = fromJS(mainSchema).setIn(
|
|
||||||
// attributesPath,
|
|
||||||
// fromJS(
|
|
||||||
// OrderedMap(
|
|
||||||
// Object.keys(get(mainSchema, attributesPath, {})).reduce((acc, current) => {
|
|
||||||
// acc[current] = fromJS(get(mainSchema, [...attributesPath, current], {}));
|
|
||||||
|
|
||||||
// return acc;
|
|
||||||
// }, {})
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const immutableData = fromJS({
|
|
||||||
// components: componentsWithImmutableSchema,
|
|
||||||
// [keyName]: mainImmutableSchema,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// return immutableData;
|
|
||||||
// };
|
|
||||||
|
|
||||||
export default createModifiedDataSchema;
|
export default createModifiedDataSchema;
|
||||||
// export { orderAllDataAttributesWithImmutable };
|
|
||||||
|
|||||||
@ -1,3 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Format the attributes to array instead of an object
|
||||||
|
* @params {Object} schemas The content types schema
|
||||||
|
* @returns {Object} The formatted content types
|
||||||
|
*/
|
||||||
const formatSchemas = schemas => {
|
const formatSchemas = schemas => {
|
||||||
return Object.keys(schemas).reduce((acc, current) => {
|
return Object.keys(schemas).reduce((acc, current) => {
|
||||||
const schema = schemas[current].schema;
|
const schema = schemas[current].schema;
|
||||||
@ -11,6 +16,11 @@ const formatSchemas = schemas => {
|
|||||||
}, {});
|
}, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @params {Object} Object of attributes
|
||||||
|
* @returns {Object[]} An array of attributes
|
||||||
|
*/
|
||||||
const toAttributesArray = attributes => {
|
const toAttributesArray = attributes => {
|
||||||
return Object.keys(attributes).reduce((acc, current) => {
|
return Object.keys(attributes).reduce((acc, current) => {
|
||||||
acc.push({ ...attributes[current], name: current });
|
acc.push({ ...attributes[current], name: current });
|
||||||
|
|||||||
@ -25,19 +25,6 @@ const data = {
|
|||||||
max: 5,
|
max: 5,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// attributes: {
|
|
||||||
// title: {
|
|
||||||
// type: 'string',
|
|
||||||
// required: true,
|
|
||||||
// },
|
|
||||||
// slide: {
|
|
||||||
// component: 'default.slide',
|
|
||||||
// type: 'component',
|
|
||||||
// repeatable: true,
|
|
||||||
// min: 1,
|
|
||||||
// max: 5,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'default.dish': {
|
'default.dish': {
|
||||||
|
|||||||
@ -6,8 +6,6 @@ import { BackHeader, ListWrapper, useTracking } from '@strapi/helper-plugin';
|
|||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { Header } from '@buffetjs/custom';
|
import { Header } from '@buffetjs/custom';
|
||||||
import ListViewContext from '../../contexts/ListViewContext';
|
import ListViewContext from '../../contexts/ListViewContext';
|
||||||
// import convertAttrObjToArray from '../../utils/convertAttrObjToArray';
|
|
||||||
// import convertAttrObjToArray from '../../utils/convertAttrObjToArray';
|
|
||||||
import getAttributeDisplayedType from '../../utils/getAttributeDisplayedType';
|
import getAttributeDisplayedType from '../../utils/getAttributeDisplayedType';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
import getTrad from '../../utils/getTrad';
|
import getTrad from '../../utils/getTrad';
|
||||||
@ -60,8 +58,6 @@ const ListView = () => {
|
|||||||
|
|
||||||
const attributes = get(modifiedData, mainDataTypeAttributesPath, []);
|
const attributes = get(modifiedData, mainDataTypeAttributesPath, []);
|
||||||
const attributesLength = attributes.length;
|
const attributesLength = attributes.length;
|
||||||
// const attributes = get(modifiedData, mainDataTypeAttributesPath, {});
|
|
||||||
// const attributesLength = Object.keys(attributes).length;
|
|
||||||
const currentDataName = get(initialData, [firstMainDataPath, 'schema', 'name'], '');
|
const currentDataName = get(initialData, [firstMainDataPath, 'schema', 'name'], '');
|
||||||
const isFromPlugin = has(initialData, [firstMainDataPath, 'plugin']);
|
const isFromPlugin = has(initialData, [firstMainDataPath, 'plugin']);
|
||||||
const hasModelBeenModified = !isEqual(modifiedData, initialData);
|
const hasModelBeenModified = !isEqual(modifiedData, initialData);
|
||||||
@ -305,7 +301,6 @@ const ListView = () => {
|
|||||||
<ListWrapper style={{ marginBottom: 80 }}>
|
<ListWrapper style={{ marginBottom: 80 }}>
|
||||||
<ListHeader actions={listActions} title={listTitle} />
|
<ListHeader actions={listActions} title={listTitle} />
|
||||||
<List
|
<List
|
||||||
// items={convertAttrObjToArray(attributes)}
|
|
||||||
items={attributes}
|
items={attributes}
|
||||||
customRowComponent={props => <CustomRow {...props} />}
|
customRowComponent={props => <CustomRow {...props} />}
|
||||||
addComponentToDZ={handleClickAddComponentToDZ}
|
addComponentToDZ={handleClickAddComponentToDZ}
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
const convertAttrObjToArray = attributes => {
|
|
||||||
return Object.keys(attributes).map((key, index) => {
|
|
||||||
return { ...attributes[key], name: key, index };
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default convertAttrObjToArray;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user