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

linkinstar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git

commit aa76208b3ec284f833e132b60a4628035e84c617
Author: LinkinStars <[email protected]>
AuthorDate: Fri Jan 26 19:11:00 2024 +0800

    feat(wecom): add tip config
---
 user-center-wecom/go.mod              |  2 +-
 user-center-wecom/go.sum              |  4 ++--
 user-center-wecom/i18n/en_US.yaml     |  3 +++
 user-center-wecom/i18n/translation.go |  1 +
 user-center-wecom/i18n/zh_CN.yaml     |  3 +++
 user-center-wecom/user_config.go      | 16 +++++++++++++++-
 6 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/user-center-wecom/go.mod b/user-center-wecom/go.mod
index c561c34..12708be 100644
--- a/user-center-wecom/go.mod
+++ b/user-center-wecom/go.mod
@@ -3,7 +3,7 @@ module 
github.com/apache/incubator-answer-plugins/user-center-wecom
 go 1.19
 
 require (
-       github.com/apache/incubator-answer v1.2.2-0.20240117083035-5418bdb2fad1
+       github.com/apache/incubator-answer v1.2.2-0.20240126082646-a9a7ff422cf0
        github.com/gin-gonic/gin v1.9.1
        github.com/imroc/req/v3 v3.33.1
        github.com/patrickmn/go-cache v2.1.0+incompatible
diff --git a/user-center-wecom/go.sum b/user-center-wecom/go.sum
index 55eaba8..3dcb860 100644
--- a/user-center-wecom/go.sum
+++ b/user-center-wecom/go.sum
@@ -6,8 +6,8 @@ github.com/alicebob/gopher-json 
v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZp
 github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod 
h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
 github.com/alicebob/miniredis/v2 v2.30.0 
h1:uA3uhDbCxfO9+DI/DuGeAMr9qI+noVWwGPNTFuKID5M=
 github.com/alicebob/miniredis/v2 v2.30.0/go.mod 
h1:84TWKZlxYkfgMucPBf5SOQBYJceZeQRFIaQgNMiCX6Q=
-github.com/apache/incubator-answer v1.2.2-0.20240117083035-5418bdb2fad1 
h1:h1QQt3WaZ3IlTIH2JdZQP17kiU5XJ0NGUsFHODnJaWg=
-github.com/apache/incubator-answer v1.2.2-0.20240117083035-5418bdb2fad1/go.mod 
h1:yoYETRAnY3Bng3wEo+B6R9nXjZ1O3brs2DKWGpKYPcA=
+github.com/apache/incubator-answer v1.2.2-0.20240126082646-a9a7ff422cf0 
h1:gDanqLBPJ39MGwZh+Kjk1mxL3MB9Q6zFtv8YXmMqtxE=
+github.com/apache/incubator-answer v1.2.2-0.20240126082646-a9a7ff422cf0/go.mod 
h1:yoYETRAnY3Bng3wEo+B6R9nXjZ1O3brs2DKWGpKYPcA=
 github.com/aymerick/douceur v0.2.0 
h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
 github.com/aymerick/douceur v0.2.0/go.mod 
h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
 github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d 
h1:pVrfxiGfwelyab6n21ZBkbkmbevaf+WvMIiR7sr97hw=
diff --git a/user-center-wecom/i18n/en_US.yaml 
b/user-center-wecom/i18n/en_US.yaml
index cb5b527..d05d9d6 100644
--- a/user-center-wecom/i18n/en_US.yaml
+++ b/user-center-wecom/i18n/en_US.yaml
@@ -13,6 +13,9 @@ plugin:
         description:
           other: Get user info from WeCom and sync to User Center
       config:
+        tip:
+          title:
+            other: Push notification service has been turned off.
         auto_sync:
           label:
             other: Turn on auto sync
diff --git a/user-center-wecom/i18n/translation.go 
b/user-center-wecom/i18n/translation.go
index 0624d1b..c3547c1 100644
--- a/user-center-wecom/i18n/translation.go
+++ b/user-center-wecom/i18n/translation.go
@@ -3,6 +3,7 @@ package i18n
 const (
        InfoName                      = 
"plugin.wecom_user_center.backend.info.name"
        InfoDescription               = 
"plugin.wecom_user_center.backend.info.description"
+       ConfigTipTitle                = 
"plugin.wecom_user_center.backend.config.tip.title"
        ConfigAutoSyncLabel           = 
"plugin.wecom_user_center.backend.config.auto_sync.label"
        ConfigAutoSyncTitle           = 
"plugin.wecom_user_center.backend.config.auto_sync.title"
        ConfigAutoSyncDescription     = 
"plugin.wecom_user_center.backend.config.auto_sync.description"
diff --git a/user-center-wecom/i18n/zh_CN.yaml 
b/user-center-wecom/i18n/zh_CN.yaml
index 1decdca..647d7e7 100644
--- a/user-center-wecom/i18n/zh_CN.yaml
+++ b/user-center-wecom/i18n/zh_CN.yaml
@@ -13,6 +13,9 @@ plugin:
         description:
           other: 从企业微信获取用户信息并同步到用户中心
       config:
+        tip:
+          title:
+            other: 推送通知服务已关闭。
         auto_sync:
           label:
             other: 打开自动同步
diff --git a/user-center-wecom/user_config.go b/user-center-wecom/user_config.go
index 1ea7d81..b33a0a4 100644
--- a/user-center-wecom/user_config.go
+++ b/user-center-wecom/user_config.go
@@ -3,10 +3,11 @@ package wecom
 import (
        "encoding/json"
        "fmt"
+       "sync"
+
        "github.com/apache/incubator-answer-plugins/user-center-wecom/i18n"
        "github.com/apache/incubator-answer/plugin"
        "github.com/segmentfault/pacman/log"
-       "sync"
 )
 
 type UserConfig struct {
@@ -36,6 +37,19 @@ func (ucc *UserConfigCache) SetUserConfig(userID string, 
config *UserConfig) {
 
 func (uc *UserCenter) UserConfigFields() []plugin.ConfigField {
        fields := make([]plugin.ConfigField, 0)
+       // Show tip for user, if the notification service is disabled
+       if !uc.Config.Notification {
+               fields = append(fields, plugin.ConfigField{
+                       Name:        "tip",
+                       Type:        plugin.ConfigTypeLegend,
+                       Title:       plugin.MakeTranslator(i18n.ConfigTipTitle),
+                       Description: plugin.Translator{},
+                       UIOptions: plugin.ConfigFieldUIOptions{
+                               ClassName:      "mb-3",
+                               FieldClassName: "mb-0 text-danger",
+                       },
+               })
+       }
        fields = append(fields, createSwitchConfig(
                "inbox_notifications",
                i18n.UserConfigInboxNotificationsTitle,

Reply via email to