Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

strapi-plugin-content-manager

Package Overview
Dependencies
Maintainers
1
Versions
276
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strapi-plugin-content-manager - npm Package Compare versions

Comparing version 3.0.0-alpha.11.3 to 3.0.0-alpha.12

admin/build/0.813da0ab1cbe659a22a5.chunk.js

9

admin/src/components/Edit/index.js

@@ -140,2 +140,4 @@ /**

const layout = this.getInputLayout(attr);
const appearance = get(layout, 'appearance');
const type = !isEmpty(appearance) ? appearance.toLowerCase() : get(layout, 'type', getInputType(details.type));

@@ -154,5 +156,6 @@ return (

onChange={this.props.onChange}
placeholder={get(layout, 'placeholder') || details.placeholder}
resetProps={this.props.resetProps}
selectOptions={get(this.props.attributes, [attr, 'enum'])}
placeholder={get(layout, 'placeholder') || details.placeholder}
type={get(layout, 'type', getInputType(details.type))}
type={type}
validations={this.getInputValidations(attr)}

@@ -177,2 +180,3 @@ value={this.props.record[attr]}

record: {},
resetProps: false,
schema: {},

@@ -190,2 +194,3 @@ };

record: PropTypes.object,
resetProps: PropTypes.bool,
schema: PropTypes.object,

@@ -192,0 +197,0 @@ };

@@ -33,4 +33,5 @@ /**

{map(filterRelationsUpload(props.schema.relations), (relation, key) => {
if (relation.nature.toLowerCase().includes('morph') && relation[key]) return '';
const Select = ['oneWay', 'oneToOne', 'manyToOne'].includes(relation.nature) && relation.dominant ? SelectOne : SelectMany;
const Select = ['oneWay', 'oneToOne', 'manyToOne', 'oneToManyMorph', 'oneToOneMorph'].includes(relation.nature) && relation.dominant ? SelectOne : SelectMany;

@@ -37,0 +38,0 @@ return (

@@ -14,2 +14,4 @@ /**

GET_DATA_SUCCEEDED,
GET_LAYOUT,
GET_LAYOUT_SUCCEEDED,
INIT_MODEL_PROPS,

@@ -52,2 +54,16 @@ ON_CANCEL,

export function getLayout(source) {
return {
type: GET_LAYOUT,
source,
};
}
export function getLayoutSucceeded(layout) {
return {
type: GET_LAYOUT_SUCCEEDED,
layout,
};
}
export function initModelProps(modelName, isCreating, source, attributes) {

@@ -54,0 +70,0 @@ const formValidations = getValidationsFromForm(

@@ -10,2 +10,4 @@ /**

export const GET_DATA_SUCCEEDED = 'ContentManager/EditPage/GET_DATA_SUCCEEDED';
export const GET_LAYOUT = 'ContentManager/EditPage/GET_LAYOUT';
export const GET_LAYOUT_SUCCEEDED = 'ContentManager/EditPage/GET_LAYOUT_SUCCEEDED';
export const INIT_MODEL_PROPS = 'ContentManager/EditPage/INIT_MODEL_PROPS';

@@ -12,0 +14,0 @@ export const ON_CANCEL = 'ContentManager/EditPage/ON_CANCEL';

@@ -37,8 +37,6 @@ /**

// Layout
import layout from '../../../../config/layout';
import {
changeData,
getData,
getLayout,
initModelProps,

@@ -64,2 +62,4 @@ onCancel,

this.props.getData(this.props.match.params.id, this.getSource(), mainField);
} else {
this.props.getLayout(this.getSource());
}

@@ -113,3 +113,3 @@

getLayout = () => (
bindLayout.call(this, get(this.context.plugins.toJS(), `${this.getSource()}.layout`, layout))
bindLayout.call(this, this.props.editPage.layout)
)

@@ -220,4 +220,2 @@

layout = bindLayout.call(this, layout);
componentDidCatch(error, info) {

@@ -232,3 +230,4 @@ console.log('err', error);

Object.keys(get(this.getSchema(), 'relations', {})).filter(relation => (
get(this.getSchema(), ['relations', relation, 'plugin']) !== 'upload'
get(this.getSchema(), ['relations', relation, 'plugin']) !== 'upload' &&
(!get(this.getSchema(), ['relations', relation, 'nature'], '').toLowerCase().includes('morph') || !get(this.getSchema(), ['relations', relation, relation]))
)).length === 0

@@ -290,2 +289,3 @@ )

record={editPage.record}
resetProps={editPage.resetProps}
schema={this.getSchema()}

@@ -295,15 +295,17 @@ />

</div>
<div className={cn('col-lg-3', this.isRelationComponentNull() ? 'hidden-xl-down' : '')}>
<div className={styles.sub_wrapper}>
{!this.isRelationComponentNull() && (
<EditRelations
currentModelName={this.getModelName()}
location={this.props.location}
changeData={this.props.changeData}
record={editPage.record}
schema={this.getSchema()}
/>
)}
{!this.isRelationComponentNull() && (
<div className={cn('col-lg-3')}>
<div className={styles.sub_wrapper}>
{!this.isRelationComponentNull() && (
<EditRelations
currentModelName={this.getModelName()}
location={this.props.location}
changeData={this.props.changeData}
record={editPage.record}
schema={this.getSchema()}
/>
)}
</div>
</div>
</div>
)}
</div>

@@ -329,2 +331,3 @@ </div>

getData: PropTypes.func.isRequired,
getLayout: PropTypes.func.isRequired,
history: PropTypes.object.isRequired,

@@ -348,2 +351,3 @@ initModelProps: PropTypes.func.isRequired,

getData,
getLayout,
initModelProps,

@@ -350,0 +354,0 @@ onCancel,

@@ -11,2 +11,3 @@ /**

GET_DATA_SUCCEEDED,
GET_LAYOUT_SUCCEEDED,
INIT_MODEL_PROPS,

@@ -30,5 +31,7 @@ ON_CANCEL,

initialRecord: Map({}),
layout: Map({}),
modelName: '',
pluginHeaderTitle: 'New Entry',
record: Map({}),
resetProps: false,
showLoader: false,

@@ -49,2 +52,4 @@ source: 'content-manager',

.update('record', () => Map(action.data));
case GET_LAYOUT_SUCCEEDED:
return state.update('layout', () => Map(action.layout));
case INIT_MODEL_PROPS:

@@ -61,3 +66,4 @@ return state

.update('formErrors', () => List([]))
.update('record', () => state.get('initialRecord'));
.update('record', () => state.get('initialRecord'))
.update('resetProps', (v) => v = !v);
case RESET_PROPS:

@@ -64,0 +70,0 @@ return initialState;

@@ -20,2 +20,3 @@ import { LOCATION_CHANGE } from 'react-router-redux';

getDataSucceeded,
getLayoutSucceeded,
setFormErrors,

@@ -26,3 +27,3 @@ setLoader,

} from './actions';
import { GET_DATA,SUBMIT } from './constants';
import { GET_DATA, GET_LAYOUT, SUBMIT } from './constants';
import {

@@ -40,10 +41,9 @@ makeSelectFileRelations,

const params = { source: action.source };
const response = yield call(
request,
`/content-manager/explorer/${modelName}/${action.id}`,
{ method: 'GET', params },
);
const [response, layout] = yield [
call(request, `/content-manager/explorer/${modelName}/${action.id}`, { method: 'GET', params }),
call(request, '/content-manager/layout', { method: 'GET', params }),
];
const pluginHeaderTitle = yield call(templateObject, { mainField: action.mainField }, response);
yield put(getDataSucceeded(action.id, response, pluginHeaderTitle.mainField));
yield put(getLayoutSucceeded(layout));
} catch(err) {

@@ -54,2 +54,12 @@ strapi.notification.error('content-manager.error.record.fetch');

function* layoutGet(action) {
try {
const params = { source: action.source };
const response = yield call(request, '/content-manager/layout', { method: 'GET', params });
yield put(getLayoutSucceeded(response));
} catch(err) {
strapi.notification('notification.error');
}
}
export function* submit() {

@@ -91,3 +101,3 @@ const currentModelName = yield select(makeSelectModelName());

}, new FormData());
const id = isCreating ? '' : record.id || record._id;

@@ -141,2 +151,3 @@ const params = { source };

const loadDataWatcher = yield fork(takeLatest, GET_DATA, dataGet);
yield fork(takeLatest, GET_LAYOUT, layoutGet);
yield fork(takeLatest, SUBMIT, submit);

@@ -143,0 +154,0 @@

@@ -30,11 +30,13 @@ /**

case DELETE_DATA_SUCCESS:
return state.update('records', (list) => (
list.filter(obj => {
if (obj._id) {
return obj._id !== action.id;
}
return state
.update('records', (list) => (
list.filter(obj => {
if (obj._id) {
return obj._id !== action.id;
}
return obj.id !== parseInt(action.id, 10);
})
));
return obj.id !== parseInt(action.id, 10);
})
))
.update('count', (v) => v = v - 1);
case CHANGE_PARAMS:

@@ -41,0 +43,0 @@ return state.updateIn(action.keys, () => action.value);

@@ -18,4 +18,4 @@ {

"EditRelations.title": "Relational data",
"EditRelations.title": "Relationale Daten",
"emptyAttributes.title": "Es gibt noch keine Felder",

@@ -22,0 +22,0 @@ "emptyAttributes.description": "Füge deinem Content-Typen das erste Feld hinzu",

const _ = require('lodash');
module.exports = {
find: async function (params) {
find: async function (params, populate) {
return this.query(function(qb) {

@@ -28,3 +28,3 @@ _.forEach(params.where, (where, key) => {

}).fetchAll({
withRelated: this.associations.map(x => x.alias)
withRelated: populate || this.associations.map(x => x.alias)
});

@@ -39,3 +39,3 @@ },

findOne: async function (params) {
findOne: async function (params, populate, raw = true) {
const record = await this

@@ -46,6 +46,27 @@ .forge({

.fetch({
withRelated: this.associations.map(x => x.alias)
withRelated: populate || this.associations.map(x => x.alias)
});
return record ? record.toJSON() : record;
const data = record ? record.toJSON() : record;
// Retrieve data manually.
if (_.isEmpty(populate)) {
const arrayOfPromises = this.associations
.filter(association => ['manyMorphToOne', 'manyMorphToMany'].includes(association.nature))
.map(association => {
return this.morph.forge()
.where({
[`${this.collectionName}_id`]: params[this.primaryKey]
})
.fetchAll()
});
const related = await Promise.all(arrayOfPromises);
related.forEach((value, index) => {
data[this.associations[index].alias] = value ? value.toJSON() : value;
});
}
return data;
},

@@ -52,0 +73,0 @@

const _ = require('lodash');
module.exports = {
find: async function (params) {
find: async function (params, populate) {
return this
.find()
.find(params.where)
.limit(Number(params.limit))
.sort(params.sort)
.skip(Number(params.skip));
.skip(Number(params.skip))
.populate(populate || this.associations.map(x => x.alias).join(' '));
},

@@ -17,9 +18,10 @@

findOne: async function (params, populate) {
return this
findOne: async function (params, populate, raw = true) {
const query = this
.findOne({
[this.primaryKey]: params[this.primaryKey] || params.id
})
.populate(populate || this.associations.map(x => x.alias).join(' '))
.lean();
.populate(populate || this.associations.map(x => x.alias).join(' '));
return raw ? query.lean() : query;
},

@@ -93,25 +95,43 @@

if (record && _.isObject(record[details.via])) {
return module.exports.update.call(this, {
id: record[details.via][this.primaryKey] || record[details.via].id,
virtualFields.push(
module.exports.update.call(this, {
id: record[details.via][this.primaryKey] || record[details.via].id,
values: {
[current]: null
},
parseRelationships: false
})
);
}
return Promise.resolve();
})
.then(response => {
// Updating the new relations
// When params.values[current] is null this means that we are removing the relation.
// Recreate relation on the first side
virtualFields.push(
strapi.query(details.model || details.collection, details.plugin).update({
id: recordId,
values: {
[current]: null
[details.via]: _.isNull(params.values[current]) ? null : value[this.primaryKey] || value.id || value._id
},
parseRelationships: false
});
})
);
// Recreate relation on the other side if the value is not null
if (!_.isNull(params.values[current])) {
virtualFields.push(
module.exports.update.call(this, {
id: value[this.primaryKey] || value.id || value._id,
values: {
[current]: recordId
},
parseRelationships: false
})
);
}
return Promise.resolve();
})
);
// Update the record on the other side.
// When params.values[current] is null this means that we are removing the relation.
virtualFields.push(strapi.query(details.model || details.collection, details.plugin).update({
id: recordId,
values: {
[details.via]: _.isNull(params.values[current]) ? null : value[this.primaryKey] || value.id || value._id
},
parseRelationships: false
}));
acc[current] = _.isNull(params.values[current]) ? null : value[current];

@@ -196,33 +216,33 @@ }

if (_.isArray(array)) {
return array.map(value => {
if (_.isPlainObject(value)) {
return value._id || value.id;
}
return array.map(value => {
if (_.isPlainObject(value)) {
return value._id || value.id;
}
return value;
})
}
return value;
})
}
if (association.type === 'model') {
return _.isEmpty(array) ? [] : transformToArrayID([array]);
}
if (association.type === 'model') {
return _.isEmpty(array) ? [] : transformToArrayID([array]);
}
return [];
};
return [];
};
// Compare array of ID to find deleted files.
const currentValue = transformToArrayID(response[current]).map(id => id.toString());
const storedValue = transformToArrayID(params.values[current]).map(id => id.toString());
// Compare array of ID to find deleted files.
const currentValue = transformToArrayID(response[current]).map(id => id.toString());
const storedValue = transformToArrayID(params.values[current]).map(id => id.toString());
const toAdd = _.difference(storedValue, currentValue);
const toRemove = _.difference(currentValue, storedValue);
const toAdd = _.difference(storedValue, currentValue);
const toRemove = _.difference(currentValue, storedValue);
// Remove relations in the other side.
toAdd.forEach(id => {
virtualFields.push(strapi.query(details.model || details.collection, details.plugin).addRelationMorph({
id,
alias: association.via,
ref: this.globalId,
refId: response._id,
field: association.alias
// Remove relations in the other side.
toAdd.forEach(id => {
virtualFields.push(strapi.query(details.model || details.collection, details.plugin).addRelationMorph({
id,
alias: association.via,
ref: this.globalId,
refId: response._id,
field: association.alias
}));

@@ -288,7 +308,7 @@ });

const entry = await module.exports.findOne.call(this, params, []);
const value = entry[params.alias] || [];
const entry = (await module.exports.findOne.call(this, params, [], false)).toJSON();
const value = [];
// Retrieve association.
const association = this.associations.find(association => association.via === params.alias)[0];
const association = this.associations.find(association => association.alias === params.alias);

@@ -300,3 +320,3 @@ if (!association) {

// Resolve if the association is already existing.
const isExisting = entry[params.alias].find(obj => {
const isExisting = value.find(obj => {
if (obj.kind === params.ref && obj.ref.toString() === params.refId.toString() && obj.field === params.field) {

@@ -316,5 +336,6 @@ return true;

value.push({
ref: params.refId,
ref: params.ref,
refId: params.refId,
kind: params.ref,
field: association.filter
field: params.field
});

@@ -321,0 +342,0 @@

@@ -5,2 +5,10 @@ {

"method": "GET",
"path": "/layout",
"handler": "ContentManager.layout",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/models",

@@ -7,0 +15,0 @@ "handler": "ContentManager.models",

@@ -10,2 +10,8 @@ 'use strict';

module.exports = {
layout: async (ctx) => {
const {source} = ctx.query;
return ctx.send(_.get(strapi.plugins, [source, 'config', 'layout'], {}));
},
models: async ctx => {

@@ -12,0 +18,0 @@ const pickData = (model) => _.pick(model, [

{
"name": "strapi-plugin-content-manager",
"version": "3.0.0-alpha.11.3",
"version": "3.0.0-alpha.12",
"description": "A powerful UI to easily manage your data.",

@@ -27,3 +27,3 @@ "strapi": {

"react-select": "^1.0.0-rc.5",
"strapi-helper-plugin": "3.0.0-alpha.11.3"
"strapi-helper-plugin": "3.0.0-alpha.12"
},

@@ -30,0 +30,0 @@ "author": {

@@ -11,3 +11,3 @@ 'use strict';

fetchAll: async (params, query) => {
const { limit, skip = 0, sort, query : request, queryAttribute, source, page } = query;
const { limit, skip = 0, sort, query : request, queryAttribute, source, page, populate = [] } = query;

@@ -19,5 +19,5 @@ // Find entries using `queries` system

sort,
query: request,
queryAttribute
});
where: request,
queryAttribute,
}, populate);
},

@@ -29,6 +29,6 @@

fetch: async (params, source) => {
fetch: async (params, source, populate, raw = true) => {
return await strapi.query(params.model, source).findOne({
id: params.id
});
}, populate, raw);
},

@@ -65,3 +65,3 @@

// Then, request plugin upload.
if (strapi.plugins.upload) {
if (strapi.plugins.upload && Object.keys(files).length > 0) {
// Upload new files and attach them to this entity.

@@ -68,0 +68,0 @@ await strapi.plugins.upload.services.upload.uploadToEntity({

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc