From 4a3c25fbfe23b714e282419eeb632a0cdd9d8b03 Mon Sep 17 00:00:00 2001
From: KuongKnight
Date: Mon, 21 May 2018 17:22:25 +0700
Subject: [PATCH 01/38] Add config id type
---
packages/strapi-bookshelf/lib/index.js | 392 +++++++++++++++++++++++--
1 file changed, 362 insertions(+), 30 deletions(-)
diff --git a/packages/strapi-bookshelf/lib/index.js b/packages/strapi-bookshelf/lib/index.js
index be0cdfaa0c..2c131643c5 100755
--- a/packages/strapi-bookshelf/lib/index.js
+++ b/packages/strapi-bookshelf/lib/index.js
@@ -12,12 +12,11 @@ const _ = require('lodash');
const bookshelf = require('bookshelf');
const pluralize = require('pluralize');
-// Strapi helpers for models.
-const utilsModels = require('strapi-utils').models;
-
// Local helpers.
const utils = require('./utils/');
-const relations = require('./relations');
+
+// Strapi helpers for models.
+const utilsModels = require('strapi-utils').models;
const PIVOT_PREFIX = '_pivot_';
const GLOBALS = {};
@@ -26,11 +25,8 @@ const GLOBALS = {};
* Bookshelf hook
*/
-/* eslint-disable no-unused-vars */
-/* eslint-disable prefer-template */
-/* eslint-disable no-case-declarations */
module.exports = function(strapi) {
- const hook = _.merge({
+ const hook = {
/**
* Default options
*/
@@ -79,17 +75,16 @@ module.exports = function(strapi) {
_.forEach(models, (definition, model) => {
definition.globalName = _.upperFirst(_.camelCase(definition.globalId));
- _.defaults(definition, {
- primaryKey: 'id'
- });
-
// Define local GLOBALS to expose every models in this file.
GLOBALS[definition.globalId] = {};
// Add some informations about ORM & client connection & tableName
definition.orm = 'bookshelf';
definition.client = _.get(connection.settings, 'client');
-
+ _.defaults(definition, {
+ primaryKey: 'id',
+ primaryKeyType: _.get(definition, 'options.idAttributeType', definition.client === 'pg' ? 'SERIAL' : 'INT AUTO_INCREMENT')
+ });
// Register the final model for Bookshelf.
const loadedModel = _.assign({
tableName: definition.collectionName,
@@ -317,7 +312,6 @@ module.exports = function(strapi) {
// Push attributes to be aware of model schema.
target[model]._attributes = definition.attributes;
- target[model].updateRelations = relations.update;
databaseUpdate.push(new Promise(async (resolve) => {
// Equilize database tables
@@ -336,19 +330,23 @@ module.exports = function(strapi) {
switch (relation.nature) {
case 'oneToOne':
case 'manyToOne':
- type = definition.client === 'pg' ? 'integer' : 'int';
+ type = definition.primaryKeyType;
break;
default:
return null;
}
} else {
switch (attribute.type) {
+ case 'uuid':
+ type = definition.client === 'pg' ? 'uuid' : 'varchar(255)';
+ break;
case 'text':
- case 'json':
type = 'text';
break;
+ case 'json':
+ type = definition.client === 'pg' ? 'jsonb' : 'text';
+ break;
case 'string':
- case 'enumeration':
case 'password':
case 'email':
type = 'varchar(255)';
@@ -358,10 +356,8 @@ module.exports = function(strapi) {
type = definition.client === 'pg' ? 'integer' : 'int';
break;
case 'float':
- type = definition.client === 'pg' ? 'double precision' : 'double';
- break;
case 'decimal':
- type = 'decimal';
+ type = attribute.type;
break;
case 'date':
case 'time':
@@ -398,7 +394,11 @@ module.exports = function(strapi) {
};
if (!tableExist) {
- const columns = generateColumns(attributes, [`id ${definition.client === 'pg' ? 'SERIAL' : 'INT AUTO_INCREMENT'} NOT NULL PRIMARY KEY`]).join(',\n\r');
+ let idAttributeBuilder = [`id ${definition.primaryKeyType} NOT NULL PRIMARY KEY`];
+ if (definition.primaryKeyType === 'uuid' && definition.client === 'pg') {
+ idAttributeBuilder = ['id uuid NOT NULL DEFAULT uuid_generate_v4() NOT NULL PRIMARY KEY'];
+ }
+ const columns = generateColumns(attributes, idAttributeBuilder).join(',\n\r');
// Create table
await ORM.knex.raw(`
@@ -483,10 +483,10 @@ module.exports = function(strapi) {
if (morphRelations) {
const attributes = {
[`${loadedModel.tableName}_id`]: {
- type: 'integer'
+ type: definition.primaryKeyType
},
[`${morphRelations.alias}_id`]: {
- type: 'integer'
+ type: definition.primaryKeyType
},
[`${morphRelations.alias}_type`]: {
type: 'text'
@@ -511,10 +511,10 @@ module.exports = function(strapi) {
const attributes = {
[`${pluralize.singular(manyRelations.collection)}_id`]: {
- type: 'integer'
+ type: definition.primaryKeyType
},
[`${pluralize.singular(definition.globalId.toLowerCase())}_id`]: {
- type: 'integer'
+ type: definition.primaryKeyType
}
};
@@ -849,7 +849,7 @@ module.exports = function(strapi) {
cb();
},
- getQueryParams: (value, type, key) => {
+ getQueryParams: (value, type, key) => {
const result = {};
switch (type) {
@@ -896,18 +896,18 @@ module.exports = function(strapi) {
};
break;
case '_sort':
- result.key = `sort`;
+ result.key = 'sort';
result.value = {
key,
order: value.toUpperCase()
};
break;
case '_start':
- result.key = `start`;
+ result.key = 'start';
result.value = parseFloat(value);
break;
case '_limit':
- result.key = `limit`;
+ result.key = 'limit';
result.value = parseFloat(value);
break;
case '_contains':
@@ -923,8 +923,340 @@ module.exports = function(strapi) {
}
return result;
+ },
+
+ manageRelations: async function (model, params) {
+ const models = _.assign(_.clone(strapi.models), Object.keys(strapi.plugins).reduce((acc, current) => {
+ _.assign(acc, strapi.plugins[current].models);
+ return acc;
+ }, {}));
+
+ const Model = models[model];
+
+ const virtualFields = [];
+ const record = await Model
+ .forge({
+ [Model.primaryKey]: params[Model.primaryKey]
+ })
+ .fetch({
+ withRelated: Model.associations.map(x => x.alias)
+ });
+
+ const response = record ? record.toJSON() : record;
+
+ // Only update fields which are on this document.
+ const values = params.parseRelationships === false ? params.values : Object.keys(JSON.parse(JSON.stringify(params.values))).reduce((acc, current) => {
+ const association = Model.associations.filter(x => x.alias === current)[0];
+ const details = Model._attributes[current];
+
+ if (_.get(Model._attributes, `${current}.isVirtual`) !== true && _.isUndefined(association)) {
+ acc[current] = params.values[current];
+ } else {
+ switch (association.nature) {
+ case 'oneWay':
+ acc[current] = _.get(params.values[current], this.primaryKey, params.values[current]) || null;
+
+ break;
+ case 'oneToOne':
+ if (response[current] !== params.values[current]) {
+ const value = _.isNull(params.values[current]) ? response[current] : params.values;
+
+ const recordId = _.isNull(params.values[current]) ? value[Model.primaryKey] || value.id || value._id : typeof value[current] === 'object' ? value[current].id : value[current];
+
+ if (response[current] && _.isObject(response[current]) && response[current][Model.primaryKey] !== value[current]) {
+ virtualFields.push(
+ this.manageRelations(details.collection || details.model, {
+ id: response[current][Model.primaryKey],
+ values: {
+ [details.via]: null
+ },
+ parseRelationships: false
+ })
+ );
+ }
+
+ // Remove previous relationship asynchronously if it exists.
+ virtualFields.push(
+ models[details.model || details.collection]
+ .forge({ id : recordId })
+ .fetch({
+ withRelated: models[details.model || details.collection].associations.map(x => x.alias)
+ })
+ .then(response => {
+ const record = response ? response.toJSON() : response;
+
+ if (record && _.isObject(record[details.via]) && record[details.via][current] !== value[current]) {
+ return this.manageRelations(model, {
+ id: record[details.via][models[details.model || details.collection].primaryKey] || record[details.via].id,
+ values: {
+ [current]: null
+ },
+ 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(this.manageRelations(details.model || details.collection, {
+ id: recordId,
+ values: {
+ [details.via]: _.isNull(params.values[current]) ? null : value[Model.primaryKey] || params.id || params._id || value.id || value._id
+ },
+ parseRelationships: false
+ }));
+
+ acc[current] = _.isNull(params.values[current]) ? null : typeof value[current] === 'object' ? value[current][Model.primaryKey] : value[current];
+ }
+
+ break;
+ case 'oneToMany':
+ case 'manyToOne':
+ case 'manyToMany':
+ if (details.dominant === true) {
+ acc[current] = params.values[current];
+ } else if (response[current] && _.isArray(response[current]) && current !== 'id') {
+ // Records to add in the relation.
+ const toAdd = _.differenceWith(params.values[current], response[current], (a, b) =>
+ ((typeof a === 'number') ? a : a[Model.primaryKey].toString()) === b[Model.primaryKey].toString()
+ );
+ // Records to remove in the relation.
+ const toRemove = _.differenceWith(response[current], params.values[current], (a, b) =>
+ a[Model.primaryKey].toString() === ((typeof b === 'number') ? b : b[Model.primaryKey].toString())
+ )
+ .filter(x => toAdd.find(y => x.id === y.id) === undefined);
+
+ // Push the work into the flow process.
+ toAdd.forEach(value => {
+ value = (typeof value === 'number') ? { id: value } : value;
+
+ value[details.via] = parseFloat(params[Model.primaryKey]);
+ params.values[Model.primaryKey] = parseFloat(params[Model.primaryKey]);
+
+ virtualFields.push(this.addRelation(details.model || details.collection, {
+ id: value[Model.primaryKey] || value.id || value._id,
+ values: association.nature === 'manyToMany' ? params.values : value,
+ foreignKey: current
+ }, details.plugin));
+ });
+
+ toRemove.forEach(value => {
+ value[details.via] = null;
+
+ virtualFields.push(this.removeRelation(details.model || details.collection, {
+ id: value[Model.primaryKey] || value.id || value._id,
+ values: association.nature === 'manyToMany' ? params.values : value,
+ foreignKey: current
+ }, details.plugin));
+ });
+ } else if (_.get(Model._attributes, `${current}.isVirtual`) !== true) {
+ acc[current] = params.values[current];
+ }
+
+ break;
+ case 'manyMorphToMany':
+ case 'manyMorphToOne':
+ // Update the relational array.
+ params.values[current].forEach(obj => {
+ const model = obj.source && obj.source !== 'content-manager' ?
+ strapi.plugins[obj.source].models[obj.ref]:
+ strapi.models[obj.ref];
+
+ virtualFields.push(this.addRelationMorph(details.model || details.collection, {
+ id: response[this.primaryKey],
+ alias: association.alias,
+ ref: model.collectionName,
+ refId: obj.refId,
+ field: obj.field
+ }, obj.source));
+ });
+ break;
+ case 'oneToManyMorph':
+ case 'manyToManyMorph':
+ const transformToArrayID = (array) => {
+ if(_.isArray(array)) {
+ return array.map(value => {
+ if (_.isPlainObject(value)) {
+ return value._id || value.id;
+ }
+
+ return value;
+ });
+ }
+
+ if (association.type === 'model') {
+ return _.isEmpty(array) ? [] : transformToArrayID([array]);
+ }
+
+ 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());
+
+ const toAdd = _.difference(storedValue, currentValue);
+ const toRemove = _.difference(currentValue, storedValue);
+
+ toAdd.forEach(id => {
+ virtualFields.push(this.addRelationMorph(details.model || details.collection, {
+ id,
+ alias: association.via,
+ ref: Model.collectionName,
+ refId: response.id,
+ field: association.alias
+ }, details.plugin));
+ });
+
+ // Update the relational array.
+ toRemove.forEach(id => {
+ virtualFields.push(this.removeRelationMorph(details.model || details.collection, {
+ id,
+ alias: association.via,
+ ref: Model.collectionName,
+ refId: response.id,
+ field: association.alias
+ }, details.plugin));
+ });
+ break;
+ case 'oneMorphToOne':
+ case 'oneMorphToMany':
+ break;
+ default:
+ }
+ }
+
+ return acc;
+ }, {});
+
+ if (!_.isEmpty(values)) {
+ virtualFields.push(Model
+ .forge({
+ [Model.primaryKey]: params[Model.primaryKey]
+ })
+ .save(values, {
+ patch: true
+ }));
+ } else {
+ virtualFields.push(Promise.resolve(_.assign(response, params.values)));
+ }
+
+ // Update virtuals fields.
+ await Promise.all(virtualFields);
+ },
+
+ addRelation: async function (model, params, source) {
+ const models = _.assign(_.clone(strapi.models), Object.keys(strapi.plugins).reduce((acc, current) => {
+ _.assign(acc, strapi.plugins[current].models);
+ return acc;
+ }, {}));
+
+ const Model = models[model];
+ const association = Model.associations.filter(x => x.via === params.foreignKey)[0];
+
+ if (!association) {
+ // Resolve silently.
+ return Promise.resolve();
+ }
+
+ switch (association.nature) {
+ case 'oneToOne':
+ case 'oneToMany':
+ return this.manageRelations(model, params);
+ case 'manyToMany':
+ return Model.forge({
+ [Model.primaryKey]: parseFloat(params[Model.primaryKey])
+ })[association.alias]().attach(params.values[Model.primaryKey]);
+ default:
+ // Resolve silently.
+ return Promise.resolve();
+ }
+ },
+
+ removeRelation: async function (model, params, source) {
+ const models = _.assign(_.clone(strapi.models), Object.keys(strapi.plugins).reduce((acc, current) => {
+ _.assign(acc, strapi.plugins[current].models);
+ return acc;
+ }, {}));
+
+ const Model = models[model];
+
+ const association = Model.associations.filter(x => x.via === params.foreignKey)[0];
+
+ if (!association) {
+ // Resolve silently.
+ return Promise.resolve();
+ }
+
+ switch (association.nature) {
+ case 'oneToOne':
+ case 'oneToMany':
+ return this.manageRelations(model, params);
+ case 'manyToMany':
+ return Model.forge({
+ [Model.primaryKey]: parseFloat(params[Model.primaryKey])
+ })[association.alias]().detach(params.values[Model.primaryKey]);
+ default:
+ // Resolve silently.
+ return Promise.resolve();
+ }
+ },
+
+ addRelationMorph: async function (model, params, source) {
+ const models = _.assign(_.clone(strapi.models), Object.keys(strapi.plugins).reduce((acc, current) => {
+ _.assign(acc, strapi.plugins[current].models);
+ return acc;
+ }, {}));
+
+ const Model = models[model];
+
+ const record = await Model.morph.forge()
+ .where({
+ [`${Model.collectionName}_id`]: params.id,
+ [`${params.alias}_id`]: params.refId,
+ [`${params.alias}_type`]: params.ref,
+ field: params.field
+ })
+ .fetch({
+ withRelated: Model.associations.map(x => x.alias)
+ });
+
+ const entry = record ? record.toJSON() : record;
+
+ if (entry) {
+ return Promise.resolve();
+ }
+
+ return await Model.morph.forge({
+ [`${Model.collectionName}_id`]: params.id,
+ [`${params.alias}_id`]: params.refId,
+ [`${params.alias}_type`]: params.ref,
+ field: params.field
+ })
+ .save();
+ },
+
+ removeRelationMorph: async function (model, params, source) {
+ const models = _.assign(_.clone(strapi.models), Object.keys(strapi.plugins).reduce((acc, current) => {
+ _.assign(acc, strapi.plugins[current].models);
+ return acc;
+ }, {}));
+
+ const Model = models[model];
+
+ return await Model.morph.forge()
+ .where({
+ [`${Model.collectionName}_id`]: params.id,
+ [`${params.alias}_id`]: params.refId,
+ [`${params.alias}_type`]: params.ref,
+ field: params.field
+ })
+ .destroy();
}
- }, relations);
+ };
return hook;
};
From f6bea4fd0a6be017fa6f4c6519f1287be141d15b Mon Sep 17 00:00:00 2001
From: KuongKnight
Date: Tue, 22 May 2018 10:35:25 +0700
Subject: [PATCH 02/38] Fix configable id type
---
packages/strapi-bookshelf/lib/index.js | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/packages/strapi-bookshelf/lib/index.js b/packages/strapi-bookshelf/lib/index.js
index 2c131643c5..9031f5ff64 100755
--- a/packages/strapi-bookshelf/lib/index.js
+++ b/packages/strapi-bookshelf/lib/index.js
@@ -83,7 +83,7 @@ module.exports = function(strapi) {
definition.client = _.get(connection.settings, 'client');
_.defaults(definition, {
primaryKey: 'id',
- primaryKeyType: _.get(definition, 'options.idAttributeType', definition.client === 'pg' ? 'SERIAL' : 'INT AUTO_INCREMENT')
+ primaryKeyType: _.get(definition, 'options.idAttributeType', 'integer')
});
// Register the final model for Bookshelf.
const loadedModel = _.assign({
@@ -341,10 +341,11 @@ module.exports = function(strapi) {
type = definition.client === 'pg' ? 'uuid' : 'varchar(255)';
break;
case 'text':
+ case 'json':
type = 'text';
break;
- case 'json':
- type = definition.client === 'pg' ? 'jsonb' : 'text';
+ case 'jsonb':
+ type = 'jsonb';
break;
case 'string':
case 'password':
@@ -394,9 +395,11 @@ module.exports = function(strapi) {
};
if (!tableExist) {
- let idAttributeBuilder = [`id ${definition.primaryKeyType} NOT NULL PRIMARY KEY`];
+ let idAttributeBuilder = [`id ${definition.client === 'pg' ? 'SERIAL' : 'INT AUTO_INCREMENT'} NOT NULL PRIMARY KEY`];
if (definition.primaryKeyType === 'uuid' && definition.client === 'pg') {
idAttributeBuilder = ['id uuid NOT NULL DEFAULT uuid_generate_v4() NOT NULL PRIMARY KEY'];
+ } else if (definition.primaryKeyType !== 'integer') {
+ idAttributeBuilder = [`id ${definition.primaryKeyType} NOT NULL PRIMARY KEY`];
}
const columns = generateColumns(attributes, idAttributeBuilder).join(',\n\r');
@@ -449,7 +452,8 @@ module.exports = function(strapi) {
const changeRequired = definition.client === 'pg'
? `ALTER COLUMN ${quote}${attribute}${quote} ${attributes[attribute].required ? 'SET' : 'DROP'} NOT NULL`
: `CHANGE ${quote}${attribute}${quote} ${quote}${attribute}${quote} ${type} ${attributes[attribute].required ? 'NOT' : ''} NULL`;
-
+ //console.log(`ALTER TABLE ${quote}${table}${quote} ${changeType}`);
+ //console.log(`ALTER TABLE ${quote}${table}${quote} ${changeRequired}`);
await ORM.knex.raw(`ALTER TABLE ${quote}${table}${quote} ${changeType}`);
await ORM.knex.raw(`ALTER TABLE ${quote}${table}${quote} ${changeRequired}`);
}
From 2bd58636d4aa8a648636ff974f794d4c6c491767 Mon Sep 17 00:00:00 2001
From: KuongKnight
Date: Mon, 28 May 2018 23:26:23 +0700
Subject: [PATCH 03/38] Add colum has ralated oneWay
---
packages/strapi-bookshelf/lib/index.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/strapi-bookshelf/lib/index.js b/packages/strapi-bookshelf/lib/index.js
index 9031f5ff64..4b54ee0230 100755
--- a/packages/strapi-bookshelf/lib/index.js
+++ b/packages/strapi-bookshelf/lib/index.js
@@ -328,6 +328,7 @@ module.exports = function(strapi) {
});
switch (relation.nature) {
+ case 'oneWay:
case 'oneToOne':
case 'manyToOne':
type = definition.primaryKeyType;
From 394ea8beaa4095f56af708d25b0422f04e8c68dc Mon Sep 17 00:00:00 2001
From: KuongKnight
Date: Tue, 29 May 2018 09:18:56 +0700
Subject: [PATCH 04/38] Fix typo
---
packages/strapi-bookshelf/lib/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-bookshelf/lib/index.js b/packages/strapi-bookshelf/lib/index.js
index 4b54ee0230..89c8ddde23 100755
--- a/packages/strapi-bookshelf/lib/index.js
+++ b/packages/strapi-bookshelf/lib/index.js
@@ -328,7 +328,7 @@ module.exports = function(strapi) {
});
switch (relation.nature) {
- case 'oneWay:
+ case 'oneWay':
case 'oneToOne':
case 'manyToOne':
type = definition.primaryKeyType;
From 6c0abfc314b0b6cda7725acdfa3c2446543c44af Mon Sep 17 00:00:00 2001
From: KuongKnight
Date: Thu, 2 Aug 2018 00:05:29 +0700
Subject: [PATCH 05/38] change length to 36 for type uuid mysql
---
packages/strapi-hook-bookshelf/lib/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-hook-bookshelf/lib/index.js b/packages/strapi-hook-bookshelf/lib/index.js
index 0fca80a529..e7776e38fd 100755
--- a/packages/strapi-hook-bookshelf/lib/index.js
+++ b/packages/strapi-hook-bookshelf/lib/index.js
@@ -398,7 +398,7 @@ module.exports = function(strapi) {
} else {
switch (attribute.type) {
case 'uuid':
- type = definition.client === 'pg' ? 'uuid' : 'varchar(255)';
+ type = definition.client === 'pg' ? 'uuid' : 'varchar(36)';
break;
case 'text':
type = definition.client === 'pg' ? type = 'text' : 'longtext';
From f508da6fce881fa143fa5a3e1fcb33028b09a795 Mon Sep 17 00:00:00 2001
From: KuongKnight
Date: Thu, 2 Aug 2018 23:13:38 +0700
Subject: [PATCH 06/38] Fixed custom primaryType option
---
packages/strapi-hook-bookshelf/lib/index.js | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/packages/strapi-hook-bookshelf/lib/index.js b/packages/strapi-hook-bookshelf/lib/index.js
index e7776e38fd..ff0d8fc8d0 100755
--- a/packages/strapi-hook-bookshelf/lib/index.js
+++ b/packages/strapi-hook-bookshelf/lib/index.js
@@ -524,7 +524,7 @@ module.exports = function(strapi) {
if (definition.primaryKeyType === 'uuid' && definition.client === 'pg') {
idAttributeBuilder = ['id uuid NOT NULL DEFAULT uuid_generate_v4() NOT NULL PRIMARY KEY'];
} else if (definition.primaryKeyType !== 'integer') {
- idAttributeBuilder = [`id ${definition.primaryKeyType} NOT NULL PRIMARY KEY`];
+ idAttributeBuilder = [`id ${getType({type: definition.primaryKeyType})} NOT NULL PRIMARY KEY`];
}
const columns = generateColumns(attributes, idAttributeBuilder).join(',\n\r');
@@ -598,8 +598,6 @@ module.exports = function(strapi) {
const changeRequired = definition.client === 'pg'
? `ALTER COLUMN ${quote}${attribute}${quote} ${attributes[attribute].required ? 'SET' : 'DROP'} NOT NULL`
: `CHANGE ${quote}${attribute}${quote} ${quote}${attribute}${quote} ${type} ${attributes[attribute].required ? 'NOT' : ''} NULL`;
- //console.log(`ALTER TABLE ${quote}${table}${quote} ${changeType}`);
- //console.log(`ALTER TABLE ${quote}${table}${quote} ${changeRequired}`);
await ORM.knex.raw(`ALTER TABLE ${quote}${table}${quote} ${changeType}`);
await ORM.knex.raw(`ALTER TABLE ${quote}${table}${quote} ${changeRequired}`);
}
From 9101ba2efdb85e313422b6f7bd8bac3e4b7dd9c4 Mon Sep 17 00:00:00 2001
From: soupette
Date: Mon, 6 Aug 2018 15:00:49 +0200
Subject: [PATCH 07/38] Fixes #1660
---
packages/strapi-admin/admin/src/components/Header/styles.scss | 2 +-
.../lib/src/components/BackHeader/styles.scss | 2 +-
.../lib/src/components/ImgPreview/styles.scss | 4 ++--
.../lib/src/components/ImgPreviewRemoveIcon/styles.scss | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/packages/strapi-admin/admin/src/components/Header/styles.scss b/packages/strapi-admin/admin/src/components/Header/styles.scss
index 1756c3bafa..09b745d219 100755
--- a/packages/strapi-admin/admin/src/components/Header/styles.scss
+++ b/packages/strapi-admin/admin/src/components/Header/styles.scss
@@ -5,7 +5,7 @@
width: 100%;
height: $header-height;
position: fixed;
- z-index: 100;
+ z-index: 1050;
left: $left-menu-width;
box-shadow: 0 1px 2px 0 rgba(40, 42, 49, 0.16);
diff --git a/packages/strapi-helper-plugin/lib/src/components/BackHeader/styles.scss b/packages/strapi-helper-plugin/lib/src/components/BackHeader/styles.scss
index c3d3e8de52..5f7d28c846 100644
--- a/packages/strapi-helper-plugin/lib/src/components/BackHeader/styles.scss
+++ b/packages/strapi-helper-plugin/lib/src/components/BackHeader/styles.scss
@@ -4,7 +4,7 @@
height: 6rem;
width: 6.5rem;
line-height: 6rem;
- z-index: 999;
+ z-index: 1040;
text-align: center;
background-color: #FFFFFF;
color: #81848A;
diff --git a/packages/strapi-helper-plugin/lib/src/components/ImgPreview/styles.scss b/packages/strapi-helper-plugin/lib/src/components/ImgPreview/styles.scss
index 4073f1c0c9..ff676fed82 100644
--- a/packages/strapi-helper-plugin/lib/src/components/ImgPreview/styles.scss
+++ b/packages/strapi-helper-plugin/lib/src/components/ImgPreview/styles.scss
@@ -20,7 +20,7 @@
background-repeat: no-repeat !important;
white-space: nowrap;
- z-index: 1;
+ z-index: 1 !important;
> img {
position: absolute;
top: 0;
@@ -49,7 +49,7 @@
display: block;
position: absolute;
top: 37px;
- z-index: 9999;
+ z-index: 999;
padding: 12px 40px 0 40px;
line-height: 18px;
color: #fff !important;
diff --git a/packages/strapi-helper-plugin/lib/src/components/ImgPreviewRemoveIcon/styles.scss b/packages/strapi-helper-plugin/lib/src/components/ImgPreviewRemoveIcon/styles.scss
index 0a52aadf99..f035392e83 100644
--- a/packages/strapi-helper-plugin/lib/src/components/ImgPreviewRemoveIcon/styles.scss
+++ b/packages/strapi-helper-plugin/lib/src/components/ImgPreviewRemoveIcon/styles.scss
@@ -6,6 +6,6 @@
height: 20px;
color: #fff;
font-size: 11px;
- z-index: 9999;
+ z-index: 999;
cursor: pointer;
}
From eceafe707463a94fe67d19fa7151af6951ab8775 Mon Sep 17 00:00:00 2001
From: soupette
Date: Mon, 6 Aug 2018 16:18:37 +0200
Subject: [PATCH 08/38] Fixes #1395
---
.../admin/src/containers/Form/index.js | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js
index c0513dfa95..390b17bf66 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js
@@ -514,12 +514,9 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
}
renderModalBodyChooseAttributes = () => {
- const attributesDisplay = forms.attributesDisplay.items;
-
- // Don't display the media field if the upload plugin isn't installed
- if (!has(this.context.plugins.toJS(), 'upload')) {
- attributesDisplay.splice(8, 1);
- }
+ const attributesDisplay = has(this.context.plugins.toJS(), 'upload')
+ ? forms.attributesDisplay.items
+ : forms.attributesDisplay.items.filter(obj => obj.type !== 'media'); // Don't display the media field if the upload plugin isn't installed
return (
map(attributesDisplay, (attribute, key) => (
From 3f2576cb6853d0196d5e402a1677e78b4ac04d55 Mon Sep 17 00:00:00 2001
From: Jim LAURIE
Date: Mon, 6 Aug 2018 17:46:58 +0200
Subject: [PATCH 09/38] Can block a user
---
packages/strapi-admin/package.json | 2 +-
.../admin/src/translations/en.json | 5 +++--
.../config/policies/permissions.js | 4 ++++
packages/strapi-plugin-users-permissions/controllers/Auth.js | 4 ++++
.../models/User.settings.json | 5 +++++
.../strapi-plugin-users-permissions/services/Providers.js | 2 +-
6 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index b5778e1491..a918c9edf7 100755
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
+}
\ No newline at end of file
diff --git a/packages/strapi-plugin-users-permissions/admin/src/translations/en.json b/packages/strapi-plugin-users-permissions/admin/src/translations/en.json
index f9878a46be..3ba2151c7e 100755
--- a/packages/strapi-plugin-users-permissions/admin/src/translations/en.json
+++ b/packages/strapi-plugin-users-permissions/admin/src/translations/en.json
@@ -43,8 +43,9 @@
"Auth.form.error.code.provide": "Incorrect code provided.",
"Auth.form.error.password.matching": "Passwords do not match.",
"Auth.form.error.params.provide": "Incorrect params provided.",
- "Auth.form.error.username.taken": "Username is already taken",
- "Auth.form.error.email.taken": "Email is already taken",
+ "Auth.form.error.username.taken": "Username is already taken.",
+ "Auth.form.error.email.taken": "Email is already taken.",
+ "Auth.form.error.blocked": "Your account has been blocked by the administrator.",
"Auth.link.forgot-password": "Forgot your password?",
"Auth.link.ready": "Ready to sign in?",
diff --git a/packages/strapi-plugin-users-permissions/config/policies/permissions.js b/packages/strapi-plugin-users-permissions/config/policies/permissions.js
index 3407b5ee41..e817b9c00c 100644
--- a/packages/strapi-plugin-users-permissions/config/policies/permissions.js
+++ b/packages/strapi-plugin-users-permissions/config/policies/permissions.js
@@ -23,6 +23,10 @@ module.exports = async (ctx, next) => {
if (role.type === 'root') {
return await next();
}
+
+ if (ctx.state.user.blocked === true) {
+ return ctx.unauthorized(`Your account has been blocked by the administrator.`);
+ }
}
// Retrieve `public` role.
if (!role) {
diff --git a/packages/strapi-plugin-users-permissions/controllers/Auth.js b/packages/strapi-plugin-users-permissions/controllers/Auth.js
index a97a9df50d..1744e6d78e 100644
--- a/packages/strapi-plugin-users-permissions/controllers/Auth.js
+++ b/packages/strapi-plugin-users-permissions/controllers/Auth.js
@@ -52,6 +52,10 @@ module.exports = {
// Check if the user exists.
const user = await strapi.query('user', 'users-permissions').findOne(query, ['role']);
+ if (user.blocked === true) {
+ return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.blocked' }] }] : 'Your account has been blocked by the administrator.');
+ }
+
if (!user) {
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.invalid' }] }] : 'Identifier or password invalid.');
}
diff --git a/packages/strapi-plugin-users-permissions/models/User.settings.json b/packages/strapi-plugin-users-permissions/models/User.settings.json
index 99479b1cba..1ed6d43186 100644
--- a/packages/strapi-plugin-users-permissions/models/User.settings.json
+++ b/packages/strapi-plugin-users-permissions/models/User.settings.json
@@ -33,6 +33,11 @@
"configurable": false,
"private": true
},
+ "blocked": {
+ "type": "boolean",
+ "default": false,
+ "configurable": false
+ },
"role": {
"model": "role",
"via": "users",
diff --git a/packages/strapi-plugin-users-permissions/services/Providers.js b/packages/strapi-plugin-users-permissions/services/Providers.js
index 57e3f3031c..da8f651186 100644
--- a/packages/strapi-plugin-users-permissions/services/Providers.js
+++ b/packages/strapi-plugin-users-permissions/services/Providers.js
@@ -134,7 +134,7 @@ const getProfile = async (provider, query, callback) => {
callback(err);
} else {
// Combine username and discriminator because discord username is not unique
- var username = body.username + '#' + body.discriminator;
+ var username = `${body.username}#${body.discriminator}`;
callback(null, {
username: username,
email: body.email
From 3645cc15f453bd328e975ec588f1469bdf17ec57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Sko=C5=99epa?=
Date: Tue, 7 Aug 2018 14:42:33 +0200
Subject: [PATCH 10/38] Fix one to many relation querying in the other
direction
---
packages/strapi-plugin-graphql/services/GraphQL.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-plugin-graphql/services/GraphQL.js b/packages/strapi-plugin-graphql/services/GraphQL.js
index eb911fae2b..81f03cf3d5 100644
--- a/packages/strapi-plugin-graphql/services/GraphQL.js
+++ b/packages/strapi-plugin-graphql/services/GraphQL.js
@@ -630,7 +630,7 @@ module.exports = {
};
if (association.type === 'model') {
- params.id = obj[association.alias];
+ params.id = obj[association.alias].id;
} else {
// Get refering model.
const ref = association.plugin ?
From b7edcffff876fa5617c2cdc43ef36c025c333ac6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Sko=C5=99epa?=
Date: Wed, 8 Aug 2018 00:05:33 +0200
Subject: [PATCH 11/38] Fix the fix
It turns out that in some situations it actually is only the id instead of object (nested queries).
---
packages/strapi-plugin-graphql/services/GraphQL.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/packages/strapi-plugin-graphql/services/GraphQL.js b/packages/strapi-plugin-graphql/services/GraphQL.js
index 81f03cf3d5..12444bf3d4 100644
--- a/packages/strapi-plugin-graphql/services/GraphQL.js
+++ b/packages/strapi-plugin-graphql/services/GraphQL.js
@@ -630,7 +630,8 @@ module.exports = {
};
if (association.type === 'model') {
- params.id = obj[association.alias].id;
+ const rel = obj[association.alias];
+ params.id = typeof rel === 'object' && 'id' in rel ? rel.id : rel;
} else {
// Get refering model.
const ref = association.plugin ?
From 1d2de999dd927e379c22d21d682fb52375b94312 Mon Sep 17 00:00:00 2001
From: Pierre Burgy
Date: Wed, 8 Aug 2018 11:31:12 +0200
Subject: [PATCH 12/38] Tick remember me by default #1716
---
packages/strapi-admin/package.json | 2 +-
.../admin/src/containers/AuthPage/actions.js | 2 +-
packages/strapi-plugin-users-permissions/services/Providers.js | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index b5778e1491..a918c9edf7 100755
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
+}
\ No newline at end of file
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/actions.js b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/actions.js
index 53d0a91bce..5c3d751d39 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/actions.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/actions.js
@@ -50,7 +50,7 @@ export function setForm(formType, email) {
data = {
identifier: '',
password: '',
- rememberMe: false,
+ rememberMe: true,
};
break;
diff --git a/packages/strapi-plugin-users-permissions/services/Providers.js b/packages/strapi-plugin-users-permissions/services/Providers.js
index 57e3f3031c..da8f651186 100644
--- a/packages/strapi-plugin-users-permissions/services/Providers.js
+++ b/packages/strapi-plugin-users-permissions/services/Providers.js
@@ -134,7 +134,7 @@ const getProfile = async (provider, query, callback) => {
callback(err);
} else {
// Combine username and discriminator because discord username is not unique
- var username = body.username + '#' + body.discriminator;
+ var username = `${body.username}#${body.discriminator}`;
callback(null, {
username: username,
email: body.email
From 5c72dbfb3262dca7a087d6099edfd793b5798818 Mon Sep 17 00:00:00 2001
From: Pierre Burgy
Date: Wed, 8 Aug 2018 11:40:21 +0200
Subject: [PATCH 13/38] Autofocus name when creating a new Content Type #1718
---
.../admin/src/containers/Form/forms.json | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/forms.json b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/forms.json
index 13c8467ec6..af00853d4e 100644
--- a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/forms.json
+++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/forms.json
@@ -2,18 +2,6 @@
"contentType": {
"baseSettings": {
"items": [
- {
- "label": {
- "id": "content-type-builder.form.contentType.item.connections"
- },
- "name": "connection",
- "type": "select",
- "value": "default",
- "items": [{}],
- "validations": {
- "required": true
- }
- },
{
"label": {
"id": "content-type-builder.form.contentType.item.name"
@@ -45,6 +33,18 @@
}
}
},
+ {
+ "label": {
+ "id": "content-type-builder.form.contentType.item.connections"
+ },
+ "name": "connection",
+ "type": "select",
+ "value": "default",
+ "items": [{}],
+ "validations": {
+ "required": true
+ }
+ },
{
"label": {
"id": "content-type-builder.form.contentType.item.description"
From 0e61914ce296d2d208ed07e05464f1c683afa5b8 Mon Sep 17 00:00:00 2001
From: Jim LAURIE
Date: Wed, 8 Aug 2018 11:44:27 +0200
Subject: [PATCH 14/38] Add upper first strapi new logs action
---
packages/strapi-admin/package.json | 2 +-
packages/strapi-generate-new/lib/after.js | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index b5778e1491..a918c9edf7 100755
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
+}
\ No newline at end of file
diff --git a/packages/strapi-generate-new/lib/after.js b/packages/strapi-generate-new/lib/after.js
index f704dc6d5e..17a8e38092 100755
--- a/packages/strapi-generate-new/lib/after.js
+++ b/packages/strapi-generate-new/lib/after.js
@@ -187,10 +187,10 @@ module.exports = (scope, cb) => {
console.log();
console.log(`👌 Your new application ${green(scope.name)} is ready at ${cyan(scope.rootPath)}.`);
console.log();
- console.log('⚡️ change directory:');
+ console.log('⚡️ Change directory:');
console.log(`$ ${green(`cd ${scope.name}`)}`);
console.log();
- console.log('⚡️ start application:');
+ console.log('⚡️ Start application:');
console.log(`$ ${green('strapi start')}`);
cb();
From 0a3b81fef64b5e4e20e9997c04f0015f5d95edc7 Mon Sep 17 00:00:00 2001
From: Pierre Burgy
Date: Wed, 8 Aug 2018 11:50:31 +0200
Subject: [PATCH 15/38] Change default database name
---
packages/strapi-generate-new/lib/before.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-generate-new/lib/before.js b/packages/strapi-generate-new/lib/before.js
index 4182643982..411063f82e 100755
--- a/packages/strapi-generate-new/lib/before.js
+++ b/packages/strapi-generate-new/lib/before.js
@@ -132,7 +132,7 @@ module.exports = (scope, cb) => {
type: 'input',
name: 'database',
message: 'Database name:',
- default: _.get(scope.database, 'database', 'strapi')
+ default: _.get(scope.database, 'database', scope.name)
},
{
when: !hasDatabaseConfig,
From ee24171e372fbb3a8e006dcba5c7eb26e28b5cc5 Mon Sep 17 00:00:00 2001
From: Aurelsicoko
Date: Wed, 8 Aug 2018 12:21:24 +0200
Subject: [PATCH 16/38] Update README
---
README.md | 70 ++++++++++++++++++++++++++++++++++---------------------
1 file changed, 43 insertions(+), 27 deletions(-)
diff --git a/README.md b/README.md
index 8d8a1610c0..e03a1ccba2 100755
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
API creation made simple, secure and fast.
-The most advanced open-source Content Management Framework to build powerful API with no effort.
+The most advanced open-source Headless-CMS to build powerful API with no effort.
@@ -32,35 +32,51 @@
-
+
-## Quick start
+## Getting Started
-We've been working on a major update to Strapi for several months now, rewriting the core framework and the administration panel. Performances has been increased, Developer eXperience has been improved and a brand new plugins
-ecosystem has been introduced. **Both versions are available, we still recommend you to use v1 for production usage.**.
+[Read the Getting Started tutorial](https://strapi.io/getting-started) or follow the steps below:
+
+#### Installation
+
+```bash
+npm install strapi@alpha -g
+````
+
+**We recommend to use the latest version of Strapi** to start your new project. Some breaking changes might happen, new releases are shipped every two weeks.
+
+#### Create a new project
+
+```bash
+strapi new my-project
+```
+
+It will generate a brand new project with the default features (authentication, permissions, content management, content type builder & file upload).
+
+Then, you're ready to start your project:
+
+```bash
+cd my-project
+strapi start
+```
+
+**Congratulations, you made it! Enjoy 🎉**
+
+---
+
+You can also give it a try using Heroku. However one of the main feature (content type builder) won't work due to the writing files restriction of Heroku.
-#### Alpha
+---
-The alpha has support for the latest version of Node.js (v9) and npm (v5).
-```bash
-npm install strapi@alpha -g
-```
-
-#### Stable
-This is the production-ready version of Strapi (v1). You should also consider that the migration to v3 will not be easy due to many breaking changes.
-```bash
-npm install strapi -g
-```
-
-Read the [Getting started](https://strapi.io/getting-started) page to create your first project using Strapi.
## Features
@@ -73,19 +89,17 @@ Read the [Getting started](https://strapi.io/getting-started) page to create you
- **Powerful CLI:** Scaffold projects and APIs on the fly.
- **SQL & NoSQL databases:** Work with Mongo as a main database, also supports Postgres, MySQL, etc.
-## Philosophy ?
+**[See more on our website](https://strapi.io/overview)**
-> At [Strapi](https://strapi.io), everything we do we believe in changing the status quo of web development. Our products are simple to use, user friendly and production-ready.
+## Contributing
-Web and mobile applications needed a powerful, simple to use and production-ready API-driven solution. That's why we created Strapi, an open-source Content Management Framework (CMF) for exposing your content (data, media) accross multi-devices.
-
-Halfway between a CMS and a framework, Strapi takes advantages of both worlds. A powerful dashboard to easily manage your content with a flexible framework layer to develop and integrate specific features.
+Please read our [Contributing Guide](./CONTRIBUTING.md) before submitting a Pull Request to the project.
## Support
For more information on the upcoming version, please take a look to our [ROADMAP](https://github.com/strapi/strapi/projects).
-### Community support
+#### Community support
For general help using Strapi, please refer to [the official Strapi documentation](https://strapi.io/documentation/). For additional help, you can use one of this channel to ask question:
@@ -95,13 +109,15 @@ For general help using Strapi, please refer to [the official Strapi documentatio
- [Twitter](https://twitter.com/strapijs)
- [Facebook](https://www.facebook.com/Strapi-616063331867161).
-### Professional support
+#### Professional support
-[Strapi Solutions](https://strapi.io), the company behind Strapi, provides a full range of solutions to get better results, faster. We're always looking for the next challenge: coaching, consulting, training, customization, etc. [Drop us an email](mailto:support@strapi.io) to see how we can help you.
+[Strapi Solutions](https://strapi.io), the company behind Strapi, provides a full range of solutions to get better results, faster. We're always looking for the next challenge: coaching, consulting, training, customization, etc.
+
+[Drop us an email](mailto:support@strapi.io) to see how we can help you.
### Migration
-Follow our [migration guides](https://github.com/strapi/strapi/wiki) on the wiki to keep your Strapi projects updated.
+Follow our [migration guides](https://github.com/strapi/strapi/wiki) on the wiki to keep your projects up-to-date.
## License
From 0725cad584870592b24541baa2f8feaea817c16a Mon Sep 17 00:00:00 2001
From: Aurelsicoko
Date: Wed, 8 Aug 2018 12:30:59 +0200
Subject: [PATCH 17/38] Update screenshot
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e03a1ccba2..6f4f7a6c5b 100755
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@
-
+
From 1acf5c465017f344953246bd88073627e29b7be5 Mon Sep 17 00:00:00 2001
From: Aurelsicoko
Date: Wed, 8 Aug 2018 12:36:02 +0200
Subject: [PATCH 18/38] Update screenshot
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 6f4f7a6c5b..85becf85cb 100755
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
API creation made simple, secure and fast.
-The most advanced open-source Headless-CMS to build powerful API with no effort.
+The most advanced open-source Content Management Framework (headless-CMS) to build powerful API with no effort.
@@ -32,7 +32,7 @@
-
+
From 73f7dadd7dfba830dc4571661e2dbecc58b1ca8e Mon Sep 17 00:00:00 2001
From: Aurelsicoko
Date: Wed, 8 Aug 2018 12:43:27 +0200
Subject: [PATCH 19/38] Update screenshot
---
README.md | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 85becf85cb..fc6b332943 100755
--- a/README.md
+++ b/README.md
@@ -40,17 +40,18 @@
## Getting Started
-[Read the Getting Started tutorial](https://strapi.io/getting-started) or follow the steps below:
+Read the Getting Started tutorial or follow the steps below:
-#### Installation
+#### ⏳ Installation
```bash
npm install strapi@alpha -g
````
-**We recommend to use the latest version of Strapi** to start your new project. Some breaking changes might happen, new releases are shipped every two weeks.
+**We recommend to use the latest version of Strapi to start your new project**.
+Some breaking changes might happen, new releases are shipped every two weeks to fix/enhance the product.
-#### Create a new project
+#### 🏗 Create a new project
```bash
strapi new my-project
@@ -58,18 +59,18 @@ strapi new my-project
It will generate a brand new project with the default features (authentication, permissions, content management, content type builder & file upload).
-Then, you're ready to start your project:
+#### 🚀 Start your project
```bash
cd my-project
strapi start
```
-**Congratulations, you made it! Enjoy 🎉**
+Congratulations, you made it! Enjoy 🎉
----
+
-You can also give it a try using Heroku. However one of the main feature (content type builder) won't work due to the writing files restriction of Heroku.
+You can also give it a try using Heroku! Be aware that one of the content type builder won't work due to the writing files restriction on the Heroku servers.
From b39b9c2fc8342be64321245f67d71b2751fa670d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20GEORGET?=
Date: Wed, 8 Aug 2018 12:47:28 +0200
Subject: [PATCH 20/38] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fc6b332943..41483e350b 100755
--- a/README.md
+++ b/README.md
@@ -76,7 +76,7 @@ You can also give it a try using Heroku! Be aware that one of the content type b
----
+
## Features
From c2b97edeb20aaf3f81f8d7ac8287b8aea2c52659 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20GEORGET?=
Date: Wed, 8 Aug 2018 12:48:17 +0200
Subject: [PATCH 21/38] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 41483e350b..6d152b0053 100755
--- a/README.md
+++ b/README.md
@@ -116,7 +116,7 @@ For general help using Strapi, please refer to [the official Strapi documentatio
[Drop us an email](mailto:support@strapi.io) to see how we can help you.
-### Migration
+## Migration
Follow our [migration guides](https://github.com/strapi/strapi/wiki) on the wiki to keep your projects up-to-date.
From 499dbfd43e20ce319149168e76e4a4b61130e012 Mon Sep 17 00:00:00 2001
From: Aurelsicoko
Date: Wed, 8 Aug 2018 14:30:40 +0200
Subject: [PATCH 22/38] Update the contributing guide
---
CONTRIBUTING.md | 117 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 96 insertions(+), 21 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5d9ab64699..da5e784159 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -32,40 +32,115 @@ If you send a pull request, please do it again the `master` branch. We are devel
## Setup Development Environment
To facilitate the contribution, we drastically reduce the amount of commands necessary to install the entire development environment. First of all, you need to check if you're using the recommended versions of Node.js (v8) and npm (v5).
-**Then, please follow the instructions below:**
+Then, please follow the instructions below:
-1. [Fork the repository](https://github.com/strapi/strapi) to your own GitHub account.
-2. Clone it to your computer `git clone git@github.com:strapi/strapi.git`.
-3. Run `npm run setup` at the root of the directory.
+#### 1. Fork the repository
-> Note: If the installation failed, please remove the global packages related to Strapi. The command `npm ls strapi` will help you to find where your packages are installed globally.
+[Go to the repository](https://github.com/strapi/strapi) and fork it to your own GitHub account.
-> Note: You can run `npm run setup:build` to build the plugins' admin (the setup time will be longer).
+#### 2. Clone the repository
+```bash
+git clone git@github.com:strapi/strapi.git
+```
-The development environment has been installed. Now, you have to create a development project to live-test your updates.
+#### 3. ⏳ Installation
+
+Go to the root of the repository.
+```bash
+cd strapi
+```
-1. Go to a folder on your computer `cd /path/to/my/folder`.
-2. Create a new project `strapi new myDevelopmentProject --dev`.
-3. Start your app with `strapi start`.
+**Two setup are available... with or without the front-end build.**
-Awesome! You are now able to make bug fixes or enhancements in the framework layer of Strapi. **To make updates in the administration panel, you need to go a little bit further.**
+Without the front-end build, you won't be able to access to the administration panel via http://localhost:1337/admin, you'll have to run the administration separately and access it through http://localhost:4000/admin.
-4. Open a new tab or new terminal window.
-5. Go to the `my-app/admin` folder of your currently running app.
-6. Run `npm start` and go to the following url [http://localhost:4000/admin](http://localhost:4000/admin)
+
+
+Without the front-end build (recommended)
+```bash
+npm run setup
+```
+or with the front-end builds
+```bash
+npm run setup:build
+```
+
+> ⚠️ If the installation failed, please remove the global packages related to Strapi. The command `npm ls strapi` will help you to find where your packages are installed globally.
+
+#### 4. 🏗 Create a new project
+
+You can open a new terminal window and go into any folder you want for the next steps.
+```bash
+cd /.../workspace/
+```
+
+The command to generate a project is the same, except you have to add the `--dev` argument at the end of line.
+```bash
+strapi new my-project --dev
+```
+
+#### 5. 🚀 Start the project
+
+First, you have to start the server.
+```bash
+cd ./my-project
+strapi start
+```
+
+The server (API) is available at http://localhost:1337
+
+> ⚠️ If you've followed the recommended setup, you should not be able to reach the administration panel at http://localhost:1337/admin.
+
+Then, you have to start the Webpack server to build and run the administration.
+```bash
+cd ./my-project/admin
+npm run start
+```
+
+The administration panel is available at http://localhost:4000/admin
+
+**Awesome! You are now able to contribute to Strapi.**
+
+---
## Plugin Development Setup
-To create a new plugin, you'll have to run the following commands
+To create a new plugin, you'll have to run the following commands:
-1. In your project folder `cd myDevelopmentProject && strapi generate:plugin my-plugin`.
-2. Make sure that the `strapi-helper-plugin` is linked to your plugin
- - In the folder where strapi is cloned `cd pathToStrapiRepo/strapi/packages/strapi-helper-plugin && npm link`.
- - In your project folder `cd pathToMyProject/myDevelopmentProject/plugins/my-plugin && npm link strapi-helper-plugin`.
-3. Start the server in the admin folder `cd pathToMyProject/myDevelopmentProject/admin && npm start` and go to the following url [http://localhost:4000/admin](http://localhost:4000/admin).
+#### 1. Generate a new plugin
-***
+```bash
+cd ./my-project
+strapi generate:plugin my-plugin
+```
+
+#### 2. Verify the symlink
+
+Make you that the `strapi-helper-plugin` is linked to your project.
+
+Please run this command in the repository folder where Strapi is cloned:
+```bash
+cd /repository/strapi/packages/strapi-helper-plugin
+npm link
+```
+
+Link the `strapi-helper-plugin` node_modules in the plugin folder:
+```bash
+cd ./my-project/plugins/my-plugin
+npm link strapi-helper-plugin
+```
+
+#### 3. Start the project
+
+```bash
+cd ./my-project/admin
+npm run start
+```
+
+The administration panel is available at http://localhost:4000/admin
+
+---
## Reporting an issue
From 092cf8f763142aa46bdb00d8da1caaf4f4f88bf6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20GEORGET?=
Date: Wed, 8 Aug 2018 14:39:21 +0200
Subject: [PATCH 23/38] Update CONTRIBUTING.md
---
CONTRIBUTING.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index da5e784159..fdb300e867 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,6 +1,6 @@
# Contribute to Strapi
-👍🎉 First off, thanks for taking the time to contribute! 🎉👍
+First off, thanks for taking the time to contribute! 🎉👍
The following is a set of guidelines for contributing to Strapi and its packages.
@@ -34,11 +34,11 @@ To facilitate the contribution, we drastically reduce the amount of commands nec
Then, please follow the instructions below:
-#### 1. Fork the repository
+#### 1. ▪️ Fork the repository
[Go to the repository](https://github.com/strapi/strapi) and fork it to your own GitHub account.
-#### 2. Clone the repository
+#### 2. 💿 Clone the repository
```bash
git clone git@github.com:strapi/strapi.git
@@ -108,14 +108,14 @@ The administration panel is available at http://localhost:4000/admin
To create a new plugin, you'll have to run the following commands:
-#### 1. Generate a new plugin
+#### 1. 🏗 Generate a new plugin
```bash
cd ./my-project
strapi generate:plugin my-plugin
```
-#### 2. Verify the symlink
+#### 2. ✅ Verify the symlink
Make you that the `strapi-helper-plugin` is linked to your project.
@@ -131,7 +131,7 @@ cd ./my-project/plugins/my-plugin
npm link strapi-helper-plugin
```
-#### 3. Start the project
+#### 3. 🚀 Start the project
```bash
cd ./my-project/admin
From cc71294de65456305859f5a13e4f9ad775872133 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20GEORGET?=
Date: Wed, 8 Aug 2018 14:40:18 +0200
Subject: [PATCH 24/38] Fix typo contributing guide
---
CONTRIBUTING.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index fdb300e867..81a301ac52 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -51,13 +51,13 @@ Go to the root of the repository.
cd strapi
```
-**Two setup are available... with or without the front-end build.**
+**Two setup are available... with or without the front-end builds.**
-Without the front-end build, you won't be able to access to the administration panel via http://localhost:1337/admin, you'll have to run the administration separately and access it through http://localhost:4000/admin.
+Without the front-end builds, you won't be able to access to the administration panel via http://localhost:1337/admin, you'll have to run the administration separately and access it through http://localhost:4000/admin.
-Without the front-end build (recommended)
+Without the front-end builds (recommended)
```bash
npm run setup
```
From e404d4cac29423b8ffd7b1156c89923727e13127 Mon Sep 17 00:00:00 2001
From: Pierre Burgy
Date: Wed, 8 Aug 2018 16:30:04 +0200
Subject: [PATCH 25/38] Fix multi active left menu links
---
.../strapi-admin/admin/src/components/LeftMenuLink/index.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/packages/strapi-admin/admin/src/components/LeftMenuLink/index.js b/packages/strapi-admin/admin/src/components/LeftMenuLink/index.js
index 5a36b8e12b..d37f84e0bc 100755
--- a/packages/strapi-admin/admin/src/components/LeftMenuLink/index.js
+++ b/packages/strapi-admin/admin/src/components/LeftMenuLink/index.js
@@ -20,9 +20,10 @@ class LeftMenuLink extends React.Component {
// We need to create our own active url checker,
// because of the two levels router.
const isLinkActive = startsWith(
- window.location.pathname.replace('/admin', ''),
- this.props.destination,
+ window.location.pathname.replace('/admin', '').concat('/'),
+ this.props.destination.concat('/'),
);
+
const plugin =
this.props.source !== 'content-manager' && this.props.source !== '' ? (
From a7f5942a7203c948713bf3fb48b8d8fd327e5d90 Mon Sep 17 00:00:00 2001
From: Pierre Burgy
Date: Wed, 8 Aug 2018 16:30:24 +0200
Subject: [PATCH 26/38] Fix multi active left menu links
---
packages/strapi-admin/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index b5778e1491..a918c9edf7 100755
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
+}
\ No newline at end of file
From 3532b20ecfd2609c7403833dd89f47d04c7c45d5 Mon Sep 17 00:00:00 2001
From: Aurelsicoko
Date: Wed, 8 Aug 2018 16:34:17 +0200
Subject: [PATCH 27/38] Remove pre-checked checkbox
---
.../admin/src/containers/AuthPage/actions.js | 2 +-
.../admin/src/containers/AuthPage/form.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/actions.js b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/actions.js
index 53d0a91bce..6c1fdd0b05 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/actions.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/actions.js
@@ -60,7 +60,7 @@ export function setForm(formType, email) {
password: '',
confirmPassword: '',
email: '',
- news: true,
+ news: false,
};
break;
case 'register-success':
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/form.json b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/form.json
index 075de9f189..08a23dbdc2 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/form.json
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/form.json
@@ -80,7 +80,7 @@
},
"name": "news",
"type": "checkbox",
- "value": true
+ "value": false
}
],
"register-success": [
From f0c331bd91b23ee921b9b28ad81117c3fb62ad3f Mon Sep 17 00:00:00 2001
From: Aurelsicoko
Date: Wed, 8 Aug 2018 16:43:50 +0200
Subject: [PATCH 28/38] Send the user to the right section in the Quickstart
tutorial
---
packages/strapi-admin/admin/src/containers/HomePage/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-admin/admin/src/containers/HomePage/index.js b/packages/strapi-admin/admin/src/containers/HomePage/index.js
index 39a12cc6aa..a307417f03 100644
--- a/packages/strapi-admin/admin/src/containers/HomePage/index.js
+++ b/packages/strapi-admin/admin/src/containers/HomePage/index.js
@@ -137,7 +137,7 @@ export class HomePage extends React.PureComponent {
const data = this.showFirstBlock()
? {
className: styles.homePageTutorialButton,
- href: 'https://strapi.io/documentation/getting-started/quick-start.html',
+ href: 'https://strapi.io/documentation/getting-started/quick-start.html#create-your-first-api',
id: 'app.components.HomePage.button.quickStart',
primary: true,
}
From 2980c200afd8a89a95e9b8f832dd414db929b858 Mon Sep 17 00:00:00 2001
From: Pierre Burgy
Date: Wed, 8 Aug 2018 17:25:25 +0200
Subject: [PATCH 29/38] Fix download display
---
.../containers/InstallPluginPage/actions.js | 27 +++++++++++---
.../containers/InstallPluginPage/constants.js | 6 ++-
.../src/containers/InstallPluginPage/index.js | 28 ++++++++------
.../containers/InstallPluginPage/reducer.js | 11 +++++-
.../src/containers/InstallPluginPage/saga.js | 37 ++++++++++++++++---
packages/strapi-admin/package.json | 2 +-
6 files changed, 82 insertions(+), 29 deletions(-)
diff --git a/packages/strapi-admin/admin/src/containers/InstallPluginPage/actions.js b/packages/strapi-admin/admin/src/containers/InstallPluginPage/actions.js
index 4de39e11f8..6f58869926 100644
--- a/packages/strapi-admin/admin/src/containers/InstallPluginPage/actions.js
+++ b/packages/strapi-admin/admin/src/containers/InstallPluginPage/actions.js
@@ -8,8 +8,10 @@ import {
DOWNLOAD_PLUGIN,
DOWNLOAD_PLUGIN_ERROR,
DOWNLOAD_PLUGIN_SUCCEEDED,
- GET_PLUGINS,
- GET_PLUGINS_SUCCEEDED,
+ GET_AVAILABLE_PLUGINS,
+ GET_AVAILABLE_PLUGINS_SUCCEEDED,
+ GET_INSTALLED_PLUGINS,
+ GET_INSTALLED_PLUGINS_SUCCEEDED,
ON_CHANGE,
} from './constants';
@@ -32,19 +34,32 @@ export function downloadPluginSucceeded() {
};
}
-export function getPlugins() {
+export function getAvailablePlugins() {
return {
- type: GET_PLUGINS,
+ type: GET_AVAILABLE_PLUGINS,
};
}
-export function getPluginsSucceeded(availablePlugins) {
+export function getAvailablePluginsSucceeded(availablePlugins) {
return {
- type: GET_PLUGINS_SUCCEEDED,
+ type: GET_AVAILABLE_PLUGINS_SUCCEEDED,
availablePlugins,
};
}
+export function getInstalledPlugins() {
+ return {
+ type: GET_INSTALLED_PLUGINS,
+ };
+}
+
+export function getInstalledPluginsSucceeded(installedPlugins) {
+ return {
+ type: GET_INSTALLED_PLUGINS_SUCCEEDED,
+ installedPlugins,
+ };
+}
+
export function onChange({ target }) {
return {
type: ON_CHANGE,
diff --git a/packages/strapi-admin/admin/src/containers/InstallPluginPage/constants.js b/packages/strapi-admin/admin/src/containers/InstallPluginPage/constants.js
index 2141383d83..06650ea0e6 100644
--- a/packages/strapi-admin/admin/src/containers/InstallPluginPage/constants.js
+++ b/packages/strapi-admin/admin/src/containers/InstallPluginPage/constants.js
@@ -7,6 +7,8 @@
export const DOWNLOAD_PLUGIN = 'StrapiAdmin/InstallPluginPage/DOWNLOAD_PLUGIN';
export const DOWNLOAD_PLUGIN_ERROR = 'StrapiAdmin/InstallPluginPage/DOWNLOAD_PLUGIN_ERROR';
export const DOWNLOAD_PLUGIN_SUCCEEDED = 'StrapiAdmin/InstallPluginPage/DOWNLOAD_PLUGIN_SUCCEEDED';
-export const GET_PLUGINS = 'StrapiAdmin/InstallPluginPage/GET_PLUGINS';
-export const GET_PLUGINS_SUCCEEDED = 'StrapiAdmin/InstallPluginPage/GET_PLUGINS_SUCCEEDED';
+export const GET_AVAILABLE_PLUGINS = 'StrapiAdmin/InstallPluginPage/GET_AVAILABLE_PLUGINS';
+export const GET_AVAILABLE_PLUGINS_SUCCEEDED = 'StrapiAdmin/InstallPluginPage/GET_AVAILABLE_PLUGINS_SUCCEEDED';
+export const GET_INSTALLED_PLUGINS = 'StrapiAdmin/InstallPluginPage/GET_INSTALLED_PLUGINS';
+export const GET_INSTALLED_PLUGINS_SUCCEEDED = 'StrapiAdmin/InstallPluginPage/GET_INSTALLED_PLUGINS_SUCCEEDED';
export const ON_CHANGE = 'StrapiAdmin/InstallPluginPage/ON_CHANGE';
diff --git a/packages/strapi-admin/admin/src/containers/InstallPluginPage/index.js b/packages/strapi-admin/admin/src/containers/InstallPluginPage/index.js
index 49634bb882..c1c4016891 100644
--- a/packages/strapi-admin/admin/src/containers/InstallPluginPage/index.js
+++ b/packages/strapi-admin/admin/src/containers/InstallPluginPage/index.js
@@ -11,7 +11,7 @@ import { Helmet } from 'react-helmet';
import { FormattedMessage } from 'react-intl';
import { bindActionCreators, compose } from 'redux';
import cn from 'classnames';
-import { get, isUndefined, map } from 'lodash';
+import { map } from 'lodash';
import {
disableGlobalOverlayBlocker,
@@ -32,7 +32,8 @@ import injectReducer from 'utils/injectReducer';
import {
downloadPlugin,
- getPlugins,
+ getAvailablePlugins,
+ getInstalledPlugins,
onChange,
} from './actions';
@@ -55,8 +56,11 @@ export class InstallPluginPage extends React.Component { // eslint-disable-line
// Don't fetch the available plugins if it has already been done
if (!this.props.didFetchPlugins) {
- this.props.getPlugins();
+ this.props.getAvailablePlugins();
}
+
+ // Get installed plugins
+ this.props.getInstalledPlugins();
}
componentWillUnmount() {
@@ -65,10 +69,10 @@ export class InstallPluginPage extends React.Component { // eslint-disable-line
}
render() {
- if (!this.props.didFetchPlugins) {
+ if (!this.props.didFetchPlugins || !this.props.didFetchInstalledPlugins) {
return ;
}
-
+
return (
@@ -112,7 +116,7 @@ export class InstallPluginPage extends React.Component { // eslint-disable-line
key={plugin.id}
plugin={plugin}
showSupportUsButton={plugin.id === 'support-us'}
- isAlreadyInstalled={!isUndefined(get(this.context.plugins.toJS(), plugin.id))}
+ isAlreadyInstalled={this.props.installedPlugins.includes(plugin.id)}
downloadPlugin={(e) => {
e.preventDefault();
e.stopPropagation();
@@ -134,19 +138,18 @@ InstallPluginPage.childContextTypes = {
downloadPlugin: PropTypes.func.isRequired,
};
-InstallPluginPage.contextTypes = {
- plugins: PropTypes.object.isRequired,
-};
-
InstallPluginPage.propTypes = {
availablePlugins: PropTypes.array.isRequired,
blockApp: PropTypes.bool.isRequired,
+ didFetchInstalledPlugins: PropTypes.bool.isRequired,
didFetchPlugins: PropTypes.bool.isRequired,
disableGlobalOverlayBlocker: PropTypes.func.isRequired,
downloadPlugin: PropTypes.func.isRequired,
enableGlobalOverlayBlocker: PropTypes.func.isRequired,
- getPlugins: PropTypes.func.isRequired,
+ getAvailablePlugins: PropTypes.func.isRequired,
+ getInstalledPlugins: PropTypes.func.isRequired,
history: PropTypes.object.isRequired,
+ installedPlugins: PropTypes.array.isRequired,
// onChange: PropTypes.func.isRequired,
// search: PropTypes.string.isRequired,
};
@@ -159,7 +162,8 @@ function mapDispatchToProps(dispatch) {
disableGlobalOverlayBlocker,
downloadPlugin,
enableGlobalOverlayBlocker,
- getPlugins,
+ getAvailablePlugins,
+ getInstalledPlugins,
onChange,
},
dispatch,
diff --git a/packages/strapi-admin/admin/src/containers/InstallPluginPage/reducer.js b/packages/strapi-admin/admin/src/containers/InstallPluginPage/reducer.js
index cc70f6f36c..2f7f007b46 100644
--- a/packages/strapi-admin/admin/src/containers/InstallPluginPage/reducer.js
+++ b/packages/strapi-admin/admin/src/containers/InstallPluginPage/reducer.js
@@ -9,14 +9,17 @@ import {
DOWNLOAD_PLUGIN,
DOWNLOAD_PLUGIN_ERROR,
DOWNLOAD_PLUGIN_SUCCEEDED,
- GET_PLUGINS_SUCCEEDED,
+ GET_AVAILABLE_PLUGINS_SUCCEEDED,
+ GET_INSTALLED_PLUGINS_SUCCEEDED,
ON_CHANGE,
} from './constants';
const initialState = fromJS({
availablePlugins: List([]),
+ installedPlugins: List([]),
blockApp: false,
didFetchPlugins: false,
+ didFetchInstalledPlugins: false,
pluginToDownload: '',
search: '',
});
@@ -35,10 +38,14 @@ function installPluginPageReducer(state = initialState, action) {
return state
.set('blockApp', false)
.set('pluginToDownload', '');
- case GET_PLUGINS_SUCCEEDED:
+ case GET_AVAILABLE_PLUGINS_SUCCEEDED:
return state
.set('didFetchPlugins', true)
.set('availablePlugins', List(action.availablePlugins));
+ case GET_INSTALLED_PLUGINS_SUCCEEDED:
+ return state
+ .set('didFetchInstalledPlugins', true)
+ .set('installedPlugins', List(action.installedPlugins));
case ON_CHANGE:
return state.updateIn(action.keys, () => action.value);
default:
diff --git a/packages/strapi-admin/admin/src/containers/InstallPluginPage/saga.js b/packages/strapi-admin/admin/src/containers/InstallPluginPage/saga.js
index ee8c18c416..0a2384a6b0 100644
--- a/packages/strapi-admin/admin/src/containers/InstallPluginPage/saga.js
+++ b/packages/strapi-admin/admin/src/containers/InstallPluginPage/saga.js
@@ -15,9 +15,10 @@ import { selectLocale } from '../LanguageProvider/selectors';
import {
downloadPluginError,
downloadPluginSucceeded,
- getPluginsSucceeded,
+ getAvailablePluginsSucceeded,
+ getInstalledPluginsSucceeded,
} from './actions';
-import { DOWNLOAD_PLUGIN, GET_PLUGINS } from './constants';
+import { DOWNLOAD_PLUGIN, GET_AVAILABLE_PLUGINS, GET_INSTALLED_PLUGINS } from './constants';
import { makeSelectPluginToDownload } from './selectors';
@@ -49,7 +50,7 @@ export function* pluginDownload() {
}
}
-export function* pluginsGet() {
+export function* getAvailablePlugins() {
try {
// Get current locale.
const locale = yield select(selectLocale());
@@ -73,20 +74,44 @@ export function* pluginsGet() {
availablePlugins = [];
}
- yield put(getPluginsSucceeded(availablePlugins));
+ yield put(getAvailablePluginsSucceeded(availablePlugins));
} catch(err) {
strapi.notification.error('notification.error');
}
}
+export function* getInstalledPlugins() {
+ try {
+ const opts = {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ };
+ let installedPlugins;
+
+ try {
+ // Retrieve plugins list.
+ installedPlugins = yield call(request, '/admin/plugins', opts);
+ } catch (e) {
+ installedPlugins = [];
+ }
+
+ yield put(getInstalledPluginsSucceeded(Object.keys(installedPlugins.plugins)));
+ } catch(err) {
+ strapi.notification.error('notification.error');
+ }
+}
// Individual exports for testing
export default function* defaultSaga() {
- const loadPluginsWatcher = yield fork(takeLatest, GET_PLUGINS, pluginsGet);
+ const loadAvailablePluginsWatcher = yield fork(takeLatest, GET_AVAILABLE_PLUGINS, getAvailablePlugins);
+ const loadInstalledPluginsWatcher = yield fork(takeLatest, GET_INSTALLED_PLUGINS, getInstalledPlugins);
yield fork(takeLatest, DOWNLOAD_PLUGIN, pluginDownload);
yield take(LOCATION_CHANGE);
- yield cancel(loadPluginsWatcher);
+ yield cancel(loadAvailablePluginsWatcher);
+ yield cancel(loadInstalledPluginsWatcher);
}
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index b5778e1491..a918c9edf7 100755
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
+}
\ No newline at end of file
From 00b4fc0238fe121cce7e717d702092c77f1e0980 Mon Sep 17 00:00:00 2001
From: Pierre Burgy
Date: Wed, 8 Aug 2018 17:27:47 +0200
Subject: [PATCH 30/38] Disable eslint for app.js log
---
packages/strapi-admin/admin/src/app.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-admin/admin/src/app.js b/packages/strapi-admin/admin/src/app.js
index a7f4cff8d0..83a6e8debd 100755
--- a/packages/strapi-admin/admin/src/app.js
+++ b/packages/strapi-admin/admin/src/app.js
@@ -129,7 +129,7 @@ if (window.location.port !== '4000') {
});
})
.catch(err => {
- console.log(err);
+ console.log(err); // eslint-disable-line no-console
});
} else if (findIndex(plugins, ['id', 'users-permissions']) === -1) {
store.dispatch(unsetHasUserPlugin());
From 6ec3295ace862348145c49ce52895142cbae9ee3 Mon Sep 17 00:00:00 2001
From: KuongKnight
Date: Mon, 13 Aug 2018 10:09:38 +0700
Subject: [PATCH 31/38] updated document
---
docs/3.x.x/en/guides/models.md | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/docs/3.x.x/en/guides/models.md b/docs/3.x.x/en/guides/models.md
index 91f0a517bc..de58ff2c6d 100644
--- a/docs/3.x.x/en/guides/models.md
+++ b/docs/3.x.x/en/guides/models.md
@@ -19,6 +19,11 @@ The info key on the model-json states information about the model. This informat
- `description`: The description of the model.
- `mainField`: Determines which model-attribute is shown when displaying the model.
+## Model options
+The options key on the model-json states.
+ - `idAttribute`: This tells the model which attribute to expect as the unique identifier for each database row (typically an auto-incrementing primary key named 'id').
+ - `idAttributeType`: Data type of `idAttribute`, accepted list of value bellow:
+
## Define the attributes
The following types are currently available:
From 95ce4091f7b83fb5b98fd4135cd66526a29aee55 Mon Sep 17 00:00:00 2001
From: Jan Brachhold
Date: Thu, 16 Aug 2018 14:33:37 +0200
Subject: [PATCH 32/38] Update DE translations - strapi-admin
---
.../admin/src/translations/de.json | 42 +++++++++----------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/packages/strapi-admin/admin/src/translations/de.json b/packages/strapi-admin/admin/src/translations/de.json
index dffa3c4271..e302899aba 100644
--- a/packages/strapi-admin/admin/src/translations/de.json
+++ b/packages/strapi-admin/admin/src/translations/de.json
@@ -16,12 +16,12 @@
"app.components.HomePage.welcome": "Willkommen an Bord!",
"app.components.HomePage.welcome.again": "Willkommen",
"app.components.HomePage.create": "Erstelle deinen ersten Inhaltstyp",
- "app.components.HomePage.welcomeBlock.content": "Wir freuen uns, dich als Mitglied der Community zu haben. Wir sind offen für Feedback, senden uns einfach eine direkt Nachricht an\u0020",
- "app.components.HomePage.welcomeBlock.content.issues": "Fehler",
- "app.components.HomePage.welcomeBlock.content.raise": "\u0020oder erhöhen\u0020",
+ "app.components.HomePage.welcomeBlock.content": "Wir freuen uns, dich als Mitglied der Community zu haben. Wir sind offen für Feedback, senden uns einfach eine direkt Nachricht in\u0020",
+ "app.components.HomePage.welcomeBlock.content.issues": "Ticket.",
+ "app.components.HomePage.welcomeBlock.content.raise": "\u0020oder eröffne\u0020",
"app.components.HomePage.createBlock.content.first": "Das\u0020",
- "app.components.HomePage.createBlock.content.second": "\u0020Plugin wird dir helfen, die Datenstruktur deiner Modelle zu definieren. Wenn du neu hier bist, empfehlen wir dir unsere\u0020",
- "app.components.HomePage.createBlock.content.tutorial": "\u0020Anleitung.",
+ "app.components.HomePage.createBlock.content.second": "\u0020Plugin wird dir helfen, die Datenstruktur deiner Modelle zu definieren. Wenn du neu hier bist, empfehlen wir dir unser\u0020",
+ "app.components.HomePage.createBlock.content.tutorial": "\u0020Tutorial.",
"app.components.HomePage.welcomeBlock.content.again": "Wir hoffen, dass du Fortschritte bei deinem Projekt machst.... Lese das Neueste über Strapi. Wir geben unser Bestes, um das Produkt auf der Grundlage deines Feedbacks zu verbessern.",
"app.components.HomePage.cta": "BESTÄTIGEN",
"app.components.HomePage.community": "Finde die Community im Web",
@@ -44,7 +44,7 @@
"app.components.InstallPluginPage.helmet": "Marktplatz - Plugins",
"app.components.InstallPluginPage.title": "Marktplatz - Plugins",
- "app.components.InstallPluginPage.description": "Erweitere problemlos deine App",
+ "app.components.InstallPluginPage.description": "Erweitere problemlos deine App.",
"app.components.InstallPluginPage.plugin.support-us.description": "Unterstütze uns durch den Kauf eines Strapi T-Shirts. Das erlaubt uns, weiter an dem Projekt arbeiten zu können und es so gut wie nur möglich zu gestalten!",
"app.components.InstallPluginPage.InputSearch.label": " ",
"app.components.InstallPluginPage.InputSearch.placeholder": "Suche nach einem Plugin... (z.B.: Authentifizierung)",
@@ -126,20 +126,20 @@
"components.ListRow.empty": "Es gibt keine Daten.",
- "components.Wysiwyg.collapse": "Collapse",
- "components.Wysiwyg.selectOptions.title": "Add a title",
- "components.Wysiwyg.selectOptions.H1": "Title H1",
- "components.Wysiwyg.selectOptions.H2": "Title H2",
- "components.Wysiwyg.selectOptions.H3": "Title H3",
- "components.Wysiwyg.selectOptions.H4": "Title H4",
- "components.Wysiwyg.selectOptions.H5": "Title H5",
- "components.Wysiwyg.selectOptions.H6": "Title H6",
- "components.Wysiwyg.ToggleMode.markdown": "Switch to markdown",
- "components.Wysiwyg.ToggleMode.preview": "Switch to preview",
- "components.WysiwygBottomControls.charactersIndicators": "characters",
- "components.WysiwygBottomControls.uploadFiles": "Attach files by dragging & dropping, {browse}, or pasting from the clipboard.",
- "components.WysiwygBottomControls.uploadFiles.browse": "selecting them",
- "components.WysiwygBottomControls.fullscreen": "Expand",
+ "components.Wysiwyg.collapse": "Verkleinern",
+ "components.Wysiwyg.selectOptions.title": "Füge einen Überschrift hinzu",
+ "components.Wysiwyg.selectOptions.H1": "Überschrift H1",
+ "components.Wysiwyg.selectOptions.H2": "Überschrift H2",
+ "components.Wysiwyg.selectOptions.H3": "Überschrift H3",
+ "components.Wysiwyg.selectOptions.H4": "Überschrift H4",
+ "components.Wysiwyg.selectOptions.H5": "Überschrift H5",
+ "components.Wysiwyg.selectOptions.H6": "Überschrift H6",
+ "components.Wysiwyg.ToggleMode.markdown": "Wechsel zu Markdown",
+ "components.Wysiwyg.ToggleMode.preview": "Wechsel zur Vorschau",
+ "components.WysiwygBottomControls.charactersIndicators": "Zeichen",
+ "components.WysiwygBottomControls.uploadFiles": "Ziehe eine Datei hierher, {browse} eine Datei zum hochladen aus oder füge sie aus der Zwischenablage ein.",
+ "components.WysiwygBottomControls.uploadFiles.browse": "wähle",
+ "components.WysiwygBottomControls.fullscreen": "Vergrößern",
"HomePage.notification.newsLetter.success": "Newsletter erfolgreich abonniert",
@@ -148,7 +148,7 @@
"Analytics": "Analytics",
"Auth & Permissions": "Authentifizierung & Berechtigungen",
- "Content Manager": "Content-Manager",
+ "Content Manager": "Inhalts-Manager",
"Content Type Builder": "Inhaltstyp-Manager",
"Files Upload": "Dateien hochladen",
"Settings Manager": "Einstellungs-Manager",
From dbc2a223c311e704ee5bfba8f027f3001b48f7f7 Mon Sep 17 00:00:00 2001
From: Jan Brachhold
Date: Thu, 16 Aug 2018 14:33:55 +0200
Subject: [PATCH 33/38] Update DE translations - strapi-plugin-content-manager
---
.../admin/src/translations/de.json | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/strapi-plugin-content-manager/admin/src/translations/de.json b/packages/strapi-plugin-content-manager/admin/src/translations/de.json
index c771c16643..48e0430f9f 100644
--- a/packages/strapi-plugin-content-manager/admin/src/translations/de.json
+++ b/packages/strapi-plugin-content-manager/admin/src/translations/de.json
@@ -1,6 +1,6 @@
{
- "plugin.description.short": "Greife blitzschnell auf alle Daten in der Datenbank zu und manipuliere sie.",
- "plugin.description.long": "Greife blitzschnell auf alle Daten in der Datenbank zu und manipuliere sie.",
+ "plugin.description.short": "Greife blitzschnell auf alle Daten in der Datenbank zu und änder sie.",
+ "plugin.description.long": "Greife blitzschnell auf alle Daten in der Datenbank zu und änder sie.",
"containers.Home.pluginHeaderTitle": "Inhalts-Manager",
"containers.Home.introduction": "Um deine Einträge zu verwalten, klicke auf den entsprechenden Link im Menü links. Dieses Plugin ist noch in aktiver Entwicklung und seine Einstellungen können nicht optimal angepasst werden.",
@@ -24,7 +24,7 @@
"containers.SettingsPage.Block.generalSettings.description": "Konfiguriere die Standardoptionen für deine Inhaltstypen.",
"containers.SettingsPage.Block.generalSettings.title" : "Allgemeines",
"containers.SettingsPage.Block.contentType.title": "Inhaltstypen",
- "containers.SettingsPage.Block.contentType.description": "Konfiguriere die spezifischen Einstellungen",
+ "containers.SettingsPage.Block.contentType.description": "Konfiguriere die spezifischen Einstellungen.",
"containers.SettingsPage.pluginHeaderDescription": "Konfigurieren Sie die Standardeinstellungen für alle Ihre Inhaltstypen.",
"components.AddFilterCTA.add": "Filter",
From 2440a15eeb6f730d79d71b6eee88445887ef1fef Mon Sep 17 00:00:00 2001
From: Jan Brachhold
Date: Thu, 16 Aug 2018 14:34:13 +0200
Subject: [PATCH 34/38] Update DE translations - strapi-plugin-upload
---
packages/strapi-plugin-upload/admin/src/translations/de.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/strapi-plugin-upload/admin/src/translations/de.json b/packages/strapi-plugin-upload/admin/src/translations/de.json
index e0b03b6caa..75c6e44d12 100644
--- a/packages/strapi-plugin-upload/admin/src/translations/de.json
+++ b/packages/strapi-plugin-upload/admin/src/translations/de.json
@@ -13,8 +13,8 @@
"EntriesNumber.number": "{number} Datei gefunden",
"EntriesNumber.number.plural": "{number} Dateien gefunden",
- "HomePage.title": "Hochladen",
- "HomePage.description": "Übersicht über alle hochgeladenen Dateien",
+ "HomePage.title": "Dateien hochladen",
+ "HomePage.description": "Übersicht über alle hochgeladenen Dateien.",
"HomePage.InputSearch.placeholder": "Suche nach einer Datei...",
"Li.linkCopied": "Link in die Zwischenablage kopiert",
From cef161bc2841ce71c0f5c8bc8e697d7e3c9f4c68 Mon Sep 17 00:00:00 2001
From: Jan Brachhold
Date: Thu, 16 Aug 2018 14:34:27 +0200
Subject: [PATCH 35/38] Update DE translations -
strapi-plugin-users-permissions
---
.../admin/src/translations/de.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/strapi-plugin-users-permissions/admin/src/translations/de.json b/packages/strapi-plugin-users-permissions/admin/src/translations/de.json
index 60ed4e4b33..4e304d04a4 100755
--- a/packages/strapi-plugin-users-permissions/admin/src/translations/de.json
+++ b/packages/strapi-plugin-users-permissions/admin/src/translations/de.json
@@ -89,8 +89,8 @@
"HeaderNav.link.providers": "Methoden",
"HeaderNav.link.roles": "Rollen",
- "HomePage.header.title": "Benutzer & Befugnisse",
- "HomePage.header.description": "Lege Rollen und deren Befugnisse fest",
+ "HomePage.header.title": "Benutzer & Berechtigungen",
+ "HomePage.header.description": "Lege Rollen und deren Berechtigungen fest.",
"InputSearch.placeholder": "Suche nach einem Benutzer",
From b48dbe09fde009c83ca124d462adb26cc1ee4226 Mon Sep 17 00:00:00 2001
From: Jim LAURIE
Date: Tue, 21 Aug 2018 08:56:42 +0200
Subject: [PATCH 36/38] Fix end line
---
packages/strapi-admin/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index a918c9edf7..b5778e1491 100755
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
\ No newline at end of file
+}
From 96515492073cac0188097d58c67cf586ba4b32f2 Mon Sep 17 00:00:00 2001
From: Jim LAURIE
Date: Tue, 21 Aug 2018 08:57:34 +0200
Subject: [PATCH 37/38] Fix end line
---
packages/strapi-admin/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index a918c9edf7..b5778e1491 100755
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
\ No newline at end of file
+}
From 5645bb7c31ea4befe8beb405ddd7b8c6d59431a8 Mon Sep 17 00:00:00 2001
From: Jim LAURIE
Date: Tue, 21 Aug 2018 09:00:33 +0200
Subject: [PATCH 38/38] Fix end line
---
packages/strapi-admin/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index a918c9edf7..b5778e1491 100755
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
\ No newline at end of file
+}