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", "connection": "default",
"collectionName": "my_super_content_type", "collectionName": "my_super_content_type",
"info": { "info": {
"name": "My super content type ⚠️" "name": "My super content type"
}, },
"attributes": { "attributes": {
"name": { "name": {

View File

@ -59,11 +59,11 @@ function LeftMenuList({ customLink, links, title }) {
return links.map(link => { return links.map(link => {
return { return {
...link, ...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 = () => const getTitle = () =>

View File

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

View File

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

View File

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

View File

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