Merge branch 'master' into fix/lifecycle

This commit is contained in:
Jim LAURIE 2018-04-25 12:27:33 +02:00 committed by GitHub
commit e6ad7de20e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 43 additions and 24 deletions

View File

@ -17,8 +17,10 @@ defineMessages(messages);
function LeftMenuFooter({ version }) { // eslint-disable-line react/prefer-stateless-function function LeftMenuFooter({ version }) { // eslint-disable-line react/prefer-stateless-function
return ( return (
<div className={styles.leftMenuFooter}> <div className={styles.leftMenuFooter}>
<div>
<FormattedMessage {...messages.poweredBy} /> <FormattedMessage {...messages.poweredBy} />
<a href="https://strapi.io" target="_blank">v{version}</a> <a href="https://strapi.io" target="_blank">v{version}</a>
</div>
<LocaleToggle /> <LocaleToggle />
</div> </div>
); );

View File

@ -3,7 +3,9 @@
.leftMenuFooter { /* stylelint-disable */ .leftMenuFooter { /* stylelint-disable */
position: absolute; position: absolute;
width: 100%; width: calc(100% - 2 * 15px);
display: flex;
justify-content: space-between;
bottom: 0; bottom: 0;
height: 3rem; height: 3rem;
padding-left: 15px; padding-left: 15px;

View File

@ -10,11 +10,12 @@
"port": "${process.env.DATABASE_PORT || 27017}", "port": "${process.env.DATABASE_PORT || 27017}",
"database": "${process.env.DATABASE_NAME || 'strapi-production'}", "database": "${process.env.DATABASE_NAME || 'strapi-production'}",
"username": "${process.env.DATABASE_USERNAME || ''}", "username": "${process.env.DATABASE_USERNAME || ''}",
"password": "${process.env.DATABASE_PASSWORD || ''}", "password": "${process.env.DATABASE_PASSWORD || ''}"
},
"options": {
"ssl": "${process.env.DATABASE_SSL || false}", "ssl": "${process.env.DATABASE_SSL || false}",
"authenticationDatabase": "${process.env.DATABASE_AUTHENTICATION_DATABASE || ''}" "authenticationDatabase": "${process.env.DATABASE_AUTHENTICATION_DATABASE || ''}"
}, }
"options": {}
} }
} }
} }

View File

@ -10,11 +10,12 @@
"port": "${process.env.DATABASE_PORT || 27017}", "port": "${process.env.DATABASE_PORT || 27017}",
"database": "${process.env.DATABASE_NAME || 'strapi-staging'}", "database": "${process.env.DATABASE_NAME || 'strapi-staging'}",
"username": "${process.env.DATABASE_USERNAME || ''}", "username": "${process.env.DATABASE_USERNAME || ''}",
"password": "${process.env.DATABASE_PASSWORD || ''}", "password": "${process.env.DATABASE_PASSWORD || ''}"
},
"options": {
"ssl": "${process.env.DATABASE_SSL || false}", "ssl": "${process.env.DATABASE_SSL || false}",
"authenticationDatabase": "${process.env.DATABASE_AUTHENTICATION_DATABASE || ''}" "authenticationDatabase": "${process.env.DATABASE_AUTHENTICATION_DATABASE || ''}"
}, }
"options": {}
} }
} }
} }

View File

@ -212,7 +212,6 @@ module.exports = (scope, cb) => {
} }
]) ])
.then(answers => { .then(answers => {
if (hasDatabaseConfig) { if (hasDatabaseConfig) {
answers = _.omit(scope.database.settings, ['client']) answers = _.omit(scope.database.settings, ['client'])
} }
@ -222,8 +221,8 @@ module.exports = (scope, cb) => {
scope.database.settings.database = answers.database; scope.database.settings.database = answers.database;
scope.database.settings.username = answers.username; scope.database.settings.username = answers.username;
scope.database.settings.password = answers.password; scope.database.settings.password = answers.password;
scope.database.settings.authenticationDatabase = answers.authenticationDatabase; scope.database.options.authenticationDatabase = answers.authenticationDatabase;
scope.database.settings.ssl = answers.ssl; scope.database.options.ssl = _.toString(answers.ssl) === 'true';
logger.info('Testing database connection...'); logger.info('Testing database connection...');

View File

@ -43,19 +43,24 @@ module.exports = function (strapi) {
initialize: cb => { initialize: cb => {
_.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-mongoose'}), (connection, connectionName) => { _.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-mongoose'}), (connection, connectionName) => {
const instance = new Mongoose(); const instance = new Mongoose();
const { uri, host, port, username, password, database, authenticationDatabase, ssl } = _.defaults(connection.settings, strapi.config.hook.settings.mongoose); const { uri, host, port, username, password, database } = _.defaults(connection.settings, strapi.config.hook.settings.mongoose);
const { authenticationDatabase, ssl } = _.defaults(connection.options, strapi.config.hook.settings.mongoose);
// Connect to mongo database // Connect to mongo database
const connectOptions = {} const connectOptions = {}
if (!_.isEmpty(username)) { if (!_.isEmpty(username)) {
connectOptions.user = username connectOptions.user = username;
if (!_.isEmpty(password)) { if (!_.isEmpty(password)) {
connectOptions.pass = password connectOptions.pass = password;
} }
} }
if (!_.isEmpty(authenticationDatabase)) { if (!_.isEmpty(authenticationDatabase)) {
connectOptions.authSource = authenticationDatabase; connectOptions.authSource = authenticationDatabase;
} }
connectOptions.ssl = ssl === true || ssl === 'true'; connectOptions.ssl = ssl === true || ssl === 'true';
instance.connect(uri || `mongodb://${host}:${port}/${database}`, connectOptions); instance.connect(uri || `mongodb://${host}:${port}/${database}`, connectOptions);

View File

@ -10,18 +10,27 @@ const logger = require('strapi-utils').logger;
module.exports = (scope, success, error) => { module.exports = (scope, success, error) => {
const Mongoose = require(path.resolve(`${scope.tmpPath}/node_modules/mongoose`)); const Mongoose = require(path.resolve(`${scope.tmpPath}/node_modules/mongoose`));
const { username, password, authenticationDatabase, ssl } = scope.database.settings const { username, password } = scope.database.settings;
const connectOptions = {} const { authenticationDatabase, ssl } = scope.database.options;
const connectOptions = {};
if (username) { if (username) {
connectOptions.user = username connectOptions.user = username;
if (password) { if (password) {
connectOptions.pass = password connectOptions.pass = password;
} }
} }
if (authenticationDatabase) { if (authenticationDatabase) {
connectOptions.authSource = authenticationDatabase; connectOptions.authSource = authenticationDatabase;
} }
connectOptions.ssl = ssl ? true : false
connectOptions.ssl = ssl ? true : false;
console.log(connectOptions);
Mongoose.connect(`mongodb://${scope.database.settings.host}:${scope.database.settings.port}/${scope.database.settings.database}`, connectOptions, function (err) { Mongoose.connect(`mongodb://${scope.database.settings.host}:${scope.database.settings.port}/${scope.database.settings.database}`, connectOptions, function (err) {
if (err) { if (err) {
logger.warn('Database connection has failed! Make sure your database is running.'); logger.warn('Database connection has failed! Make sure your database is running.');

View File

@ -115,13 +115,13 @@ module.exports = {
try { try {
const modelJSON = _.cloneDeep(require(modelFilePath)); const modelJSON = _.cloneDeep(require(modelFilePath));
modelJSON.attributes = formatedAttributes; modelJSON.connection = connection;
modelJSON.collectionName = collectionName;
modelJSON.info = { modelJSON.info = {
name, name,
description description
}; };
modelJSON.connection = connection; modelJSON.attributes = formatedAttributes;
modelJSON.collectionName = collectionName;
const clearRelationsErrors = Service.clearRelations(model, plugin); const clearRelationsErrors = Service.clearRelations(model, plugin);

View File

@ -181,7 +181,7 @@ module.exports = {
_.forEach(attributesConfigurable, attribute => { _.forEach(attributesConfigurable, attribute => {
if (_.has(attribute, 'params.type')) { if (_.has(attribute, 'params.type')) {
attrs[attribute.name] = attribute.params; attrs[attribute.name] = _.omit(attribute.params, 'multiple');
if (attribute.params.type === 'media') { if (attribute.params.type === 'media') {
const via = _.findKey(strapi.plugins.upload.models.file.attributes, {collection: '*'}); const via = _.findKey(strapi.plugins.upload.models.file.attributes, {collection: '*'});