Fix functional feedback

This commit is contained in:
soupette 2019-12-06 16:40:50 +01:00
parent 4cc805a037
commit c81624bda1
6 changed files with 39 additions and 47 deletions

View File

@ -2,7 +2,7 @@
"connection": "default",
"collectionName": "my_super_content_type",
"info": {
"name": "My super content type ⚠️"
"name": "My super content type"
},
"attributes": {
"name": {

View File

@ -59,11 +59,11 @@ function LeftMenuList({ customLink, links, title }) {
return links.map(link => {
return {
...link,
links: matchSorter(link.links, search, { keys: ['name'] }),
links: matchSorter(link.links, search, { keys: ['title'] }),
};
});
}
return matchSorter(links, search, { keys: ['name'] });
return matchSorter(links, search, { keys: ['title'] });
};
const getTitle = () =>

View File

@ -1,6 +1,6 @@
import React, { memo, useEffect, useReducer, useState, useRef } from 'react';
import PropTypes from 'prop-types';
import { get, groupBy, set, size, sortBy } from 'lodash';
import { camelCase, get, groupBy, set, size, sortBy } from 'lodash';
import {
request,
LoadingIndicatorPage,
@ -349,7 +349,7 @@ const DataManagerProvider = ({ allIcons, children }) => {
to: `/plugins/${pluginId}/content-types/${uid}`,
}))
.filter(obj => obj !== null),
obj => obj.title
obj => camelCase(obj.title)
);
const shouldRedirect = () => {

View File

@ -401,20 +401,9 @@ const reducer = (state, action) => {
...pathToAttributes,
attributeToRemoveName,
];
console.log(
pathToAttributeToRemove,
state.getIn([
'modifiedData',
'contentType',
'schema',
'attributes',
'price_range',
])
);
// return state;
const attributeToRemoveData = state.getIn(pathToAttributeToRemove);
// console.log(attributeToRemoveData);
// return state;
const isRemovingRelationAttribute =
attributeToRemoveData.get('nature') !== undefined;
// Only content types can have relations that with themselves since
@ -452,11 +441,11 @@ const reducer = (state, action) => {
// Reset the state with the initial data
// All created components and content types will be lost
// if (!action.hasJustCreatedSchema) {
// newState = newState
// .update('components', () => state.get('initialComponents'))
// .update('contentTypes', () => state.get('initialContentTypes'));
// }
if (!action.hasJustCreatedSchema) {
newState = newState
.update('components', () => state.get('initialComponents'))
.update('contentTypes', () => state.get('initialContentTypes'));
}
return newState;
}

View File

@ -1,5 +1,6 @@
import { fromJS } from 'immutable';
import pluralize from 'pluralize';
import { snakeCase } from 'lodash';
import makeUnique from '../../utils/makeUnique';
import { createComponentUid } from './utils/createUid';
import {
@ -52,7 +53,7 @@ const reducer = (state, action) => {
return null;
})
.update('name', oldValue => {
return pluralize(oldValue, shouldPluralizeName(value));
return pluralize(snakeCase(oldValue), shouldPluralizeName(value));
})
.update('targetAttribute', oldValue => {
if (['oneWay', 'manyWay'].includes(value)) {
@ -61,7 +62,7 @@ const reducer = (state, action) => {
return pluralize(
oldValue === '-'
? oneThatIsCreatingARelationWithAnother
? snakeCase(oneThatIsCreatingARelationWithAnother)
: oldValue,
shouldPluralizeTargetAttribute(value)
);
@ -80,7 +81,7 @@ const reducer = (state, action) => {
.update('target', () => value)
.update('name', () => {
return pluralize(
selectedContentTypeFriendlyName,
snakeCase(selectedContentTypeFriendlyName),
shouldPluralizeName(obj.get('nature'))
);
})
@ -90,7 +91,7 @@ const reducer = (state, action) => {
}
return pluralize(
oneThatIsCreatingARelationWithAnother,
snakeCase(oneThatIsCreatingARelationWithAnother),
shouldPluralizeTargetAttribute(obj.get('nature'))
);
});
@ -187,7 +188,7 @@ const reducer = (state, action) => {
dataToSet = { type: 'enumeration', enum: [] };
} else if (attributeType === 'relation') {
dataToSet = {
name: nameToSetForRelation,
name: snakeCase(nameToSetForRelation),
nature: 'oneWay',
targetAttribute: '-',
target: targetUid,

View File

@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { Prompt, useHistory, useLocation } from 'react-router-dom';
import PropTypes from 'prop-types';
import { get, isEqual } from 'lodash';
import { get, has, isEqual } from 'lodash';
import {
BackHeader,
ListWrapper,
@ -67,6 +67,7 @@ const ListPage = () => {
[firstMainDataPath, 'schema', 'name'],
''
);
const isFromPlugin = has(initialData, [firstMainDataPath, 'plugin']);
const hasModelBeenModified = !isEqual(modifiedData, initialData);
const forTarget = isInContentTypeView ? 'contentType' : 'component';
@ -211,25 +212,26 @@ const ListPage = () => {
: [],
title: {
label,
cta: isInDevelopmentMode
? {
icon: 'pencil-alt',
onClick: async () => {
await wait();
cta:
isInDevelopmentMode && !isFromPlugin
? {
icon: 'pencil-alt',
onClick: async () => {
await wait();
push({
search: makeSearch({
modalType: firstMainDataPath,
actionType: 'edit',
settingType: 'base',
forTarget: firstMainDataPath,
targetUid,
headerDisplayName: label,
}),
});
},
}
: null,
push({
search: makeSearch({
modalType: firstMainDataPath,
actionType: 'edit',
settingType: 'base',
forTarget: firstMainDataPath,
targetUid,
headerDisplayName: label,
}),
});
},
}
: null,
},
content: getDescription(),
};