Просмотр исходного кода

Merge pull request #3076 from weseek/dev/4.1.x

Dev/4.1.x
Yuki Takei 5 лет назад
Родитель
Сommit
9412958371

+ 5 - 0
CHANGES.md

@@ -1,5 +1,10 @@
 # CHANGES
 # CHANGES
 
 
+## v4.1.11-RC
+
+* Improvement: Generating draft DOM id strategy
+* Fix: GROWI version downgrade causes a validation error for user.lang
+
 ## v4.1.10
 ## v4.1.10
 
 
 * Fix: Make listing users API secure
 * Fix: Make listing users API secure

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "growi",
   "name": "growi",
-  "version": "4.1.10-RC",
+  "version": "4.1.11-RC",
   "description": "Team collaboration software using markdown",
   "description": "Team collaboration software using markdown",
   "tags": [
   "tags": [
     "wiki",
     "wiki",

+ 4 - 4
src/client/js/components/MyDraftList/Draft.jsx

@@ -104,10 +104,9 @@ class Draft extends React.Component {
   }
   }
 
 
   renderControls() {
   renderControls() {
-    const { t, path } = this.props;
+    const { t, path, index } = this.props;
 
 
-    const encodedPath = path.replace(/\//g, '-');
-    const tooltipTargetId = `draft-copied-tooltip_${encodedPath}`;
+    const tooltipTargetId = `draft-copied-tooltip_${index}`;
 
 
     return (
     return (
       <div className="icon-container">
       <div className="icon-container">
@@ -115,7 +114,7 @@ class Draft extends React.Component {
           ? null
           ? null
           : (
           : (
             <a
             <a
-              href={`${this.props.path}#edit`}
+              href={`${path}#edit`}
               target="_blank"
               target="_blank"
               rel="noopener noreferrer"
               rel="noopener noreferrer"
               data-toggle="tooltip"
               data-toggle="tooltip"
@@ -202,6 +201,7 @@ Draft.propTypes = {
   t: PropTypes.func.isRequired,
   t: PropTypes.func.isRequired,
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
 
 
+  index: PropTypes.number.isRequired,
   path: PropTypes.string.isRequired,
   path: PropTypes.string.isRequired,
   markdown: PropTypes.string.isRequired,
   markdown: PropTypes.string.isRequired,
   isExist: PropTypes.bool.isRequired,
   isExist: PropTypes.bool.isRequired,

+ 2 - 1
src/client/js/components/MyDraftList/MyDraftList.jsx

@@ -91,9 +91,10 @@ class MyDraftList extends React.Component {
    *
    *
    */
    */
   generateDraftList(drafts) {
   generateDraftList(drafts) {
-    return drafts.map((draft) => {
+    return drafts.map((draft, index) => {
       return (
       return (
         <Draft
         <Draft
+          index={index}
           key={draft.path}
           key={draft.path}
           path={draft.path}
           path={draft.path}
           markdown={draft.markdown}
           markdown={draft.markdown}

+ 16 - 0
src/lib/util/locale-utils.js

@@ -2,6 +2,11 @@ const fs = require('fs');
 
 
 const helpers = require('./helpers');
 const helpers = require('./helpers');
 
 
+const MIGRATE_LOCALE_MAP = {
+  en: 'en_US',
+  ja: 'ja_JP',
+};
+
 /**
 /**
  * List locales dirents
  * List locales dirents
  */
  */
@@ -28,7 +33,18 @@ function listLocaleIds() {
     .map(meta => meta.id);
     .map(meta => meta.id);
 }
 }
 
 
+function migrateDeprecatedLocaleId(localeId) {
+  const toValue = MIGRATE_LOCALE_MAP[localeId];
+
+  if (toValue != null) {
+    return toValue;
+  }
+
+  return localeId;
+}
+
 module.exports = {
 module.exports = {
   listLocaleMetadatas,
   listLocaleMetadatas,
   listLocaleIds,
   listLocaleIds,
+  migrateDeprecatedLocaleId,
 };
 };

+ 5 - 1
src/server/models/user.js

@@ -11,7 +11,7 @@ const md5 = require('md5');
 const ObjectId = mongoose.Schema.Types.ObjectId;
 const ObjectId = mongoose.Schema.Types.ObjectId;
 const crypto = require('crypto');
 const crypto = require('crypto');
 
 
-const { listLocaleIds } = require('@commons/util/locale-utils');
+const { listLocaleIds, migrateDeprecatedLocaleId } = require('@commons/util/locale-utils');
 
 
 module.exports = function(crowi) {
 module.exports = function(crowi) {
   const STATUS_REGISTERED = 1;
   const STATUS_REGISTERED = 1;
@@ -75,6 +75,10 @@ module.exports = function(crowi) {
       },
       },
     },
     },
   });
   });
+  // eslint-disable-next-line prefer-arrow-callback
+  userSchema.pre('validate', function() {
+    this.lang = migrateDeprecatedLocaleId(this.lang);
+  });
   userSchema.plugin(mongoosePaginate);
   userSchema.plugin(mongoosePaginate);
   userSchema.plugin(uniqueValidator);
   userSchema.plugin(uniqueValidator);