You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by sh...@apache.org on 2024/03/14 06:34:26 UTC

(incubator-answer) branch feat/1.3.0/ui updated (741591de -> 87d8d2a0)

This is an automated email from the ASF dual-hosted git repository.

shuai pushed a change to branch feat/1.3.0/ui
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git


    from 741591de fix: hide split componnets
     new 6201a5a7 fix: answer add pending state
     new 87d8d2a0 fix: diff error

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 i18n/en_US.yaml                                    |  1 +
 ui/config-overrides.js                             | 16 ++++-----
 .../Questions/Detail/components/Answer/index.tsx   |  6 ++++
 ui/src/utils/common.ts                             | 42 +++++++++++-----------
 4 files changed, 36 insertions(+), 29 deletions(-)


(incubator-answer) 02/02: fix: diff error

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch feat/1.3.0/ui
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 87d8d2a00825f4c2fdf917534eac1c82a4fe22ba
Author: shuai <li...@sifou.com>
AuthorDate: Thu Mar 14 14:34:02 2024 +0800

    fix: diff error
---
 ui/src/utils/common.ts | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.ts
index 13644cd0..27d303b3 100644
--- a/ui/src/utils/common.ts
+++ b/ui/src/utils/common.ts
@@ -23,6 +23,8 @@ import pattern from '@/common/pattern';
 import { USER_AGENT_NAMES } from '@/common/constants';
 import type * as Type from '@/common/interface';
 
+const Diff = require('diff');
+
 function thousandthDivision(num) {
   const reg = /\d{1,3}(?=(\d{3})+$)/g;
   return `${num}`.replace(reg, '$&,');
@@ -184,30 +186,28 @@ function diffText(newText: string, oldText?: string): string {
     return escapeHtml(newText);
   }
   let result = [];
-  import('diff').then((Diff) => {
-    const diff = Diff.diffChars(escapeHtml(oldText), escapeHtml(newText));
-    result = diff.map((part) => {
-      if (part.added) {
-        if (part.value.replace(/\n/g, '').length <= 0) {
-          return `<span class="review-text-add d-block">${part.value.replace(
-            /\n/g,
-            '↵\n',
-          )}</span>`;
-        }
-        return `<span class="review-text-add">${part.value}</span>`;
+  const diff = Diff.diffChars(escapeHtml(oldText), escapeHtml(newText));
+  result = diff.map((part) => {
+    if (part.added) {
+      if (part.value.replace(/\n/g, '').length <= 0) {
+        return `<span class="review-text-add d-block">${part.value.replace(
+          /\n/g,
+          '↵\n',
+        )}</span>`;
       }
-      if (part.removed) {
-        if (part.value.replace(/\n/g, '').length <= 0) {
-          return `<span class="review-text-delete text-decoration-none d-block">${part.value.replace(
-            /\n/g,
-            '↵\n',
-          )}</span>`;
-        }
-        return `<span class="review-text-delete">${part.value}</span>`;
+      return `<span class="review-text-add">${part.value}</span>`;
+    }
+    if (part.removed) {
+      if (part.value.replace(/\n/g, '').length <= 0) {
+        return `<span class="review-text-delete text-decoration-none d-block">${part.value.replace(
+          /\n/g,
+          '↵\n',
+        )}</span>`;
       }
+      return `<span class="review-text-delete">${part.value}</span>`;
+    }
 
-      return part.value;
-    });
+    return part.value;
   });
 
   return result.join('');


(incubator-answer) 01/02: fix: answer add pending state

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch feat/1.3.0/ui
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 6201a5a740908818afa24cf78fd70e087fd12ef4
Author: shuai <li...@sifou.com>
AuthorDate: Thu Mar 14 12:13:06 2024 +0800

    fix: answer add pending state
---
 i18n/en_US.yaml                                          |  1 +
 ui/config-overrides.js                                   | 16 ++++++++--------
 .../pages/Questions/Detail/components/Answer/index.tsx   |  6 ++++++
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index 7236e700..37a2ecdc 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -1882,3 +1882,4 @@ ui:
     post_reopen: This post has been reopened.
     post_list: This post has been listed.
     post_unlist: This post has been unlisted.
+    post_pending: Your post is awaiting review. This is a preview, it will be visible after it has been approved.
diff --git a/ui/config-overrides.js b/ui/config-overrides.js
index 770d8096..11496b08 100644
--- a/ui/config-overrides.js
+++ b/ui/config-overrides.js
@@ -44,14 +44,14 @@ module.exports = {
       minChunks: 2,
       cacheGroups: {
         automaticNamePrefix: 'chunk',
-        // components: {
-        //   test: /[\\/]components[\\/]/,
-        //   name: 'components',
-        //   priority: 14,
-        //   reuseExistingChunk: true,
-        //   minChunks: 1,
-        //   chunks: 'initial',
-        // },
+        components: {
+          test: /[\\/]components[\\/]/,
+          name: 'components',
+          priority: 14,
+          reuseExistingChunk: true,
+          minChunks: process.env.NODE_ENV === 'production' ? 1 : 2,
+          chunks: 'initial',
+        },
         i18next: {
           name: 'i18next',
           test: /[\/]node_modules[\/](i18next)[\/]/,
diff --git a/ui/src/pages/Questions/Detail/components/Answer/index.tsx b/ui/src/pages/Questions/Detail/components/Answer/index.tsx
index 1fc90955..474c83d6 100644
--- a/ui/src/pages/Questions/Detail/components/Answer/index.tsx
+++ b/ui/src/pages/Questions/Detail/components/Answer/index.tsx
@@ -99,6 +99,12 @@ const Index: FC<Props> = ({
           {t('post_deleted', { keyPrefix: 'messages' })}
         </Alert>
       )}
+      {data.status === 11 && (
+        <Alert variant="secondary" className="mb-4">
+          {t('post_pending', { keyPrefix: 'messages' })}
+        </Alert>
+      )}
+
       {data?.accepted === 2 && (
         <div className="mb-3 lh-1">
           <Badge bg="success" pill>