mirror of
https://github.com/strapi/strapi.git
synced 2025-11-09 06:40:42 +00:00
Fix plugins.toJS in all plugins
This commit is contained in:
parent
0c01ea2121
commit
4a18512122
@ -184,6 +184,7 @@ export class EditPage extends React.Component {
|
|||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
getSchema = () =>
|
getSchema = () =>
|
||||||
|
/* eslint-disable indent */
|
||||||
this.getSource() !== pluginId
|
this.getSource() !== pluginId
|
||||||
? get(this.props.schema, [
|
? get(this.props.schema, [
|
||||||
'models',
|
'models',
|
||||||
@ -192,6 +193,7 @@ export class EditPage extends React.Component {
|
|||||||
this.getModelName(),
|
this.getModelName(),
|
||||||
])
|
])
|
||||||
: get(this.props.schema, ['models', this.getModelName()]);
|
: get(this.props.schema, ['models', this.getModelName()]);
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
||||||
getPluginHeaderTitle = () => {
|
getPluginHeaderTitle = () => {
|
||||||
if (this.isCreating()) {
|
if (this.isCreating()) {
|
||||||
@ -199,9 +201,15 @@ export class EditPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const title = get(this.getSchema(), 'editDisplay.displayedField');
|
const title = get(this.getSchema(), 'editDisplay.displayedField');
|
||||||
const valueToDisplay = get(this.props.editPage, ['initialRecord', title], null);
|
const valueToDisplay = get(
|
||||||
|
this.props.editPage,
|
||||||
|
['initialRecord', title],
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
return isEmpty(toString(valueToDisplay)) ? null : truncate(valueToDisplay, { length: '24', separator: '.' });
|
return isEmpty(toString(valueToDisplay))
|
||||||
|
? null
|
||||||
|
: truncate(valueToDisplay, { length: '24', separator: '.' });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -436,7 +444,12 @@ export class EditPage extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={`${pluginId}.link`} onClick={() => this.context.emitEvent('willEditContentTypeLayoutFromEditView')}>
|
<li
|
||||||
|
key={`${pluginId}.link`}
|
||||||
|
onClick={() =>
|
||||||
|
this.context.emitEvent('willEditContentTypeLayoutFromEditView')
|
||||||
|
}
|
||||||
|
>
|
||||||
<NavLink {...message} url={url} />
|
<NavLink {...message} url={url} />
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
@ -488,7 +501,7 @@ export class EditPage extends React.Component {
|
|||||||
retrieveLinksContainerComponent = () => {
|
retrieveLinksContainerComponent = () => {
|
||||||
// Should be retrieved from the global props (@soupette)
|
// Should be retrieved from the global props (@soupette)
|
||||||
const { plugins } = this.context;
|
const { plugins } = this.context;
|
||||||
const appPlugins = plugins.toJS();
|
const appPlugins = plugins;
|
||||||
const componentToInject = Object.keys(appPlugins).reduce((acc, current) => {
|
const componentToInject = Object.keys(appPlugins).reduce((acc, current) => {
|
||||||
// Retrieve injected compos from plugin
|
// Retrieve injected compos from plugin
|
||||||
// if compo can be injected in left.links area push the compo in the array
|
// if compo can be injected in left.links area push the compo in the array
|
||||||
@ -506,7 +519,12 @@ export class EditPage extends React.Component {
|
|||||||
const Component = compo.component;
|
const Component = compo.component;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={compo.key} onClick={() => this.context.emitEvent('willEditContentTypeFromEditView')}>
|
<li
|
||||||
|
key={compo.key}
|
||||||
|
onClick={() =>
|
||||||
|
this.context.emitEvent('willEditContentTypeFromEditView')
|
||||||
|
}
|
||||||
|
>
|
||||||
<Component {...this} {...compo.props} />
|
<Component {...this} {...compo.props} />
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
@ -639,7 +657,7 @@ export class EditPage extends React.Component {
|
|||||||
actions={this.pluginHeaderActions()}
|
actions={this.pluginHeaderActions()}
|
||||||
subActions={this.pluginHeaderSubActions()}
|
subActions={this.pluginHeaderSubActions()}
|
||||||
title={{ id: this.getPluginHeaderTitle() }}
|
title={{ id: this.getPluginHeaderTitle() }}
|
||||||
titleId="addNewEntry"
|
titleId='addNewEntry'
|
||||||
/>
|
/>
|
||||||
<PopUpWarning
|
<PopUpWarning
|
||||||
isOpen={showWarning}
|
isOpen={showWarning}
|
||||||
@ -650,7 +668,7 @@ export class EditPage extends React.Component {
|
|||||||
cancel: `${pluginId}.popUpWarning.button.cancel`,
|
cancel: `${pluginId}.popUpWarning.button.cancel`,
|
||||||
confirm: `${pluginId}.popUpWarning.button.confirm`,
|
confirm: `${pluginId}.popUpWarning.button.confirm`,
|
||||||
}}
|
}}
|
||||||
popUpWarningType="danger"
|
popUpWarningType='danger'
|
||||||
onConfirm={this.handleConfirm}
|
onConfirm={this.handleConfirm}
|
||||||
/>
|
/>
|
||||||
<PopUpWarning
|
<PopUpWarning
|
||||||
@ -662,10 +680,10 @@ export class EditPage extends React.Component {
|
|||||||
cancel: `${pluginId}.popUpWarning.button.cancel`,
|
cancel: `${pluginId}.popUpWarning.button.cancel`,
|
||||||
confirm: `${pluginId}.popUpWarning.button.confirm`,
|
confirm: `${pluginId}.popUpWarning.button.confirm`,
|
||||||
}}
|
}}
|
||||||
popUpWarningType="danger"
|
popUpWarningType='danger'
|
||||||
onConfirm={this.handleConfirm}
|
onConfirm={this.handleConfirm}
|
||||||
/>
|
/>
|
||||||
<div className="row">
|
<div className='row'>
|
||||||
{this.renderEdit()}
|
{this.renderEdit()}
|
||||||
{this.shouldDisplayedRightSection() && (
|
{this.shouldDisplayedRightSection() && (
|
||||||
<div className={cn('col-lg-3')}>
|
<div className={cn('col-lg-3')}>
|
||||||
@ -765,7 +783,11 @@ const withConnect = connect(
|
|||||||
mapDispatchToProps,
|
mapDispatchToProps,
|
||||||
);
|
);
|
||||||
|
|
||||||
const withReducer = strapi.injectReducer({ key: 'editPage', reducer, pluginId });
|
const withReducer = strapi.injectReducer({
|
||||||
|
key: 'editPage',
|
||||||
|
reducer,
|
||||||
|
pluginId,
|
||||||
|
});
|
||||||
const withSaga = strapi.injectSaga({ key: 'editPage', saga, pluginId });
|
const withSaga = strapi.injectSaga({ key: 'editPage', saga, pluginId });
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
|
|||||||
@ -10,7 +10,12 @@ import {
|
|||||||
submitContentTypeSucceeded,
|
submitContentTypeSucceeded,
|
||||||
submitTempContentTypeSucceeded,
|
submitTempContentTypeSucceeded,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { GET_DATA, DELETE_MODEL, SUBMIT_CONTENT_TYPE, SUBMIT_TEMP_CONTENT_TYPE } from './constants';
|
import {
|
||||||
|
GET_DATA,
|
||||||
|
DELETE_MODEL,
|
||||||
|
SUBMIT_CONTENT_TYPE,
|
||||||
|
SUBMIT_TEMP_CONTENT_TYPE,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
export function* getData() {
|
export function* getData() {
|
||||||
try {
|
try {
|
||||||
@ -26,18 +31,34 @@ export function* getData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* deleteModel({ context: { plugins, updatePlugin }, modelName }) {
|
export function* deleteModel({
|
||||||
|
context: { plugins, updatePlugin },
|
||||||
|
modelName,
|
||||||
|
}) {
|
||||||
try {
|
try {
|
||||||
const requestURL = `/${pluginId}/models/${modelName}`;
|
const requestURL = `/${pluginId}/models/${modelName}`;
|
||||||
const response = yield call(request, requestURL, { method: 'DELETE' }, true);
|
const response = yield call(
|
||||||
|
request,
|
||||||
|
requestURL,
|
||||||
|
{ method: 'DELETE' },
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
if (response.ok === true) {
|
if (response.ok === true) {
|
||||||
strapi.notification.success(`${pluginId}.notification.success.contentTypeDeleted`);
|
strapi.notification.success(
|
||||||
|
`${pluginId}.notification.success.contentTypeDeleted`,
|
||||||
|
);
|
||||||
yield put(deleteModelSucceeded(modelName));
|
yield put(deleteModelSucceeded(modelName));
|
||||||
|
|
||||||
const appPlugins = plugins.toJS ? plugins.toJS() : plugins;
|
const appPlugins = plugins;
|
||||||
const appMenu = get(appPlugins, ['content-manager', 'leftMenuSections'], []);
|
const appMenu = get(
|
||||||
const updatedMenu = appMenu[0].links.filter(el => el.destination !== modelName);
|
appPlugins,
|
||||||
|
['content-manager', 'leftMenuSections'],
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
const updatedMenu = appMenu[0].links.filter(
|
||||||
|
el => el.destination !== modelName,
|
||||||
|
);
|
||||||
appMenu[0].links = sortBy(updatedMenu, 'label');
|
appMenu[0].links = sortBy(updatedMenu, 'label');
|
||||||
updatePlugin('content-manager', 'leftMenuSections', appMenu);
|
updatePlugin('content-manager', 'leftMenuSections', appMenu);
|
||||||
}
|
}
|
||||||
@ -71,12 +92,19 @@ export function* submitCT({
|
|||||||
if (name !== oldContentTypeName) {
|
if (name !== oldContentTypeName) {
|
||||||
emitEvent('didEditNameOfContentType');
|
emitEvent('didEditNameOfContentType');
|
||||||
|
|
||||||
const appPlugins = plugins.toJS ? plugins.toJS() : plugins;
|
const appPlugins = plugins;
|
||||||
const appMenu = get(appPlugins, ['content-manager', 'leftMenuSections'], []);
|
const appMenu = get(
|
||||||
|
appPlugins,
|
||||||
|
['content-manager', 'leftMenuSections'],
|
||||||
|
[],
|
||||||
|
);
|
||||||
const oldContentTypeNameIndex = appMenu[0].links.findIndex(
|
const oldContentTypeNameIndex = appMenu[0].links.findIndex(
|
||||||
el => el.destination === oldContentTypeName,
|
el => el.destination === oldContentTypeName,
|
||||||
);
|
);
|
||||||
const updatedLink = { destination: name.toLowerCase(), label: capitalize(pluralize(name)) };
|
const updatedLink = {
|
||||||
|
destination: name.toLowerCase(),
|
||||||
|
label: capitalize(pluralize(name)),
|
||||||
|
};
|
||||||
appMenu[0].links.splice(oldContentTypeNameIndex, 1, updatedLink);
|
appMenu[0].links.splice(oldContentTypeNameIndex, 1, updatedLink);
|
||||||
appMenu[0].links = sortBy(appMenu[0].links, 'label');
|
appMenu[0].links = sortBy(appMenu[0].links, 'label');
|
||||||
updatePlugin('content-manager', 'leftMenuSections', appMenu);
|
updatePlugin('content-manager', 'leftMenuSections', appMenu);
|
||||||
@ -92,7 +120,10 @@ export function* submitCT({
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore-next */
|
/* istanbul ignore-next */
|
||||||
export function* submitTempCT({ body, context: { emitEvent, plugins, updatePlugin } }) {
|
export function* submitTempCT({
|
||||||
|
body,
|
||||||
|
context: { emitEvent, plugins, updatePlugin },
|
||||||
|
}) {
|
||||||
try {
|
try {
|
||||||
emitEvent('willSaveContentType');
|
emitEvent('willSaveContentType');
|
||||||
|
|
||||||
@ -105,9 +136,16 @@ export function* submitTempCT({ body, context: { emitEvent, plugins, updatePlugi
|
|||||||
yield put(submitTempContentTypeSucceeded());
|
yield put(submitTempContentTypeSucceeded());
|
||||||
|
|
||||||
const { name } = body;
|
const { name } = body;
|
||||||
const appPlugins = plugins.toJS ? plugins.toJS() : plugins;
|
const appPlugins = plugins;
|
||||||
const appMenu = get(appPlugins, ['content-manager', 'leftMenuSections'], []);
|
const appMenu = get(
|
||||||
const newLink = { destination: name.toLowerCase(), label: capitalize(pluralize(name)) };
|
appPlugins,
|
||||||
|
['content-manager', 'leftMenuSections'],
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
const newLink = {
|
||||||
|
destination: name.toLowerCase(),
|
||||||
|
label: capitalize(pluralize(name)),
|
||||||
|
};
|
||||||
appMenu[0].links.push(newLink);
|
appMenu[0].links.push(newLink);
|
||||||
appMenu[0].links = sortBy(appMenu[0].links, 'label');
|
appMenu[0].links = sortBy(appMenu[0].links, 'label');
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class AttributesPickerModal extends React.Component {
|
|||||||
|
|
||||||
getAttributes = () => {
|
getAttributes = () => {
|
||||||
const { plugins } = this.context;
|
const { plugins } = this.context;
|
||||||
const appPlugins = plugins.toJS ? plugins.toJS() : plugins;
|
const appPlugins = plugins;
|
||||||
|
|
||||||
return attributes.filter(attr => {
|
return attributes.filter(attr => {
|
||||||
if (appPlugins.hasOwnProperty('upload')) {
|
if (appPlugins.hasOwnProperty('upload')) {
|
||||||
@ -71,7 +71,9 @@ class AttributesPickerModal extends React.Component {
|
|||||||
const { push } = this.props;
|
const { push } = this.props;
|
||||||
|
|
||||||
emitEvent('didSelectContentTypeFieldType', { type });
|
emitEvent('didSelectContentTypeFieldType', { type });
|
||||||
push({ search: `modalType=attributeForm&attributeType=${type}&settingType=base&actionType=create` });
|
push({
|
||||||
|
search: `modalType=attributeForm&attributeType=${type}&settingType=base&actionType=create`,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
@ -117,9 +119,11 @@ class AttributesPickerModal extends React.Component {
|
|||||||
this.updateNodeToFocus(next);
|
this.updateNodeToFocus(next);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleOnClosed = () => this.setState(prevState => ({ isDisplayed: !prevState.isDisplayed }));
|
handleOnClosed = () =>
|
||||||
|
this.setState(prevState => ({ isDisplayed: !prevState.isDisplayed }));
|
||||||
|
|
||||||
handleOnOpened = () => this.setState(prevState => ({ isDisplayed: !prevState.isDisplayed }));
|
handleOnOpened = () =>
|
||||||
|
this.setState(prevState => ({ isDisplayed: !prevState.isDisplayed }));
|
||||||
|
|
||||||
handleToggle = () => {
|
handleToggle = () => {
|
||||||
const { push } = this.props;
|
const { push } = this.props;
|
||||||
@ -156,9 +160,13 @@ class AttributesPickerModal extends React.Component {
|
|||||||
onOpened={this.handleOnOpened}
|
onOpened={this.handleOnOpened}
|
||||||
>
|
>
|
||||||
<HeaderModal>
|
<HeaderModal>
|
||||||
<HeaderModalTitle title={`${pluginId}.popUpForm.choose.attributes.header.title`} />
|
<HeaderModalTitle
|
||||||
|
title={`${pluginId}.popUpForm.choose.attributes.header.title`}
|
||||||
|
/>
|
||||||
</HeaderModal>
|
</HeaderModal>
|
||||||
<BodyModal style={{ paddingTop: '2.3rem' }}>{attributes.map(this.renderAttribute)}</BodyModal>
|
<BodyModal style={{ paddingTop: '2.3rem' }}>
|
||||||
|
{attributes.map(this.renderAttribute)}
|
||||||
|
</BodyModal>
|
||||||
<FooterModal />
|
<FooterModal />
|
||||||
</WrapperModal>
|
</WrapperModal>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user