mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 15:44:59 +00:00
Init backend migration
This commit is contained in:
parent
a898a0b300
commit
8aae88bac5
@ -7,7 +7,7 @@ import SelectWrapper from '../SelectWrapper';
|
||||
|
||||
const Form = ({ keys, layout, modifiedData, fieldName, onChange }) => {
|
||||
const currentField = get(layout, ['schema', 'attributes', fieldName], '');
|
||||
const currentFieldMeta = get(layout, ['metadata', fieldName, 'edit'], {});
|
||||
const currentFieldMeta = get(layout, ['metadatas', fieldName, 'edit'], {});
|
||||
|
||||
if (currentField.type === 'relation') {
|
||||
return (
|
||||
|
||||
@ -56,7 +56,7 @@ function Inputs({
|
||||
get(attribute, 'plugin', '') === 'upload' &&
|
||||
(model || collection) === 'file';
|
||||
const multiple = collection == 'file';
|
||||
const metadata = get(layout, ['metadata', name, 'edit'], {});
|
||||
const metadatas = get(layout, ['metadatas', name, 'edit'], {});
|
||||
const type = isMedia ? 'file' : get(attribute, 'type', null);
|
||||
const inputStyle = type === 'text' ? { height: '196px' } : {};
|
||||
const validations = omit(attribute, [
|
||||
@ -68,7 +68,7 @@ function Inputs({
|
||||
'plugin',
|
||||
'enum',
|
||||
]);
|
||||
const { description, visible } = metadata;
|
||||
const { description, visible } = metadatas;
|
||||
const value = get(modifiedData, keys);
|
||||
|
||||
if (visible === false) {
|
||||
@ -78,7 +78,7 @@ function Inputs({
|
||||
|
||||
return (
|
||||
<InputsIndex
|
||||
{...metadata}
|
||||
{...metadatas}
|
||||
autoFocus={autoFocus}
|
||||
didCheckErrors={didCheckErrors}
|
||||
errors={inputErrors}
|
||||
|
||||
@ -382,7 +382,11 @@ function EditView({
|
||||
{fields.map((fieldsRow, key) => {
|
||||
const [{ name }] = fieldsRow;
|
||||
const group = get(layout, ['schema', 'attributes', name], {});
|
||||
const groupMeta = get(layout, ['metadata', name, 'edit'], {});
|
||||
const groupMetas = get(
|
||||
layout,
|
||||
['metadatas', name, 'edit'],
|
||||
{}
|
||||
);
|
||||
const groupValue = get(
|
||||
modifiedData,
|
||||
[name],
|
||||
@ -393,7 +397,7 @@ function EditView({
|
||||
return (
|
||||
<Group
|
||||
{...group}
|
||||
{...groupMeta}
|
||||
{...groupMetas}
|
||||
addField={keys => {
|
||||
dispatch({
|
||||
type: 'ADD_FIELD_TO_GROUP',
|
||||
@ -475,7 +479,7 @@ function EditView({
|
||||
);
|
||||
const relationMetas = get(
|
||||
layout,
|
||||
['metadata', relationName, 'edit'],
|
||||
['metadatas', relationName, 'edit'],
|
||||
{}
|
||||
);
|
||||
const value = get(modifiedData, [relationName], null);
|
||||
@ -486,7 +490,7 @@ function EditView({
|
||||
{...relationMetas}
|
||||
key={relationName}
|
||||
name={relationName}
|
||||
relationType={relation.relationType}
|
||||
relationsType={relation.relationType}
|
||||
value={value}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -119,7 +119,7 @@ function ListView({
|
||||
|
||||
// Helpers
|
||||
const getMetaDatas = (path = []) =>
|
||||
get(layouts, [slug, 'metadata', ...path], {});
|
||||
get(layouts, [slug, 'metadatas', ...path], {});
|
||||
const getListLayout = () => get(layouts, [slug, 'layouts', 'list'], []);
|
||||
const getAllLabels = () => {
|
||||
return sortBy(
|
||||
|
||||
@ -37,7 +37,7 @@ function ListLayout({
|
||||
};
|
||||
|
||||
const fieldName = displayedData[fieldToEditIndex];
|
||||
const fieldPath = ['metadata', fieldName, 'list'];
|
||||
const fieldPath = ['metadatas', fieldName, 'list'];
|
||||
|
||||
const form = [
|
||||
{
|
||||
@ -108,7 +108,7 @@ function ListLayout({
|
||||
name={data}
|
||||
label={get(
|
||||
modifiedData,
|
||||
['metadata', data, 'list', 'label'],
|
||||
['metadatas', data, 'list', 'label'],
|
||||
''
|
||||
)}
|
||||
onClick={onClick}
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
"errors": [],
|
||||
"inputDescription": { "id": "content-manager.form.Input.pageEntries.inputDescription" },
|
||||
"name": "settings.pageSize",
|
||||
"selectOptions": ["10", "20", "50", "100"],
|
||||
"selectOptions": [10, 20, 50, 100],
|
||||
"type": "select",
|
||||
"validations": {}
|
||||
},
|
||||
|
||||
@ -2,7 +2,7 @@ import React, { memo, useEffect, useCallback, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators, compose } from 'redux';
|
||||
import { get, isEqual, isEmpty, upperFirst } from 'lodash';
|
||||
import { get, isEqual, upperFirst } from 'lodash';
|
||||
|
||||
import {
|
||||
BackHeader,
|
||||
@ -165,6 +165,7 @@ function SettingViewModel({
|
||||
get(modifiedData, ['layouts', 'list'], []);
|
||||
const getEditRemainingFields = () => {
|
||||
const attributes = getAttributes();
|
||||
const metadatas = get(modifiedData, ['metadatas'], {});
|
||||
const displayedFields = getEditLayout().reduce(
|
||||
(acc, curr) => [...acc, ...curr.rowContent],
|
||||
[]
|
||||
@ -172,6 +173,7 @@ function SettingViewModel({
|
||||
|
||||
return Object.keys(attributes)
|
||||
.filter(attr => get(attributes, [attr, 'type'], '') !== 'relation')
|
||||
.filter(attr => get(metadatas, [attr, 'edit', 'visible'], false) === true)
|
||||
.filter(attr => {
|
||||
return displayedFields.findIndex(el => el.name === attr) === -1;
|
||||
});
|
||||
@ -185,10 +187,15 @@ function SettingViewModel({
|
||||
.filter(attr => displayedFields.indexOf(attr) === -1);
|
||||
};
|
||||
const getListRemainingFields = () => {
|
||||
const metadata = get(modifiedData, ['metadata'], {});
|
||||
const metadatas = get(modifiedData, ['metadatas'], {});
|
||||
const attributes = getAttributes();
|
||||
|
||||
return Object.keys(metadata)
|
||||
.filter(key => !isEmpty(get(modifiedData, ['metadata', key, 'list'])))
|
||||
return Object.keys(metadatas)
|
||||
.filter(key => {
|
||||
const type = get(attributes, [key, 'type'], '');
|
||||
|
||||
return !['json', 'relation', 'group'].includes(type) && !!type;
|
||||
})
|
||||
.filter(field => {
|
||||
return !getListDisplayedFields().includes(field);
|
||||
});
|
||||
|
||||
@ -9,13 +9,17 @@ import { getDataSucceeded, submitSucceeded } from './actions';
|
||||
import { GET_DATA, ON_SUBMIT } from './constants';
|
||||
import { makeSelectModifiedData } from './selectors';
|
||||
|
||||
const getRequestUrl = path => `/${pluginId}/fixtures/${path}`;
|
||||
const getRequestUrl = path => `/${pluginId}/${path}`;
|
||||
|
||||
export function* getData({ uid }) {
|
||||
try {
|
||||
const { layout } = yield call(request, getRequestUrl(`layouts/${uid}`), {
|
||||
method: 'GET',
|
||||
});
|
||||
const { data: layout } = yield call(
|
||||
request,
|
||||
getRequestUrl(`content-types/${uid}`),
|
||||
{
|
||||
method: 'GET',
|
||||
}
|
||||
);
|
||||
|
||||
yield put(getDataSucceeded(layout));
|
||||
} catch (err) {
|
||||
@ -29,7 +33,9 @@ export function* submit({ emitEvent, uid }) {
|
||||
// We need to send the unformated edit layout
|
||||
set(body, 'layouts.edit', unformatLayout(body.layouts.edit));
|
||||
|
||||
yield call(request, getRequestUrl(`layouts/${uid}`), {
|
||||
delete body.schema;
|
||||
|
||||
yield call(request, getRequestUrl(`content-types/${uid}`), {
|
||||
method: 'PUT',
|
||||
body,
|
||||
});
|
||||
|
||||
@ -27,6 +27,7 @@ ListRow.propTypes = {
|
||||
name: PropTypes.string,
|
||||
push: PropTypes.func,
|
||||
type: PropTypes.string,
|
||||
// uid: PropTypes.string,
|
||||
};
|
||||
|
||||
export default memo(ListRow);
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"customBootstrapClass": "col-md-4",
|
||||
"didCheckErrors": false,
|
||||
"errors": [],
|
||||
"name": "search",
|
||||
"name": "searchable",
|
||||
"type": "toggle",
|
||||
"validations": {}
|
||||
},
|
||||
@ -13,7 +13,7 @@
|
||||
"customBootstrapClass": "col-md-4",
|
||||
"didCheckErrors": false,
|
||||
"errors": [],
|
||||
"name": "filters",
|
||||
"name": "filterable",
|
||||
"type": "toggle",
|
||||
"validations": {}
|
||||
},
|
||||
@ -33,7 +33,7 @@
|
||||
"errors": [],
|
||||
"inputDescription": { "id": "content-manager.form.Input.pageEntries.inputDescription" },
|
||||
"name": "pageSize",
|
||||
"selectOptions": ["10", "20", "50", "100"],
|
||||
"selectOptions": [10, 20, 50, 100],
|
||||
"type": "select",
|
||||
"validations": {}
|
||||
}
|
||||
|
||||
@ -59,7 +59,8 @@ function SettingsView({
|
||||
if (showWarningSubmit) {
|
||||
toggleWarningSubmit();
|
||||
}
|
||||
}, [shouldToggleModalSubmit, showWarningSubmit]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [shouldToggleModalSubmit]);
|
||||
useEffect(() => {
|
||||
if (isEmpty(initialData)) {
|
||||
getData();
|
||||
|
||||
@ -7,16 +7,21 @@ import { getDataSucceeded, submitSucceeded } from './actions';
|
||||
import { GET_DATA, ON_SUBMIT } from './constants';
|
||||
import { makeSelectModifiedData } from './selectors';
|
||||
|
||||
const getRequestUrl = path => `/${pluginId}/fixtures/${path}`;
|
||||
const getRequestUrl = path => `/${pluginId}/${path}`;
|
||||
|
||||
export function* getData() {
|
||||
try {
|
||||
const [{ generalSettings }, { groups }, { models }] = yield all(
|
||||
['general-settings', 'groups', 'models'].map(endPoint =>
|
||||
const [
|
||||
{ data: generalSettings },
|
||||
{ data: groups },
|
||||
{ data: models },
|
||||
] = yield all(
|
||||
// const data = yield all(
|
||||
['general-settings', 'groups', 'content-types'].map(endPoint =>
|
||||
call(request, getRequestUrl(endPoint), { method: 'GET' })
|
||||
)
|
||||
);
|
||||
|
||||
// console.log({ data });
|
||||
yield put(getDataSucceeded(generalSettings, groups, models));
|
||||
} catch (err) {
|
||||
strapi.notification.error('content-manager.error.model.fetch');
|
||||
|
||||
@ -5,18 +5,15 @@ import pluginId from '../pluginId';
|
||||
|
||||
async function didGetSecuredData() {
|
||||
const { updatePlugin } = this.props;
|
||||
const requestURL = `/${pluginId}/fixtures/models`;
|
||||
const requestURL = `/${pluginId}/content-types`;
|
||||
|
||||
try {
|
||||
const { models } = await request(requestURL, { method: 'GET' });
|
||||
const { data } = await request(requestURL, { method: 'GET' });
|
||||
|
||||
const menu = [
|
||||
{
|
||||
name: 'Content Types',
|
||||
links: models,
|
||||
// links: map(omit(models, 'plugins'), (model, key) => ({
|
||||
// label: model.labelPlural || model.label || key,
|
||||
// destination: key,
|
||||
// })),
|
||||
links: data,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user