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

Merge branch 'master' into fix/gw7681-fix-oidc-reconnection

Haku Mizuki 4 лет назад
Родитель
Сommit
2063b334ed

+ 5 - 1
.github/workflows/reusable-app-prod.yml

@@ -177,7 +177,11 @@ jobs:
     if: ${{ !inputs.skip-cypress }}
 
     runs-on: ubuntu-latest
-    container: cypress/base:16.13.0
+    container:
+      image: cypress/base:16.13.0
+      # solve permissions issue
+      # see: https://github.com/cypress-io/github-action/issues/446#issuecomment-987015822
+      options: --user 1001
 
     strategy:
       fail-fast: false

+ 7 - 10
packages/app/src/components/Sidebar/RecentChanges.tsx

@@ -56,16 +56,13 @@ function LargePageItem({ page }) {
   }
 
   const tags = page.tags;
-  // when tag document is deleted from database directly tags includes null
-  const tagElements = tags.includes(null)
-    ? <></>
-    : tags.map((tag) => {
-      return (
-        <a key={tag.name} href={`/_search?q=tag:${tag.name}`} className="grw-tag-label badge badge-secondary mr-2 small">
-          {tag.name}
-        </a>
-      );
-    });
+  const tagElements = tags.map((tag) => {
+    return (
+      <a key={tag.name} href={`/_search?q=tag:${tag.name}`} className="grw-tag-label badge badge-secondary mr-2 small">
+        {tag.name}
+      </a>
+    );
+  });
 
   return (
     <li className="list-group-item py-3 px-0">

+ 3 - 1
packages/app/src/server/routes/apiv3/pages.js

@@ -381,7 +381,9 @@ module.exports = (crowi) => {
         if (!relationsMap.has(pageId)) {
           relationsMap.set(pageId, []);
         }
-        relationsMap.get(pageId).push(relation.relatedTag);
+        if (relation.relatedTag != null) {
+          relationsMap.get(pageId).push(relation.relatedTag);
+        }
       });
       // add tags to each page
       result.pages.forEach((page) => {

+ 6 - 0
packages/app/src/server/service/config-loader.ts

@@ -298,6 +298,12 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type:    ValueType.BOOLEAN,
     default: false,
   },
+  ELASTICSEARCH_REINDEX_ON_BOOT: {
+    ns:      'crowi',
+    key:     'app:elasticsearchReindexOnBoot',
+    type:    ValueType.BOOLEAN,
+    default: false,
+  },
   USE_ELASTICSEARCH_V6: {
     ns:      'crowi',
     key:     'app:useElasticsearchV6',

+ 8 - 1
packages/app/src/server/service/search-delegator/elasticsearch.ts

@@ -47,6 +47,8 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
 
   isElasticsearchV6: boolean
 
+  isElasticsearchReindexOnBoot: boolean
+
   elasticsearch: any
 
   client: any
@@ -65,6 +67,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
     this.isElasticsearchV6 = this.configManager.getConfig('crowi', 'app:useElasticsearchV6');
 
     this.elasticsearch = this.isElasticsearchV6 ? elasticsearch6 : elasticsearch7;
+    this.isElasticsearchReindexOnBoot = this.configManager.getConfig('crowi', 'app:elasticsearchReindexOnBoot');
     this.client = null;
 
     // In Elasticsearch RegExp, we don't need to used ^ and $.
@@ -144,7 +147,11 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
   }
 
   async init() {
-    return this.normalizeIndices();
+    const normalizeIndices = await this.normalizeIndices();
+    if (this.isElasticsearchReindexOnBoot) {
+      return this.rebuildIndex();
+    }
+    return normalizeIndices;
   }
 
   /**