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
return (
<div className={styles.leftMenuFooter}>
<FormattedMessage {...messages.poweredBy} />
<a href="https://strapi.io" target="_blank">v{version}</a>
<div>
<FormattedMessage {...messages.poweredBy} />
<a href="https://strapi.io" target="_blank">v{version}</a>
</div>
<LocaleToggle />
</div>
);

View File

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

View File

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

View File

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

View File

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

View File

@ -43,19 +43,24 @@ module.exports = function (strapi) {
initialize: cb => {
_.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-mongoose'}), (connection, connectionName) => {
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
const connectOptions = {}
if (!_.isEmpty(username)) {
connectOptions.user = username
connectOptions.user = username;
if (!_.isEmpty(password)) {
connectOptions.pass = password
connectOptions.pass = password;
}
}
if (!_.isEmpty(authenticationDatabase)) {
connectOptions.authSource = authenticationDatabase;
}
connectOptions.ssl = ssl === true || ssl === 'true';
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) => {
const Mongoose = require(path.resolve(`${scope.tmpPath}/node_modules/mongoose`));
const { username, password, authenticationDatabase, ssl } = scope.database.settings
const connectOptions = {}
const { username, password } = scope.database.settings;
const { authenticationDatabase, ssl } = scope.database.options;
const connectOptions = {};
if (username) {
connectOptions.user = username
connectOptions.user = username;
if (password) {
connectOptions.pass = password
connectOptions.pass = password;
}
}
if (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) {
if (err) {
logger.warn('Database connection has failed! Make sure your database is running.');

View File

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

View File

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