A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
Release/1.2.5 (#759)
LinkinStars937de4397885
diff --git a/.github/ISSUE_TEMPLATE/config.yaml b/.github/ISSUE_TEMPLATE/config.yamlindex bfb8cd99..3b27f824 100644--- a/.github/ISSUE_TEMPLATE/config.yaml+++ b/.github/ISSUE_TEMPLATE/config.yaml@@ -1,3 +1,20 @@+# Licensed to the Apache Software Foundation (ASF) under one+# or more contributor license agreements. See the NOTICE file+# distributed with this work for additional information+# regarding copyright ownership. The ASF licenses this file+# to you under the Apache License, Version 2.0 (the+# "License"); you may not use this file except in compliance+# with the License. You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing,+# software distributed under the License is distributed on an+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+# KIND, either express or implied. See the License for the+# specific language governing permissions and limitations+# under the License.+blank_issues_enabled: truecontact_links:- name: Supportdiff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.ymldeleted file mode 100644index be4ec951..00000000--- a/.github/workflows/uffizzi-build.yml+++ /dev/null@@ -1,115 +0,0 @@-# Licensed to the Apache Software Foundation (ASF) under one-# or more contributor license agreements. See the NOTICE file-# distributed with this work for additional information-# regarding copyright ownership. The ASF licenses this file-# to you under the Apache License, Version 2.0 (the-# "License"); you may not use this file except in compliance-# with the License. You may obtain a copy of the License at-#-# http://www.apache.org/licenses/LICENSE-2.0-#-# Unless required by applicable law or agreed to in writing,-# software distributed under the License is distributed on an-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-# KIND, either express or implied. See the License for the-# specific language governing permissions and limitations-# under the License.--name: Build PR Image-on:- pull_request:- types: [opened, synchronize, reopened, closed]--jobs:- build-answer:- name: Build and push `Answer`- runs-on: ubuntu-latest- outputs:- tags: ${{ steps.meta.outputs.tags }}- if: ${{ github.event.action != 'closed' && github.repository_owner == 'apache' }}- steps:- - name: Checkout git repo- uses: actions/checkout@v4-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v2-- - name: Generate UUID image name- id: uuid- run: echo "UUID_WORKER=answer-$(uuidgen --time)" >> $GITHUB_ENV-- - name: Docker metadata- id: meta- uses: docker/metadata-action@v4- with:- images: registry.uffizzi.com/${{ env.UUID_WORKER }}- tags: |- type=raw,value=30d-- - name: Build and Push Image to registry.uffizzi.com - Uffizzi's ephemeral Registry- uses: docker/build-push-action@v3- with:- context: .- file: ./Dockerfile- tags: ${{ steps.meta.outputs.tags }}- labels: ${{ steps.meta.outputs.labels }}- push: true- cache-from: type=gha- cache-to: type=gha, mode=max-- render-compose-file:- name: Render Docker Compose File- # Pass output of this workflow to another triggered by `workflow_run` event.- runs-on: ubuntu-latest- needs:- - build-answer- outputs:- compose-file-cache-key: ${{ steps.hash.outputs.hash }}- steps:- - name: Checkout git repo- uses: actions/checkout@v4- - name: Render Compose File- run: |- ANSWER_IMAGE=${{ needs.build-answer.outputs.tags }}- export ANSWER_IMAGE- export UFFIZZI_URL=\$UFFIZZI_URL- # Render simple template from environment variables.- envsubst < docker-compose.uffizzi.yml > docker-compose.rendered.yml- cat docker-compose.rendered.yml- - name: Upload Rendered Compose File as Artifact- uses: actions/upload-artifact@v3- with:- name: preview-spec- path: docker-compose.rendered.yml- retention-days: 2- - name: Serialize PR Event to File- run: |- cat << EOF > event.json- ${{ toJSON(github.event) }}-- EOF- - name: Upload PR Event as Artifact- uses: actions/upload-artifact@v3- with:- name: preview-spec- path: event.json- retention-days: 2-- delete-preview:- name: Call for Preview Deletion- runs-on: ubuntu-latest- if: ${{ github.event.action == 'closed' && github.repository_owner == 'apache' }}- steps:- # If this PR is closing, we will not render a compose file nor pass it to the next workflow.- - name: Serialize PR Event to File- run: |- cat << EOF > event.json- ${{ toJSON(github.event) }}-- EOF- - name: Upload PR Event as Artifact- uses: actions/upload-artifact@v3- with:- name: preview-spec- path: event.json- retention-days: 2diff --git a/.github/workflows/uffizzi-preview.yml b/.github/workflows/uffizzi-preview.ymldeleted file mode 100644index c7a38f33..00000000--- a/.github/workflows/uffizzi-preview.yml+++ /dev/null@@ -1,113 +0,0 @@-# Licensed to the Apache Software Foundation (ASF) under one-# or more contributor license agreements. See the NOTICE file-# distributed with this work for additional information-# regarding copyright ownership. The ASF licenses this file-# to you under the Apache License, Version 2.0 (the-# "License"); you may not use this file except in compliance-# with the License. You may obtain a copy of the License at-#-# http://www.apache.org/licenses/LICENSE-2.0-#-# Unless required by applicable law or agreed to in writing,-# software distributed under the License is distributed on an-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-# KIND, either express or implied. See the License for the-# specific language governing permissions and limitations-# under the License.--name: Deploy Uffizzi Preview--on:- workflow_run:- workflows:- - "Build PR Image"- types:- - completed--jobs:- cache-compose-file:- name: Cache Compose File- runs-on: ubuntu-latest- if: ${{ github.event.workflow_run.conclusion == 'success' }}- outputs:- compose-file-cache-key: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }}- git-ref: ${{ steps.event.outputs.GIT_REF }}- pr-number: ${{ steps.event.outputs.PR_NUMBER }}- action: ${{ steps.event.outputs.ACTION }}- steps:- - name: Download artifacts- # Fetch output (zip archive) from the workflow run that triggered this workflow.- uses: actions/github-script@v6- with:- script: |- let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({- owner: context.repo.owner,- repo: context.repo.repo,- run_id: context.payload.workflow_run.id,- });- let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {- return artifact.name == "preview-spec"- })[0];- if (matchArtifact === undefined) {- throw TypeError('Build Artifact not found!');- }- let download = await github.rest.actions.downloadArtifact({- owner: context.repo.owner,- repo: context.repo.repo,- artifact_id: matchArtifact.id,- archive_format: 'zip',- });- let fs = require('fs');- fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data));-- - name: 'Accept event from first stage'- run: unzip preview-spec.zip event.json-- - name: Read Event into ENV- id: event- run: |- echo PR_NUMBER=$(jq '.number | tonumber' < event.json) >> $GITHUB_OUTPUT- echo ACTION=$(jq --raw-output '.action | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT- echo GIT_REF=$(jq --raw-output '.pull_request.head.sha | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT-- - name: Hash Rendered Compose File- id: hash- # If the previous workflow was triggered by a PR close event, we will not have a compose file artifact.- if: ${{ steps.event.outputs.ACTION != 'closed' }}- run: |- unzip preview-spec.zip docker-compose.rendered.yml- echo "COMPOSE_FILE_HASH=$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" >> $GITHUB_OUTPUT-- - name: Cache Rendered Compose File- if: ${{ steps.event.outputs.ACTION != 'closed' }}- uses: actions/cache@v3- with:- path: docker-compose.rendered.yml- key: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }}-- - name: DEBUG - Print Job Outputs- if: ${{ runner.debug }}- run: |- echo "PR number: ${{ steps.event.outputs.PR_NUMBER }}"- echo "Git Ref: ${{ steps.event.outputs.GIT_REF }}"- echo "Action: ${{ steps.event.outputs.ACTION }}"- echo "Compose file hash: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }}"- cat event.json-- deploy-uffizzi-preview:- name: Use Remote Workflow to Preview on Uffizzi- needs:- - cache-compose-file- if: ${{ github.event.workflow_run.conclusion == 'success' }}- uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2- with:- # If this workflow was triggered by a PR close event, cache-key will be an empty string- # and this reusable workflow will delete the preview deployment.- compose-file-cache-key: ${{ needs.cache-compose-file.outputs.compose-file-cache-key }}- compose-file-cache-path: docker-compose.rendered.yml- server: https://app.uffizzi.com- pr-number: ${{ needs.cache-compose-file.outputs.pr-number }}- permissions:- contents: read- pull-requests: write- id-token: writediff --git a/Dockerfile b/Dockerfileindex 38ca086c..6278e1a5 100644--- a/Dockerfile+++ b/Dockerfile@@ -47,7 +47,9 @@ RUN mkdir -p /data/uploads && chmod 777 /data/uploads \FROM alpineLABEL maintainer="[email protected]"-ENV TZ "Asia/Shanghai"+ARG TIMEZONE+ENV TIMEZONE=${TIMEZONE:-"Asia/Shanghai"}+RUN apk update \&& apk --no-cache add \bash \@@ -58,7 +60,9 @@ RUN apk update \openssh \sqlite \gnupg \- && echo "Asia/Shanghai" > /etc/timezone+ tzdata \+ && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \+ && echo "${TIMEZONE}" > /etc/timezoneCOPY --from=golang-builder /usr/bin/answer /usr/bin/answerCOPY --from=golang-builder /data /datadiff --git a/Makefile b/Makefileindex 6750d95d..637257f6 100644--- a/Makefile+++ b/Makefile@@ -1,6 +1,6 @@.PHONY: build clean ui-VERSION=1.2.1+VERSION=1.2.5BIN=answerDIR_SRC=./cmd/answerDOCKER_CMD=dockerdiff --git a/README.md b/README.mdindex 4d5a6596..c0509510 100644--- a/README.md+++ b/README.md@@ -23,7 +23,7 @@ To learn more about the project, visit [answer.apache.org](https://answer.apache### Running with docker```bash-docker run -d -p 9080:80 -v answer-data:/data --name answer apache/answer:1.2.1+docker run -d -p 9080:80 -v answer-data:/data --name answer apache/answer:1.2.5```For more information, see [Installation](https://answer.apache.org/docs/installation).@@ -43,11 +43,17 @@ You can also check out the [plugins here](https://answer.apache.org/plugins).- Golang >= 1.18- Node.js >= 16.17- pnpm >= 8+- mockgen >= 1.6.0+- wire >= 0.5.0### Build```bash+# install wire and mockgen for building+$ make generate+# install frontend dependencies and build$ make ui+# install backend dependencies and build$ make build```diff --git a/cmd/wire_gen.go b/cmd/wire_gen.goindex a057660c..199c2ce9 100644--- a/cmd/wire_gen.go+++ b/cmd/wire_gen.go@@ -201,8 +201,8 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,collectionController := controller.NewCollectionController(collectionService)answerActivityRepo := activity.NewAnswerActivityRepo(dataData, activityRepo, userRankRepo, notificationQueueService)answerActivityService := activity2.NewAnswerActivityService(answerActivityRepo, configService)- externalNotificationService := notification.NewExternalNotificationService(dataData, userNotificationConfigRepo, followRepo, emailService, userRepo, externalNotificationQueueService)- questionService := service.NewQuestionService(questionRepo, tagCommonService, questionCommon, userCommon, userRepo, revisionService, metaService, collectionCommon, answerActivityService, emailService, notificationQueueService, externalNotificationQueueService, activityQueueService, siteInfoCommonService, externalNotificationService)+ externalNotificationService := notification.NewExternalNotificationService(dataData, userNotificationConfigRepo, followRepo, emailService, userRepo, externalNotificationQueueService, userExternalLoginRepo, siteInfoCommonService)+ questionService := service.NewQuestionService(questionRepo, tagCommonService, questionCommon, userCommon, userRepo, userRoleRelService, revisionService, metaService, collectionCommon, answerActivityService, emailService, notificationQueueService, externalNotificationQueueService, activityQueueService, siteInfoCommonService, externalNotificationService)answerService := service.NewAnswerService(answerRepo, questionRepo, questionCommon, userCommon, collectionCommon, userRepo, revisionService, answerActivityService, answerCommon, voteRepo, emailService, userRoleRelService, notificationQueueService, externalNotificationQueueService, activityQueueService)questionController := controller.NewQuestionController(questionService, answerService, rankService, siteInfoCommonService, captchaService, rateLimitMiddleware)answerController := controller.NewAnswerController(answerService, rankService, captchaService, siteInfoCommonService, rateLimitMiddleware)@@ -227,7 +227,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,siteInfoController := controller_admin.NewSiteInfoController(siteInfoService)controllerSiteInfoController := controller.NewSiteInfoController(siteInfoCommonService)notificationRepo := notification2.NewNotificationRepo(dataData)- notificationCommon := notificationcommon.NewNotificationCommon(dataData, notificationRepo, userCommon, activityRepo, followRepo, objService, notificationQueueService)+ notificationCommon := notificationcommon.NewNotificationCommon(dataData, notificationRepo, userCommon, activityRepo, followRepo, objService, notificationQueueService, userExternalLoginRepo, siteInfoCommonService)notificationService := notification.NewNotificationService(dataData, notificationRepo, notificationCommon, revisionService, userRepo)notificationController := controller.NewNotificationController(notificationService, rankService)dashboardService := dashboard.NewDashboardService(questionRepo, answerRepo, commentCommonRepo, voteRepo, userRepo, reportRepo, configService, siteInfoCommonService, serviceConf, dataData)@@ -241,10 +241,12 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,activityController := controller.NewActivityController(activityService)roleController := controller_admin.NewRoleController(roleService)pluginConfigRepo := plugin_config.NewPluginConfigRepo(dataData)- pluginCommonService := plugin_common.NewPluginCommonService(pluginConfigRepo, configService, dataData)+ pluginUserConfigRepo := plugin_config.NewPluginUserConfigRepo(dataData)+ pluginCommonService := plugin_common.NewPluginCommonService(pluginConfigRepo, pluginUserConfigRepo, configService, dataData)pluginController := controller_admin.NewPluginController(pluginCommonService)permissionController := controller.NewPermissionController(rankService)- answerAPIRouter := router.NewAnswerAPIRouter(langController, userController, commentController, reportController, voteController, tagController, followController, collectionController, questionController, answerController, searchController, revisionController, rankController, controller_adminReportController, userAdminController, reasonController, themeController, siteInfoController, controllerSiteInfoController, notificationController, dashboardController, uploadController, activityController, roleController, pluginController, permissionController)+ userPluginController := controller.NewUserPluginController(pluginCommonService)+ answerAPIRouter := router.NewAnswerAPIRouter(langController, userController, commentController, reportController, voteController, tagController, followController, collectionController, questionController, answerController, searchController, revisionController, rankController, controller_adminReportController, userAdminController, reasonController, themeController, siteInfoController, controllerSiteInfoController, notificationController, dashboardController, uploadController, activityController, roleController, pluginController, permissionController, userPluginController)swaggerRouter := router.NewSwaggerRouter(swaggerConf)uiRouter := router.NewUIRouter(controllerSiteInfoController, siteInfoCommonService)authUserMiddleware := middleware.NewAuthUserMiddleware(authService, siteInfoCommonService)diff --git a/docker-compose.uffizzi.yml b/docker-compose.uffizzi.ymldeleted file mode 100644index 74d75bb7..00000000--- a/docker-compose.uffizzi.yml+++ /dev/null@@ -1,77 +0,0 @@-# Licensed to the Apache Software Foundation (ASF) under one-# or more contributor license agreements. See the NOTICE file-# distributed with this work for additional information-# regarding copyright ownership. The ASF licenses this file-# to you under the Apache License, Version 2.0 (the-# "License"); you may not use this file except in compliance-# with the License. You may obtain a copy of the License at-#-# http://www.apache.org/licenses/LICENSE-2.0-#-# Unless required by applicable law or agreed to in writing,-# software distributed under the License is distributed on an-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-# KIND, either express or implied. See the License for the-# specific language governing permissions and limitations-# under the License.--version: "3.9"--# uffizzi integration-x-uffizzi:- ingress:- service: answer- port: 80--services:-- answer:- image: "${ANSWER_IMAGE}"- environment:- - AUTO_INSTALL=true- - DB_TYPE=mysql- - DB_USERNAME=root- - DB_PASSWORD=password- - DB_HOST=127.0.0.1:3306- - DB_NAME=answer- - LANGUAGE=en_US- - SITE_NAME=answer-test- - SITE_URL=http://localhost- - ADMIN_NAME=admin123- - ADMIN_PASSWORD=admin123- volumes:- - answer-data:/data- depends_on:- mysql:- condition: service_healthy- links:- - db- deploy:- resources:- limits:- memory: 4000M-- mysql:- image: mysql:latest- environment:- - MYSQL_DATABASE=answer- - MYSQL_ROOT_PASSWORD=password- - MYSQL_USER=mysql- - MYSQL_PASSWORD=mysql- healthcheck:- test: [ "CMD", "mysqladmin" ,"ping", "-uroot", "-ppassword" ]- timeout: 20s- retries: 10- command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', '--skip-character-set-client-handshake']- volumes:- - sql_data:/var/lib/mysql- deploy:- resources:- limits:- memory: 500M--volumes:- answer-data:- sql_data:diff --git a/docs/docs.go b/docs/docs.goindex 7a6d08bd..dc56880a 100644--- a/docs/docs.go+++ b/docs/docs.go@@ -5895,6 +5895,132 @@ const docTemplate = `{}}},+ "/answer/api/v1/user/plugin/config": {+ "get": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "get user plugin config",+ "produces": [+ "application/json"+ ],+ "tags": [+ "UserPlugin"+ ],+ "summary": "get user plugin config",+ "parameters": [+ {+ "type": "string",+ "description": "plugin_slug_name",+ "name": "plugin_slug_name",+ "in": "query",+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "allOf": [+ {+ "$ref": "#/definitions/handler.RespBody"+ },+ {+ "type": "object",+ "properties": {+ "data": {+ "$ref": "#/definitions/schema.GetPluginConfigResp"+ }+ }+ }+ ]+ }+ }+ }+ },+ "put": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "update user plugin config",+ "consumes": [+ "application/json"+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "UserPlugin"+ ],+ "summary": "update user plugin config",+ "parameters": [+ {+ "description": "UpdatePluginConfigReq",+ "name": "data",+ "in": "body",+ "required": true,+ "schema": {+ "$ref": "#/definitions/schema.UpdateUserPluginConfigReq"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/handler.RespBody"+ }+ }+ }+ }+ },+ "/answer/api/v1/user/plugin/configs": {+ "get": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "get plugin list that used for user.",+ "consumes": [+ "application/json"+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "UserPlugin"+ ],+ "summary": "get plugin list that used for user.",+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "allOf": [+ {+ "$ref": "#/definitions/handler.RespBody"+ },+ {+ "type": "object",+ "properties": {+ "data": {+ "type": "array",+ "items": {+ "$ref": "#/definitions/schema.GetUserPluginListResp"+ }+ }+ }+ }+ ]+ }+ }+ }+ }+ },"/answer/api/v1/user/ranking": {"get": {"security": [@@ -7822,22 +7948,13 @@ const docTemplate = `{"type": "object","properties": {"all_new_question": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"},"all_new_question_for_following_tags": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"},"inbox": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"}}},@@ -7894,6 +8011,17 @@ const docTemplate = `{}}},+ "schema.GetUserPluginListResp": {+ "type": "object",+ "properties": {+ "name": {+ "type": "string"+ },+ "slug_name": {+ "type": "string"+ }+ }+ },"schema.GetVoteWithPageResp": {"type": "object","properties": {@@ -9428,22 +9556,13 @@ const docTemplate = `{"type": "object","properties": {"all_new_question": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"},"all_new_question_for_following_tags": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"},"inbox": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"}}},@@ -9464,6 +9583,22 @@ const docTemplate = `{}}},+ "schema.UpdateUserPluginConfigReq": {+ "type": "object",+ "required": [+ "plugin_slug_name"+ ],+ "properties": {+ "config_fields": {+ "type": "object",+ "additionalProperties": {}+ },+ "plugin_slug_name": {+ "type": "string",+ "maxLength": 100+ }+ }+ },"schema.UpdateUserRoleReq": {"type": "object","required": [diff --git a/docs/img/logo.svg b/docs/img/logo.svgindex b30be2de..f07ef040 100644--- a/docs/img/logo.svg+++ b/docs/img/logo.svg@@ -1,3 +1,21 @@+<!--+Licensed to the Apache Software Foundation (ASF) under one+or more contributor license agreements. See the NOTICE file+distributed with this work for additional information+regarding copyright ownership. The ASF licenses this file+to you under the Apache License, Version 2.0 (the+"License"); you may not use this file except in compliance+with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++Unless required by applicable law or agreed to in writing,+software distributed under the License is distributed on an+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+KIND, either express or implied. See the License for the+specific language governing permissions and limitations+under the License.+--><svg width="126" height="44" viewBox="0 0 126 44" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="125.49" height="44" rx="6" fill="white"/><path fill-rule="evenodd" clip-rule="evenodd" d="M8 14.4C8 12.1598 8 11.0397 8.43597 10.184C8.81947 9.43139 9.43139 8.81947 10.184 8.43597C11.0397 8 12.1598 8 14.4 8H29.6C31.8402 8 32.9603 8 33.816 8.43597C34.5686 8.81947 35.1805 9.43139 35.564 10.184C36 11.0397 36 12.1598 36 14.4V24.0892C36 26.9608 36 28.3967 35.5628 29.6643C35.1761 30.7853 34.5451 31.8063 33.7153 32.6535C32.7771 33.6115 31.4928 34.2536 28.9244 35.5378L28 36V32H14.4C12.1598 32 11.0397 32 10.184 31.564C9.43139 31.1805 8.81947 30.5686 8.43597 29.816C8 28.9603 8 27.8402 8 25.6V14.4ZM28 20C28 23.3137 25.3137 26 22 26C18.6954 26 16.0148 23.3285 16.0001 20.0274V20H28Z" fill="#0033FF"/>diff --git a/docs/swagger.json b/docs/swagger.jsonindex 77a1ada3..83bde221 100644--- a/docs/swagger.json+++ b/docs/swagger.json@@ -5864,6 +5864,132 @@}}},+ "/answer/api/v1/user/plugin/config": {+ "get": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "get user plugin config",+ "produces": [+ "application/json"+ ],+ "tags": [+ "UserPlugin"+ ],+ "summary": "get user plugin config",+ "parameters": [+ {+ "type": "string",+ "description": "plugin_slug_name",+ "name": "plugin_slug_name",+ "in": "query",+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "allOf": [+ {+ "$ref": "#/definitions/handler.RespBody"+ },+ {+ "type": "object",+ "properties": {+ "data": {+ "$ref": "#/definitions/schema.GetPluginConfigResp"+ }+ }+ }+ ]+ }+ }+ }+ },+ "put": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "update user plugin config",+ "consumes": [+ "application/json"+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "UserPlugin"+ ],+ "summary": "update user plugin config",+ "parameters": [+ {+ "description": "UpdatePluginConfigReq",+ "name": "data",+ "in": "body",+ "required": true,+ "schema": {+ "$ref": "#/definitions/schema.UpdateUserPluginConfigReq"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "$ref": "#/definitions/handler.RespBody"+ }+ }+ }+ }+ },+ "/answer/api/v1/user/plugin/configs": {+ "get": {+ "security": [+ {+ "ApiKeyAuth": []+ }+ ],+ "description": "get plugin list that used for user.",+ "consumes": [+ "application/json"+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "UserPlugin"+ ],+ "summary": "get plugin list that used for user.",+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "allOf": [+ {+ "$ref": "#/definitions/handler.RespBody"+ },+ {+ "type": "object",+ "properties": {+ "data": {+ "type": "array",+ "items": {+ "$ref": "#/definitions/schema.GetUserPluginListResp"+ }+ }+ }+ }+ ]+ }+ }+ }+ }+ },"/answer/api/v1/user/ranking": {"get": {"security": [@@ -7791,22 +7917,13 @@"type": "object","properties": {"all_new_question": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"},"all_new_question_for_following_tags": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"},"inbox": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"}}},@@ -7863,6 +7980,17 @@}}},+ "schema.GetUserPluginListResp": {+ "type": "object",+ "properties": {+ "name": {+ "type": "string"+ },+ "slug_name": {+ "type": "string"+ }+ }+ },"schema.GetVoteWithPageResp": {"type": "object","properties": {@@ -9397,22 +9525,13 @@"type": "object","properties": {"all_new_question": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"},"all_new_question_for_following_tags": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"},"inbox": {- "type": "array",- "items": {- "$ref": "#/definitions/schema.NotificationChannelConfig"- }+ "$ref": "#/definitions/schema.NotificationChannelConfig"}}},@@ -9433,6 +9552,22 @@}}},+ "schema.UpdateUserPluginConfigReq": {+ "type": "object",+ "required": [+ "plugin_slug_name"+ ],+ "properties": {+ "config_fields": {+ "type": "object",+ "additionalProperties": {}+ },+ "plugin_slug_name": {+ "type": "string",+ "maxLength": 100+ }+ }+ },"schema.UpdateUserRoleReq": {"type": "object","required": [diff --git a/docs/swagger.yaml b/docs/swagger.yamlindex f3f53a76..ca78bc49 100644--- a/docs/swagger.yaml+++ b/docs/swagger.yaml@@ -1008,17 +1008,11 @@ definitions:schema.GetUserNotificationConfigResp:properties:all_new_question:- items:- $ref: '#/definitions/schema.NotificationChannelConfig'- type: array+ $ref: '#/definitions/schema.NotificationChannelConfig'all_new_question_for_following_tags:- items:- $ref: '#/definitions/schema.NotificationChannelConfig'- type: array+ $ref: '#/definitions/schema.NotificationChannelConfig'inbox:- items:- $ref: '#/definitions/schema.NotificationChannelConfig'- type: array+ $ref: '#/definitions/schema.NotificationChannelConfig'type: objectschema.GetUserPageResp:properties:@@ -1059,6 +1053,13 @@ definitions:description: usernametype: stringtype: object+ schema.GetUserPluginListResp:+ properties:+ name:+ type: string+ slug_name:+ type: string+ type: objectschema.GetVoteWithPageResp:properties:answer_id:@@ -2116,17 +2117,11 @@ definitions:schema.UpdateUserNotificationConfigReq:properties:all_new_question:- items:- $ref: '#/definitions/schema.NotificationChannelConfig'- type: array+ $ref: '#/definitions/schema.NotificationChannelConfig'all_new_question_for_following_tags:- items:- $ref: '#/definitions/schema.NotificationChannelConfig'- type: array+ $ref: '#/definitions/schema.NotificationChannelConfig'inbox:- items:- $ref: '#/definitions/schema.NotificationChannelConfig'- type: array+ $ref: '#/definitions/schema.NotificationChannelConfig'type: objectschema.UpdateUserPasswordReq:properties:@@ -2140,6 +2135,17 @@ definitions:- password- user_idtype: object+ schema.UpdateUserPluginConfigReq:+ properties:+ config_fields:+ additionalProperties: {}+ type: object+ plugin_slug_name:+ maxLength: 100+ type: string+ required:+ - plugin_slug_name+ type: objectschema.UpdateUserRoleReq:properties:role_id:@@ -6010,6 +6016,79 @@ paths:summary: RetrievePassWordtags:- User+ /answer/api/v1/user/plugin/config:+ get:+ description: get user plugin config+ parameters:+ - description: plugin_slug_name+ in: query+ name: plugin_slug_name+ required: true+ type: string+ produces:+ - application/json+ responses:+ "200":+ description: OK+ schema:+ allOf:+ - $ref: '#/definitions/handler.RespBody'+ - properties:+ data:+ $ref: '#/definitions/schema.GetPluginConfigResp'+ type: object+ security:+ - ApiKeyAuth: []+ summary: get user plugin config+ tags:+ - UserPlugin+ put:+ consumes:+ - application/json+ description: update user plugin config+ parameters:+ - description: UpdatePluginConfigReq+ in: body+ name: data+ required: true+ schema:+ $ref: '#/definitions/schema.UpdateUserPluginConfigReq'+ produces:+ - application/json+ responses:+ "200":+ description: OK+ schema:+ $ref: '#/definitions/handler.RespBody'+ security:+ - ApiKeyAuth: []+ summary: update user plugin config+ tags:+ - UserPlugin+ /answer/api/v1/user/plugin/configs:+ get:+ consumes:+ - application/json+ description: get plugin list that used for user.+ produces:+ - application/json+ responses:+ "200":+ description: OK+ schema:+ allOf:+ - $ref: '#/definitions/handler.RespBody'+ - properties:+ data:+ items:+ $ref: '#/definitions/schema.GetUserPluginListResp'+ type: array+ type: object+ security:+ - ApiKeyAuth: []+ summary: get plugin list that used for user.+ tags:+ - UserPlugin/answer/api/v1/user/ranking:get:consumes:diff --git a/go.mod b/go.modindex 1a3b49f6..f4ab5699 100644--- a/go.mod+++ b/go.mod@@ -1,3 +1,20 @@+// Licensed to the Apache Software Foundation (ASF) under one+// or more contributor license agreements. See the NOTICE file+// distributed with this work for additional information+// regarding copyright ownership. The ASF licenses this file+// to you under the Apache License, Version 2.0 (the+// "License"); you may not use this file except in compliance+// with the License. You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing,+// software distributed under the License is distributed on an+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+// KIND, either express or implied. See the License for the+// specific language governing permissions and limitations+// under the License.+module github.com/apache/incubator-answergo 1.18diff --git a/i18n/en_US.yaml b/i18n/en_US.yamlindex e99d99bc..e155edff 100644--- a/i18n/en_US.yaml+++ b/i18n/en_US.yaml@@ -83,6 +83,9 @@ backend:level_3:description:other: Level 3 (high reputation required for mature community)+ level_custom:+ description:+ other: Custom Levelrank_question_add_label:other: Ask questionrank_answer_add_label:@@ -695,6 +698,13 @@ ui:character: URL slug contains unallowed character set.desc:label: Description+ revision:+ label: Revision+ edit_summary:+ label: Edit summary+ placeholder: >-+ Briefly explain your changes (corrected spelling, fixed grammar,+ improved formatting)btn_cancel: Cancelbtn_submit: Submitbtn_post: Post new tag@@ -724,22 +734,6 @@ ui:title: Edit Tagdefault_reason: Edit tagdefault_first_reason: Add tag- form:- fields:- revision:- label: Revision- display_name:- label: Display name- slug_name:- label: URL slug- info: URL slug up to 35 characters.- desc:- label: Description- edit_summary:- label: Edit summary- placeholder: >-- Briefly explain your changes (corrected spelling, fixed grammar,- improved formatting)btn_save_edits: Save editsbtn_cancel: Canceldates:@@ -763,7 +757,7 @@ ui:btn_flag: Flagbtn_save_edits: Save editsbtn_cancel: Cancel- show_more: Show more comments+ show_more: "{{count}} more comments"tip_question: >-Use comments to ask for more information or suggest improvements. Avoidanswering questions in comments.@@ -999,10 +993,10 @@ ui:label: Locationplaceholder: "City, Country"notification:- heading: Notifications- email: Email+ heading: Email Notifications+ turn_on: Turn oninbox:- label: Email notifications+ label: Inbox notificationsdescription: Answers to your questions, comments, invites, and more.all_new_question:label: All new questions@@ -1058,7 +1052,7 @@ ui:answers: answersinvite_to_answer:title: People Asked- desc: Invite people who you think might know the answer.+ desc: Select people who you think might know the answer.invite: Invite to answeradd: Add peoplesearch: Search people@@ -1159,6 +1153,11 @@ ui:close: Closereopen: Reopenok: OK+ light: Light+ dark: Dark+ system_setting: System setting+ default: Default+ reset: Resetsearch:title: Search Resultskeywords: Keywords@@ -1687,11 +1686,12 @@ ui:themes:label: Themestext: Select an existing theme.+ color_scheme:+ label: Color schemenavbar_style:- label: Navbar Style- text: Select an existing theme.+ label: Navbar styleprimary_color:- label: Primary Color+ label: Primary colortext: Modify the colors used by your themescss_and_html:page_title: CSS and HTMLdiff --git a/i18n/fr_FR.yaml b/i18n/fr_FR.yamlindex 0e8f3ba5..35b0de61 100644--- a/i18n/fr_FR.yaml+++ b/i18n/fr_FR.yaml@@ -746,7 +746,7 @@ ui:btn_flag: Balisebtn_save_edits: Enregistrer les modificationsbtn_cancel: Annuler- show_more: Afficher plus de commentaires+ show_more: "{{count}} commentaires restants"tip_question: >-Utilisez les commentaires pour demander plus d'informations ou suggérer des améliorations. Évitez de répondre aux questions dans les commentaires.tip_answer: >-diff --git a/i18n/zh_CN.yaml b/i18n/zh_CN.yamlindex a5a54289..a73c93f4 100644--- a/i18n/zh_CN.yaml+++ b/i18n/zh_CN.yaml@@ -681,6 +681,12 @@ ui:character: URL 固定链接包含非法字符。desc:label: 描述+ revision:+ label: 编辑历史+ edit_summary:+ label: 编辑摘要+ placeholder: >-+ 简单描述更改原因 (错别字、文字表达、格式等等)btn_cancel: 取消btn_submit: 提交btn_post: 发布新标签@@ -707,22 +713,7 @@ ui:edit_tag:title: 编辑标签default_reason: 编辑标签- default_first_reason: Add tag- form:- fields:- revision:- label: 编辑历史- display_name:- label: 显示名称- slug_name:- label: URL 固定链接- info: URL 固定链接不能超过 35 个字符。- desc:- label: 描述- edit_summary:- label: 编辑摘要- placeholder: >-- 简单描述更改原因 (错别字、文字表达、格式等等)+ default_first_reason: 添加标签btn_save_edits: 保存更改btn_cancel: 取消dates:@@ -746,7 +737,7 @@ ui:btn_flag: 举报btn_save_edits: 保存btn_cancel: 取消- show_more: 显示更多评论+ show_more: "{{count}}条剩余评论"tip_question: >-使用评论提问更多信息或者提出改进意见。尽量避免使用评论功能回答问题。tip_answer: >-diff --git a/i18n/zh_TW.yaml b/i18n/zh_TW.yamlindex 3455642a..8c6ddf7a 100644--- a/i18n/zh_TW.yaml+++ b/i18n/zh_TW.yaml@@ -746,7 +746,7 @@ ui:btn_flag: 舉報btn_save_edits: 保存btn_cancel: 取消- show_more: 顯示更多評論+ show_more: "{{count}}條剩餘評論"tip_question: >-通过評論询问更多问题或提出改進建議。避免在評論中回答問題。tip_answer: >-diff --git a/internal/base/constant/privilege.go b/internal/base/constant/privilege.goindex 01824774..a0fcc674 100644--- a/internal/base/constant/privilege.go+++ b/internal/base/constant/privilege.go@@ -24,7 +24,7 @@ import "github.com/apache/incubator-answer/internal/base/reason"type Privilege struct {Key string `json:"key"`Label string `json:"label"`- Value int `json:"value"`+ Value int `validate:"gte=1" json:"value"`}const (diff --git a/internal/base/constant/site_info.go b/internal/base/constant/site_info.goindex 94c39f74..de6f4183 100644--- a/internal/base/constant/site_info.go+++ b/internal/base/constant/site_info.go@@ -37,3 +37,10 @@ const (// PermalinkQuestionIDByShortID /questions/11PermalinkQuestionIDByShortID)++const (+ ColorSchemeDefault = "default"+ ColorSchemeLight = "light"+ ColorSchemeDark = "dark"+ ColorSchemeSystem = "system"+)diff --git a/internal/base/middleware/auth.go b/internal/base/middleware/auth.goindex 0fdc2c42..44fd20a2 100644--- a/internal/base/middleware/auth.go+++ b/internal/base/middleware/auth.go@@ -89,18 +89,51 @@ func (am *AuthUserMiddleware) EjectUserBySiteInfo() gin.HandlerFunc {return}- _, isLogin := ctx.Get(ctxUUIDKey)- if !isLogin {+ // If site in private mode, user must login.+ userInfo := GetUserInfoFromContext(ctx)+ if userInfo == nil {handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil)ctx.Abort()return}+ // If user is not active, eject user.+ if userInfo.EmailStatus != entity.EmailStatusAvailable {+ handler.HandleResponse(ctx, errors.Forbidden(reason.EmailNeedToBeVerified),+ &schema.ForbiddenResp{Type: schema.ForbiddenReasonTypeInactive})+ ctx.Abort()+ return+ }+ ctx.Next()+ }+}++// MustAuthWithoutAccountAvailable auth user info, any login user can access though user is not active.+func (am *AuthUserMiddleware) MustAuthWithoutAccountAvailable() gin.HandlerFunc {+ return func(ctx *gin.Context) {+ token := ExtractToken(ctx)+ if len(token) == 0 {+ handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil)+ ctx.Abort()+ return+ }+ userInfo, err := am.authService.GetUserCacheInfo(ctx, token)+ if err != nil || userInfo == nil {+ handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil)+ ctx.Abort()+ return+ }+ if userInfo.UserStatus == entity.UserStatusDeleted {+ handler.HandleResponse(ctx, errors.Unauthorized(reason.UnauthorizedError), nil)+ ctx.Abort()+ return+ }+ ctx.Set(ctxUUIDKey, userInfo)ctx.Next()}}-// MustAuth auth user info. If the user does not log in, an unauthenticated error is displayed-func (am *AuthUserMiddleware) MustAuth() gin.HandlerFunc {+// MustAuthAndAccountAvailable auth user info and check user status, only allow active user access.+func (am *AuthUserMiddleware) MustAuthAndAccountAvailable() gin.HandlerFunc {return func(ctx *gin.Context) {token := ExtractToken(ctx)if len(token) == 0 {diff --git a/internal/base/reason/privilege.go b/internal/base/reason/privilege.goindex e98058c8..1186a2c3 100644--- a/internal/base/reason/privilege.go+++ b/internal/base/reason/privilege.go@@ -20,9 +20,10 @@package reasonconst (- PrivilegeLevel1Desc = "privilege.level_1.description"- PrivilegeLevel2Desc = "privilege.level_2.description"- PrivilegeLevel3Desc = "privilege.level_3.description"+ PrivilegeLevel1Desc = "privilege.level_1.description"+ PrivilegeLevel2Desc = "privilege.level_2.description"+ PrivilegeLevel3Desc = "privilege.level_3.description"+ PrivilegeLevelCustomDesc = "privilege.level_custom.description"RankQuestionAddLabel = "privilege.rank_question_add_label"RankAnswerAddLabel = "privilege.rank_answer_add_label"diff --git a/internal/base/server/http.go b/internal/base/server/http.goindex 6e0b6727..daaf90fb 100644--- a/internal/base/server/http.go+++ b/internal/base/server/http.go@@ -74,9 +74,14 @@ func NewHTTPServer(debug bool,unAuthV1.Use(authUserMiddleware.Auth(), authUserMiddleware.EjectUserBySiteInfo())answerRouter.RegisterUnAuthAnswerAPIRouter(unAuthV1)+ // register api that must be authenticated but no need to check account status+ authWithoutStatusV1 := r.Group("/answer/api/v1")+ authWithoutStatusV1.Use(authUserMiddleware.MustAuthWithoutAccountAvailable())+ answerRouter.RegisterAuthUserWithAnyStatusAnswerAPIRouter(authWithoutStatusV1)+// register api that must be authenticatedauthV1 := r.Group("/answer/api/v1")- authV1.Use(authUserMiddleware.MustAuth())+ authV1.Use(authUserMiddleware.MustAuthAndAccountAvailable())answerRouter.RegisterAnswerAPIRouter(authV1)adminauthV1 := r.Group("/answer/admin/api")diff --git a/internal/controller/controller.go b/internal/controller/controller.goindex 4e6f2564..0dd8e3ef 100644--- a/internal/controller/controller.go+++ b/internal/controller/controller.go@@ -46,4 +46,5 @@ var ProviderSetController = wire.NewSet(NewConnectorController,NewUserCenterController,NewPermissionController,+ NewUserPluginController,)diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.goindex 88e8ca0a..6b4c4bbe 100644--- a/internal/controller/template_controller.go+++ b/internal/controller/template_controller.go@@ -22,6 +22,7 @@ package controllerimport ("encoding/json""fmt"+ "github.com/apache/incubator-answer/internal/entity""html/template""net/http""regexp"@@ -376,6 +377,7 @@ func (tc *TemplateController) QuestionInfo(ctx *gin.Context) {"detail": detail,"answers": answers,"comments": comments,+ "noindex": detail.Show == entity.QuestionHide,})}diff --git a/internal/controller/user_controller.go b/internal/controller/user_controller.goindex c9149ca2..4ef50e9e 100644--- a/internal/controller/user_controller.go+++ b/internal/controller/user_controller.go@@ -384,7 +384,7 @@ func (uc *UserController) UserModifyPassWord(ctx *gin.Context) {req.AccessToken = middleware.ExtractToken(ctx)isAdmin := middleware.GetUserIsAdminModerator(ctx)if !isAdmin {- captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, entity.CaptchaActionPassword, req.UserID,+ captchaPass := uc.actionService.ActionRecordVerifyCaptcha(ctx, entity.CaptchaActionEditUserinfo, req.UserID,req.CaptchaID, req.CaptchaCode)if !captchaPass {errFields := append([]*validator.FormErrorField{}, &validator.FormErrorField{@@ -394,7 +394,7 @@ func (uc *UserController) UserModifyPassWord(ctx *gin.Context) {handler.HandleResponse(ctx, errors.BadRequest(reason.CaptchaVerificationFailed), errFields)return}- _, err := uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionPassword, req.UserID)+ _, err := uc.actionService.ActionRecordAdd(ctx, entity.CaptchaActionEditUserinfo, req.UserID)if err != nil {log.Error(err)}@@ -424,7 +424,7 @@ func (uc *UserController) UserModifyPassWord(ctx *gin.Context) {}err = uc.userService.UserModifyPassword(ctx, req)if err == nil {- uc.actionService.ActionRecordDel(ctx, entity.CaptchaActionPassword, req.UserID)+ uc.actionService.ActionRecordDel(ctx, entity.CaptchaActionEditUserinfo, req.UserID)}handler.HandleResponse(ctx, err, nil)}diff --git a/internal/controller/user_plugin_controller.go b/internal/controller/user_plugin_controller.gonew file mode 100644index 00000000..f55dc73b--- /dev/null+++ b/internal/controller/user_plugin_controller.go@@ -0,0 +1,153 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package controller++import (+ "encoding/json"+ "github.com/apache/incubator-answer/internal/base/middleware"+ "github.com/apache/incubator-answer/internal/base/reason"+ "github.com/segmentfault/pacman/errors"+ "net/http"++ "github.com/apache/incubator-answer/internal/base/handler"+ "github.com/apache/incubator-answer/internal/schema"+ "github.com/apache/incubator-answer/internal/service/plugin_common"+ "github.com/apache/incubator-answer/plugin"+ "github.com/gin-gonic/gin"+)++// UserPluginController role controller+type UserPluginController struct {+ pluginCommonService *plugin_common.PluginCommonService+}++// NewUserPluginController new controller+func NewUserPluginController(pluginCommonService *plugin_common.PluginCommonService) *UserPluginController {+ return &UserPluginController{pluginCommonService: pluginCommonService}+}++// GetUserPluginList get plugin list that used for user.+// @Summary get plugin list that used for user.+// @Description get plugin list that used for user.+// @Tags UserPlugin+// @Security ApiKeyAuth+// @Accept json+// @Produce json+// @Success 200 {object} handler.RespBody{data=[]schema.GetUserPluginListResp}+// @Router /answer/api/v1/user/plugin/configs [get]+func (pc *UserPluginController) GetUserPluginList(ctx *gin.Context) {+ resp := make([]*schema.GetUserPluginListResp, 0)+ _ = plugin.CallUserConfig(func(base plugin.UserConfig) error {+ info := base.Info()+ if plugin.StatusManager.IsEnabled(info.SlugName) {+ resp = append(resp, &schema.GetUserPluginListResp{+ Name: info.Name.Translate(ctx),+ SlugName: info.SlugName,+ })+ }+ return nil+ })+ handler.HandleResponse(ctx, nil, resp)+}++// GetUserPluginConfig get user plugin config+// @Summary get user plugin config+// @Description get user plugin config+// @Tags UserPlugin+// @Security ApiKeyAuth+// @Produce json+// @Param plugin_slug_name query string true "plugin_slug_name"+// @Success 200 {object} handler.RespBody{data=schema.GetPluginConfigResp}+// @Router /answer/api/v1/user/plugin/config [get]+func (pc *UserPluginController) GetUserPluginConfig(ctx *gin.Context) {+ req := &schema.GetUserPluginConfigReq{}+ if handler.BindAndCheck(ctx, req) {+ return+ }++ req.UserID = middleware.GetLoginUserIDFromContext(ctx)++ resp := &schema.GetUserPluginConfigResp{}+ _ = plugin.CallUserConfig(func(fn plugin.UserConfig) error {+ if fn.Info().SlugName != req.PluginSlugName {+ return nil+ }+ info := fn.Info()+ resp.Name = info.Name.Translate(ctx)+ resp.SlugName = info.SlugName+ resp.SetConfigFields(ctx, fn.UserConfigFields())+ return nil+ })++ configValue, err := pc.pluginCommonService.GetUserPluginConfig(ctx, req)+ if err != nil {+ handler.HandleResponse(ctx, err, nil)+ return+ }+ if len(configValue) > 0 {+ configValueMapping := make(map[string]any)+ _ = json.Unmarshal([]byte(configValue), &configValueMapping)+ for _, field := range resp.ConfigFields {+ if value, ok := configValueMapping[field.Name]; ok {+ field.Value = value+ }+ }+ }++ handler.HandleResponse(ctx, err, resp)+}++// UpdatePluginUserConfig update user plugin config+// @Summary update user plugin config+// @Description update user plugin config+// @Tags UserPlugin+// @Accept json+// @Produce json+// @Security ApiKeyAuth+// @Param data body schema.UpdateUserPluginConfigReq true "UpdatePluginConfigReq"+// @Success 200 {object} handler.RespBody+// @Router /answer/api/v1/user/plugin/config [put]+func (pc *UserPluginController) UpdatePluginUserConfig(ctx *gin.Context) {+ req := &schema.UpdateUserPluginConfigReq{}+ if handler.BindAndCheck(ctx, req) {+ return+ }+ if !plugin.StatusManager.IsEnabled(req.PluginSlugName) {+ handler.HandleResponse(ctx, errors.New(http.StatusBadRequest, reason.RequestFormatError), nil)+ return+ }++ req.UserID = middleware.GetLoginUserIDFromContext(ctx)++ configFields, _ := json.Marshal(req.ConfigFields)+ err := plugin.CallUserConfig(func(fn plugin.UserConfig) error {+ if fn.Info().SlugName == req.PluginSlugName {+ return fn.UserConfigReceiver(req.UserID, configFields)+ }+ return nil+ })+ if err != nil {+ handler.HandleResponse(ctx, err, nil)+ return+ }++ err = pc.pluginCommonService.UpdatePluginUserConfig(ctx, req)+ handler.HandleResponse(ctx, err, nil)+}diff --git a/internal/controller_admin/plugin_controller.go b/internal/controller_admin/plugin_controller.goindex 769fc3bd..bfde841d 100644--- a/internal/controller_admin/plugin_controller.go+++ b/internal/controller_admin/plugin_controller.go@@ -31,12 +31,12 @@ import (// PluginController role controllertype PluginController struct {- PluginCommonService *plugin_common.PluginCommonService+ pluginCommonService *plugin_common.PluginCommonService}// NewPluginController new controller-func NewPluginController(PluginCommonService *plugin_common.PluginCommonService) *PluginController {- return &PluginController{PluginCommonService: PluginCommonService}+func NewPluginController(pluginCommonService *plugin_common.PluginCommonService) *PluginController {+ return &PluginController{pluginCommonService: pluginCommonService}}// GetAllPluginStatus get all plugins status@@ -150,7 +150,7 @@ func (pc *PluginController) UpdatePluginStatus(ctx *gin.Context) {}plugin.StatusManager.Enable(req.PluginSlugName, req.Enabled)- err := pc.PluginCommonService.UpdatePluginStatus(ctx)+ err := pc.pluginCommonService.UpdatePluginStatus(ctx)handler.HandleResponse(ctx, err, nil)}@@ -220,6 +220,6 @@ func (pc *PluginController) UpdatePluginConfig(ctx *gin.Context) {return}- err = pc.PluginCommonService.UpdatePluginConfig(ctx, req)+ err = pc.pluginCommonService.UpdatePluginConfig(ctx, req)handler.HandleResponse(ctx, err, nil)}diff --git a/internal/entity/plugin_user_config_entity.go b/internal/entity/plugin_user_config_entity.gonew file mode 100644index 00000000..edf93c9f--- /dev/null+++ b/internal/entity/plugin_user_config_entity.go@@ -0,0 +1,33 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package entity++// PluginUserConfig plugin config+type PluginUserConfig struct {+ ID int `xorm:"not null pk autoincr INT(11) id"`+ UserID string `xorm:"not null default 0 BIGINT(20) UNIQUE(uk_up) user_id"`+ PluginSlugName string `xorm:"VARCHAR(128) UNIQUE(uk_up) plugin_slug_name"`+ Value string `xorm:"TEXT value"`+}++// TableName config table name+func (PluginUserConfig) TableName() string {+ return "plugin_user_config"+}diff --git a/internal/entity/user_entity.go b/internal/entity/user_entity.goindex 32821864..cfc2b6c2 100644--- a/internal/entity/user_entity.go+++ b/internal/entity/user_entity.go@@ -65,6 +65,7 @@ type User struct {IPInfo string `xorm:"not null default '' VARCHAR(255) ip_info"`IsAdmin bool `xorm:"not null default false BOOL is_admin"`Language string `xorm:"not null default '' VARCHAR(100) language"`+ ColorScheme string `xorm:"not null default '' VARCHAR(100) color_scheme"`}// TableName user table namediff --git a/internal/migrations/init_data.go b/internal/migrations/init_data.goindex b39ece43..494e0cf5 100644--- a/internal/migrations/init_data.go+++ b/internal/migrations/init_data.go@@ -67,6 +67,7 @@ var (&entity.PluginConfig{},&entity.UserExternalLogin{},&entity.UserNotificationConfig{},+ &entity.PluginUserConfig{},}roles = []*entity.Role{diff --git a/internal/migrations/migrations.go b/internal/migrations/migrations.goindex 41515383..dbd3acdb 100644--- a/internal/migrations/migrations.go+++ b/internal/migrations/migrations.go@@ -94,6 +94,7 @@ var migrations = []Migration{NewMigration("v1.1.3", "set default user notification config", setDefaultUserNotificationConfig, false),NewMigration("v1.2.0", "add recover answer permission", addRecoverPermission, true),NewMigration("v1.2.1", "add password login control", addPasswordLoginControl, true),+ NewMigration("v1.2.5", "add notification plugin and theme config", addNotificationPluginAndThemeConfig, true),}func GetMigrations() []Migration {diff --git a/internal/migrations/v19.go b/internal/migrations/v19.gonew file mode 100644index 00000000..c4478a34--- /dev/null+++ b/internal/migrations/v19.go@@ -0,0 +1,34 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package migrations++import (+ "context"+ "github.com/apache/incubator-answer/internal/entity"+ "xorm.io/xorm"+)++func addNotificationPluginAndThemeConfig(ctx context.Context, x *xorm.Engine) error {+ type User struct {+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ ColorScheme string `xorm:"not null default '' VARCHAR(100) color_scheme"`+ }+ return x.Context(ctx).Sync(new(entity.PluginUserConfig), new(User))+}diff --git a/internal/repo/answer/answer_repo.go b/internal/repo/answer/answer_repo.goindex 3a71fd70..60a49fa4 100644--- a/internal/repo/answer/answer_repo.go+++ b/internal/repo/answer/answer_repo.go@@ -416,7 +416,7 @@ func (ar *answerRepo) updateSearch(ctx context.Context, answerID string) (err er// get questionvar (- question *entity.Question+ question = new(entity.Question))exist, err = ar.data.DB.Context(ctx).Where("id = ?", answer.QuestionID).Get(&question)if err != nil {diff --git a/internal/repo/plugin_config/plugin_config_repo.go b/internal/repo/plugin_config/plugin_config_repo.goindex ddcd3ed2..1ad2e495 100644--- a/internal/repo/plugin_config/plugin_config_repo.go+++ b/internal/repo/plugin_config/plugin_config_repo.go@@ -50,7 +50,7 @@ func (ur *pluginConfigRepo) SavePluginConfig(ctx context.Context, pluginSlugNameold.Value = configValue_, err = ur.data.DB.Context(ctx).ID(old.ID).Update(old)} else {- _, err = ur.data.DB.Context(ctx).InsertOne(&entity.PluginConfig{PluginSlugName: pluginSlugName, Value: configValue})+ _, err = ur.data.DB.Context(ctx).Insert(&entity.PluginConfig{PluginSlugName: pluginSlugName, Value: configValue})}if err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()diff --git a/internal/repo/plugin_config/plugin_user_config_repo.go b/internal/repo/plugin_config/plugin_user_config_repo.gonew file mode 100644index 00000000..5b3b54de--- /dev/null+++ b/internal/repo/plugin_config/plugin_user_config_repo.go@@ -0,0 +1,99 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package plugin_config++import (+ "context"+ "github.com/apache/incubator-answer/internal/base/pager"+ "xorm.io/xorm"++ "github.com/apache/incubator-answer/internal/base/data"+ "github.com/apache/incubator-answer/internal/base/reason"+ "github.com/apache/incubator-answer/internal/entity"+ "github.com/apache/incubator-answer/internal/service/plugin_common"+ "github.com/segmentfault/pacman/errors"+)++type pluginUserConfigRepo struct {+ data *data.Data+}++// NewPluginUserConfigRepo new repository+func NewPluginUserConfigRepo(data *data.Data) plugin_common.PluginUserConfigRepo {+ return &pluginUserConfigRepo{+ data: data,+ }+}++func (ur *pluginUserConfigRepo) SaveUserPluginConfig(ctx context.Context, userID string,+ pluginSlugName, configValue string) (err error) {+ _, err = ur.data.DB.Transaction(func(session *xorm.Session) (interface{}, error) {+ session = session.Context(ctx)+ old := &entity.PluginUserConfig{+ UserID: userID,+ PluginSlugName: pluginSlugName,+ }+ exist, err := session.Get(old)+ if err != nil {+ return nil, err+ }+ if exist {+ old.Value = configValue+ _, err = session.ID(old.ID).Update(old)+ } else {+ _, err = session.Insert(&entity.PluginUserConfig{+ UserID: userID,+ PluginSlugName: pluginSlugName,+ Value: configValue,+ })+ }+ if err != nil {+ return nil, err+ }+ return nil, nil+ })+ if err != nil {+ err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()+ }+ return nil+}++func (ur *pluginUserConfigRepo) GetPluginUserConfig(ctx context.Context, userID, pluginSlugName string) (+ pluginUserConfig *entity.PluginUserConfig, exist bool, err error) {+ pluginUserConfig = &entity.PluginUserConfig{+ UserID: userID,+ PluginSlugName: pluginSlugName,+ }+ exist, err = ur.data.DB.Context(ctx).Get(pluginUserConfig)+ if err != nil {+ err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()+ }+ return pluginUserConfig, exist, err+}++func (ur *pluginUserConfigRepo) GetPluginUserConfigPage(ctx context.Context, page, pageSize int) (+ pluginUserConfigs []*entity.PluginUserConfig, total int64, err error) {+ pluginUserConfigs = make([]*entity.PluginUserConfig, 0)+ total, err = pager.Help(page, pageSize, &pluginUserConfigs, &entity.PluginUserConfig{}, ur.data.DB.Context(ctx))+ if err != nil {+ err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()+ }+ return+}diff --git a/internal/repo/provider.go b/internal/repo/provider.goindex 0814487e..931ccde1 100644--- a/internal/repo/provider.go+++ b/internal/repo/provider.go@@ -96,4 +96,5 @@ var ProviderSetRepo = wire.NewSet(plugin_config.NewPluginConfigRepo,user_notification_config.NewUserNotificationConfigRepo,limit.NewRateLimitRepo,+ plugin_config.NewPluginUserConfigRepo,)diff --git a/internal/repo/question/question_repo.go b/internal/repo/question/question_repo.goindex 2cd9a325..6c97620a 100644--- a/internal/repo/question/question_repo.go+++ b/internal/repo/question/question_repo.go@@ -23,18 +23,13 @@ import ("context""encoding/json""fmt"- "github.com/apache/incubator-answer/plugin"- "github.com/segmentfault/pacman/log""strings""time""unicode"- "xorm.io/xorm"-- "github.com/apache/incubator-answer/internal/base/handler"- "xorm.io/builder""github.com/apache/incubator-answer/internal/base/constant""github.com/apache/incubator-answer/internal/base/data"+ "github.com/apache/incubator-answer/internal/base/handler""github.com/apache/incubator-answer/internal/base/pager""github.com/apache/incubator-answer/internal/base/reason""github.com/apache/incubator-answer/internal/entity"@@ -43,8 +38,11 @@ import ("github.com/apache/incubator-answer/internal/service/unique""github.com/apache/incubator-answer/pkg/htmltext""github.com/apache/incubator-answer/pkg/uid"-+ "github.com/apache/incubator-answer/plugin""github.com/segmentfault/pacman/errors"+ "github.com/segmentfault/pacman/log"+ "xorm.io/builder"+ "xorm.io/xorm")// questionRepo question repository@@ -77,7 +75,6 @@ func (qr *questionRepo) AddQuestion(ctx context.Context, question *entity.Questiif handler.GetEnableShortID(ctx) {question.ID = uid.EnShortID(question.ID)}- _ = qr.updateSearch(ctx, question.ID)return}@@ -101,7 +98,7 @@ func (qr *questionRepo) UpdateQuestion(ctx context.Context, question *entity.Queif handler.GetEnableShortID(ctx) {question.ID = uid.EnShortID(question.ID)}- _ = qr.updateSearch(ctx, question.ID)+ _ = qr.UpdateSearch(ctx, question.ID)return}@@ -112,7 +109,7 @@ func (qr *questionRepo) UpdatePvCount(ctx context.Context, questionID string) (eif err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- _ = qr.updateSearch(ctx, question.ID)+ _ = qr.UpdateSearch(ctx, question.ID)return nil}@@ -124,7 +121,7 @@ func (qr *questionRepo) UpdateAnswerCount(ctx context.Context, questionID stringif err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- _ = qr.updateSearch(ctx, question.ID)+ _ = qr.UpdateSearch(ctx, question.ID)return nil}@@ -156,7 +153,7 @@ func (qr *questionRepo) UpdateQuestionStatus(ctx context.Context, questionID strif err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- _ = qr.updateSearch(ctx, questionID)+ _ = qr.UpdateSearch(ctx, questionID)return nil}@@ -166,7 +163,7 @@ func (qr *questionRepo) UpdateQuestionStatusWithOutUpdateTime(ctx context.Contexif err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- _ = qr.updateSearch(ctx, question.ID)+ _ = qr.UpdateSearch(ctx, question.ID)return nil}@@ -176,7 +173,7 @@ func (qr *questionRepo) RecoverQuestion(ctx context.Context, questionID string)if err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- _ = qr.updateSearch(ctx, questionID)+ _ = qr.UpdateSearch(ctx, questionID)return nil}@@ -195,7 +192,7 @@ func (qr *questionRepo) UpdateAccepted(ctx context.Context, question *entity.Queif err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- _ = qr.updateSearch(ctx, question.ID)+ _ = qr.UpdateSearch(ctx, question.ID)return nil}@@ -205,7 +202,7 @@ func (qr *questionRepo) UpdateLastAnswer(ctx context.Context, question *entity.Qif err != nil {return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- _ = qr.updateSearch(ctx, question.ID)+ _ = qr.UpdateSearch(ctx, question.ID)return nil}@@ -347,19 +344,22 @@ func (qr *questionRepo) SitemapQuestions(ctx context.Context, page, pageSize int}// GetQuestionPage query question page-func (qr *questionRepo) GetQuestionPage(ctx context.Context, page, pageSize int, userID, tagID, orderCond string, inDays int) (+func (qr *questionRepo) GetQuestionPage(ctx context.Context, page, pageSize int, tagIDs []string, userID, orderCond string, inDays int, showHidden bool) (questionList []*entity.Question, total int64, err error) {questionList = make([]*entity.Question, 0)session := qr.data.DB.Context(ctx).Where("question.status = ? OR question.status = ?",entity.QuestionStatusAvailable, entity.QuestionStatusClosed)- if len(tagID) > 0 {+ if len(tagIDs) > 0 {session.Join("LEFT", "tag_rel", "question.id = tag_rel.object_id")- session.And("tag_rel.tag_id = ?", tagID)+ session.In("tag_rel.tag_id", tagIDs)session.And("tag_rel.status = ?", entity.TagRelStatusAvailable)}if len(userID) > 0 {session.And("question.user_id = ?", userID)+ if !showHidden {+ session.And("question.show = ?", entity.QuestionShow)+ }} else {session.And("question.show = ?", entity.QuestionShow)}@@ -462,8 +462,8 @@ func (qr *questionRepo) AdminQuestionPage(ctx context.Context, search *schema.Adreturn rows, count, nil}-// updateSearch update search, if search plugin not enable, do nothing-func (qr *questionRepo) updateSearch(ctx context.Context, questionID string) (err error) {+// UpdateSearch update search, if search plugin not enable, do nothing+func (qr *questionRepo) UpdateSearch(ctx context.Context, questionID string) (err error) {// check search pluginvar s plugin.Search_ = plugin.CallSearch(func(search plugin.Search) error {@@ -544,7 +544,7 @@ func (qr *questionRepo) RemoveAllUserQuestion(ctx context.Context, userID string// update search contentfor _, id := range questionIDs {- _ = qr.updateSearch(ctx, id)+ _ = qr.UpdateSearch(ctx, id)}return nil}diff --git a/internal/repo/search_common/search_repo.go b/internal/repo/search_common/search_repo.goindex de3c03eb..0443bfe9 100644--- a/internal/repo/search_common/search_repo.go+++ b/internal/repo/search_common/search_repo.go@@ -98,7 +98,7 @@ func NewSearchRepo(}// SearchContents search question and answer data-func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagIDs []string, userID string, votes int, page, size int, order string) (resp []*schema.SearchResult, total int64, err error) {+func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagIDs [][]string, userID string, votes int, page, size int, order string) (resp []*schema.SearchResult, total int64, err error) {words = filterWords(words)var (@@ -152,16 +152,20 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagIDsast := "tag_rel" + strconv.Itoa(ti)b.Join("INNER", "tag_rel as "+ast, "question.id = "+ast+".object_id").And(builder.Eq{- ast + ".tag_id": tagID,ast + ".status": entity.TagRelStatusAvailable,- })+ }).+ And(builder.In(ast+".tag_id", tagID))ub.Join("INNER", "tag_rel as "+ast, "question_id = "+ast+".object_id").And(builder.Eq{- ast + ".tag_id": tagID,ast + ".status": entity.TagRelStatusAvailable,- })- argsQ = append(argsQ, entity.TagRelStatusAvailable, tagID)- argsA = append(argsA, entity.TagRelStatusAvailable, tagID)+ }).+ And(builder.In(ast+".tag_id", tagID))+ argsQ = append(argsQ, entity.TagRelStatusAvailable)+ argsA = append(argsA, entity.TagRelStatusAvailable)+ for _, t := range tagID {+ argsQ = append(argsQ, t)+ argsA = append(argsA, t)+ }}// check user@@ -236,7 +240,7 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagIDs}// SearchQuestions search question data-func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, tagIDs []string, notAccepted bool, views, answers int, page, size int, order string) (resp []*schema.SearchResult, total int64, err error) {+func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, tagIDs [][]string, notAccepted bool, views, answers int, page, size int, order string) (resp []*schema.SearchResult, total int64, err error) {words = filterWords(words)var (qfs = qFields@@ -269,10 +273,13 @@ func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, tagIDast := "tag_rel" + strconv.Itoa(ti)b.Join("INNER", "tag_rel as "+ast, "question.id = "+ast+".object_id").And(builder.Eq{- ast + ".tag_id": tagID,ast + ".status": entity.TagRelStatusAvailable,- })- args = append(args, entity.TagRelStatusAvailable, tagID)+ }).+ And(builder.In(ast+".tag_id", tagID))+ args = append(args, entity.TagRelStatusAvailable)+ for _, t := range tagID {+ args = append(args, t)+ }}// check need filter has not accepted@@ -343,7 +350,7 @@ func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, tagID}// SearchAnswers search answer data-func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, tagIDs []string, accepted bool, questionID string, page, size int, order string) (resp []*schema.SearchResult, total int64, err error) {+func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, tagIDs [][]string, accepted bool, questionID string, page, size int, order string) (resp []*schema.SearchResult, total int64, err error) {words = filterWords(words)var (@@ -378,10 +385,13 @@ func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, tagIDsast := "tag_rel" + strconv.Itoa(ti)b.Join("INNER", "tag_rel as "+ast, "question_id = "+ast+".object_id").And(builder.Eq{- ast + ".tag_id": tagID,ast + ".status": entity.TagRelStatusAvailable,- })- args = append(args, entity.TagRelStatusAvailable, tagID)+ }).+ And(builder.In(ast+".tag_id", tagID))+ args = append(args, entity.TagRelStatusAvailable)+ for _, t := range tagID {+ args = append(args, t)+ }}// check limit accepteddiff --git a/internal/repo/tag/tag_repo.go b/internal/repo/tag/tag_repo.goindex c56e7d58..eea54995 100644--- a/internal/repo/tag/tag_repo.go+++ b/internal/repo/tag/tag_repo.go@@ -21,6 +21,7 @@ package tagimport ("context"+"github.com/apache/incubator-answer/internal/base/data""github.com/apache/incubator-answer/internal/base/reason""github.com/apache/incubator-answer/internal/entity"@@ -118,6 +119,15 @@ func (tr *tagRepo) GetTagSynonymCount(ctx context.Context, tagID string) (countreturn}+func (tr *tagRepo) GetIDsByMainTagId(ctx context.Context, mainTagID string) (tagIDs []string, err error) {+ session := tr.data.DB.Context(ctx).Table(entity.Tag{}.TableName()).Where(builder.Eq{"status": entity.TagStatusAvailable, "main_tag_id": converter.StringToInt64(mainTagID)}).Cols("id")+ err = session.Find(&tagIDs)+ if err != nil {+ err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()+ }+ return+}+// GetTagList get tag list allfunc (tr *tagRepo) GetTagList(ctx context.Context, tag *entity.Tag) (tagList []*entity.Tag, err error) {tagList = make([]*entity.Tag, 0)diff --git a/internal/repo/user/user_repo.go b/internal/repo/user/user_repo.goindex deb1427d..628394cf 100644--- a/internal/repo/user/user_repo.go+++ b/internal/repo/user/user_repo.go@@ -155,8 +155,9 @@ func (ur *userRepo) UpdateEmail(ctx context.Context, userID, email string) (errreturn}-func (ur *userRepo) UpdateLanguage(ctx context.Context, userID, language string) (err error) {- _, err = ur.data.DB.Context(ctx).Where("id = ?", userID).Update(&entity.User{Language: language})+func (ur *userRepo) UpdateUserInterface(ctx context.Context, userID, language, colorSchema string) (err error) {+ session := ur.data.DB.Context(ctx).Where("id = ?", userID)+ _, err = session.Cols("language", "color_scheme").Update(&entity.User{Language: language, ColorScheme: colorSchema})if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}diff --git a/internal/repo/user_external_login/user_external_login_repo.go b/internal/repo/user_external_login/user_external_login_repo.goindex ba049543..8b78b8b4 100644--- a/internal/repo/user_external_login/user_external_login_repo.go+++ b/internal/repo/user_external_login/user_external_login_repo.go@@ -72,6 +72,17 @@ func (ur *userExternalLoginRepo) GetByExternalID(ctx context.Context, provider,return}+// GetByUserID get by user ID+func (ur *userExternalLoginRepo) GetByUserID(ctx context.Context, provider, userID string) (+ userInfo *entity.UserExternalLogin, exist bool, err error) {+ userInfo = &entity.UserExternalLogin{}+ exist, err = ur.data.DB.Context(ctx).Where("user_id = ?", userID).Where("provider = ?", provider).Get(userInfo)+ if err != nil {+ err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()+ }+ return+}+// GetUserExternalLoginList get by external IDfunc (ur *userExternalLoginRepo) GetUserExternalLoginList(ctx context.Context, userID string) (resp []*entity.UserExternalLogin, err error) {diff --git a/internal/router/answer_api_router.go b/internal/router/answer_api_router.goindex 0a6d7b83..7e856903 100644--- a/internal/router/answer_api_router.go+++ b/internal/router/answer_api_router.go@@ -53,6 +53,7 @@ type AnswerAPIRouter struct {roleController *controller_admin.RoleControllerpluginController *controller_admin.PluginControllerpermissionController *controller.PermissionController+ userPluginController *controller.UserPluginController}func NewAnswerAPIRouter(@@ -82,6 +83,7 @@ func NewAnswerAPIRouter(roleController *controller_admin.RoleController,pluginController *controller_admin.PluginController,permissionController *controller.PermissionController,+ userPluginController *controller.UserPluginController,) *AnswerAPIRouter {return &AnswerAPIRouter{langController: langController,@@ -110,6 +112,7 @@ func NewAnswerAPIRouter(roleController: roleController,pluginController: pluginController,permissionController: permissionController,+ userPluginController: userPluginController,}}@@ -141,9 +144,6 @@ func (a *AnswerAPIRouter) RegisterMustUnAuthAnswerAPIRouter(authUserMiddleware *func (a *AnswerAPIRouter) RegisterUnAuthAnswerAPIRouter(r *gin.RouterGroup) {// user- r.GET("/user/logout", a.userController.UserLogout)- r.POST("/user/email/change/code", middleware.BanAPIForUserCenter, a.userController.UserChangeEmailSendCode)- r.POST("/user/email/verification/send", middleware.BanAPIForUserCenter, a.userController.UserVerifyEmailSend)r.GET("/personal/user/info", a.userController.GetOtherUserInfoByUsername)r.GET("/user/ranking", a.userController.UserRanking)@@ -183,6 +183,12 @@ func (a *AnswerAPIRouter) RegisterUnAuthAnswerAPIRouter(r *gin.RouterGroup) {r.GET("/personal/rank/page", a.rankController.GetRankPersonalWithPage)}+func (a *AnswerAPIRouter) RegisterAuthUserWithAnyStatusAnswerAPIRouter(r *gin.RouterGroup) {+ r.GET("/user/logout", a.userController.UserLogout)+ r.POST("/user/email/change/code", middleware.BanAPIForUserCenter, a.userController.UserChangeEmailSendCode)+ r.POST("/user/email/verification/send", middleware.BanAPIForUserCenter, a.userController.UserVerifyEmailSend)+}+func (a *AnswerAPIRouter) RegisterAnswerAPIRouter(r *gin.RouterGroup) {// revisionsr.GET("/revisions/unreviewed", a.revisionController.GetUnreviewedRevisionList)@@ -268,6 +274,10 @@ func (a *AnswerAPIRouter) RegisterAnswerAPIRouter(r *gin.RouterGroup) {r.GET("/activity/timeline", a.activityController.GetObjectTimeline)r.GET("/activity/timeline/detail", a.activityController.GetObjectTimelineDetail)+ // plugin+ r.GET("/user/plugin/configs", a.userPluginController.GetUserPluginList)+ r.GET("/user/plugin/config", a.userPluginController.GetUserPluginConfig)+ r.PUT("/user/plugin/config", a.userPluginController.UpdatePluginUserConfig)}func (a *AnswerAPIRouter) RegisterAnswerAdminAPIRouter(r *gin.RouterGroup) {diff --git a/internal/schema/comment_schema.go b/internal/schema/comment_schema.goindex 0030b819..4f318d87 100644--- a/internal/schema/comment_schema.go+++ b/internal/schema/comment_schema.go@@ -130,7 +130,7 @@ type GetCommentWithPageReq struct {// comment idCommentID string `validate:"omitempty" form:"comment_id"`// query condition- QueryCond string `validate:"omitempty,oneof=vote" form:"query_cond"`+ QueryCond string `validate:"omitempty,oneof=vote created_at" form:"query_cond"`// user idUserID string `json:"-"`// whether user can edit itdiff --git a/internal/schema/plugin_admin_schema.go b/internal/schema/plugin_admin_schema.goindex 76d1e9d0..c588c6da 100644--- a/internal/schema/plugin_admin_schema.go+++ b/internal/schema/plugin_admin_schema.go@@ -78,9 +78,11 @@ func (g *GetPluginConfigResp) SetConfigFields(ctx *gin.Context, fields []plugin.Required: field.Required,Value: field.Value,UIOptions: ConfigFieldUIOptions{- Rows: field.UIOptions.Rows,- InputType: string(field.UIOptions.InputType),- Variant: field.UIOptions.Variant,+ Rows: field.UIOptions.Rows,+ InputType: string(field.UIOptions.InputType),+ Variant: field.UIOptions.Variant,+ ClassName: field.UIOptions.ClassName,+ FieldClassName: field.UIOptions.FieldClassName,},}configField.UIOptions.Placeholder = field.UIOptions.Placeholder.Translate(ctx)@@ -128,13 +130,15 @@ type ConfigField struct {}type ConfigFieldUIOptions struct {- Placeholder string `json:"placeholder,omitempty"`- Rows string `json:"rows,omitempty"`- InputType string `json:"input_type,omitempty"`- Label string `json:"label,omitempty"`- Action *UIOptionAction `json:"action,omitempty"`- Variant string `json:"variant,omitempty"`- Text string `json:"text,omitempty"`+ Placeholder string `json:"placeholder,omitempty"`+ Rows string `json:"rows,omitempty"`+ InputType string `json:"input_type,omitempty"`+ Label string `json:"label,omitempty"`+ Action *UIOptionAction `json:"action,omitempty"`+ Variant string `json:"variant,omitempty"`+ Text string `json:"text,omitempty"`+ ClassName string `json:"class_name,omitempty"`+ FieldClassName string `json:"field_class_name,omitempty"`}type ConfigFieldOption struct {diff --git a/internal/schema/plugin_user_schema.go b/internal/schema/plugin_user_schema.gonew file mode 100644index 00000000..b2734cb1--- /dev/null+++ b/internal/schema/plugin_user_schema.go@@ -0,0 +1,102 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package schema++import (+ "github.com/apache/incubator-answer/plugin"+ "github.com/gin-gonic/gin"+)++type GetUserPluginListResp struct {+ Name string `json:"name"`+ SlugName string `json:"slug_name"`+}++type UpdateUserPluginReq struct {+ PluginSlugName string `validate:"required,gt=1,lte=100" json:"plugin_slug_name"`+ UserID string `json:"-"`+}++type GetUserPluginConfigReq struct {+ PluginSlugName string `validate:"required,gt=1,lte=100" form:"plugin_slug_name"`+ UserID string `json:"-"`+}++type GetUserPluginConfigResp struct {+ Name string `json:"name"`+ SlugName string `json:"slug_name"`+ ConfigFields []*ConfigField `json:"config_fields"`+}++func (g *GetUserPluginConfigResp) SetConfigFields(ctx *gin.Context, fields []plugin.ConfigField) {+ for _, field := range fields {+ configField := &ConfigField{+ Name: field.Name,+ Type: string(field.Type),+ Title: field.Title.Translate(ctx),+ Description: field.Description.Translate(ctx),+ Required: field.Required,+ Value: field.Value,+ UIOptions: ConfigFieldUIOptions{+ Rows: field.UIOptions.Rows,+ InputType: string(field.UIOptions.InputType),+ Variant: field.UIOptions.Variant,+ ClassName: field.UIOptions.ClassName,+ FieldClassName: field.UIOptions.FieldClassName,+ },+ }+ configField.UIOptions.Placeholder = field.UIOptions.Placeholder.Translate(ctx)+ configField.UIOptions.Label = field.UIOptions.Label.Translate(ctx)+ configField.UIOptions.Text = field.UIOptions.Text.Translate(ctx)+ if field.UIOptions.Action != nil {+ uiOptionAction := &UIOptionAction{+ Url: field.UIOptions.Action.Url,+ Method: field.UIOptions.Action.Method,+ }+ if field.UIOptions.Action.Loading != nil {+ uiOptionAction.Loading = &LoadingAction{+ Text: field.UIOptions.Action.Loading.Text.Translate(ctx),+ State: string(field.UIOptions.Action.Loading.State),+ }+ }+ if field.UIOptions.Action.OnComplete != nil {+ uiOptionAction.OnCompleteAction = &OnCompleteAction{+ ToastReturnMessage: field.UIOptions.Action.OnComplete.ToastReturnMessage,+ RefreshFormConfig: field.UIOptions.Action.OnComplete.RefreshFormConfig,+ }+ }+ configField.UIOptions.Action = uiOptionAction+ }++ for _, option := range field.Options {+ configField.Options = append(configField.Options, ConfigFieldOption{+ Label: option.Label.Translate(ctx),+ Value: option.Value,+ })+ }+ g.ConfigFields = append(g.ConfigFields, configField)+ }+}++type UpdateUserPluginConfigReq struct {+ PluginSlugName string `validate:"required,gt=1,lte=100" json:"plugin_slug_name"`+ ConfigFields map[string]any `json:"config_fields"`+ UserID string `json:"-"`+}diff --git a/internal/schema/search_schema.go b/internal/schema/search_schema.goindex e1533953..90b08ceb 100644--- a/internal/schema/search_schema.go+++ b/internal/schema/search_schema.go@@ -64,7 +64,7 @@ type SearchCondition struct {// only show this question's answerQuestionID string// search query tags- Tags []string+ Tags [][]string// search query keywordsWords []string}diff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.goindex fc56bf5a..2953b944 100644--- a/internal/schema/siteinfo_schema.go+++ b/internal/schema/siteinfo_schema.go@@ -136,6 +136,7 @@ type SiteCustomCssHTMLReq struct {type SiteThemeReq struct {Theme string `validate:"required,gt=0,lte=255" json:"theme"`ThemeConfig map[string]interface{} `validate:"omitempty" json:"theme_config"`+ ColorScheme string `validate:"omitempty,gt=0,lte=100" json:"color_scheme"`}type SiteSeoReq struct {@@ -171,6 +172,7 @@ type SiteThemeResp struct {ThemeOptions []*ThemeOption `json:"theme_options"`Theme string `json:"theme"`ThemeConfig map[string]interface{} `json:"theme_config"`+ ColorScheme string `json:"color_scheme"`}func (s *SiteThemeResp) TrTheme(ctx context.Context) {@@ -284,6 +286,8 @@ const (PrivilegeLevel2 PrivilegeLevel = 2// PrivilegeLevel3 highPrivilegeLevel3 PrivilegeLevel = 3+ // PrivilegeLevelCustom custom+ PrivilegeLevelCustom PrivilegeLevel = 99)type PrivilegeLevel int@@ -308,16 +312,18 @@ type GetPrivilegesConfigResp struct {type PrivilegeOption struct {Level PrivilegeLevel `json:"level"`LevelDesc string `json:"level_desc"`- Privileges []*constant.Privilege `json:"privileges"`+ Privileges []*constant.Privilege `validate:"dive" json:"privileges"`}// UpdatePrivilegesConfigReq update privileges config requesttype UpdatePrivilegesConfigReq struct {- Level PrivilegeLevel `validate:"required,min=1,max=3" json:"level"`+ Level PrivilegeLevel `validate:"required,min=1,max=3|eq=99" json:"level"`+ CustomPrivileges []*constant.Privilege `validate:"dive" json:"custom_privileges"`}var (DefaultPrivilegeOptions PrivilegeOptions+ DefaultCustomPrivilegeOption *PrivilegeOptionprivilegeOptionsLevelMapping = map[string][]int{constant.RankQuestionAddKey: {1, 1, 1},constant.RankAnswerAddKey: {1, 1, 1},@@ -368,4 +374,11 @@ func init() {})}}++ // set up default custom privilege option+ DefaultCustomPrivilegeOption = &PrivilegeOption{+ Level: PrivilegeLevelCustom,+ LevelDesc: reason.PrivilegeLevelCustomDesc,+ Privileges: DefaultPrivilegeOptions[0].Privileges,+ }}diff --git a/internal/schema/user_notification_schema.go b/internal/schema/user_notification_schema.goindex c2506286..4c2cd3f9 100644--- a/internal/schema/user_notification_schema.go+++ b/internal/schema/user_notification_schema.go@@ -38,41 +38,13 @@ func NewNotificationChannelsFormJson(jsonStr string) NotificationChannels {return list}-func (n *NotificationChannels) Format(sequences []constant.NotificationChannelKey) {- if n == nil {- *n = make([]*NotificationChannelConfig, 0)- return- }- mapping := make(map[constant.NotificationChannelKey]*NotificationChannelConfig)- for _, item := range *n {- mapping[item.Key] = &NotificationChannelConfig{- Key: item.Key,- Enable: item.Enable,- }- }- newList := make([]*NotificationChannelConfig, 0)- for _, ch := range sequences {- if c, ok := mapping[ch]; ok {- newList = append(newList, c)- } else {- newList = append(newList, &NotificationChannelConfig{- Key: ch,- })- }- }- *n = newList-}--func (n *NotificationChannels) CheckEnable(ch constant.NotificationChannelKey) bool {- if n == nil {- return false- }- for _, item := range *n {- if item.Key == ch {- return item.Enable- }+func NewNotificationChannelConfigFormJson(jsonStr string) NotificationChannelConfig {+ var list NotificationChannels+ _ = json.Unmarshal([]byte(jsonStr), &list)+ if len(list) > 0 {+ return *list[0]}- return false+ return NotificationChannelConfig{}}func (n *NotificationChannels) ToJsonString() string {@@ -81,62 +53,39 @@ func (n *NotificationChannels) ToJsonString() string {}type NotificationConfig struct {- Inbox NotificationChannels `json:"inbox"`- AllNewQuestion NotificationChannels `json:"all_new_question"`- AllNewQuestionForFollowingTags NotificationChannels `json:"all_new_question_for_following_tags"`-}--func (n *NotificationConfig) ToJsonString() string {- data, _ := json.Marshal(n)- return string(data)+ Inbox NotificationChannelConfig `json:"inbox"`+ AllNewQuestion NotificationChannelConfig `json:"all_new_question"`+ AllNewQuestionForFollowingTags NotificationChannelConfig `json:"all_new_question_for_following_tags"`}func NewNotificationConfig(configs []*entity.UserNotificationConfig) NotificationConfig {nc := NotificationConfig{}- nc.Inbox = make([]*NotificationChannelConfig, 0)- nc.AllNewQuestion = make([]*NotificationChannelConfig, 0)- nc.AllNewQuestionForFollowingTags = make([]*NotificationChannelConfig, 0)for _, item := range configs {switch item.Source {case string(constant.InboxSource):- nc.Inbox = NewNotificationChannelsFormJson(item.Channels)+ nc.Inbox = NewNotificationChannelConfigFormJson(item.Channels)case string(constant.AllNewQuestionSource):- nc.AllNewQuestion = NewNotificationChannelsFormJson(item.Channels)+ nc.AllNewQuestion = NewNotificationChannelConfigFormJson(item.Channels)case string(constant.AllNewQuestionForFollowingTagsSource):- nc.AllNewQuestionForFollowingTags = NewNotificationChannelsFormJson(item.Channels)+ nc.AllNewQuestionForFollowingTags = NewNotificationChannelConfigFormJson(item.Channels)}}return nc}-func (n *NotificationConfig) FromJsonString(data string) {- if len(data) > 0 {- _ = json.Unmarshal([]byte(data), n)- return- }- n.Inbox = make([]*NotificationChannelConfig, 0)- n.AllNewQuestion = make([]*NotificationChannelConfig, 0)- n.AllNewQuestionForFollowingTags = make([]*NotificationChannelConfig, 0)- return-}-func (n *NotificationConfig) Format() {- n.Inbox.Format([]constant.NotificationChannelKey{constant.EmailChannel})- n.AllNewQuestion.Format([]constant.NotificationChannelKey{constant.EmailChannel})- n.AllNewQuestionForFollowingTags.Format([]constant.NotificationChannelKey{constant.EmailChannel})-}--func (n *NotificationConfig) CheckEnable(- source constant.NotificationSource, channel constant.NotificationChannelKey) bool {- switch source {- case constant.InboxSource:- return n.Inbox.CheckEnable(channel)- case constant.AllNewQuestionSource:- return n.AllNewQuestion.CheckEnable(channel)- case constant.AllNewQuestionForFollowingTagsSource:- return n.AllNewQuestionForFollowingTags.CheckEnable(channel)+ if n.Inbox.Key == "" {+ n.Inbox.Key = constant.EmailChannel+ n.Inbox.Enable = false+ }+ if n.AllNewQuestion.Key == "" {+ n.AllNewQuestion.Key = constant.EmailChannel+ n.AllNewQuestion.Enable = false+ }+ if n.AllNewQuestionForFollowingTags.Key == "" {+ n.AllNewQuestionForFollowingTags.Key = constant.EmailChannel+ n.AllNewQuestionForFollowingTags.Enable = false}- return false}// UpdateUserNotificationConfigReq update user notification config requestdiff --git a/internal/schema/user_schema.go b/internal/schema/user_schema.goindex 4906faff..53909066 100644--- a/internal/schema/user_schema.go+++ b/internal/schema/user_schema.go@@ -21,6 +21,9 @@ package schemaimport ("encoding/json"+ "github.com/apache/incubator-answer/internal/base/reason"+ "github.com/apache/incubator-answer/internal/base/translator"+ "github.com/segmentfault/pacman/errors""github.com/apache/incubator-answer/internal/base/constant""github.com/apache/incubator-answer/internal/base/validator"@@ -80,6 +83,8 @@ type UserLoginResp struct {Location string `json:"location"`// languageLanguage string `json:"language"`+ // Color scheme+ ColorScheme string `json:"color_scheme"`// access tokenAccessToken string `json:"access_token"`// role id@@ -110,6 +115,9 @@ func (r *GetCurrentLoginUserInfoResp) ConvertFromUserEntity(userInfo *entity.User.CreatedAt = userInfo.CreatedAt.Unix()r.LastLoginDate = userInfo.LastLoginDate.Unix()r.Status = constant.ConvertUserStatus(userInfo.Status, userInfo.MailStatus)+ if len(r.ColorScheme) == 0 {+ r.ColorScheme = constant.ColorSchemeDefault+ }}// GetOtherUserInfoByUsernameResp get user response@@ -278,10 +286,25 @@ func (req *UpdateInfoRequest) Check() (errFields []*validator.FormErrorField, ertype UpdateUserInterfaceRequest struct {// languageLanguage string `validate:"required,gt=1,lte=100" json:"language"`+ // Color scheme+ ColorScheme string `validate:"required,gt=1,lte=100" json:"color_scheme"`// user idUserId string `json:"-"`}+func (req *UpdateUserInterfaceRequest) Check() (errFields []*validator.FormErrorField, err error) {+ if !translator.CheckLanguageIsValid(req.Language) {+ return nil, errors.BadRequest(reason.LangNotFound)+ }+ if req.ColorScheme != constant.ColorSchemeDefault &&+ req.ColorScheme != constant.ColorSchemeLight &&+ req.ColorScheme != constant.ColorSchemeDark &&+ req.ColorScheme != constant.ColorSchemeSystem {+ req.ColorScheme = constant.ColorSchemeDefault+ }+ return nil, nil+}+type UserRetrievePassWordRequest struct {Email string `validate:"required,email,gt=0,lte=500" json:"e_mail"`CaptchaID string `json:"captcha_id"`@@ -325,6 +348,7 @@ type UserBasicInfo struct {Avatar string `json:"avatar"`Website string `json:"website"`Location string `json:"location"`+ Language string `json:"language"`Status string `json:"status"`}diff --git a/internal/service/action/captcha_strategy.go b/internal/service/action/captcha_strategy.goindex b4830d1b..72dfefed 100644--- a/internal/service/action/captcha_strategy.go+++ b/internal/service/action/captcha_strategy.go@@ -36,10 +36,6 @@ func (cs *CaptchaService) ValidationStrategy(ctx context.Context, unit, actionTylog.Error(err)return false}- // If no operation previously, it is considered to be the first operation- if info == nil {- return true- }switch actionType {case entity.CaptchaActionEmail:return cs.CaptchaActionEmail(ctx, unit, info)@@ -71,119 +67,152 @@ func (cs *CaptchaService) ValidationStrategy(ctx context.Context, unit, actionTyreturn false}-func (cs *CaptchaService) CaptchaActionEmail(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionEmail(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {// You need a verification code every timereturn false}-func (cs *CaptchaService) CaptchaActionPassword(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionPassword(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 3setTime := int64(60 * 30) //secondsnow := time.Now().Unix()- if now-actioninfo.LastTime <= setTime && actioninfo.Num >= setNum {+ if now-actionInfo.LastTime <= setTime && actionInfo.Num >= setNum {return false}- if now-actioninfo.LastTime != 0 && now-actioninfo.LastTime > setTime {+ if now-actionInfo.LastTime != 0 && now-actionInfo.LastTime > setTime {cs.captchaRepo.SetActionType(ctx, unit, entity.CaptchaActionPassword, "", 0)}return true}-func (cs *CaptchaService) CaptchaActionEditUserinfo(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionEditUserinfo(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 3setTime := int64(60 * 30) //secondsnow := time.Now().Unix()- if now-actioninfo.LastTime <= setTime && actioninfo.Num >= setNum {+ if now-actionInfo.LastTime <= setTime && actionInfo.Num >= setNum {return false}- if now-actioninfo.LastTime != 0 && now-actioninfo.LastTime > setTime {+ if now-actionInfo.LastTime != 0 && now-actionInfo.LastTime > setTime {cs.captchaRepo.SetActionType(ctx, unit, entity.CaptchaActionEditUserinfo, "", 0)}return true}-func (cs *CaptchaService) CaptchaActionQuestion(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionQuestion(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 10setTime := int64(5) //secondsnow := time.Now().Unix()- if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {+ if now-actionInfo.LastTime <= setTime || actionInfo.Num >= setNum {return false}return true}-func (cs *CaptchaService) CaptchaActionAnswer(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionAnswer(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 10setTime := int64(5) //secondsnow := time.Now().Unix()- if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {+ if now-actionInfo.LastTime <= setTime || actionInfo.Num >= setNum {return false}return true}-func (cs *CaptchaService) CaptchaActionComment(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionComment(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 30setTime := int64(1) //secondsnow := time.Now().Unix()- if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {+ if now-actionInfo.LastTime <= setTime || actionInfo.Num >= setNum {return false}return true}-func (cs *CaptchaService) CaptchaActionEdit(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionEdit(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 10- if actioninfo.Num >= setNum {+ if actionInfo.Num >= setNum {return false}return true}-func (cs *CaptchaService) CaptchaActionInvitationAnswer(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionInvitationAnswer(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 30- if actioninfo.Num >= setNum {+ if actionInfo.Num >= setNum {return false}return true}-func (cs *CaptchaService) CaptchaActionSearch(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionSearch(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }now := time.Now().Unix()setNum := 20setTime := int64(60) //seconds- if now-int64(actioninfo.LastTime) <= setTime && actioninfo.Num >= setNum {+ if now-int64(actionInfo.LastTime) <= setTime && actionInfo.Num >= setNum {return false}- if now-actioninfo.LastTime > setTime {+ if now-actionInfo.LastTime > setTime {cs.captchaRepo.SetActionType(ctx, unit, entity.CaptchaActionSearch, "", 0)}return true}-func (cs *CaptchaService) CaptchaActionReport(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionReport(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 30setTime := int64(1) //secondsnow := time.Now().Unix()- if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {+ if now-actionInfo.LastTime <= setTime || actionInfo.Num >= setNum {return false}return true}-func (cs *CaptchaService) CaptchaActionDelete(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionDelete(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 5setTime := int64(5) //secondsnow := time.Now().Unix()- if now-actioninfo.LastTime <= setTime || actioninfo.Num >= setNum {+ if now-actionInfo.LastTime <= setTime || actionInfo.Num >= setNum {return false}return true}-func (cs *CaptchaService) CaptchaActionVote(ctx context.Context, unit string, actioninfo *entity.ActionRecordInfo) bool {+func (cs *CaptchaService) CaptchaActionVote(ctx context.Context, unit string, actionInfo *entity.ActionRecordInfo) bool {+ if actionInfo == nil {+ return true+ }setNum := 40- if actioninfo.Num >= setNum {+ if actionInfo.Num >= setNum {return false}return truediff --git a/internal/service/activity/activity.go b/internal/service/activity/activity.goindex 8591ff2e..cb634d2a 100644--- a/internal/service/activity/activity.go+++ b/internal/service/activity/activity.go@@ -206,7 +206,7 @@ func (as *ActivityService) getTimelineActivityComment(ctx context.Context, objecif err != nil {log.Error(err)} else {- return revision.Log+ return converter.Markdown2HTML(revision.Log)}return}@@ -218,7 +218,7 @@ func (as *ActivityService) getTimelineActivityComment(ctx context.Context, objec} else {closeMsg := &schema.CloseQuestionMeta{}if err := json.Unmarshal([]byte(metaInfo.Value), closeMsg); err == nil {- return closeMsg.CloseMsg+ return converter.Markdown2HTML(closeMsg.CloseMsg)}}}diff --git a/internal/service/comment/comment_service.go b/internal/service/comment/comment_service.goindex df93b1a4..0caa2a14 100644--- a/internal/service/comment/comment_service.go+++ b/internal/service/comment/comment_service.go@@ -21,9 +21,6 @@ package commentimport ("context"- "github.com/apache/incubator-answer/pkg/token"- "time"-"github.com/apache/incubator-answer/internal/base/constant""github.com/apache/incubator-answer/internal/base/pager""github.com/apache/incubator-answer/internal/base/reason"@@ -38,10 +35,12 @@ import ("github.com/apache/incubator-answer/internal/service/permission"usercommon "github.com/apache/incubator-answer/internal/service/user_common""github.com/apache/incubator-answer/pkg/htmltext"+ "github.com/apache/incubator-answer/pkg/token""github.com/apache/incubator-answer/pkg/uid""github.com/jinzhu/copier""github.com/segmentfault/pacman/errors""github.com/segmentfault/pacman/log"+ "time")// CommentRepo comment repositorydiff --git a/internal/service/notification/external_notification.go b/internal/service/notification/external_notification.goindex bb025e55..58228884 100644--- a/internal/service/notification/external_notification.go+++ b/internal/service/notification/external_notification.go@@ -26,7 +26,9 @@ import ("github.com/apache/incubator-answer/internal/service/activity_common""github.com/apache/incubator-answer/internal/service/export""github.com/apache/incubator-answer/internal/service/notice_queue"+ "github.com/apache/incubator-answer/internal/service/siteinfo_common"usercommon "github.com/apache/incubator-answer/internal/service/user_common"+ "github.com/apache/incubator-answer/internal/service/user_external_login""github.com/apache/incubator-answer/internal/service/user_notification_config""github.com/segmentfault/pacman/log")@@ -38,6 +40,8 @@ type ExternalNotificationService struct {emailService *export.EmailServiceuserRepo usercommon.UserReponotificationQueueService notice_queue.ExternalNotificationQueueService+ userExternalLoginRepo user_external_login.UserExternalLoginRepo+ siteInfoService siteinfo_common.SiteInfoCommonService}func NewExternalNotificationService(@@ -47,6 +51,8 @@ func NewExternalNotificationService(emailService *export.EmailService,userRepo usercommon.UserRepo,notificationQueueService notice_queue.ExternalNotificationQueueService,+ userExternalLoginRepo user_external_login.UserExternalLoginRepo,+ siteInfoService siteinfo_common.SiteInfoCommonService,) *ExternalNotificationService {n := &ExternalNotificationService{data: data,@@ -55,6 +61,8 @@ func NewExternalNotificationService(emailService: emailService,userRepo: userRepo,notificationQueueService: notificationQueueService,+ userExternalLoginRepo: userExternalLoginRepo,+ siteInfoService: siteInfoService,}notificationQueueService.RegisterHandler(n.Handler)return ndiff --git a/internal/service/notification/new_comment_notification.go b/internal/service/notification/new_comment_notification.goindex de69038a..048c66f1 100644--- a/internal/service/notification/new_comment_notification.go+++ b/internal/service/notification/new_comment_notification.go@@ -49,7 +49,6 @@ func (ns *ExternalNotificationService) handleNewCommentNotification(ctx context.ns.sendNewCommentNotificationEmail(ctx, msg.ReceiverUserID, msg.ReceiverEmail, msg.ReceiverLang, msg.NewCommentTemplateRawData)}}-return nil}diff --git a/internal/service/notification/new_question_notification.go b/internal/service/notification/new_question_notification.goindex 29a5a9ce..c079ac28 100644--- a/internal/service/notification/new_question_notification.go+++ b/internal/service/notification/new_question_notification.go@@ -21,17 +21,23 @@ package notificationimport ("context"+ "strings"+ "time"+"github.com/apache/incubator-answer/internal/base/constant""github.com/apache/incubator-answer/internal/schema"+ "github.com/apache/incubator-answer/pkg/display""github.com/apache/incubator-answer/pkg/token"+ "github.com/apache/incubator-answer/plugin"+ "github.com/jinzhu/copier""github.com/segmentfault/pacman/i18n""github.com/segmentfault/pacman/log"- "time")type NewQuestionSubscriber struct {- UserID string `json:"user_id"`- Channels schema.NotificationChannels `json:"channels"`+ UserID string `json:"user_id"`+ Channels schema.NotificationChannels `json:"channels"`+ NotificationSource constant.NotificationSource `json:"notification_source"`}func (ns *ExternalNotificationService) handleNewQuestionNotification(ctx context.Context,@@ -60,6 +66,8 @@ func (ns *ExternalNotificationService) handleNewQuestionNotification(ctx context}}}++ ns.syncNewQuestionNotificationToPlugin(ctx, msg)return nil}@@ -94,8 +102,9 @@ func (ns *ExternalNotificationService) getNewQuestionSubscribers(ctx context.Concontinue}subscribersMapping[userNotificationConfig.UserID] = &NewQuestionSubscriber{- UserID: userNotificationConfig.UserID,- Channels: schema.NewNotificationChannelsFormJson(userNotificationConfig.Channels),+ UserID: userNotificationConfig.UserID,+ Channels: schema.NewNotificationChannelsFormJson(userNotificationConfig.Channels),+ NotificationSource: constant.AllNewQuestionForFollowingTagsSource,}}log.Debugf("get %d subscribers from tags", len(subscribersMapping))@@ -113,8 +122,9 @@ func (ns *ExternalNotificationService) getNewQuestionSubscribers(ctx context.Concontinue}subscribersMapping[notificationConfig.UserID] = &NewQuestionSubscriber{- UserID: notificationConfig.UserID,- Channels: schema.NewNotificationChannelsFormJson(notificationConfig.Channels),+ UserID: notificationConfig.UserID,+ Channels: schema.NewNotificationChannelsFormJson(notificationConfig.Channels),+ NotificationSource: constant.AllNewQuestionSource,}}@@ -182,3 +192,80 @@ func (ns *ExternalNotificationService) sendNewQuestionNotificationEmail(ctx contns.emailService.SendAndSaveCodeWithTime(ctx, userInfo.EMail, title, body, rawData.UnsubscribeCode, codeContent.ToJSONString(), 1*24*time.Hour)}++func (ns *ExternalNotificationService) syncNewQuestionNotificationToPlugin(ctx context.Context,+ msg *schema.ExternalNotificationMsg) {+ _ = plugin.CallNotification(func(fn plugin.Notification) error {+ // 1. get all this new question's tags followers+ subscribersMapping := make(map[string]plugin.NotificationType)+ for _, tagID := range msg.NewQuestionTemplateRawData.TagIDs {+ userIDs, err := ns.followRepo.GetFollowUserIDs(ctx, tagID)+ if err != nil {+ log.Error(err)+ continue+ }+ for _, userID := range userIDs {+ subscribersMapping[userID] = plugin.NotificationNewQuestionFollowedTag+ }+ }++ // 2. get all new question's followers+ questionSubscribers := fn.GetNewQuestionSubscribers()+ for _, subscriber := range questionSubscribers {+ subscribersMapping[subscriber] = plugin.NotificationNewQuestion+ }++ // 3. remove question owner+ delete(subscribersMapping, msg.NewQuestionTemplateRawData.QuestionAuthorUserID)++ pluginNotificationMsg := ns.newPluginQuestionNotification(ctx, msg)++ // 4. send notification+ for subscriberUserID, notificationType := range subscribersMapping {+ newMsg := plugin.NotificationMessage{}+ _ = copier.Copy(&newMsg, pluginNotificationMsg)+ newMsg.ReceiverUserID = subscriberUserID+ newMsg.Type = notificationType++ if len(subscriberUserID) > 0 {+ userInfo, _, _ := ns.userRepo.GetByUserID(ctx, subscriberUserID)+ if userInfo != nil {+ newMsg.ReceiverLang = userInfo.Language+ }+ }++ userInfo, exist, err := ns.userExternalLoginRepo.GetByUserID(ctx, fn.Info().SlugName, subscriberUserID)+ if err != nil {+ log.Errorf("get user external login info failed: %v", err)+ return nil+ }+ if exist {+ newMsg.ReceiverExternalID = userInfo.ExternalID+ }+ fn.Notify(newMsg)+ }+ return nil+ })+}++func (ns *ExternalNotificationService) newPluginQuestionNotification(+ ctx context.Context, msg *schema.ExternalNotificationMsg) (raw *plugin.NotificationMessage) {+ raw = &plugin.NotificationMessage{+ ReceiverUserID: msg.ReceiverUserID,+ ReceiverLang: msg.ReceiverLang,+ QuestionTitle: msg.NewQuestionTemplateRawData.QuestionTitle,+ QuestionTags: strings.Join(msg.NewQuestionTemplateRawData.Tags, ","),+ }+ siteInfo, err := ns.siteInfoService.GetSiteGeneral(ctx)+ if err != nil {+ return raw+ }+ seoInfo, err := ns.siteInfoService.GetSiteSeo(ctx)+ if err != nil {+ return raw+ }+ raw.QuestionUrl = display.QuestionURL(+ seoInfo.Permalink, siteInfo.SiteUrl,+ msg.NewQuestionTemplateRawData.QuestionID, msg.NewQuestionTemplateRawData.QuestionTitle)+ return raw+}diff --git a/internal/service/notification_common/notification.go b/internal/service/notification_common/notification.goindex 84a2084f..2338023c 100644--- a/internal/service/notification_common/notification.go+++ b/internal/service/notification_common/notification.go@@ -24,6 +24,10 @@ import ("fmt""time"+ "github.com/apache/incubator-answer/internal/service/siteinfo_common"+ "github.com/apache/incubator-answer/internal/service/user_external_login"+ "github.com/apache/incubator-answer/pkg/display"+"github.com/apache/incubator-answer/internal/base/constant""github.com/apache/incubator-answer/internal/base/data""github.com/apache/incubator-answer/internal/base/reason"@@ -59,6 +63,8 @@ type NotificationCommon struct {userCommon *usercommon.UserCommonobjectInfoService *object_info.ObjServicenotificationQueueService notice_queue.NotificationQueueService+ userExternalLoginRepo user_external_login.UserExternalLoginRepo+ siteInfoService siteinfo_common.SiteInfoCommonService}func NewNotificationCommon(@@ -69,6 +75,8 @@ func NewNotificationCommon(followRepo activity_common.FollowRepo,objectInfoService *object_info.ObjService,notificationQueueService notice_queue.NotificationQueueService,+ userExternalLoginRepo user_external_login.UserExternalLoginRepo,+ siteInfoService siteinfo_common.SiteInfoCommonService,) *NotificationCommon {notification := &NotificationCommon{data: data,@@ -78,6 +86,8 @@ func NewNotificationCommon(userCommon: userCommon,objectInfoService: objectInfoService,notificationQueueService: notificationQueueService,+ userExternalLoginRepo: userExternalLoginRepo,+ siteInfoService: siteInfoService,}notificationQueueService.RegisterHandler(notification.AddNotification)return notification@@ -183,6 +193,10 @@ func (ns *NotificationCommon) AddNotification(ctx context.Context, msg *schema.N}go ns.SendNotificationToAllFollower(ctx, msg, questionID)++ if msg.Type == schema.NotificationTypeInbox {+ ns.syncNotificationToPlugin(ctx, objInfo, msg)+ }return nil}@@ -226,3 +240,72 @@ func (ns *NotificationCommon) SendNotificationToAllFollower(ctx context.Context,ns.notificationQueueService.Send(ctx, t)}}++func (ns *NotificationCommon) syncNotificationToPlugin(ctx context.Context, objInfo *schema.SimpleObjectInfo,+ msg *schema.NotificationMsg) {+ siteInfo, err := ns.siteInfoService.GetSiteGeneral(ctx)+ if err != nil {+ log.Errorf("get site general info failed: %v", err)+ return+ }+ seoInfo, err := ns.siteInfoService.GetSiteSeo(ctx)+ if err != nil {+ log.Errorf("get site seo info failed: %v", err)+ return+ }++ objInfo.QuestionID = uid.DeShortID(objInfo.QuestionID)+ objInfo.AnswerID = uid.DeShortID(objInfo.AnswerID)+ pluginNotificationMsg := plugin.NotificationMessage{+ Type: plugin.NotificationType(msg.NotificationAction),+ ReceiverUserID: msg.ReceiverUserID,+ TriggerUserID: msg.TriggerUserID,+ QuestionTitle: objInfo.Title,+ }++ if len(objInfo.QuestionID) > 0 {+ pluginNotificationMsg.QuestionUrl =+ display.QuestionURL(seoInfo.Permalink, siteInfo.SiteUrl, objInfo.QuestionID, objInfo.Title)+ }+ if len(objInfo.AnswerID) > 0 {+ pluginNotificationMsg.AnswerUrl =+ display.AnswerURL(seoInfo.Permalink, siteInfo.SiteUrl, objInfo.QuestionID, objInfo.Title, objInfo.AnswerID)+ }+ if len(objInfo.CommentID) > 0 {+ pluginNotificationMsg.CommentUrl =+ display.CommentURL(seoInfo.Permalink, siteInfo.SiteUrl, objInfo.QuestionID, objInfo.Title, objInfo.AnswerID, objInfo.CommentID)+ }++ if len(msg.TriggerUserID) > 0 {+ triggerUser, exist, err := ns.userCommon.GetUserBasicInfoByID(ctx, msg.TriggerUserID)+ if err != nil {+ log.Errorf("get trigger user basic info failed: %v", err)+ return+ }+ if exist {+ pluginNotificationMsg.TriggerUserID = triggerUser.ID+ pluginNotificationMsg.TriggerUserDisplayName = triggerUser.DisplayName+ pluginNotificationMsg.TriggerUserUrl = display.UserURL(siteInfo.SiteUrl, triggerUser.Username)+ }+ }++ if len(pluginNotificationMsg.ReceiverLang) == 0 && len(msg.ReceiverUserID) > 0 {+ userInfo, _, _ := ns.userCommon.GetUserBasicInfoByID(ctx, msg.ReceiverUserID)+ if userInfo != nil {+ pluginNotificationMsg.ReceiverLang = userInfo.Language+ }+ }++ _ = plugin.CallNotification(func(fn plugin.Notification) error {+ userInfo, exist, err := ns.userExternalLoginRepo.GetByUserID(ctx, fn.Info().SlugName, msg.ReceiverUserID)+ if err != nil {+ log.Errorf("get user external login info failed: %v", err)+ return nil+ }+ if exist {+ pluginNotificationMsg.ReceiverExternalID = userInfo.ExternalID+ }+ fn.Notify(pluginNotificationMsg)+ return nil+ })+}diff --git a/internal/service/plugin_common/plugin_common_service.go b/internal/service/plugin_common/plugin_common_service.goindex ef9ccfde..d064fa99 100644--- a/internal/service/plugin_common/plugin_common_service.go+++ b/internal/service/plugin_common/plugin_common_service.go@@ -42,22 +42,92 @@ type PluginConfigRepo interface {GetPluginConfigAll(ctx context.Context) (pluginConfigs []*entity.PluginConfig, err error)}+type PluginUserConfigRepo interface {+ SaveUserPluginConfig(ctx context.Context, userID string, pluginSlugName, configValue string) (err error)+ GetPluginUserConfig(ctx context.Context, userID, pluginSlugName string) (+ pluginUserConfig *entity.PluginUserConfig, exist bool, err error)+ GetPluginUserConfigPage(ctx context.Context, page, pageSize int) (+ pluginUserConfigs []*entity.PluginUserConfig, total int64, err error)+}+// PluginCommonService user servicetype PluginCommonService struct {- configService *config.ConfigService- pluginConfigRepo PluginConfigRepo- data *data.Data+ configService *config.ConfigService+ pluginConfigRepo PluginConfigRepo+ pluginUserConfigRepo PluginUserConfigRepo+ data *data.Data}// NewPluginCommonService new report servicefunc NewPluginCommonService(pluginConfigRepo PluginConfigRepo,+ pluginUserConfigRepo PluginUserConfigRepo,configService *config.ConfigService,data *data.Data,) *PluginCommonService {+ p := &PluginCommonService{+ configService: configService,+ pluginConfigRepo: pluginConfigRepo,+ pluginUserConfigRepo: pluginUserConfigRepo,+ data: data,+ }+ p.initPluginData()+ return p+}++// UpdatePluginStatus update plugin status+func (ps *PluginCommonService) UpdatePluginStatus(ctx context.Context) (err error) {+ content, err := plugin.StatusManager.MarshalJSON()+ if err != nil {+ return errors.InternalServer(reason.UnknownError).WithError(err)+ }+ return ps.configService.UpdateConfig(ctx, constant.PluginStatus, string(content))+}++// UpdatePluginConfig update plugin config+func (ps *PluginCommonService) UpdatePluginConfig(ctx context.Context, req *schema.UpdatePluginConfigReq) (err error) {+ configValue, _ := json.Marshal(req.ConfigFields)+ err = ps.pluginConfigRepo.SavePluginConfig(ctx, req.PluginSlugName, string(configValue))+ if err != nil {+ return err+ }++ _ = plugin.CallSearch(func(search plugin.Search) error {+ if search.Info().SlugName == req.PluginSlugName {+ search.RegisterSyncer(ctx, search_sync.NewPluginSyncer(ps.data))+ }+ return nil+ })+ return nil+}++// UpdatePluginUserConfig update plugin config+func (ps *PluginCommonService) UpdatePluginUserConfig(ctx context.Context, req *schema.UpdateUserPluginConfigReq) (err error) {+ configValue, _ := json.Marshal(req.ConfigFields)+ err = ps.pluginUserConfigRepo.SaveUserPluginConfig(ctx, req.UserID, req.PluginSlugName, string(configValue))+ if err != nil {+ return err+ }+ return nil+}++// GetUserPluginConfig get user plugin config+func (ps *PluginCommonService) GetUserPluginConfig(ctx context.Context, req *schema.GetUserPluginConfigReq) (+ configValue string, err error) {+ pluginUserConfig, exist, err := ps.pluginUserConfigRepo.GetPluginUserConfig(ctx, req.UserID, req.PluginSlugName)+ if err != nil {+ return "", err+ }+ if !exist {+ return "", nil+ }+ return pluginUserConfig.Value, nil+}++func (ps *PluginCommonService) initPluginData() {// init plugin status- pluginStatus, err := configService.GetStringValue(context.TODO(), constant.PluginStatus)+ pluginStatus, err := ps.configService.GetStringValue(context.TODO(), constant.PluginStatus)if err != nil {log.Error(err)} else {@@ -67,7 +137,7 @@ func NewPluginCommonService(}// init plugin config- pluginConfigs, err := pluginConfigRepo.GetPluginConfigAll(context.Background())+ pluginConfigs, err := ps.pluginConfigRepo.GetPluginConfigAll(context.Background())if err != nil {log.Error(err)} else {@@ -83,44 +153,49 @@ func NewPluginCommonService(}}- err = plugin.CallCache(func(cache plugin.Cache) error {- data.Cache = cache+ _ = plugin.CallCache(func(cache plugin.Cache) error {+ ps.data.Cache = cachereturn nil})- if err != nil {- log.Errorf("parse plugin cache failed: %v", err)- }}- return &PluginCommonService{- configService: configService,- pluginConfigRepo: pluginConfigRepo,- data: data,- }-}--// UpdatePluginStatus update plugin status-func (ps *PluginCommonService) UpdatePluginStatus(ctx context.Context) (err error) {- content, err := plugin.StatusManager.MarshalJSON()- if err != nil {- return errors.InternalServer(reason.UnknownError).WithError(err)- }- return ps.configService.UpdateConfig(ctx, constant.PluginStatus, string(content))-}--// UpdatePluginConfig update plugin config-func (ps *PluginCommonService) UpdatePluginConfig(ctx context.Context, req *schema.UpdatePluginConfigReq) (err error) {- configValue, _ := json.Marshal(req.ConfigFields)- err = ps.pluginConfigRepo.SavePluginConfig(ctx, req.PluginSlugName, string(configValue))- if err != nil {- return err- }-- _ = plugin.CallSearch(func(search plugin.Search) error {- if search.Info().SlugName == req.PluginSlugName {- search.RegisterSyncer(ctx, search_sync.NewPluginSyncer(ps.data))+ // init plugin user config+ plugin.RegisterGetPluginUserConfigFunc(func(userID, pluginSlugName string) []byte {+ pluginUserConfig, exist, err := ps.pluginUserConfigRepo.GetPluginUserConfig(context.Background(), userID, pluginSlugName)+ if err != nil {+ log.Error(err)+ return nil}- return nil+ if !exist {+ return nil+ }+ return []byte(pluginUserConfig.Value)})- return nil++ // init plugin user config data+ go func() {+ page, pageSize := 1, 1000+ for {+ userConfigs, _, err := ps.pluginUserConfigRepo.GetPluginUserConfigPage(context.Background(), page, pageSize)+ if err != nil {+ log.Error(err)+ return+ }+ if len(userConfigs) == 0 {+ return+ }+ for _, userConfig := range userConfigs {+ err := plugin.CallUserConfig(func(fn plugin.UserConfig) error {+ if fn.Info().SlugName == userConfig.PluginSlugName {+ return fn.UserConfigReceiver(userConfig.UserID, []byte(userConfig.Value))+ }+ return nil+ })+ if err != nil {+ log.Errorf("parse plugin user config failed: %s %v", userConfig.PluginSlugName, err)+ }+ }+ page+++ }+ }()}diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.goindex 72835731..9fbda693 100644--- a/internal/service/question_common/question.go+++ b/internal/service/question_common/question.go@@ -54,7 +54,7 @@ type QuestionRepo interface {UpdateQuestion(ctx context.Context, question *entity.Question, Cols []string) (err error)GetQuestion(ctx context.Context, id string) (question *entity.Question, exist bool, err error)GetQuestionList(ctx context.Context, question *entity.Question) (questions []*entity.Question, err error)- GetQuestionPage(ctx context.Context, page, pageSize int, userID, tagID, orderCond string, inDays int) (+ GetQuestionPage(ctx context.Context, page, pageSize int, tagIDs []string, userID, orderCond string, inDays int, showHidden bool) (questionList []*entity.Question, total int64, err error)UpdateQuestionStatus(ctx context.Context, questionID string, status int) (err error)UpdateQuestionStatusWithOutUpdateTime(ctx context.Context, question *entity.Question) (err error)@@ -72,6 +72,7 @@ type QuestionRepo interface {GetUserQuestionCount(ctx context.Context, userID string) (count int64, err error)SitemapQuestions(ctx context.Context, page, pageSize int) (questionIDList []*schema.SiteMapQuestionInfo, err error)RemoveAllUserQuestion(ctx context.Context, userID string) (err error)+ UpdateSearch(ctx context.Context, questionID string) (err error)}// QuestionCommon user servicediff --git a/internal/service/question_service.go b/internal/service/question_service.goindex f9159304..a4d5ffe6 100644--- a/internal/service/question_service.go+++ b/internal/service/question_service.go@@ -22,9 +22,6 @@ package serviceimport ("encoding/json""fmt"- "github.com/apache/incubator-answer/internal/service/notification"- "github.com/apache/incubator-answer/internal/service/siteinfo_common"- "github.com/apache/incubator-answer/pkg/token""strings""time"@@ -42,13 +39,17 @@ import ("github.com/apache/incubator-answer/internal/service/export""github.com/apache/incubator-answer/internal/service/meta""github.com/apache/incubator-answer/internal/service/notice_queue"+ "github.com/apache/incubator-answer/internal/service/notification""github.com/apache/incubator-answer/internal/service/permission"questioncommon "github.com/apache/incubator-answer/internal/service/question_common""github.com/apache/incubator-answer/internal/service/revision_common"+ "github.com/apache/incubator-answer/internal/service/role"+ "github.com/apache/incubator-answer/internal/service/siteinfo_common"tagcommon "github.com/apache/incubator-answer/internal/service/tag_common"usercommon "github.com/apache/incubator-answer/internal/service/user_common""github.com/apache/incubator-answer/pkg/converter""github.com/apache/incubator-answer/pkg/htmltext"+ "github.com/apache/incubator-answer/pkg/token""github.com/apache/incubator-answer/pkg/uid""github.com/jinzhu/copier""github.com/segmentfault/pacman/errors"@@ -65,6 +66,7 @@ type QuestionService struct {questioncommon *questioncommon.QuestionCommonuserCommon *usercommon.UserCommonuserRepo usercommon.UserRepo+ userRoleRelService *role.UserRoleRelServicerevisionService *revision_common.RevisionServicemetaService *meta.MetaServicecollectionCommon *collectioncommon.CollectionCommon@@ -83,6 +85,7 @@ func NewQuestionService(questioncommon *questioncommon.QuestionCommon,userCommon *usercommon.UserCommon,userRepo usercommon.UserRepo,+ userRoleRelService *role.UserRoleRelService,revisionService *revision_common.RevisionService,metaService *meta.MetaService,collectionCommon *collectioncommon.CollectionCommon,@@ -100,6 +103,7 @@ func NewQuestionService(questioncommon: questioncommon,userCommon: userCommon,userRepo: userRepo,+ userRoleRelService: userRoleRelService,revisionService: revisionService,metaService: metaService,collectionCommon: collectionCommon,@@ -314,6 +318,7 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.Questionif err != nil {return}+ _ = qs.questionRepo.UpdateSearch(ctx, question.ID)revisionDTO := &schema.AddRevisionDTO{UserID: question.UserID,@@ -1237,15 +1242,31 @@ func (qs *QuestionService) SimilarQuestion(ctx context.Context, questionID strinfunc (qs *QuestionService) GetQuestionPage(ctx context.Context, req *schema.QuestionPageReq) (questions []*schema.QuestionPageResp, total int64, err error) {questions = make([]*schema.QuestionPageResp, 0)-+ // query by user role+ showHidden := false+ if req.LoginUserID != "" && req.UserIDBeSearched != "" {+ showHidden = req.LoginUserID == req.UserIDBeSearched+ if !showHidden {+ userRole, err := qs.userRoleRelService.GetUserRole(ctx, req.LoginUserID)+ if err != nil {+ return nil, 0, err+ }+ showHidden = userRole == role.RoleAdminID || userRole == role.RoleModeratorID+ }+ }// query by tag condition+ var tagIDs = make([]string, 0)if len(req.Tag) > 0 {tagInfo, exist, err := qs.tagCommon.GetTagBySlugName(ctx, strings.ToLower(req.Tag))if err != nil {return nil, 0, err}if exist {- req.TagID = tagInfo.ID+ synTagIds, err := qs.tagCommon.GetTagIDsByMainTagID(ctx, tagInfo.ID)+ if err != nil {+ return nil, 0, err+ }+ tagIDs = append(synTagIds, tagInfo.ID)}}@@ -1262,7 +1283,7 @@ func (qs *QuestionService) GetQuestionPage(ctx context.Context, req *schema.Ques}questionList, total, err := qs.questionRepo.GetQuestionPage(ctx, req.Page, req.PageSize,- req.UserIDBeSearched, req.TagID, req.OrderCond, req.InDays)+ tagIDs, req.UserIDBeSearched, req.OrderCond, req.InDays, showHidden)if err != nil {return nil, 0, err}diff --git a/internal/service/search_common/search.go b/internal/service/search_common/search.goindex d1aea547..c19fdc49 100644--- a/internal/service/search_common/search.go+++ b/internal/service/search_common/search.go@@ -26,8 +26,8 @@ import ()type SearchRepo interface {- SearchContents(ctx context.Context, words []string, tagIDs []string, userID string, votes, page, size int, order string) (resp []*schema.SearchResult, total int64, err error)- SearchQuestions(ctx context.Context, words []string, tagIDs []string, notAccepted bool, views, answers int, page, size int, order string) (resp []*schema.SearchResult, total int64, err error)- SearchAnswers(ctx context.Context, words []string, tagIDs []string, accepted bool, questionID string, page, size int, order string) (resp []*schema.SearchResult, total int64, err error)+ SearchContents(ctx context.Context, words []string, tagIDs [][]string, userID string, votes, page, size int, order string) (resp []*schema.SearchResult, total int64, err error)+ SearchQuestions(ctx context.Context, words []string, tagIDs [][]string, notAccepted bool, views, answers int, page, size int, order string) (resp []*schema.SearchResult, total int64, err error)+ SearchAnswers(ctx context.Context, words []string, tagIDs [][]string, accepted bool, questionID string, page, size int, order string) (resp []*schema.SearchResult, total int64, err error)ParseSearchPluginResult(ctx context.Context, sres []plugin.SearchResult) (resp []*schema.SearchResult, err error)}diff --git a/internal/service/search_parser/search_parser.go b/internal/service/search_parser/search_parser.goindex a5dfd670..6485e162 100644--- a/internal/service/search_parser/search_parser.go+++ b/internal/service/search_parser/search_parser.go@@ -105,7 +105,7 @@ func (sp *SearchParser) ParseStructure(ctx context.Context, dto *schema.SearchDT}// parseTags parse search tags, return tag ids array-func (sp *SearchParser) parseTags(ctx context.Context, query *string) (tags []string) {+func (sp *SearchParser) parseTags(ctx context.Context, query *string) (tags [][]string) {var (// expire tag patternexprTag = `\[(.*?)\]`@@ -119,17 +119,25 @@ func (sp *SearchParser) parseTags(ctx context.Context, query *string) (tags []streturn}- tags = []string{}+ tags = make([][]string, 0)for _, item := range res {+ tagGroup := make([]string, 0)tag, exists, err := sp.tagCommonService.GetTagBySlugName(ctx, item[1])if err != nil || !exists {continue}+ tagGroup = append(tagGroup, tag.ID)if tag.MainTagID > 0 {- tags = append(tags, fmt.Sprintf("%d", tag.MainTagID))- } else {- tags = append(tags, tag.ID)+ tagGroup = append(tagGroup, fmt.Sprintf("%d", tag.MainTagID))}+ synIDs, err := sp.tagCommonService.GetTagIDsByMainTagID(ctx, tag.ID)+ if err != nil || !exists {+ continue+ }+ tagGroup = append(tagGroup, tag.ID)+ tagGroup = append(tagGroup, synIDs...)+ tagGroup = converter.UniqueArray(tagGroup)+ tags = append(tags, tagGroup)}// limit maximum 5 tagsdiff --git a/internal/service/siteinfo/siteinfo_service.go b/internal/service/siteinfo/siteinfo_service.goindex 7f609e6c..f82a7c7f 100644--- a/internal/service/siteinfo/siteinfo_service.go+++ b/internal/service/siteinfo/siteinfo_service.go@@ -311,8 +311,18 @@ func (s *SiteInfoService) GetPrivilegesConfig(ctx context.Context) (resp *schemaif err = s.siteInfoCommonService.GetSiteInfoByType(ctx, constant.SiteTypePrivileges, privilege); err != nil {return nil, err}+ privilegeOptions := schema.DefaultPrivilegeOptions+ if privilege.CustomPrivileges != nil && len(privilege.CustomPrivileges) > 0 {+ privilegeOptions = append(privilegeOptions, &schema.PrivilegeOption{+ Level: schema.PrivilegeLevelCustom,+ LevelDesc: reason.PrivilegeLevelCustomDesc,+ Privileges: privilege.CustomPrivileges,+ })+ } else {+ privilegeOptions = append(privilegeOptions, schema.DefaultCustomPrivilegeOption)+ }resp = &schema.GetPrivilegesConfigResp{- Options: s.translatePrivilegeOptions(ctx),+ Options: s.translatePrivilegeOptions(ctx, privilegeOptions),SelectedLevel: schema.PrivilegeLevel3,}if privilege != nil && privilege.Level > 0 {@@ -321,9 +331,9 @@ func (s *SiteInfoService) GetPrivilegesConfig(ctx context.Context) (resp *schemareturn resp, nil}-func (s *SiteInfoService) translatePrivilegeOptions(ctx context.Context) (options []*schema.PrivilegeOption) {+func (s *SiteInfoService) translatePrivilegeOptions(ctx context.Context, privilegeOptions []*schema.PrivilegeOption) (options []*schema.PrivilegeOption) {la := handler.GetLangByCtx(ctx)- for _, option := range schema.DefaultPrivilegeOptions {+ for _, option := range privilegeOptions {op := &schema.PrivilegeOption{Level: option.Level,LevelDesc: translator.Tr(la, option.LevelDesc),@@ -341,12 +351,43 @@ func (s *SiteInfoService) translatePrivilegeOptions(ctx context.Context) (option}func (s *SiteInfoService) UpdatePrivilegesConfig(ctx context.Context, req *schema.UpdatePrivilegesConfigReq) (err error) {- chooseOption := schema.DefaultPrivilegeOptions.Choose(req.Level)- if chooseOption == nil {+ var choosePrivileges []*constant.Privilege+ if req.Level == schema.PrivilegeLevelCustom {+ choosePrivileges = req.CustomPrivileges+ } else {+ chooseOption := schema.DefaultPrivilegeOptions.Choose(req.Level)+ if chooseOption == nil {+ return nil+ }+ choosePrivileges = chooseOption.Privileges+ }+ if choosePrivileges == nil {return nil}// update site info that user choose which privilege level+ if req.Level == schema.PrivilegeLevelCustom {+ privilegeMap := make(map[string]int)+ for _, privilege := range req.CustomPrivileges {+ privilegeMap[privilege.Key] = privilege.Value+ }+ var privileges []*constant.Privilege+ for _, privilege := range constant.RankAllPrivileges {+ privileges = append(privileges, &constant.Privilege{+ Key: privilege.Key,+ Label: privilege.Label,+ Value: privilegeMap[privilege.Key],+ })+ }+ req.CustomPrivileges = privileges+ } else {+ privilege := &schema.UpdatePrivilegesConfigReq{}+ if err = s.siteInfoCommonService.GetSiteInfoByType(ctx, constant.SiteTypePrivileges, privilege); err != nil {+ return err+ }+ req.CustomPrivileges = privilege.CustomPrivileges+ }+content, _ := json.Marshal(req)data := &entity.SiteInfo{Type: constant.SiteTypePrivileges,@@ -359,7 +400,7 @@ func (s *SiteInfoService) UpdatePrivilegesConfig(ctx context.Context, req *schem}// update privilege in config- for _, privilege := range chooseOption.Privileges {+ for _, privilege := range choosePrivileges {err = s.configService.UpdateConfig(ctx, privilege.Key, fmt.Sprintf("%d", privilege.Value))if err != nil {return errdiff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.goindex 74a0f0ab..fe8b3b53 100644--- a/internal/service/tag_common/tag_common.go+++ b/internal/service/tag_common/tag_common.go@@ -60,6 +60,7 @@ type TagRepo interface {MustGetTagByNameOrID(ctx context.Context, tagID, slugName string) (tag *entity.Tag, exist bool, err error)UpdateTagSynonym(ctx context.Context, tagSlugNameList []string, mainTagID int64, mainTagSlugName string) (err error)GetTagSynonymCount(ctx context.Context, tagID string) (count int64, err error)+ GetIDsByMainTagId(ctx context.Context, mainTagID string) (tagIDs []string, err error)GetTagList(ctx context.Context, tag *entity.Tag) (tagList []*entity.Tag, err error)}@@ -364,6 +365,12 @@ func (ts *TagCommonService) GetTagByID(ctx context.Context, tagID string) (tag *return}+// GetTagIDsByMainTagID get object tag+func (ts *TagCommonService) GetTagIDsByMainTagID(ctx context.Context, tagID string) (tagIDs []string, err error) {+ tagIDs, err = ts.tagRepo.GetIDsByMainTagId(ctx, tagID)+ return+}+// GetTagBySlugName get object tagfunc (ts *TagCommonService) GetTagBySlugName(ctx context.Context, slugName string) (tag *entity.Tag, exist bool, err error) {tag, exist, err = ts.tagCommonRepo.GetTagBySlugName(ctx, slugName)diff --git a/internal/service/user_common/user.go b/internal/service/user_common/user.goindex 75358884..334bcc4e 100644--- a/internal/service/user_common/user.go+++ b/internal/service/user_common/user.go@@ -48,7 +48,7 @@ type UserRepo interface {UpdateEmailStatus(ctx context.Context, userID string, emailStatus int) errorUpdateNoticeStatus(ctx context.Context, userID string, noticeStatus int) errorUpdateEmail(ctx context.Context, userID, email string) error- UpdateLanguage(ctx context.Context, userID, language string) error+ UpdateUserInterface(ctx context.Context, userID, language, colorSchema string) (err error)UpdatePass(ctx context.Context, userID, pass string) errorUpdateInfo(ctx context.Context, userInfo *entity.User) (err error)GetByUserID(ctx context.Context, userID string) (userInfo *entity.User, exist bool, err error)@@ -153,6 +153,7 @@ func (us *UserCommon) FormatUserBasicInfo(ctx context.Context, userInfo *entity.userBasicInfo.DisplayName = userInfo.DisplayNameuserBasicInfo.Website = userInfo.WebsiteuserBasicInfo.Location = userInfo.Location+ userBasicInfo.Language = userInfo.LanguageuserBasicInfo.Status = constant.ConvertUserStatus(userInfo.Status, userInfo.MailStatus)if userBasicInfo.Status == constant.UserDeleted {userBasicInfo.Avatar = ""diff --git a/internal/service/user_external_login/user_external_login_service.go b/internal/service/user_external_login/user_external_login_service.goindex ccd3b52d..6cd69aec 100644--- a/internal/service/user_external_login/user_external_login_service.go+++ b/internal/service/user_external_login/user_external_login_service.go@@ -49,6 +49,7 @@ type UserExternalLoginRepo interface {AddUserExternalLogin(ctx context.Context, user *entity.UserExternalLogin) (err error)UpdateInfo(ctx context.Context, userInfo *entity.UserExternalLogin) (err error)GetByExternalID(ctx context.Context, provider, externalID string) (userInfo *entity.UserExternalLogin, exist bool, err error)+ GetByUserID(ctx context.Context, provider, userID string) (userInfo *entity.UserExternalLogin, exist bool, err error)GetUserExternalLoginList(ctx context.Context, userID string) (resp []*entity.UserExternalLogin, err error)DeleteUserExternalLogin(ctx context.Context, userID, externalID string) (err error)SetCacheUserExternalLoginInfo(ctx context.Context, key string, info *schema.ExternalLoginUserInfoCache) (err error)diff --git a/internal/service/user_notification_config/user_notification_config_service.go b/internal/service/user_notification_config/user_notification_config_service.goindex dee84939..cc6bc1b1 100644--- a/internal/service/user_notification_config/user_notification_config_service.go+++ b/internal/service/user_notification_config/user_notification_config_service.go@@ -96,7 +96,9 @@ func (us *UserNotificationConfigService) SetDefaultUserNotificationConfig(ctx co}func (us *UserNotificationConfigService) convertToEntity(ctx context.Context, userID string,- source constant.NotificationSource, channels schema.NotificationChannels) (c *entity.UserNotificationConfig) {+ source constant.NotificationSource, channel schema.NotificationChannelConfig) (c *entity.UserNotificationConfig) {+ var channels schema.NotificationChannels+ channels = append(channels, &channel)c = &entity.UserNotificationConfig{UserID: userID,Source: string(source),@@ -110,17 +112,3 @@ func (us *UserNotificationConfigService) convertToEntity(ctx context.Context, us}return c}--func (us *UserNotificationConfigService) CheckEnable(- ctx context.Context, userID string, source constant.NotificationSource,- channel constant.NotificationChannelKey) (enable bool, err error) {- conf, exist, err := us.userNotificationConfigRepo.GetByUserIDAndSource(ctx, userID, source)- if err != nil {- return false, err- }- if !exist {- return false, nil- }- notificationChannels := schema.NewNotificationChannelsFormJson(conf.Channels)- return notificationChannels.CheckEnable(channel), nil-}diff --git a/internal/service/user_service.go b/internal/service/user_service.goindex a0e0dbb7..c6d98fc2 100644--- a/internal/service/user_service.go+++ b/internal/service/user_service.go@@ -381,14 +381,7 @@ func (us *UserService) formatUserInfoForUpdateInfo(// UserUpdateInterface update user interfacefunc (us *UserService) UserUpdateInterface(ctx context.Context, req *schema.UpdateUserInterfaceRequest) (err error) {- if !translator.CheckLanguageIsValid(req.Language) {- return errors.BadRequest(reason.LangNotFound)- }- err = us.userRepo.UpdateLanguage(ctx, req.UserId, req.Language)- if err != nil {- return- }- return nil+ return us.userRepo.UpdateUserInterface(ctx, req.UserId, req.Language, req.ColorScheme)}// UserRegisterByEmail user registerdiff --git a/pkg/converter/array.go b/pkg/converter/array.goindex 7718ee69..2b122203 100644--- a/pkg/converter/array.go+++ b/pkg/converter/array.go@@ -32,3 +32,15 @@ func ArrayNotInArray(original []string, search []string) []string {}return result}++func UniqueArray[T comparable](input []T) []T {+ result := make([]T, 0, len(input))+ seen := make(map[T]bool, len(input))+ for _, element := range input {+ if !seen[element] {+ result = append(result, element)+ seen[element] = true+ }+ }+ return result+}diff --git a/pkg/display/url.go b/pkg/display/url.goindex 1a9c5196..8f42f2f5 100644--- a/pkg/display/url.go+++ b/pkg/display/url.go@@ -58,3 +58,8 @@ func CommentURL(permalink int, siteUrl, questionID, title, answerID, commentID s}return QuestionURL(permalink, siteUrl, questionID, title) + "?commentId=" + commentID}++// UserURL get user url+func UserURL(siteUrl, username string) string {+ return siteUrl + "/users/" + username+}diff --git a/plugin/config.go b/plugin/config.goindex 5e6ed5dd..b03e794e 100644--- a/plugin/config.go+++ b/plugin/config.go@@ -32,6 +32,7 @@ const (ConfigTypeTimezone ConfigType = "timezone"ConfigTypeSwitch ConfigType = "switch"ConfigTypeButton ConfigType = "button"+ ConfigTypeLegend ConfigType = "legend")const (@@ -63,13 +64,15 @@ type ConfigField struct {}type ConfigFieldUIOptions struct {- Placeholder Translator `json:"placeholder,omitempty"`- Rows string `json:"rows,omitempty"`- InputType InputType `json:"input_type,omitempty"`- Label Translator `json:"label,omitempty"`- Action *UIOptionAction `json:"action,omitempty"`- Variant string `json:"variant,omitempty"`- Text Translator `json:"text,omitempty"`+ Placeholder Translator `json:"placeholder,omitempty"`+ Rows string `json:"rows,omitempty"`+ InputType InputType `json:"input_type,omitempty"`+ Label Translator `json:"label,omitempty"`+ Action *UIOptionAction `json:"action,omitempty"`+ Variant string `json:"variant,omitempty"`+ Text Translator `json:"text,omitempty"`+ ClassName string `json:"class_name,omitempty"`+ FieldClassName string `json:"field_class_name,omitempty"`}type ConfigFieldOption struct {diff --git a/plugin/notification.go b/plugin/notification.gonew file mode 100644index 00000000..4c483bcd--- /dev/null+++ b/plugin/notification.go@@ -0,0 +1,92 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package plugin++// NotificationType is the type of the notification+type NotificationType string++const (+ NotificationUpdateQuestion NotificationType = "notification.action.update_question"+ NotificationAnswerTheQuestion NotificationType = "notification.action.answer_the_question"+ NotificationUpVotedTheQuestion NotificationType = "notification.action.up_voted_question"+ NotificationDownVotedTheQuestion NotificationType = "notification.action.down_voted_question"+ NotificationUpdateAnswer NotificationType = "notification.action.update_answer"+ NotificationAcceptAnswer NotificationType = "notification.action.accept_answer"+ NotificationUpVotedTheAnswer NotificationType = "notification.action.up_voted_answer"+ NotificationDownVotedTheAnswer NotificationType = "notification.action.down_voted_answer"+ NotificationCommentQuestion NotificationType = "notification.action.comment_question"+ NotificationCommentAnswer NotificationType = "notification.action.comment_answer"+ NotificationUpVotedTheComment NotificationType = "notification.action.up_voted_comment"+ NotificationReplyToYou NotificationType = "notification.action.reply_to_you"+ NotificationMentionYou NotificationType = "notification.action.mention_you"+ NotificationYourQuestionIsClosed NotificationType = "notification.action.your_question_is_closed"+ NotificationYourQuestionWasDeleted NotificationType = "notification.action.your_question_was_deleted"+ NotificationYourAnswerWasDeleted NotificationType = "notification.action.your_answer_was_deleted"+ NotificationYourCommentWasDeleted NotificationType = "notification.action.your_comment_was_deleted"+ NotificationInvitedYouToAnswer NotificationType = "notification.action.invited_you_to_answer"+ NotificationNewQuestion NotificationType = "notification.action.new_question"+ NotificationNewQuestionFollowedTag NotificationType = "notification.action.new_question_followed_tag"+)++type Notification interface {+ Base++ // GetNewQuestionSubscribers returns the subscribers of the new question notification+ GetNewQuestionSubscribers() (userIDs []string)++ // Notify sends a notification to the user+ Notify(msg NotificationMessage)+}++type NotificationMessage struct {+ // the type of the notification+ Type NotificationType `json:"notification_type"`+ // the receiver user id+ ReceiverUserID string `json:"receiver_user_id"`+ // the receiver user using language+ ReceiverLang string `json:"receiver_lang"`+ // the receiver user external id (optional)+ ReceiverExternalID string `json:"receiver_external_id"`++ // Who triggered the notification (optional, admin or system operation will not have this field)+ TriggerUserID string `json:"trigger_user_id"`+ // The trigger user's display name (optional, admin or system operation will not have this field)+ TriggerUserDisplayName string `json:"trigger_user_display_name"`+ // The trigger user's url (optional, admin or system operation will not have this field)+ TriggerUserUrl string `json:"trigger_user_url"`++ // the question title+ QuestionTitle string `json:"question_title"`+ // the question url+ QuestionUrl string `json:"question_url"`+ // the question tags (comma separated, optional, only for new question notification)+ QuestionTags string `json:"tags"`++ // the answer url (optional, only for new answer notification)+ AnswerUrl string `json:"answer_url"`+ // the comment url (optional, only for new comment notification)+ CommentUrl string `json:"comment_url"`+}++var (+ // CallNotification is a function that calls all registered notification plugins+ CallNotification,+ registerNotification = MakePlugin[Notification](false)+)diff --git a/plugin/plugin.go b/plugin/plugin.goindex 1fec7842..79e43f68 100644--- a/plugin/plugin.go+++ b/plugin/plugin.go@@ -21,6 +21,7 @@ package pluginimport ("encoding/json"+ "github.com/segmentfault/pacman/i18n""github.com/apache/incubator-answer/internal/base/handler""github.com/apache/incubator-answer/internal/base/translator"@@ -48,6 +49,10 @@ func Register(p Base) {registerConfig(p.(Config))}+ if _, ok := p.(UserConfig); ok {+ registerUserConfig(p.(UserConfig))+ }+if _, ok := p.(Connector); ok {registerConnector(p.(Connector))}@@ -79,6 +84,10 @@ func Register(p Base) {if _, ok := p.(Search); ok {registerSearch(p.(Search))}++ if _, ok := p.(Notification); ok {+ registerNotification(p.(Notification))+ }}type Stack[T Base] struct {@@ -153,6 +162,11 @@ func Translate(ctx *GinContext, key string) string {return translator.Tr(handler.GetLang(ctx), key)}+// TranslateWithData translates the key to the language with data+func TranslateWithData(lang i18n.Language, key string, data any) string {+ return translator.TrWithData(lang, key, data)+}+// TranslateFn presents a generator of translated string.// We use it to delegate the translation work outside the plugin.type TranslateFn func(ctx *GinContext) stringdiff --git a/plugin/search.go b/plugin/search.goindex 20ff0f0a..719d4294 100644--- a/plugin/search.go+++ b/plugin/search.go@@ -56,7 +56,7 @@ type SearchBasicCond struct {// The keywords for search.Words []string// TagIDs is a list of tag IDs.- TagIDs []string+ TagIDs [][]string// The object's owner user ID.UserID string// The order of the search result.diff --git a/plugin/user_config.go b/plugin/user_config.gonew file mode 100644index 00000000..07070d84--- /dev/null+++ b/plugin/user_config.go@@ -0,0 +1,52 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package plugin++type UserConfig interface {+ Base++ // UserConfigFields returns the list of config fields+ UserConfigFields() []ConfigField+ // UserConfigReceiver receives the config data, it calls when the config is saved or initialized.+ // We recommend to unmarshal the data to a struct, and then use the struct to do something.+ // The config is encoded in JSON format.+ // It depends on the definition of ConfigFields.+ UserConfigReceiver(userID string, config []byte) error+}++var (+ // CallUserConfig is a function that calls all registered config plugins+ CallUserConfig,+ registerUserConfig = MakePlugin[UserConfig](false)+ getPluginUserConfigFn func(userID, pluginSlugName string) []byte+)++// GetPluginUserConfig returns the user config of the given user id+func GetPluginUserConfig(userID, pluginSlugName string) []byte {+ if getPluginUserConfigFn != nil {+ return getPluginUserConfigFn(userID, pluginSlugName)+ }+ return nil+}++// RegisterGetPluginUserConfigFunc registers a function to get the user config of the given user id+func RegisterGetPluginUserConfigFunc(fn func(userID, pluginSlugName string) []byte) {+ getPluginUserConfigFn = fn+}diff --git a/ui/.env.production b/ui/.env.productionindex e04b4d35..33d84710 100644--- a/ui/.env.production+++ b/ui/.env.production@@ -1,2 +1,4 @@+TSC_COMPILE_ON_ERROR=true+ESLINT_NO_DEV_ERRORS=truePUBLIC_URL = /REACT_APP_API_URL = /diff --git a/ui/.eslintrc.js b/ui/.eslintrc.jsindex 46c00687..1d905260 100644--- a/ui/.eslintrc.js+++ b/ui/.eslintrc.js@@ -109,5 +109,7 @@ module.exports = {'newlines-between': 'always',},],+ 'jsx-a11y/click-events-have-key-events': 'off',+ 'jsx-a11y/no-noninteractive-tabindex': 'off',},};diff --git a/ui/.prettierrc.json b/ui/.prettierrc.jsonindex bf0ed214..c707926a 100644--- a/ui/.prettierrc.json+++ b/ui/.prettierrc.json@@ -5,4 +5,4 @@"jsxBracketSameLine": true,"printWidth": 80,"endOfLine": "auto"-}\ No newline at end of file+}diff --git a/ui/package.json b/ui/package.jsonindex 1ad29594..ac7e4411 100644--- a/ui/package.json+++ b/ui/package.json@@ -16,7 +16,7 @@},"dependencies": {"axios": "^0.27.2",- "bootstrap": "^5.3.0",+ "bootstrap": "^5.3.2","bootstrap-icons": "^1.10.5","classnames": "^2.3.1","codemirror": "5.65.0",@@ -32,7 +32,7 @@"qrcode": "^1.5.1","qs": "^6.11.0","react": "^18.2.0",- "react-bootstrap": "^2.7.4",+ "react-bootstrap": "^2.10.0","react-dom": "^18.2.0","react-helmet-async": "^1.3.0","react-i18next": "^11.18.3",diff --git a/ui/pnpm-lock.yaml b/ui/pnpm-lock.yamlindex b1555ee7..77f3c9b1 100644--- a/ui/pnpm-lock.yaml+++ b/ui/pnpm-lock.yaml@@ -29,8 +29,8 @@ importers:specifier: ^0.27.2version: 0.27.2bootstrap:- specifier: ^5.3.0- version: 5.3.0(@popperjs/[email protected])+ specifier: ^5.3.2+ version: 5.3.2(@popperjs/[email protected])bootstrap-icons:specifier: ^1.10.5version: 1.10.5@@ -77,8 +77,8 @@ importers:specifier: ^18.2.0version: 18.2.0react-bootstrap:- specifier: ^2.7.4+ specifier: ^2.10.0react-dom:specifier: ^18.2.0version: 18.2.0([email protected])@@ -211,13 +211,13 @@ importers:version: 3.1.0purgecss-webpack-plugin:specifier: ^4.1.3- version: 4.1.3([email protected])+ version: 4.1.3([email protected])react-app-rewired:specifier: ^2.2.1version: 2.2.1([email protected])react-scripts:specifier: 5.0.1- version: 5.0.1(@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ version: 5.0.1(@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])sass:specifier: ^1.54.4version: 1.54.9@@ -342,6 +342,12 @@ packages:dependencies:'@babel/types': 7.19.0+ /@babel/[email protected]:+ resolution: {integrity: sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg==}+ engines: {node: '>=6.9.0'}+ dependencies:+ '@babel/types': 7.23.6+/@babel/[email protected]:resolution: {integrity: sha512-yFQ0YCHoIqarl8BCRwBL8ulYUaZpz3bNsA7oFepAzee+8/+ImtADXNOmO5vJvsPff3qi+hvpkY/NYBTrBQgdNw==}engines: {node: '>=6.9.0'}@@ -438,11 +444,11 @@ packages:dependencies:'@babel/types': 7.19.0- /@babel/[email protected]:- resolution: {integrity: sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==}+ /@babel/[email protected]:+ resolution: {integrity: sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==}engines: {node: '>=6.9.0'}dependencies:- '@babel/types': 7.21.4+ '@babel/types': 7.23.6/@babel/[email protected]:resolution: {integrity: sha512-3HBZ377Fe14RbLIA+ac3sY4PTgpxHVkFrESaWhoI5PuyXPBBX8+C34qblV9G89ZtycGJCmCI/Ut+VUDK4bltNQ==}@@ -469,8 +475,8 @@ packages:resolution: {integrity: sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw==}engines: {node: '>=6.9.0'}- /@babel/[email protected]:- resolution: {integrity: sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==}+ /@babel/[email protected]:+ resolution: {integrity: sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==}engines: {node: '>=6.9.0'}/@babel/[email protected](@babel/[email protected]):@@ -521,14 +527,18 @@ packages:resolution: {integrity: sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==}engines: {node: '>=6.9.0'}- /@babel/[email protected]:- resolution: {integrity: sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==}+ /@babel/[email protected]:+ resolution: {integrity: sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==}engines: {node: '>=6.9.0'}/@babel/[email protected]:resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==}engines: {node: '>=6.9.0'}+ /@babel/[email protected]:+ resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==}+ engines: {node: '>=6.9.0'}+/@babel/[email protected]:resolution: {integrity: sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==}engines: {node: '>=6.9.0'}@@ -840,14 +850,14 @@ packages:'@babel/core': 7.19.1'@babel/helper-plugin-utils': 7.19.0- /@babel/[email protected](@babel/[email protected]):- resolution: {integrity: sha512-l9xd3N+XG4fZRxEP3vXdK6RW7vN1Uf5dxzRC/09wV86wqZ/YYQooBIGNsiRdfNR3/q2/5pPzV4B54J/9ctX5jw==}+ /@babel/[email protected](@babel/[email protected]):+ resolution: {integrity: sha512-YZiAIpkJAwQXBJLIQbRFayR5c+gJ35Vcz3bg954k7cd73zqjvhacJuL9RbrzPz8qPmZdgqP6EUKwy0PCNhaaPA==}engines: {node: '>=6.9.0'}peerDependencies:'@babel/core': ^7.0.0-0dependencies:'@babel/core': 7.19.1- '@babel/helper-plugin-utils': 7.20.2+ '@babel/helper-plugin-utils': 7.22.5/@babel/[email protected](@babel/[email protected]):resolution: {integrity: sha512-/DU3RXad9+bZwrgWJQKbr39gYbJpLJHezqEzRzi/BHRlJ9zsQb4CK2CA/5apllXNomwA1qHwzvHl+AdEmC5krQ==}@@ -883,14 +893,14 @@ packages:'@babel/core': 7.19.1'@babel/helper-plugin-utils': 7.19.0- /@babel/[email protected](@babel/[email protected]):- resolution: {integrity: sha512-5hewiLct5OKyh6PLKEYaFclcqtIgCb6bmELouxjF6up5q3Sov7rOayW4RwhbaBL0dit8rA80GNfY+UuDp2mBbQ==}+ /@babel/[email protected](@babel/[email protected]):+ resolution: {integrity: sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg==}engines: {node: '>=6.9.0'}peerDependencies:'@babel/core': ^7.0.0-0dependencies:'@babel/core': 7.19.1- '@babel/helper-plugin-utils': 7.20.2+ '@babel/helper-plugin-utils': 7.22.5/@babel/[email protected](@babel/[email protected]):resolution: {integrity: sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==}@@ -1264,18 +1274,18 @@ packages:'@babel/plugin-syntax-jsx': 7.18.6(@babel/[email protected])'@babel/types': 7.19.0- /@babel/[email protected](@babel/[email protected]):- resolution: {integrity: sha512-6OAWljMvQrZjR2DaNhVfRz6dkCAVV+ymcLUmaf8bccGOHn2v5rHJK3tTpij0BuhdYWP4LLaqj5lwcdlpAAPuvg==}+ /@babel/[email protected](@babel/[email protected]):+ resolution: {integrity: sha512-5xOpoPguCZCRbo/JeHlloSkTA8Bld1J/E1/kLfD1nsuiW1m8tduTA1ERCgIZokDflX/IBzKcqR3l7VlRgiIfHA==}engines: {node: '>=6.9.0'}peerDependencies:'@babel/core': ^7.0.0-0dependencies:'@babel/core': 7.19.1- '@babel/helper-annotate-as-pure': 7.18.6- '@babel/helper-module-imports': 7.21.4- '@babel/helper-plugin-utils': 7.20.2- '@babel/plugin-syntax-jsx': 7.21.4(@babel/[email protected])- '@babel/types': 7.21.4+ '@babel/helper-annotate-as-pure': 7.22.5+ '@babel/helper-module-imports': 7.22.15+ '@babel/helper-plugin-utils': 7.22.5+ '@babel/plugin-syntax-jsx': 7.23.3(@babel/[email protected])+ '@babel/types': 7.23.6/@babel/[email protected](@babel/[email protected]):resolution: {integrity: sha512-I8VfEPg9r2TRDdvnHgPepTKvuRomzA8+u+nhY7qSI1fR2hRNebasZEETLyM5mAUr0Ku56OkXJ0I7NHJnO6cJiQ==}@@ -1530,17 +1540,17 @@ packages:dependencies:regenerator-runtime: 0.13.9- /@babel/[email protected]:- resolution: {integrity: sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==}+ /@babel/[email protected]:+ resolution: {integrity: sha512-mM8eg4yl5D6i3lu2QKPuPH4FArvJ8KhTofbE7jwMUv9KX5mBvwPAqnV3MlyBNqdp9RyRKP6Yck8TrfYrPvX3bg==}engines: {node: '>=6.9.0'}dependencies:- regenerator-runtime: 0.13.11+ regenerator-runtime: 0.14.1- /@babel/[email protected]:- resolution: {integrity: sha512-mM8eg4yl5D6i3lu2QKPuPH4FArvJ8KhTofbE7jwMUv9KX5mBvwPAqnV3MlyBNqdp9RyRKP6Yck8TrfYrPvX3bg==}+ /@babel/[email protected]:+ resolution: {integrity: sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==}engines: {node: '>=6.9.0'}dependencies:- regenerator-runtime: 0.14.0+ regenerator-runtime: 0.14.1/@babel/[email protected]:resolution: {integrity: sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==}@@ -1575,12 +1585,12 @@ packages:'@babel/helper-validator-identifier': 7.19.1to-fast-properties: 2.0.0- /@babel/[email protected]:- resolution: {integrity: sha512-rU2oY501qDxE8Pyo7i/Orqma4ziCOrby0/9mvbDUGEfvZjb279Nk9k19e2fiCxHbRRpY2ZyrgW1eq22mvmOIzA==}+ /@babel/[email protected]:+ resolution: {integrity: sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg==}engines: {node: '>=6.9.0'}dependencies:- '@babel/helper-string-parser': 7.19.4- '@babel/helper-validator-identifier': 7.19.1+ '@babel/helper-string-parser': 7.23.4+ '@babel/helper-validator-identifier': 7.22.20to-fast-properties: 2.0.0/@bcoe/[email protected]:@@ -2285,7 +2295,7 @@ packages:collect-v8-coverage: 1.0.1exit: 0.1.2glob: 7.2.3- graceful-fs: 4.2.11+ graceful-fs: 4.2.10istanbul-lib-coverage: 3.2.0istanbul-lib-instrument: 5.2.0istanbul-lib-report: 3.0.0@@ -2314,7 +2324,7 @@ packages:engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}dependencies:callsites: 3.1.0- graceful-fs: 4.2.11+ graceful-fs: 4.2.10source-map: 0.6.1/@jest/[email protected]:@@ -2340,7 +2350,7 @@ packages:engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}dependencies:'@jest/test-result': 27.5.1- graceful-fs: 4.2.11+ graceful-fs: 4.2.10jest-haste-map: 27.5.1jest-runtime: 27.5.1transitivePeerDependencies:@@ -2419,13 +2429,18 @@ packages:dependencies:'@jridgewell/set-array': 1.1.2'@jridgewell/sourcemap-codec': 1.4.15- '@jridgewell/trace-mapping': 0.3.18+ '@jridgewell/trace-mapping': 0.3.22dev: true/@jridgewell/[email protected]:resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==}engines: {node: '>=6.0.0'}+ /@jridgewell/[email protected]:+ resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==}+ engines: {node: '>=6.0.0'}+ dev: true+/@jridgewell/[email protected]:resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==}engines: {node: '>=6.0.0'}@@ -2436,11 +2451,11 @@ packages:'@jridgewell/gen-mapping': 0.3.2'@jridgewell/trace-mapping': 0.3.17- /@jridgewell/[email protected]:- resolution: {integrity: sha512-b+fsZXeLYi9fEULmfBrhxn4IrPlINf8fiNarzTof004v3lFdntdwa9PF7vFJqm3mg7s+ScJMxXaE3Acp1irZcg==}+ /@jridgewell/[email protected]:+ resolution: {integrity: sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==}dependencies:'@jridgewell/gen-mapping': 0.3.3- '@jridgewell/trace-mapping': 0.3.18+ '@jridgewell/trace-mapping': 0.3.22dev: true/@jridgewell/[email protected]:@@ -2462,11 +2477,11 @@ packages:'@jridgewell/resolve-uri': 3.1.0'@jridgewell/sourcemap-codec': 1.4.14- /@jridgewell/[email protected]:- resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==}+ /@jridgewell/[email protected]:+ resolution: {integrity: sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==}dependencies:- '@jridgewell/resolve-uri': 3.1.0- '@jridgewell/sourcemap-codec': 1.4.14+ '@jridgewell/resolve-uri': 3.1.1+ '@jridgewell/sourcemap-codec': 1.4.15dev: true/@jridgewell/[email protected]:@@ -2556,12 +2571,13 @@ packages:resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==}dev: false- /@react-aria/[email protected]([email protected]):- resolution: {integrity: sha512-OFiYQdv+Yk7AO7IsQu/fAEPijbeTwrrEYvdNoJ3sblBBedD5j5fBTNWrUPNVlwC4XWWnWTCMaRIVsJujsFiWXg==}+ /@react-aria/[email protected]([email protected]):+ resolution: {integrity: sha512-NqzkLFP8ZVI4GSorS0AYljC13QW2sc8bDqJOkBvkAt3M8gbcAXJWVRGtZBCRscki9RZF+rNlnPdg0G0jYkhJcg==}+ engines: {node: '>= 12'}peerDependencies:react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0dependencies:- '@swc/helpers': 0.4.14+ '@swc/helpers': 0.5.3react: 18.2.0dev: false@@ -2570,8 +2586,8 @@ packages:engines: {node: '>=14'}dev: false- /@restart/[email protected]([email protected]):- resolution: {integrity: sha512-3BekqcwB6Umeya+16XPooARn4qEPW6vNvwYnlofIYe6h9qG1/VeD7UvShCWx11eFz5ELYmwIEshz+MkPX3wjcQ==}+ /@restart/[email protected]([email protected]):+ resolution: {integrity: sha512-cZFXYTxbpzYcieq/mBwSyXgqnGMHoBVh3J7MU0CCoIB4NRZxV9/TuwTBAaLMqpNhC3zTPMCgkQ5Ey07L02Xmcw==}peerDependencies:react: '>=16.8.0'dependencies:@@ -2585,16 +2601,16 @@ packages:react: '>=16.14.0'react-dom: '>=16.14.0'dependencies:- '@babel/runtime': 7.22.5+ '@babel/runtime': 7.23.8'@popperjs/core': 2.11.8- '@react-aria/ssr': 3.6.0([email protected])- '@restart/hooks': 0.4.9([email protected])- '@types/warning': 3.0.0+ '@react-aria/ssr': 3.9.1([email protected])+ '@restart/hooks': 0.4.15([email protected])+ '@types/warning': 3.0.3dequal: 2.0.3dom-helpers: 5.2.1react: 18.2.0react-dom: 18.2.0([email protected])- uncontrollable: 8.0.2([email protected])+ uncontrollable: 8.0.4([email protected])warning: 4.0.3dev: false@@ -2880,10 +2896,10 @@ packages:resolution: {integrity: sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw==}dev: true- /@swc/[email protected]:- resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==}+ /@swc/[email protected]:+ resolution: {integrity: sha512-FaruWX6KdudYloq1AHD/4nU+UsMTdNE8CKyrseXWEcgjDAbvkwJg2QGPAnfIJLIWsjZOSPLOAykK6fuYp4vp4A==}dependencies:- tslib: 2.4.0+ tslib: 2.6.2dev: false/@swc/[email protected]:@@ -3042,12 +3058,26 @@ packages:'@types/eslint': 8.4.6'@types/estree': 0.0.51+ /@types/[email protected]:+ resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==}+ dependencies:+ '@types/eslint': 8.56.2+ '@types/estree': 1.0.5+ dev: true+/@types/[email protected]:resolution: {integrity: sha512-/fqTbjxyFUaYNO7VcW5g+4npmqVACz1bB7RTHYuLj+PRjw9hrCwrUXVQFpChUS0JsyEFvMZ7U/PfmvWgxJhI9g==}dependencies:'@types/estree': 1.0.0'@types/json-schema': 7.0.13+ /@types/[email protected]:+ resolution: {integrity: sha512-uQDwm1wFHmbBbCZCqAlq6Do9LYwByNZHWzXppSnay9SuwJ+VRbjkbLABer54kcPnMSlG6Fdiy2yaFXm/z9Z5gw==}+ dependencies:+ '@types/estree': 1.0.5+ '@types/json-schema': 7.0.15+ dev: true+/@types/[email protected]:resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==}@@ -3057,8 +3087,8 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==}- /@types/[email protected]:- resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==}+ /@types/[email protected]:+ resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}dev: true/@types/[email protected]:@@ -3119,6 +3149,10 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-RbSSoHliUbnXj3ny0CNFOoxrIDV6SUGyStHsvDqosw6CkdPV8TtWGlfecuK4ToyMEAql6pzNxgCFKanovUzlgQ==}+ /@types/[email protected]:+ resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}+ dev: true+/@types/[email protected]:resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==}@@ -3172,10 +3206,10 @@ packages:'@types/react': 18.0.20dev: true- /@types/[email protected]:- resolution: {integrity: sha512-VnCdSxfcm08KjsJVQcfBmhEQAPnLB8G08hAxn39azX1qYBQ/5RVQuoHuKIcfKOdncuaUvEpFKFzEvbtIMsfVew==}+ /@types/[email protected]:+ resolution: {integrity: sha512-hT/+s0VQs2ojCX823m60m5f0sL5idt9SO6Tj6Dg+rdphGPIeJbJ6CxvBYkgkGKrYeDjvIpKTR38UzmtHJOGW3Q==}dependencies:- '@types/react': 18.2.22+ '@types/react': 18.0.20dev: false/@types/[email protected]:@@ -3185,14 +3219,6 @@ packages:'@types/scheduler': 0.16.2csstype: 3.1.1- /@types/[email protected]:- resolution: {integrity: sha512-60fLTOLqzarLED2O3UQImc/lsNRgG0jE/a1mPW9KjMemY0LMITWEsbS4VvZ4p6rorEHd5YKxxmMKSDK505GHpA==}- dependencies:- '@types/prop-types': 15.7.5- '@types/scheduler': 0.16.2- csstype: 3.1.1- dev: false-/@types/[email protected]:resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==}dependencies:@@ -3230,8 +3256,8 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==}- /@types/[email protected]:- resolution: {integrity: sha512-t/Tvs5qR47OLOr+4E9ckN8AmP2Tf16gWq+/qA4iUGS/OOyHVO8wv2vjJuX8SNOUTJyWb+2t7wJm6cXILFnOROA==}+ /@types/[email protected]:+ resolution: {integrity: sha512-D1XC7WK8K+zZEveUPY+cf4+kgauk8N4eHr/XIHXGlGYkHLud6hK9lYfZk1ry1TNh798cZUCgb6MqGEG8DkJt6Q==}dev: false/@types/[email protected]:@@ -3649,32 +3675,32 @@ packages:'@webassemblyjs/helper-numbers': 1.11.1'@webassemblyjs/helper-wasm-bytecode': 1.11.1- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-LHY/GSAZZRpsNQH+/oHqhRQ5FT7eoULcBqgfyTB5nQHogFnK3/7QoN7dLnwSE/JkUAF0SrRuclT7ODqMFtWxxQ==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==}dependencies:- '@webassemblyjs/helper-numbers': 1.11.5- '@webassemblyjs/helper-wasm-bytecode': 1.11.5+ '@webassemblyjs/helper-numbers': 1.11.6+ '@webassemblyjs/helper-wasm-bytecode': 1.11.6dev: true/@webassemblyjs/[email protected]:resolution: {integrity: sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==}- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-1j1zTIC5EZOtCplMBG/IEwLtUojtwFVwdyVMbL/hwWqbzlQoJsWCOavrdnLkemwNoC/EOwtUFch3fuo+cbcXYQ==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==}dev: true/@webassemblyjs/[email protected]:resolution: {integrity: sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==}- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-L65bDPmfpY0+yFrsgz8b6LhXmbbs38OnwDCf6NpnMUYqa+ENfE5Dq9E42ny0qz/PdR0LJyq/T5YijPnU8AXEpA==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==}dev: true/@webassemblyjs/[email protected]:resolution: {integrity: sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==}- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-fDKo1gstwFFSfacIeH5KfwzjykIE6ldh1iH9Y/8YkAZrhmu4TctqYjSh7t0K2VyDSXOZJ1MLhht/k9IvYGcIxg==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==}dev: true/@webassemblyjs/[email protected]:@@ -3684,19 +3710,19 @@ packages:'@webassemblyjs/helper-api-error': 1.11.1'@xtuc/long': 4.2.2- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-DhykHXM0ZABqfIGYNv93A5KKDw/+ywBFnuWybZZWcuzWHfbp21wUfRkbtz7dMGwGgT4iXjWuhRMA2Mzod6W4WA==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==}dependencies:- '@webassemblyjs/floating-point-hex-parser': 1.11.5- '@webassemblyjs/helper-api-error': 1.11.5+ '@webassemblyjs/floating-point-hex-parser': 1.11.6+ '@webassemblyjs/helper-api-error': 1.11.6'@xtuc/long': 4.2.2dev: true/@webassemblyjs/[email protected]:resolution: {integrity: sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==}- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-oC4Qa0bNcqnjAowFn7MPCETQgDYytpsfvz4ujZz63Zu/a/v71HeCAAmZsgZ3YVKec3zSPYytG3/PrRCqbtcAvA==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==}dev: true/@webassemblyjs/[email protected]:@@ -3707,13 +3733,13 @@ packages:'@webassemblyjs/helper-wasm-bytecode': 1.11.1'@webassemblyjs/wasm-gen': 1.11.1- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-uEoThA1LN2NA+K3B9wDo3yKlBfVtC6rh0i4/6hvbz071E8gTNZD/pT0MsBf7MeD6KbApMSkaAK0XeKyOZC7CIA==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==}dependencies:- '@webassemblyjs/ast': 1.11.5- '@webassemblyjs/helper-buffer': 1.11.5- '@webassemblyjs/helper-wasm-bytecode': 1.11.5- '@webassemblyjs/wasm-gen': 1.11.5+ '@webassemblyjs/ast': 1.11.6+ '@webassemblyjs/helper-buffer': 1.11.6+ '@webassemblyjs/helper-wasm-bytecode': 1.11.6+ '@webassemblyjs/wasm-gen': 1.11.6dev: true/@webassemblyjs/[email protected]:@@ -3721,8 +3747,8 @@ packages:dependencies:'@xtuc/ieee754': 1.2.0- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-37aGq6qVL8A8oPbPrSGMBcp38YZFXcHfiROflJn9jxSdSMMM5dS5P/9e2/TpaJuhE+wFrbukN2WI6Hw9MH5acg==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==}dependencies:'@xtuc/ieee754': 1.2.0dev: true@@ -3732,8 +3758,8 @@ packages:dependencies:'@xtuc/long': 4.2.2- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-ajqrRSXaTJoPW+xmkfYN6l8VIeNnR4vBOTQO9HzR7IygoCcKWkICbKFbVTNMjMgMREqXEr0+2M6zukzM47ZUfQ==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==}dependencies:'@xtuc/long': 4.2.2dev: true@@ -3741,8 +3767,8 @@ packages:/@webassemblyjs/[email protected]:resolution: {integrity: sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==}- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-WiOhulHKTZU5UPlRl53gHR8OxdGsSOxqfpqWeA2FmcwBMaoEdz6b2x2si3IwC9/fSPLfe8pBMRTHVMk5nlwnFQ==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==}dev: true/@webassemblyjs/[email protected]:@@ -3757,17 +3783,17 @@ packages:'@webassemblyjs/wasm-parser': 1.11.1'@webassemblyjs/wast-printer': 1.11.1- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-C0p9D2fAu3Twwqvygvf42iGCQ4av8MFBLiTb+08SZ4cEdwzWx9QeAHDo1E2k+9s/0w1DM40oflJOpkZ8jW4HCQ==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==}dependencies:- '@webassemblyjs/ast': 1.11.5- '@webassemblyjs/helper-buffer': 1.11.5- '@webassemblyjs/helper-wasm-bytecode': 1.11.5- '@webassemblyjs/helper-wasm-section': 1.11.5- '@webassemblyjs/wasm-gen': 1.11.5- '@webassemblyjs/wasm-opt': 1.11.5- '@webassemblyjs/wasm-parser': 1.11.5- '@webassemblyjs/wast-printer': 1.11.5+ '@webassemblyjs/ast': 1.11.6+ '@webassemblyjs/helper-buffer': 1.11.6+ '@webassemblyjs/helper-wasm-bytecode': 1.11.6+ '@webassemblyjs/helper-wasm-section': 1.11.6+ '@webassemblyjs/wasm-gen': 1.11.6+ '@webassemblyjs/wasm-opt': 1.11.6+ '@webassemblyjs/wasm-parser': 1.11.6+ '@webassemblyjs/wast-printer': 1.11.6dev: true/@webassemblyjs/[email protected]:@@ -3779,14 +3805,14 @@ packages:'@webassemblyjs/leb128': 1.11.1'@webassemblyjs/utf8': 1.11.1- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-14vteRlRjxLK9eSyYFvw1K8Vv+iPdZU0Aebk3j6oB8TQiQYuO6hj9s4d7qf6f2HJr2khzvNldAFG13CgdkAIfA==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==}dependencies:- '@webassemblyjs/ast': 1.11.5- '@webassemblyjs/helper-wasm-bytecode': 1.11.5- '@webassemblyjs/ieee754': 1.11.5- '@webassemblyjs/leb128': 1.11.5- '@webassemblyjs/utf8': 1.11.5+ '@webassemblyjs/ast': 1.11.6+ '@webassemblyjs/helper-wasm-bytecode': 1.11.6+ '@webassemblyjs/ieee754': 1.11.6+ '@webassemblyjs/leb128': 1.11.6+ '@webassemblyjs/utf8': 1.11.6dev: true/@webassemblyjs/[email protected]:@@ -3797,13 +3823,13 @@ packages:'@webassemblyjs/wasm-gen': 1.11.1'@webassemblyjs/wasm-parser': 1.11.1- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-tcKwlIXstBQgbKy1MlbDMlXaxpucn42eb17H29rawYLxm5+MsEmgPzeCP8B1Cl69hCice8LeKgZpRUAPtqYPgw==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==}dependencies:- '@webassemblyjs/ast': 1.11.5- '@webassemblyjs/helper-buffer': 1.11.5- '@webassemblyjs/wasm-gen': 1.11.5- '@webassemblyjs/wasm-parser': 1.11.5+ '@webassemblyjs/ast': 1.11.6+ '@webassemblyjs/helper-buffer': 1.11.6+ '@webassemblyjs/wasm-gen': 1.11.6+ '@webassemblyjs/wasm-parser': 1.11.6dev: true/@webassemblyjs/[email protected]:@@ -3816,15 +3842,15 @@ packages:'@webassemblyjs/leb128': 1.11.1'@webassemblyjs/utf8': 1.11.1- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-SVXUIwsLQlc8srSD7jejsfTU83g7pIGr2YYNb9oHdtldSxaOhvA5xwvIiWIfcX8PlSakgqMXsLpLfbbJ4cBYew==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==}dependencies:- '@webassemblyjs/ast': 1.11.5- '@webassemblyjs/helper-api-error': 1.11.5- '@webassemblyjs/helper-wasm-bytecode': 1.11.5- '@webassemblyjs/ieee754': 1.11.5- '@webassemblyjs/leb128': 1.11.5- '@webassemblyjs/utf8': 1.11.5+ '@webassemblyjs/ast': 1.11.6+ '@webassemblyjs/helper-api-error': 1.11.6+ '@webassemblyjs/helper-wasm-bytecode': 1.11.6+ '@webassemblyjs/ieee754': 1.11.6+ '@webassemblyjs/leb128': 1.11.6+ '@webassemblyjs/utf8': 1.11.6dev: true/@webassemblyjs/[email protected]:@@ -3833,10 +3859,10 @@ packages:'@webassemblyjs/ast': 1.11.1'@xtuc/long': 4.2.2- /@webassemblyjs/[email protected]:- resolution: {integrity: sha512-f7Pq3wvg3GSPUPzR0F6bmI89Hdb+u9WXrSKc4v+N0aV0q6r42WoF92Jp2jEorBEBRoRNXgjp53nBniDXcqZYPA==}+ /@webassemblyjs/[email protected]:+ resolution: {integrity: sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==}dependencies:- '@webassemblyjs/ast': 1.11.5+ '@webassemblyjs/ast': 1.11.6'@xtuc/long': 4.2.2dev: true@@ -3870,20 +3896,20 @@ packages:acorn: 7.4.1acorn-walk: 7.2.0resolution: {integrity: sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==}peerDependencies:acorn: ^8dependencies:- acorn: 8.10.0- dev: true+ acorn: 8.8.0- resolution: {integrity: sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==}+ resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==}peerDependencies:acorn: ^8dependencies:- acorn: 8.8.0+ acorn: 8.11.3+ dev: trueresolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}@@ -3917,6 +3943,12 @@ packages:engines: {node: '>=0.4.0'}hasBin: true+ resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==}+ engines: {node: '>=0.4.0'}+ hasBin: true+ dev: true+resolution: {integrity: sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==}engines: {node: '>=0.4.0'}@@ -4294,7 +4326,7 @@ packages:resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}engines: {node: '>=10', npm: '>=6'}dependencies:- '@babel/runtime': 7.22.5+ '@babel/runtime': 7.23.8cosmiconfig: 7.0.1resolve: 1.22.1@@ -4387,7 +4419,7 @@ packages:'@babel/preset-env': 7.19.1(@babel/[email protected])'@babel/preset-react': 7.18.6(@babel/[email protected])'@babel/preset-typescript': 7.18.6(@babel/[email protected])- '@babel/runtime': 7.19.0+ '@babel/runtime': 7.23.8babel-plugin-macros: 3.1.0babel-plugin-transform-react-remove-prop-types: 0.4.24transitivePeerDependencies:@@ -4457,10 +4489,10 @@ packages:resolution: {integrity: sha512-oSX26F37V7QV7NCE53PPEL45d7EGXmBgHG3pDpZvcRaKVzWMqIRL9wcqJUyEha1esFtM3NJzvmxFXDxjJYD0jQ==}dev: false- /[email protected](@popperjs/[email protected]):- resolution: {integrity: sha512-UnBV3E3v4STVNQdms6jSGO2CvOkjUMdDAVR2V5N4uCMdaIkaQjbcEAMqRimDHIs4uqBYzDAKCQwCB+97tJgHQw==}+ /[email protected](@popperjs/[email protected]):+ resolution: {integrity: sha512-D32nmNWiQHo94BKHLmOrdjlL05q1c8oxbtBphQFb9Z5to6eGRDCm0QgeaZ4zFBHzfg2++rqa2JkqCcxDy0sH0g==}peerDependencies:- '@popperjs/core': ^2.11.7+ '@popperjs/core': ^2.11.8dependencies:'@popperjs/core': 2.11.8dev: false@@ -4502,15 +4534,15 @@ packages:node-releases: 2.0.6update-browserslist-db: 1.0.9([email protected])- resolution: {integrity: sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==}+ resolution: {integrity: sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==}engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}hasBin: truedependencies:- caniuse-lite: 1.0.30001481- electron-to-chromium: 1.4.369- node-releases: 2.0.10- update-browserslist-db: 1.0.11([email protected])+ caniuse-lite: 1.0.30001579+ electron-to-chromium: 1.4.640+ node-releases: 2.0.14+ update-browserslist-db: 1.0.13([email protected])dev: true@@ -4567,7 +4599,7 @@ packages:resolution: {integrity: sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==}dependencies:pascal-case: 3.1.2- tslib: 2.4.0+ tslib: 2.6.2resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==}@@ -4601,8 +4633,8 @@ packages:resolution: {integrity: sha512-DdUCktgMSM+1ndk9EFMZcavsGszV7zxV9O7MtOHniTa/iyAIwJCF0dFVBdU9SijJbfh29hC9bCs07wu8pjnGJQ==}- resolution: {integrity: sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==}+ resolution: {integrity: sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==}dev: true@@ -4656,7 +4688,7 @@ packages:normalize-path: 3.0.0readdirp: 3.6.0optionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3resolution: {integrity: sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==}@@ -5198,6 +5230,10 @@ packages:resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==}+ resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}+ dev: false+resolution: {integrity: sha512-DbtaLuy59224U+xCiukkxSq8clq++MOtJ1Et7LED1fLszWe88EoblEYFBJ895sB1mC6B4uu3xPT/IjClELhMbA==}dependencies:@@ -5748,8 +5784,8 @@ packages:resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==}dependencies:- '@babel/runtime': 7.22.5- csstype: 3.1.1+ '@babel/runtime': 7.23.8+ csstype: 3.1.3dev: false@@ -5804,7 +5840,7 @@ packages:resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==}dependencies:no-case: 3.0.4- tslib: 2.4.0+ tslib: 2.6.2resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==}@@ -5840,8 +5876,8 @@ packages:resolution: {integrity: sha512-x+JnqyluoJv8I0U9gVe+Sk2st8vF0CzMt78SXxuoWCooLLY2k5VerIBdpvG7ql6GKI4dzNnPjmqgDJ76EdaAKw==}- resolution: {integrity: sha512-LfxbHXdA/S+qyoTEA4EbhxGjrxx7WK2h6yb5K2v0UCOufUKX+VZaHbl3svlzZfv9sGseym/g3Ne4DpsgRULmqg==}+ resolution: {integrity: sha512-z/6oZ/Muqk4BaE7P69bXhUhpJbUM9ZJeka43ZwxsDshKtePns4mhBlh8bU5+yrnOnz3fhG82XLzGUXazOmsWnA==}dev: true@@ -5878,11 +5914,11 @@ packages:resolution: {integrity: sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==}engines: {node: '>=10.13.0'}dependencies:- graceful-fs: 4.2.11+ graceful-fs: 4.2.10tapable: 2.2.1- resolution: {integrity: sha512-eyV8f0y1+bzyfh8xAwW/WTSZpLbjhqc4ne9eGSH4Zo2ejdyiNG9pU6mf9DG8a7+Auk6MFTlNOT4Y2y/9k8GKVg==}+ resolution: {integrity: sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==}engines: {node: '>=10.13.0'}dependencies:graceful-fs: 4.2.11@@ -5998,8 +6034,8 @@ packages:resolution: {integrity: sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==}- resolution: {integrity: sha512-9978wrXM50Y4rTMmW5kXIC09ZdXQZqkE4mxhwkd8VbzsGkXGPgV4zWuqQJgCEzYngdo2dYDa0l8xhX4fkSwJSg==}+ resolution: {integrity: sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w==}dev: true@@ -6143,7 +6179,7 @@ packages:eslint: 8.53.0dev: true- /[email protected](@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected]):+ /[email protected](@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected]):resolution: {integrity: sha512-K6rNzvkIeHaTd8m/QEh1Zko0KI7BACWkkneSs6s9cKZC/J27X3eZR6Upt1jkmZ/4FK+XUOPPxMEN7+lbUXfSlA==}engines: {node: '>=14.0.0'}peerDependencies:@@ -6161,7 +6197,7 @@ packages:babel-preset-react-app: 10.0.1confusing-browser-globals: 1.0.11eslint: 8.53.0- eslint-plugin-flowtype: 8.0.3(@babel/[email protected])(@babel/[email protected])([email protected])+ eslint-plugin-flowtype: 8.0.3(@babel/[email protected])(@babel/[email protected])([email protected])eslint-plugin-import: 2.26.0(@typescript-eslint/[email protected])([email protected])eslint-plugin-jest: 25.7.0(@typescript-eslint/[email protected])([email protected])([email protected])([email protected])eslint-plugin-jsx-a11y: 6.8.0([email protected])@@ -6290,7 +6326,7 @@ packages:regexpp: 3.2.0dev: trueresolution: {integrity: sha512-dX8l6qUL6O+fYPtpNRideCFSpmWOUVx5QcaGLVqe/vlDiBSe4vYljDWDETwnyFzpl7By/WVIu6rcrniCgH9BqQ==}engines: {node: '>=12.0.0'}peerDependencies:@@ -6298,8 +6334,8 @@ packages:'@babel/plugin-transform-react-jsx': ^7.14.9eslint: ^8.1.0dependencies:- '@babel/plugin-syntax-flow': 7.21.4(@babel/[email protected])- '@babel/plugin-transform-react-jsx': 7.21.0(@babel/[email protected])+ '@babel/plugin-syntax-flow': 7.23.3(@babel/[email protected])+ '@babel/plugin-transform-react-jsx': 7.23.4(@babel/[email protected])eslint: 8.53.0lodash: 4.17.21string-natural-compare: 3.0.1@@ -6976,8 +7012,8 @@ packages:resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}- resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}+ resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}os: [darwin]requiresBuild: true@@ -7894,7 +7930,7 @@ packages:ci-info: 3.4.0deepmerge: 4.2.2glob: 7.2.3- graceful-fs: 4.2.11+ graceful-fs: 4.2.10jest-circus: 27.5.1jest-environment-jsdom: 27.5.1jest-environment-node: 27.5.1@@ -8006,7 +8042,7 @@ packages:micromatch: 4.0.5walker: 1.0.8optionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3resolution: {integrity: sha512-jtq7VVyG8SqAorDpApwiJJImd0V2wv1xzdheGHRGyuT7gZm6gG47QEskOlzsN1PG/6WNaCo5pmwMHDf3AkG2pQ==}@@ -8066,7 +8102,7 @@ packages:'@jest/types': 27.5.1'@types/stack-utils': 2.0.1chalk: 4.1.2- graceful-fs: 4.2.11+ graceful-fs: 4.2.10micromatch: 4.0.5pretty-format: 27.5.1slash: 3.0.0@@ -8149,7 +8185,7 @@ packages:'@types/node': 16.11.59chalk: 4.1.2emittery: 0.8.1- graceful-fs: 4.2.11+ graceful-fs: 4.2.10jest-docblock: 27.5.1jest-environment-jsdom: 27.5.1jest-environment-node: 27.5.1@@ -8184,7 +8220,7 @@ packages:collect-v8-coverage: 1.0.1execa: 5.1.1glob: 7.2.3- graceful-fs: 4.2.11+ graceful-fs: 4.2.10jest-haste-map: 27.5.1jest-message-util: 27.5.1jest-mock: 27.5.1@@ -8202,7 +8238,7 @@ packages:engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}dependencies:'@types/node': 16.11.59- graceful-fs: 4.2.11+ graceful-fs: 4.2.10resolution: {integrity: sha512-yYykXI5a0I31xX67mgeLw1DZ0bJB+gpq5IpSuCAoyDi0+BhgU/RIrL+RTzDmkNTchvDFWKP8lp+w/42Z3us5sA==}@@ -8220,7 +8256,7 @@ packages:babel-preset-current-node-syntax: 1.0.1(@babel/[email protected])chalk: 4.1.2expect: 27.5.1- graceful-fs: 4.2.11+ graceful-fs: 4.2.10jest-diff: 27.5.1jest-get-type: 27.5.1jest-haste-map: 27.5.1@@ -8447,7 +8483,7 @@ packages:dependencies:universalify: 2.0.0optionalDependencies:- graceful-fs: 4.2.11+ graceful-fs: 4.2.10resolution: {integrity: sha512-pfog5gdDxPdV4eP7Kg87M8/bHgshlZ5pybl+yKxAnCZ5O7lCIn7Ixydj03wOlnDQesky2BPyA91SQ+5Y/mNwzw==}@@ -8663,7 +8699,7 @@ packages:resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==}dependencies:- tslib: 2.4.0+ tslib: 2.6.2resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}@@ -8917,7 +8953,7 @@ packages:jsonp: 0.2.1react: 18.2.0react-dom: 18.2.0([email protected])- react-scripts: 5.0.1(@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ react-scripts: 5.0.1(@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])transitivePeerDependencies:- supports-colordev: false@@ -8926,7 +8962,7 @@ packages:resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==}dependencies:lower-case: 2.0.2- tslib: 2.4.0+ tslib: 2.6.2resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==}@@ -8935,8 +8971,8 @@ packages:resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==}- resolution: {integrity: sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w==}+ resolution: {integrity: sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==}dev: true@@ -9202,7 +9238,7 @@ packages:resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==}dependencies:dot-case: 3.0.4- tslib: 2.4.0+ tslib: 2.6.2resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}@@ -9230,7 +9266,7 @@ packages:resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==}dependencies:no-case: 3.0.4- tslib: 2.4.0+ tslib: 2.6.2resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==}@@ -10122,13 +10158,13 @@ packages:resolution: {integrity: sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==}engines: {node: '>=6'}resolution: {integrity: sha512-1OHS0WE935w66FjaFSlV06ycmn3/A8a6Q+iVUmmCYAujQ1HPdX+psMXUhASEW0uF1PYEpOlhMc5ApigVqYK08g==}peerDependencies:webpack: '*'dependencies:purgecss: 4.1.3- webpack: 5.80.0+ webpack: 5.89.0webpack-sources: 3.2.3dev: true@@ -10216,7 +10252,7 @@ packages:object-assign: 4.1.1promise: 8.2.0raf: 3.4.1- regenerator-runtime: 0.13.9+ regenerator-runtime: 0.13.11whatwg-fetch: 3.6.2@@ -10225,12 +10261,12 @@ packages:peerDependencies:react-scripts: '>=2.1.3'dependencies:- react-scripts: 5.0.1(@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ react-scripts: 5.0.1(@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])semver: 5.7.1dev: true- resolution: {integrity: sha512-EPKPwhfbxsKsNBhJBitJwqul9fvmlYWSft6jWE2EpqhEyjhqIqNihvQo2onE5XtS+QHOavUSNmA+8Lnv5YeAyg==}+ resolution: {integrity: sha512-87gRP69VAfeU2yKgp8RI3HvzhPNrnYIV2QNranYXataz3ef+k7OhvKGGdxQLQfUsQ2RTmlY66tn4pdFrZ94hNg==}peerDependencies:'@types/react': '>=16.14.8'react: '>=16.14.0'@@ -10239,11 +10275,11 @@ packages:'@types/react':optional: truedependencies:- '@babel/runtime': 7.22.5- '@restart/hooks': 0.4.9([email protected])+ '@babel/runtime': 7.23.8+ '@restart/hooks': 0.4.15([email protected])'@restart/ui': 1.6.6([email protected])([email protected])'@types/react': 18.0.20- '@types/react-transition-group': 4.4.6+ '@types/react-transition-group': 4.4.10classnames: 2.3.2dom-helpers: 5.2.1invariant: 2.2.4@@ -10388,7 +10424,7 @@ packages:react: 18.2.0dev: false- /[email protected](@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]):+ /[email protected](@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]):resolution: {integrity: sha512-8VAmEm/ZAwQzJ+GOMLbBsTdDKOpuZh7RPs0UymvBR2vRk4iZWCskjbFnxqjrzoIvlNNRZ3QJFx6/qDSi6zSnaQ==}engines: {node: '>=14.0.0'}hasBin: true@@ -10416,7 +10452,7 @@ packages:dotenv: 10.0.0dotenv-expand: 5.1.0eslint: 8.53.0- eslint-config-react-app: 7.0.1(@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])+ eslint-config-react-app: 7.0.1(@babel/[email protected])(@babel/[email protected])([email protected])([email protected])([email protected])eslint-webpack-plugin: 3.2.0([email protected])([email protected])file-loader: 6.2.0([email protected])fs-extra: 10.1.0@@ -10450,7 +10486,7 @@ packages:webpack-manifest-plugin: 4.1.1([email protected])workbox-webpack-plugin: 6.5.4([email protected])optionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3transitivePeerDependencies:- '@babel/plugin-syntax-flow'- '@babel/plugin-transform-react-jsx'@@ -10490,7 +10526,7 @@ packages:react: '>=16.6.0'react-dom: '>=16.6.0'dependencies:- '@babel/runtime': 7.22.5+ '@babel/runtime': 7.23.8dom-helpers: 5.2.1loose-envify: 1.4.0prop-types: 15.8.1@@ -10593,13 +10629,13 @@ packages:resolution: {integrity: sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==}- resolution: {integrity: sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==}+ resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==}resolution: {integrity: sha512-LsrGtPmbYg19bcPHwdtmXwbW+TqNvtY4riE3P83foeHRroMbH6/2ddFBfab3t7kbzc7v7p4wbkIecHImqt0QNg==}dependencies:- '@babel/runtime': 7.22.5+ '@babel/runtime': 7.23.8resolution: {integrity: sha512-jbD/FT0+9MBU2XAZluI7w2OBs1RBi6p9M83nkoZayQXXU9e8Robt69FcZc7wU4eJD/YFTjn1JdCk3rbMJajz8Q==}@@ -10782,14 +10818,14 @@ packages:engines: {node: '>=10.0.0'}hasBin: trueoptionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==}engines: {node: '>=14.18.0', npm: '>=8.0.0'}hasBin: trueoptionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3dev: true@@ -10907,11 +10943,11 @@ packages:ajv: 6.12.6ajv-keywords: 3.5.2([email protected])- resolution: {integrity: sha512-pvjEHOgWc9OWA/f/DE3ohBWTD6EleVLf7iFUkoSwAxttdBhB9QUebQgxER2kWueOvRJXPHNnyrvvh9eZINB8Eg==}+ resolution: {integrity: sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==}engines: {node: '>= 10.13.0'}dependencies:- '@types/json-schema': 7.0.13+ '@types/json-schema': 7.0.15ajv: 6.12.6ajv-keywords: 3.5.2([email protected])dev: true@@ -10995,8 +11031,8 @@ packages:dependencies:randombytes: 2.1.0- resolution: {integrity: sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==}+ resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==}dependencies:randombytes: 2.1.0dev: true@@ -11573,8 +11609,8 @@ packages:ansi-escapes: 4.3.2supports-hyperlinks: 2.3.0- resolution: {integrity: sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==}+ resolution: {integrity: sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==}engines: {node: '>= 10.13.0'}peerDependencies:'@swc/core': '*'@@ -11589,15 +11625,16 @@ packages:uglify-js:optional: truedependencies:- '@jridgewell/trace-mapping': 0.3.15+ '@jridgewell/trace-mapping': 0.3.22jest-worker: 27.5.1- schema-utils: 3.1.1- serialize-javascript: 6.0.0- terser: 5.15.0- webpack: 5.74.0+ schema-utils: 3.3.0+ serialize-javascript: 6.0.2+ terser: 5.27.0+ webpack: 5.89.0+ dev: true- resolution: {integrity: sha512-AfKwIktyP7Cu50xNjXF/6Qb5lBNzYaWpU6YfoX3uZicTx0zTy0stDDCsvjDapKsSDvOeWo5MEq4TmdBy2cNoHw==}+ resolution: {integrity: sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==}engines: {node: '>= 10.13.0'}peerDependencies:'@swc/core': '*'@@ -11612,13 +11649,12 @@ packages:uglify-js:optional: truedependencies:- '@jridgewell/trace-mapping': 0.3.18+ '@jridgewell/trace-mapping': 0.3.15jest-worker: 27.5.1- schema-utils: 3.1.2- serialize-javascript: 6.0.1- terser: 5.17.1- webpack: 5.80.0- dev: true+ schema-utils: 3.1.1+ serialize-javascript: 6.0.0+ terser: 5.15.0+ webpack: 5.74.0resolution: {integrity: sha512-L1BJiXVmheAQQy+as0oF3Pwtlo4s3Wi1X2zNZ2NxOB4wx9bdS9Vk67XQENLFdLYGCK/Z2di53mTj/hBafR+dTA==}@@ -11630,13 +11666,13 @@ packages:commander: 2.20.3source-map-support: 0.5.21- resolution: {integrity: sha512-hVl35zClmpisy6oaoKALOpS0rDYLxRFLHhRuDlEGTKey9qHjS1w9GMORjuwIMt70Wan4lwsLYyWDVnWgF+KUEw==}+ resolution: {integrity: sha512-bi1HRwVRskAjheeYl291n3JC4GgO/Ty4z1nVs5AAsmonJulGxpSektecnNedrwK9C7vpvVtcX3cw00VSLt7U2A==}engines: {node: '>=10'}hasBin: truedependencies:- '@jridgewell/source-map': 0.3.3- acorn: 8.10.0+ '@jridgewell/source-map': 0.3.5+ acorn: 8.11.3commander: 2.20.3source-map-support: 0.5.21dev: true@@ -11791,12 +11827,8 @@ packages:resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}- resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==}-resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}- dev: trueresolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}@@ -11925,15 +11957,15 @@ packages:peerDependencies:react: '>=15.0.0'dependencies:- '@babel/runtime': 7.22.5- '@types/react': 18.2.22+ '@babel/runtime': 7.23.8+ '@types/react': 18.0.20invariant: 2.2.4react: 18.2.0react-lifecycles-compat: 3.0.4dev: false- resolution: {integrity: sha512-/GDx+K1STGtpgTsj5Dj3J51YaKxZDblbCQHTH1zHLuoBEWodj6MjtRVv3TUijj1JYLRLSFsFzN8NV4M3QV4d9w==}+ resolution: {integrity: sha512-ulRWYWHvscPFc0QQXvyJjY6LIXU56f0h8pQFvhxiKk5V1fcI8gp9Ht9leVAhrVjzqMw0BgjspBINx9r6oyJUvQ==}peerDependencies:react: '>=16.14.0'dependencies:@@ -11989,13 +12021,13 @@ packages:resolution: {integrity: sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==}engines: {node: '>=4'}- resolution: {integrity: sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==}+ resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==}hasBin: truepeerDependencies:browserslist: '>= 4.21.0'dependencies:- browserslist: 4.21.5+ browserslist: 4.22.2escalade: 3.1.1picocolors: 1.0.0dev: true@@ -12117,7 +12149,7 @@ packages:rollup: 3.29.4sass: 1.54.9optionalDependencies:- fsevents: 2.3.2+ fsevents: 2.3.3dev: true@@ -12152,7 +12184,7 @@ packages:engines: {node: '>=10.13.0'}dependencies:glob-to-regexp: 0.4.1- graceful-fs: 4.2.11+ graceful-fs: 4.2.10resolution: {integrity: sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA==}@@ -12300,8 +12332,8 @@ packages:- esbuild- uglify-js- resolution: {integrity: sha512-OIMiq37XK1rWO8mH9ssfFKZsXg4n6klTEDL7S8/HqbAOBBaiy8ABvXvz0dDCXeEF9gqwxSvVk611zFPjS8hJxA==}+ resolution: {integrity: sha512-qyfIC10pOr70V+jkmud8tMfajraGCZMBWJtrmuBymQKCrLTRejBI8STDp1MCyZu/QTdZSeacCQYpYNQVOzX5kw==}engines: {node: '>=10.13.0'}hasBin: truepeerDependencies:@@ -12310,17 +12342,17 @@ packages:webpack-cli:optional: truedependencies:- '@types/eslint-scope': 3.7.4- '@types/estree': 1.0.1- '@webassemblyjs/ast': 1.11.5- '@webassemblyjs/wasm-edit': 1.11.5- '@webassemblyjs/wasm-parser': 1.11.5- acorn: 8.10.0- acorn-import-assertions: 1.8.0([email protected])- browserslist: 4.21.5+ '@types/eslint-scope': 3.7.7+ '@types/estree': 1.0.5+ '@webassemblyjs/ast': 1.11.6+ '@webassemblyjs/wasm-edit': 1.11.6+ '@webassemblyjs/wasm-parser': 1.11.6+ acorn: 8.11.3+ acorn-import-assertions: 1.9.0([email protected])+ browserslist: 4.22.2chrome-trace-event: 1.0.3- enhanced-resolve: 5.13.0- es-module-lexer: 1.2.1+ enhanced-resolve: 5.15.0+ es-module-lexer: 1.4.1eslint-scope: 5.1.1events: 3.3.0glob-to-regexp: 0.4.1@@ -12329,9 +12361,9 @@ packages:loader-runner: 4.3.0mime-types: 2.1.35neo-async: 2.6.2- schema-utils: 3.1.2+ schema-utils: 3.3.0tapable: 2.2.1- terser-webpack-plugin: 5.3.7([email protected])+ terser-webpack-plugin: 5.3.10([email protected])watchpack: 2.4.0webpack-sources: 3.2.3transitivePeerDependencies:@@ -12461,7 +12493,7 @@ packages:'@apideck/better-ajv-errors': 0.3.6([email protected])'@babel/core': 7.19.1'@babel/preset-env': 7.19.1(@babel/[email protected])- '@babel/runtime': 7.22.5+ '@babel/runtime': 7.23.8'@rollup/plugin-babel': 5.3.1(@babel/[email protected])([email protected])'@rollup/plugin-node-resolve': 11.2.1([email protected])'@rollup/plugin-replace': 2.4.2([email protected])diff --git a/ui/public/index.html b/ui/public/index.htmlindex eeb5fb11..f5a9c141 100644--- a/ui/public/index.html+++ b/ui/public/index.html@@ -19,7 +19,7 @@--><!DOCTYPE html>-<html>+<html data-bs-theme=""><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />diff --git a/ui/src/assets/images/default-avatar.svg b/ui/src/assets/images/default-avatar.svgindex 08e0a60b..7ecd67fc 100644--- a/ui/src/assets/images/default-avatar.svg+++ b/ui/src/assets/images/default-avatar.svg@@ -1,3 +1,21 @@+<!--+Licensed to the Apache Software Foundation (ASF) under one+or more contributor license agreements. See the NOTICE file+distributed with this work for additional information+regarding copyright ownership. The ASF licenses this file+to you under the Apache License, Version 2.0 (the+"License"); you may not use this file except in compliance+with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++Unless required by applicable law or agreed to in writing,+software distributed under the License is distributed on an+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+KIND, either express or implied. See the License for the+specific language governing permissions and limitations+under the License.+--><svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="32" height="32" fill="#DEE2E6"/><path d="M8.5 25C8.5 25 7 25 7 23.5C7 22 8.5 17.5 16 17.5C23.5 17.5 25 22 25 23.5C25 25 23.5 25 23.5 25H8.5ZM16 16C17.1935 16 18.3381 15.5259 19.182 14.682C20.0259 13.8381 20.5 12.6935 20.5 11.5C20.5 10.3065 20.0259 9.16193 19.182 8.31802C18.3381 7.47411 17.1935 7 16 7C14.8065 7 13.6619 7.47411 12.818 8.31802C11.9741 9.16193 11.5 10.3065 11.5 11.5C11.5 12.6935 11.9741 13.8381 12.818 14.682C13.6619 15.5259 14.8065 16 16 16Z" fill="#6C757D"/>diff --git a/ui/src/common/color.scss b/ui/src/common/color.scssnew file mode 100644index 00000000..66436873--- /dev/null+++ b/ui/src/common/color.scss@@ -0,0 +1,132 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++++:root {+ --an-side-nav-link: rgba(0, 0, 0, 0.65);+ --an-toolbar-divider: rgba(0, 0, 0, 0.1);+ --an-ced4da: #ced4da;+ --an-e9ecef: #e9ecef;+ --an-pre: #161b22;+ --an-6c757d: #6c757d;+ --an-212529: #212529;+ --an-gray-300: var(--bs-gray-300);+ --an-white: #fff;+ --an-inbox-warning:#fff3cd80;+ --an-f5: #f5f5f5;+ --an-answer-item-border-top: rgba(0, 0, 0, .125);+ --an-answer-inbox-nav-border-top: var(--bs-border-color);+ --an-comment-item-border-bottom: var(--bs-colors-gray-200, #E9ECEF);+ --an-editor-toolbar-hover: #f8f9fa;+ --ans-editor-toolbar-focus: #dae0e5;+ --an-editor-placeholder-color: #6c757d;+ --an-side-nav-link-hover-color: black;+ --an-invite-answer-item-active: #e9ecef;+ --an-alert-exist-color: #055160;+}+++[data-bs-theme="dark"] {+ --an-side-nav-link: rgba(255, 255, 255, 0.65);+ --an-toolbar-divider: rgba(255, 255, 255, 0.3);+ --an-ced4da: var(--bs-border-color);+ --an-e9ecef: #161b22;+ --an-pre: #161b22;+ --an-6c757d: var(--bs-body-color);+ --an-212529: var(--bs-body-color);+ --an-gray-300: #161b22;+ --an-white: #000;+ --an-inbox-warning:#38363180;+ --an-f5: var(--bs-body-bg);+ --an-answer-item-border-top: var(--bs-border-color);+ --an-answer-inbox-nav-border-top: var(--bs-border-color);+ --an-comment-item-border-bottom: var(--bs-border-color);+ --an-editor-toolbar-hover: var(--bs-tertiary-bg);+ --ans-editor-toolbar-focus: var(--bs-tertiary-bg);+ --an-editor-placeholder-color: var(--bs-body-color);+ --an-side-nav-link-hover-color: var(--bs-body-color);+ --an-invite-answer-item-active: var(--bs-tertiary-bg);+ --an-alert-exist-color: #60cee4;+ }++[data-bs-theme="dark"] {+ .link-dark {+ color: rgba(var(--bs-emphasis-color-rgb),0.8)!important;+ }+ /** CodeMirror **/++ .CodeMirror {+ background: var(--bs-body-bg);+ color: var(--bs-body-color);+ }+ .CodeMirror-cursor {+ border-left: 1px solid var(--bs-body-color);+ }+ .cm-header, .cm-link, .cm-url {+ color: var(--bs-body-color);+ }+ div.CodeMirror-selected { background: rgba(127, 190, 244, 0.4); }+ .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: rgba(84,174,255,0.4); }+ .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: rgba(84,174,255,0.4); }++ .bg-light {+ background-color: rgba(0, 0, 0, 0.5) !important;+ }+ .text-bg-dark {+ color: #000 !important;+ background-color: RGBA(255, 255, 255, var(--bs-bg-opacity, 1)) !important;+ }+ /** side nav **/+ #sideNav {+ .nav-link:hover, .nav-link.active {+ background-color: #2b3035 !important;+ }+ }++ /** tag **/+ .badge-tag {+ background: rgba($blue-900, 0.5);+ color: $blue-300;+ &:hover {+ color: $blue-300;+ background: $blue-900;+ }+ }+ .badge-tag-required {+ background: $gray-800;+ color:$gray-300;+ border: 1px solid $gray-600;+ &:hover {+ color: $gray-300;+ background: $gray-700;+ }+ }+ .badge-tag-reserved {+ color: $orange-300;+ background: rgba($orange-900, 0.5);+ border: 1px solid $orange-900;+ &:hover {+ color: $orange-300;+ background: rgba($orange-900, 1);+ }+ }+++}diff --git a/ui/src/common/constants.ts b/ui/src/common/constants.tsindex 87b2377b..373e41d2 100644--- a/ui/src/common/constants.ts+++ b/ui/src/common/constants.ts@@ -28,6 +28,8 @@ export const DRAFT_QUESTION_STORAGE_KEY = '_a_dq_';export const DRAFT_ANSWER_STORAGE_KEY = '_a_da_';export const DRAFT_TIMESIGH_STORAGE_KEY = '|_a_t_s_|';export const QUESTIONS_ORDER_STORAGE_KEY = '_a_qok_';+export const DEFAULT_THEME = 'system';+export const ADMIN_PRIVILEGE_CUSTOM_LEVEL = 99;export const USER_AGENT_NAMES = {SegmentFault: 'SegmentFault',@@ -634,3 +636,5 @@ export const SYSTEM_AVATAR_OPTIONS = [value: 'gravatar',},];++export const TAG_SLUG_NAME_MAX_LENGTH = 35;diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.tsindex 68f3be95..201a5ae0 100644--- a/ui/src/common/interface.ts+++ b/ui/src/common/interface.ts@@ -440,6 +440,7 @@ export type themeConfig = {};export interface AdminSettingsTheme {theme: string;+ color_scheme: string;theme_options?: { label: string; value: string }[];theme_config: Record<string, themeConfig>;}@@ -622,12 +623,17 @@ export interface NotificationConfigItem {key: string;}export interface NotificationConfig {- all_new_question: NotificationConfigItem[];- all_new_question_for_following_tags: NotificationConfigItem[];- inbox: NotificationConfigItem[];+ all_new_question: NotificationConfigItem;+ all_new_question_for_following_tags: NotificationConfigItem;+ inbox: NotificationConfigItem;}export interface ActivatedPlugin {name: string;slug_name: string;}++export interface UserPluginsConfigRes {+ name: string;+ slug_name: string;+}diff --git a/ui/src/components/Comment/components/ActionBar/index.tsx b/ui/src/components/Comment/components/ActionBar/index.tsxindex 82d6619e..c55bf40e 100644--- a/ui/src/components/Comment/components/ActionBar/index.tsx+++ b/ui/src/components/Comment/components/ActionBar/index.tsx@@ -41,20 +41,27 @@ const ActionBar = ({const { t } = useTranslation('translation', { keyPrefix: 'comment' });return (- <div className="d-flex justify-content-between small">- <div className="d-flex align-items-center link-secondary">+ <div className="d-flex justify-content-between flex-wrap small">+ <div className="d-flex align-items-center flex-wrap link-secondary">{userStatus !== 'deleted' ? (- <Link to={`/users/${username}`}>{nickName}</Link>+ <Link+ to={`/users/${username}`}+ className="name-ellipsis"+ style={{ maxWidth: '200px' }}>+ {nickName}+ </Link>) : (<span>{nickName}</span>)}<span className="mx-1">•</span>- <FormatTime time={createdAt} className="me-3" />+ <FormatTime time={createdAt} className="me-3 flex-shrink-0" /><Buttontitle={t('tip_vote')}variant="link"size="sm"- className={`me-3 btn-no-border p-0 ${isVote ? '' : 'link-secondary'}`}+ className={`flex-shrink-0 me-3 btn-no-border p-0 ${+ isVote ? '' : 'link-secondary'+ }`}onClick={onVote}><Icon name="hand-thumbs-up-fill" />{voteCount > 0 && <span className="ms-2">{voteCount}</span>}@@ -96,11 +103,7 @@ const ActionBar = ({<Dropdown.Menu align="end">{memberActions.map((action) => {return (- <Dropdown.Item- key={action.name}- variant="link"- size="sm"- onClick={() => onAction(action)}>+ <Dropdown.Item key={action.name} onClick={() => onAction(action)}>{action.name}</Dropdown.Item>);diff --git a/ui/src/components/Comment/index.scss b/ui/src/components/Comment/index.scssindex 47254f57..1387c2c6 100644--- a/ui/src/components/Comment/index.scss+++ b/ui/src/components/Comment/index.scss@@ -30,7 +30,7 @@}}}- border-bottom: 1px solid var(--bs-colors-gray-200, #E9ECEF);+ border-bottom: 1px solid var(--an-comment-item-border-bottom);}.fmt {display: inline;diff --git a/ui/src/components/Comment/index.tsx b/ui/src/components/Comment/index.tsxindex 9a2d4ab3..be2d5553 100644--- a/ui/src/components/Comment/index.tsx+++ b/ui/src/components/Comment/index.tsx@@ -74,10 +74,8 @@ const Comment = ({ objectId, mode, commentId }) => {useEffect(() => {if (pageIndex === 0 && commentId) {- console.log('scrollCallback');setTimeout(() => {const el = document.getElementById(commentId);- console.log(el);scrollToElementTop(el);bgFadeOut(el);}, 100);@@ -92,6 +90,9 @@ const Comment = ({ objectId, mode, commentId }) => {if (!data) {return;}+ if (data.count <= 3) {+ data.list.sort((a, b) => a.created_at - b.created_at);+ }if (pageIndex === 1 || pageIndex === 0) {setComments(data?.list);} else {@@ -419,7 +420,10 @@ const Comment = ({ objectId, mode, commentId }) => {onClick={() => {setPageIndex(pageIndex + 1);}}>- {t('show_more')}+ {t('show_more', {+ count:+ data.count - (pageIndex === 0 ? 3 : pageIndex * pageSize),+ })}</Button>)}</div>diff --git a/ui/src/components/Counts/index.tsx b/ui/src/components/Counts/index.tsxindex e3b7dbef..3b5fbe3a 100644--- a/ui/src/components/Counts/index.tsx+++ b/ui/src/components/Counts/index.tsx@@ -51,7 +51,7 @@ const Index: FC<Props> = ({return (<div className={classname('d-flex align-items-center', className)}>{showVotes && (- <div className="d-flex align-items-center">+ <div className="d-flex align-items-center flex-shrink-0"><Icon name="hand-thumbs-up-fill me-1" /><span>{data.votes} {t('votes')}@@ -60,7 +60,7 @@ const Index: FC<Props> = ({)}{showAccepted && (- <div className="d-flex align-items-center ms-3 text-success">+ <div className="d-flex align-items-center ms-3 text-success flex-shrink-0"><Icon name="check-circle-fill me-1" /><span>{t('accepted')}</span></div>@@ -68,7 +68,7 @@ const Index: FC<Props> = ({{showAnswers && (<div- className={`d-flex align-items-center ms-3 ${+ className={`d-flex flex-shrink-0 align-items-center ms-3 ${isAccepted ? 'text-success' : ''}`}>{isAccepted ? (@@ -82,7 +82,7 @@ const Index: FC<Props> = ({</div>)}{showViews && (- <span className="summary-stat ms-3">+ <span className="summary-stat ms-3 flex-shrink-0"><Icon name="eye-fill" /><em className="fst-normal ms-1">{data.views} {t('views')}diff --git a/ui/src/components/CustomizeTheme/index.tsx b/ui/src/components/CustomizeTheme/index.tsxindex 46c0c6ec..ff49e550 100644--- a/ui/src/components/CustomizeTheme/index.tsx+++ b/ui/src/components/CustomizeTheme/index.tsx@@ -58,6 +58,22 @@ const Index: FC = () => {.round().array()}}+ :root[data-bs-theme='dark'] {+ --bs-link-color: ${tintColor(primaryColor, 0.6).hex()};+ --bs-link-color-rgb: ${tintColor(primaryColor, 0.6)+ .round()+ .array()};+ --bs-link-hover-color: ${shiftColor(+ tintColor(primaryColor, 0.6),+ -0.8,+ ).hex()};+ --bs-link-hover-color-rgb: ${shiftColor(+ tintColor(primaryColor, 0.6),+ -0.8,+ )+ .round()+ .array()};+ }.nav-pills {--bs-nav-pills-link-active-bg: ${primaryColor.hex()};}@@ -109,6 +125,12 @@ const Index: FC = () => {0.5,)}%27/%3e%3c/svg%3e");}+ .tag-selector-wrap--focus {+ box-shadow: 0 0 0 0.25rem ${primaryColor+ .fade(0.75)+ .string()} !important;+ border-color: ${tintColor(primaryColor, 0.5)} !important;+ }.dropdown-menu {--bs-dropdown-link-active-bg: rgb(var(--bs-primary-rgb));}@@ -128,6 +150,21 @@ const Index: FC = () => {.badge-tag:not(.badge-tag-reserved, .badge-tag-required):hover {background-color: ${tintColor(primaryColor, 0.2).hex()};}++ [data-bs-theme="dark"] .badge-tag:not(.badge-tag-reserved):not(.badge-tag-required) {+ background-color: rgba(${shadeColor(primaryColor, 0.2)+ .rgb()+ .array()+ .join(',')}, .5) !important;+ color: ${tintColor(primaryColor, 0.4).hex()} !important;+ }+ [data-bs-theme="dark"] .badge-tag:not(.badge-tag-reserved, .badge-tag-required):hover {+ background-color: rgba(${tintColor(+ primaryColor,+ 0.4,+ ).hex()}, 0.8) !important;+ color: ${tintColor(primaryColor, 0.6).hex()} !important;+ }`}</style>)}diff --git a/ui/src/components/Editor/ToolBars/image.tsx b/ui/src/components/Editor/ToolBars/image.tsxindex 48f1b039..95737db6 100644--- a/ui/src/components/Editor/ToolBars/image.tsx+++ b/ui/src/components/Editor/ToolBars/image.tsx@@ -117,7 +117,7 @@ const Image = ({ editorInstance }) => {editor.replaceSelection(loadingText);const urls = await upload(fileList).catch((ex) => {- console.log('ex: ', ex);+ console.error('upload file error: ', ex);});const text: string[] = [];diff --git a/ui/src/components/Editor/index.scss b/ui/src/components/Editor/index.scssindex e71d27fb..67b5f454 100644--- a/ui/src/components/Editor/index.scss+++ b/ui/src/components/Editor/index.scss@@ -20,16 +20,16 @@.md-editor-wrap {display: flex;flex-direction: column;- background-color: #fff;- border: 1px solid #ced4da;+ background-color: var(-bs-body-bg);+ border: 1px solid var(--an-ced4da);overflow: hidden;.toolbar-wrap {- border-bottom: 1px solid #ced4da;+ border-bottom: 1px solid var(--an-ced4da);.toolbar-divider {float: left;width: 1px;height: 15px;- background-color: rgba(0, 0, 0, 0.1);+ background-color: var(--an-toolbar-divider);margin: 10px 8px;}.toolbar-item-wrap {@@ -57,7 +57,7 @@box-sizing: border-box;outline: none;cursor: pointer;- background-color: #fff;+ background-color: var(--bs-body-bg);height: 100%;width: 100%;border-radius: 0;@@ -66,10 +66,10 @@border-radius: 3px;&:hover {- background-color: #f8f9fa;+ background-color: var(--an-editor-toolbar-hover);}&:focus {- background-color: #dae0e5;+ background-color: var(--ans-editor-toolbar-focus);}&.icon-heading {background-position: 0px -144px;@@ -204,7 +204,7 @@padding: 16px 0;}.CodeMirror-placeholder {- color: #6c757d;+ color: var(--an-editor-placeholder-color);}}}diff --git a/ui/src/components/FollowingTags/index.tsx b/ui/src/components/FollowingTags/index.tsxindex 571acf3d..223af5e1 100644--- a/ui/src/components/FollowingTags/index.tsx+++ b/ui/src/components/FollowingTags/index.tsx@@ -70,7 +70,7 @@ const Index: FC = () => {onChange={handleTagsChange}hiddenDescriptionhiddenCreateBtn- alwaysShowAddBtn+ autoFocus/></Card.Body></Card>diff --git a/ui/src/components/Header/index.scss b/ui/src/components/Header/index.scssindex caf67481..1a02c332 100644--- a/ui/src/components/Header/index.scss+++ b/ui/src/components/Header/index.scss@@ -22,7 +22,7 @@#header {transform: translate3d(0,0,0);--bs-navbar-padding-y: 0.75rem;- background: linear-gradient(180deg, rgb(var(--bs-primary-rgb)) 0%, rgba(var(--bs-primary-rgb), 0.95) 100%);+ background: var(--bs-primary);box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 0.125rem 0.25rem rgb(0 0 0 / 8%);.logo {max-height: 2rem;@@ -70,7 +70,22 @@// style for colored navbar&.theme-light {- background: linear-gradient(180deg, rgb(255, 255, 255) 0%, rgba(255, 255, 255, 0.95) 100%);+ background: rgb(255, 255, 255);+ .nav-link {+ color: rgba(0, 0, 0, 0.65);+ }+ .placeholder-search {+ box-shadow: none;+ color: var(--bs-body-color);+ background-color: rgba(255, 255, 255, .2);+ border: $border-width $border-style #dee2e6;+ &:focus {+ border: $border-width $border-style $border-color;+ }+ &::placeholder {+ color: rgba(0, 0, 0, 0.65);+ }+ }}.maxw-400 {diff --git a/ui/src/components/QuestionList/index.tsx b/ui/src/components/QuestionList/index.tsxindex ee09dc1f..4f410990 100644--- a/ui/src/components/QuestionList/index.tsx+++ b/ui/src/components/QuestionList/index.tsx@@ -103,8 +103,8 @@ const QuestionList: FC<Props> = ({{li.status === 2 ? ` [${t('closed')}]` : ''}</NavLink></h5>- <div className="d-flex flex-column flex-md-row align-items-md-center small mb-2 text-secondary">- <div className="d-flex">+ <div className="d-flex flex-wrap flex-column flex-md-row align-items-md-center small mb-2 text-secondary">+ <div className="d-flex flex-wrap me-0 me-md-3"><BaseUserCarddata={li.operator}showAvatar={false}@@ -113,7 +113,7 @@ const QuestionList: FC<Props> = ({•<FormatTimetime={li.operated_at}- className="text-secondary ms-1"+ className="text-secondary ms-1 flex-shrink-0"preFix={t(li.operation_type)}/></div>@@ -124,7 +124,7 @@ const QuestionList: FC<Props> = ({views: li.view_count,}}isAccepted={li.accepted_answer_id >= 1}- className="ms-0 ms-md-3 mt-2 mt-md-0"+ className="mt-2 mt-md-0"/></div><div className="question-tags m-n1">diff --git a/ui/src/components/SchemaForm/README.md b/ui/src/components/SchemaForm/README.mdindex c5e42e04..13149ae4 100644--- a/ui/src/components/SchemaForm/README.md+++ b/ui/src/components/SchemaForm/README.md@@ -183,8 +183,9 @@ export interface BaseUIOptions {empty?: string;// Will be appended to the className of the form component itselfclassName?: classnames.Argument;+ class_name?: classnames.Argument;// The className that will be attached to a form field container- fieldClassName?: classnames.Argument;+ field_class_name?: classnames.Argument;// Make a form component render into simplified modereadOnly?: boolean;simplify?: boolean;diff --git a/ui/src/components/SchemaForm/components/Button.tsx b/ui/src/components/SchemaForm/components/Button.tsxindex 38bad913..0371992f 100644--- a/ui/src/components/SchemaForm/components/Button.tsx+++ b/ui/src/components/SchemaForm/components/Button.tsx@@ -17,31 +17,43 @@* under the License.*/-import React, { FC, useLayoutEffect, useState } from 'react';+import { FC, useEffect, useState } from 'react';import { Button, ButtonProps, Spinner } from 'react-bootstrap';import { request } from '@/utils';import type { UIAction, FormKit } from '../types';import { useToast } from '@/hooks';+import { Icon } from '@/components';interface Props {fieldName: string;text: string;action: UIAction | undefined;+ actionType?: 'submit' | 'click';+ clickCallback?: () => void;formKit: FormKit;readOnly: boolean;variant?: ButtonProps['variant'];size?: ButtonProps['size'];+ iconName?: string;+ nowrap?: boolean;+ title?: string;}const Index: FC<Props> = ({fieldName,action,+ actionType = 'submit',formKit,text = '',readOnly = false,variant = 'primary',size,+ iconName = '',+ nowrap = false,+ clickCallback,+ title,}) => {+ console.log('Button.tsx: action:', title);const Toast = useToast();const [isLoading, setLoading] = useState(false);const handleToast = (msg, type: 'success' | 'danger' = 'success') => {@@ -62,6 +74,12 @@ const Index: FC<Props> = ({}};const handleAction = () => {+ if (actionType === 'click') {+ if (typeof clickCallback === 'function') {+ clickCallback();+ }+ return;+ }if (!action) {return;}@@ -87,13 +105,39 @@ const Index: FC<Props> = ({setLoading(false);});};- useLayoutEffect(() => {+ useEffect(() => {if (action?.loading?.state === 'pending') {setLoading(true);}}, []);const loadingText = action?.loading?.text || text;const disabled = isLoading || readOnly;+ if (nowrap) {+ return (+ <Button+ name={fieldName}+ onClick={handleAction}+ disabled={disabled}+ size={size}+ title={title}+ variant={variant}>+ {isLoading ? (+ <>+ <Spinner+ className="align-middle me-2"+ animation="border"+ size="sm"+ variant={variant}+ />+ {loadingText}+ </>+ ) : (+ text+ )}+ {iconName && <Icon name={iconName} />}+ </Button>+ );+ }return (<div className="d-flex">@@ -102,6 +146,7 @@ const Index: FC<Props> = ({onClick={handleAction}disabled={disabled}size={size}+ title={title}variant={variant}>{isLoading ? (<>@@ -116,6 +161,7 @@ const Index: FC<Props> = ({) : (text)}+ {iconName && <Icon name={iconName} />}</Button></div>);diff --git a/ui/src/components/SchemaForm/components/Input.tsx b/ui/src/components/SchemaForm/components/Input.tsxindex 97229d13..1a3fe319 100644--- a/ui/src/components/SchemaForm/components/Input.tsx+++ b/ui/src/components/SchemaForm/components/Input.tsx@@ -63,7 +63,7 @@ const Index: FC<Props> = ({onChange={handleChange}disabled={readOnly}isInvalid={fieldObject?.isInvalid}- style={type === 'color' ? { width: '6rem' } : {}}+ style={type === 'color' ? { width: '100px', flex: 'none' } : {}}/>);};diff --git a/ui/src/components/SchemaForm/components/InputGroup.tsx b/ui/src/components/SchemaForm/components/InputGroup.tsxnew file mode 100644index 00000000..88cb0388--- /dev/null+++ b/ui/src/components/SchemaForm/components/InputGroup.tsx@@ -0,0 +1,90 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++import { FC } from 'react';+import { InputGroup } from 'react-bootstrap';++import type { FormKit, InputGroupOptions } from '../types';++import Button from './Button';++interface Props {+ formKitWithContext: FormKit;+ uiOpt: InputGroupOptions;+ prefixText?: string;+ suffixText?: string;+ children: React.ReactNode;+}++const InputGroupBtn = ({+ formKitWithContext,+ uiOpt,+}: {+ formKitWithContext: FormKit;+ uiOpt:+ | InputGroupOptions['prefixBtnOptions']+ | InputGroupOptions['suffixBtnOptions'];+}) => {+ return (+ <Button+ fieldName="1"+ text={String(uiOpt?.text)}+ iconName={uiOpt?.iconName ? uiOpt?.iconName : ''}+ action={uiOpt?.action ? uiOpt?.action : undefined}+ actionType="click"+ clickCallback={uiOpt?.clickCallback ? uiOpt?.clickCallback : undefined}+ formKit={formKitWithContext}+ variant={uiOpt?.variant ? uiOpt.variant : undefined}+ size={uiOpt?.size ? uiOpt?.size : undefined}+ title={uiOpt?.title ? uiOpt?.title : ''}+ nowrap+ readOnly={false}+ />+ );+};++const Index: FC<Props> = ({+ formKitWithContext,+ uiOpt,+ prefixText = null,+ suffixText = null,+ children,+}) => {+ return (+ <InputGroup>+ {prefixText && <InputGroup.Text>{prefixText}</InputGroup.Text>}+ {uiOpt && 'prefixBtnOptions' in uiOpt && (+ <InputGroupBtn+ uiOpt={uiOpt.prefixBtnOptions}+ formKitWithContext={formKitWithContext}+ />+ )}+ {children}+ {uiOpt && 'suffixBtnOptions' in uiOpt && (+ <InputGroupBtn+ uiOpt={uiOpt.suffixBtnOptions}+ formKitWithContext={formKitWithContext}+ />+ )}+ {suffixText ? <InputGroup.Text>{suffixText}</InputGroup.Text> : null}+ </InputGroup>+ );+};++export default Index;diff --git a/ui/src/components/SchemaForm/components/Legend.tsx b/ui/src/components/SchemaForm/components/Legend.tsxindex fe8e52cc..75c5f0a9 100644--- a/ui/src/components/SchemaForm/components/Legend.tsx+++ b/ui/src/components/SchemaForm/components/Legend.tsx@@ -22,9 +22,10 @@ import { Form } from 'react-bootstrap';interface Props {title: string;+ className?: string | undefined;}-const Index: FC<Props> = ({ title }) => {- return <Form.Label>{title}</Form.Label>;+const Index: FC<Props> = ({ title, className }) => {+ return <Form.Label className={className}>{title}</Form.Label>;};export default Index;diff --git a/ui/src/components/SchemaForm/components/index.ts b/ui/src/components/SchemaForm/components/index.tsindex 4e74be30..df28f4ac 100644--- a/ui/src/components/SchemaForm/components/index.ts+++ b/ui/src/components/SchemaForm/components/index.ts@@ -26,6 +26,7 @@ import Upload from './Upload';import Textarea from './Textarea';import Input from './Input';import Button from './Button';+import InputGroup from './InputGroup';export {Legend,@@ -37,4 +38,5 @@ export {Textarea,Input,Button,+ InputGroup,};diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsxindex e3464bc9..2bb91e31 100644--- a/ui/src/components/SchemaForm/index.tsx+++ b/ui/src/components/SchemaForm/index.tsx@@ -37,6 +37,7 @@ import type {FormRef,BaseUIOptions,FormKit,+ InputGroupOptions,} from './types';import {Legend,@@ -48,6 +49,7 @@ import {Textarea,Input,Button as SfButton,+ InputGroup,} from './components';export * from './types';@@ -258,16 +260,19 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (uiSchema?.[key] || {};formData ||= {};const fieldState = formData[key];+ if (uiOpt?.class_name) {+ uiOpt.className = uiOpt.class_name;+ }const uiSimplify = widget === 'legend' || uiOpt?.simplify;- let groupClassName: BaseUIOptions['fieldClassName'] = uiOpt?.simplify+ let groupClassName: BaseUIOptions['field_class_name'] = uiOpt?.simplify? 'mb-2': 'mb-3';if (widget === 'legend') {groupClassName = 'mb-0';}- if (uiOpt?.fieldClassName) {- groupClassName = uiOpt.fieldClassName;+ if (uiOpt?.field_class_name) {+ groupClassName = uiOpt.field_class_name;}const readOnly = uiOpt?.readOnly || false;@@ -283,7 +288,9 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = ({/* Uniform processing `label` */}{title && !uiSimplify ? <Form.Label>{title}</Form.Label> : null}{/* Handling of individual specific controls */}- {widget === 'legend' ? <Legend title={title} /> : null}+ {widget === 'legend' ? (+ <Legend title={title} className={String(uiOpt?.className)} />+ ) : null}{widget === 'select' ? (<Selectdesc={description}@@ -377,8 +384,33 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (uiOpt && 'variant' in uiOpt ? uiOpt.variant : undefined}size={uiOpt && 'size' in uiOpt ? uiOpt.size : undefined}+ title={uiOpt && 'title' in uiOpt ? uiOpt?.title : ''}/>) : null}+ {widget === 'input_group' ? (+ <InputGroup+ formKitWithContext={formKitWithContext}+ uiOpt={uiOpt as InputGroupOptions}+ prefixText={+ (uiOpt && 'prefixText' in uiOpt && uiOpt.prefixText) || ''+ }+ suffixText={+ (uiOpt && 'suffixText' in uiOpt && uiOpt.suffixText) || ''+ }>+ <Input+ type={+ uiOpt && 'inputType' in uiOpt ? uiOpt.inputType : 'text'+ }+ placeholder={+ uiOpt && 'placeholder' in uiOpt ? uiOpt.placeholder : ''+ }+ fieldName={key}+ onChange={onChange}+ formData={formData}+ readOnly={readOnly}+ />+ </InputGroup>+ ) : null}{/* Unified handling of `Feedback` and `Text` */}<Form.Control.Feedback type="invalid">{fieldState?.errorMsg}@@ -397,6 +429,7 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (</Form>);};+export const initFormData = (schema: JSONSchema): Type.FormDataType => {const formData: Type.FormDataType = {};const props: JSONSchema['properties'] = schema?.properties || {};diff --git a/ui/src/components/SchemaForm/types.ts b/ui/src/components/SchemaForm/types.tsindex 69cbe617..8347b98f 100644--- a/ui/src/components/SchemaForm/types.ts+++ b/ui/src/components/SchemaForm/types.ts@@ -58,8 +58,9 @@ export interface BaseUIOptions {empty?: string;// Will be appended to the className of the form component itselfclassName?: classnames.Argument;+ class_name?: classnames.Argument;// The className that will be attached to a **form field container**- fieldClassName?: classnames.Argument;+ field_class_name?: classnames.Argument;// Make a form component render into simplified modereadOnly?: boolean;simplify?: boolean;@@ -112,10 +113,20 @@ export interface TextareaOptions extends BaseUIOptions {export interface ButtonOptions extends BaseUIOptions {text: string;- icon?: string;+ iconName?: string;action?: UIAction;+ actionType: 'click' | 'submit';variant?: ButtonProps['variant'];size?: ButtonProps['size'];+ title?: string;+ clickCallback?: () => void;+}++export interface InputGroupOptions extends InputOptions {+ prefixText?: string;+ suffixText?: string;+ prefixBtnOptions?: ButtonOptions;+ suffixBtnOptions?: ButtonOptions;}export type UIOptions =@@ -127,7 +138,8 @@ export type UIOptions =| CheckboxOptions| RadioOptions| TextareaOptions- | ButtonOptions;+ | ButtonOptions+ | InputGroupOptions;export type UIWidget =| 'textarea'@@ -139,7 +151,8 @@ export type UIWidget =| 'timezone'| 'switch'| 'legend'- | 'button';+ | 'button'+ | 'input_group';export interface UISchema {[key: string]: {'ui:widget'?: UIWidget;diff --git a/ui/src/components/SideNav/index.scss b/ui/src/components/SideNav/index.scssindex 802dbcd1..d8bcc8f1 100644--- a/ui/src/components/SideNav/index.scss+++ b/ui/src/components/SideNav/index.scss@@ -17,7 +17,6 @@* under the License.*/-#sideNav {.nav-wrap {position: sticky;@@ -32,14 +31,14 @@max-width: calc(100% - 24px);}.nav-link {- color: rgba(0, 0, 0, 0.65);+ color: var(--an-side-nav-link);}.nav-link:hover {- color: rgba(0, 0, 0);+ color: var(--an-side-nav-link-hover-color);background-color: var(--bs-gray-100);}.nav-link.active {- color: black;+ color: var(--an-side-nav-link-hover-color);background-color: var(--bs-gray-200);}.side-nav-right-line {@@ -48,7 +47,7 @@right: 12px;width: 1px;height: 100%;- background-color: var(--bs-gray-300);+ background-color: var(--bs-border-color);min-height: calc(100vh - 62px - 74px);}}diff --git a/ui/src/components/TagSelector/index.scss b/ui/src/components/TagSelector/index.scssindex 415ac0c0..1a53ac42 100644--- a/ui/src/components/TagSelector/index.scss+++ b/ui/src/components/TagSelector/index.scss@@ -28,8 +28,43 @@}.dropdown-item.active {- color: #212529;- background-color: #e9ecef;+ color: var(--bs-body-color);+ background-color: var(--an-invite-answer-item-active);}+ .hover-hand:hover {+ cursor: pointer;+ }++ .a-placeholder {+ color: var(--bs-secondary-color);+ }++ .a-input {+ padding: 0;+ background: transparent !important;+ box-shadow: none;+ border: none;+ min-width: 60px;+ }+ .a-input:focus {+ box-shadow: none !important;+ border: none;+ }++ .a-input-width {+ display: inline-block;+ position: absolute;+ height: 0;+ overflow: hidden;+ max-width: calc(100% - 40px);+ text-overflow: ellipsis;+ white-space: nowrap;+ }++}+.tag-selector-wrap--focus {+ color: var(--bs-body-color);+ background-color: var(--bs-body-bg);+ outline: 0;}diff --git a/ui/src/components/TagSelector/index.tsx b/ui/src/components/TagSelector/index.tsxindex 9d0d8df3..5afffc0d 100644--- a/ui/src/components/TagSelector/index.tsx+++ b/ui/src/components/TagSelector/index.tsx@@ -18,8 +18,8 @@*//* eslint-disable no-nested-ternary */-import { FC, useState, useEffect } from 'react';-import { Dropdown, FormControl, Button, Form } from 'react-bootstrap';+import { FC, useState, useEffect, useRef } from 'react';+import { Dropdown, Button, Form } from 'react-bootstrap';import { useTranslation } from 'react-i18next';import { marked } from 'marked';@@ -28,18 +28,18 @@ import classNames from 'classnames';import { useTagModal, useToast } from '@/hooks';import type * as Type from '@/common/interface';import { queryTags, useUserPermission } from '@/services';+// import { OutsideClickListener } from '@/components';import './index.scss';interface IProps {value?: Type.Tag[];onChange?: (tags: Type.Tag[]) => void;- onFocus?: () => void;- onBlur?: () => void;hiddenDescription?: boolean;hiddenCreateBtn?: boolean;- showRequiredTagText?: boolean;- alwaysShowAddBtn?: boolean;+ maxTagLength?: number;+ showRequiredTag?: boolean;+ autoFocus?: boolean;}let timer;@@ -47,28 +47,33 @@ let timer;const TagSelector: FC<IProps> = ({value = [],onChange,- onFocus = () => {},- onBlur = () => {},hiddenDescription = false,hiddenCreateBtn = false,- alwaysShowAddBtn = false,- showRequiredTagText = false,+ maxTagLength = 0,+ showRequiredTag = false,+ autoFocus = false,}) => {- const [initialValue, setInitialValue] = useState<Type.Tag[]>([...value]);+ const containerRef = useRef<HTMLDivElement>(null);+ const inputRef = useRef<HTMLInputElement>(null);+ const [initialized, setInitialized] = useState(false);+ const [focusState, setFocusState] = useState(autoFocus);+ const [showMenu, setShowMenu] = useState(false);const [currentIndex, setCurrentIndex] = useState<number>(0);const [repeatIndex, setRepeatIndex] = useState(-1);const [searchValue, setSearchValue] = useState<string>('');const [tags, setTags] = useState<Type.Tag[] | null>(null);+ const [requiredTags, setRequiredTags] = useState<Type.Tag[] | null>(null);const { t } = useTranslation('translation', { keyPrefix: 'tag_selector' });- const [visibleMenu, setVisibleMenu] = useState(false);const { data: userPermission } = useUserPermission('tag.add');+ const canAddTag =+ (maxTagLength > 0 && value?.length < maxTagLength) || maxTagLength === 0;const toast = useToast();const tagModal = useTagModal({onConfirm: (data) => {if (!(onChange instanceof Function)) {return;}- const findIndex = initialValue.findIndex(+ const findIndex = value.findIndex((item) => item.slug_name.toLowerCase() === data.slug_name.toLowerCase(),);if (findIndex === -1) {@@ -79,6 +84,7 @@ const TagSelector: FC<IProps> = ({parsed_text: marked(data.original_text),},]);+ setSearchValue('');} else {setRepeatIndex(findIndex);clearTimeout(timer);@@ -91,7 +97,7 @@ const TagSelector: FC<IProps> = ({const filterTags = (result) => {const tagArray: Type.Tag[] = [];- result.forEach((item) => {+ result?.forEach((item) => {const findIndex = value.findIndex((v) => {const tagName1 = v.slug_name.toLowerCase();const tagName2 =@@ -109,33 +115,56 @@ const TagSelector: FC<IProps> = ({return tagArray;};- useEffect(() => {- setInitialValue(value);- if (tags) {- const tagArray: Type.Tag[] = filterTags(tags || []);-- setTags(tagArray);+ const handleMenuShow = (bol: boolean) => {+ setShowMenu(bol);+ const ele = document.getElementById('a-dropdown-menu');+ if (ele) {+ if (bol) {+ ele.classList.add('show');+ } else {+ ele.classList.remove('show');+ }}- }, [value]);+ };++ const handleTagSelectorFocus = () => {+ setFocusState(true);+ inputRef.current?.focus();+ };++ const handleTagSelectorBlur = () => {+ setFocusState(false);+ setCurrentIndex(0);+ handleMenuShow(false);+ };const fetchTags = (str) => {+ if (!showRequiredTag && !str) {+ setTags([]);+ return;+ }queryTags(str).then((res) => {const tagArray: Type.Tag[] = filterTags(res || []);+ if (str === '') {+ setRequiredTags(res?.length > 5 ? res.slice(0, 5) : res);+ }+ handleMenuShow(tagArray.length > 0);setTags(tagArray?.length > 5 ? tagArray.slice(0, 5) : tagArray);});};- useEffect(() => {- fetchTags(searchValue);- }, [visibleMenu]);-const resetSearch = () => {setCurrentIndex(0);setSearchValue('');- setTags([]);+ if (canAddTag) {+ const tagArray: Type.Tag[] = filterTags(requiredTags);+ setTags(tagArray.length > 0 ? tagArray : []);+ } else {+ setTags([]);+ }};const handleClick = (val: Type.Tag) => {- const findIndex = initialValue.findIndex(+ const findIndex = value.findIndex((item) => item.slug_name.toLowerCase() === val.slug_name.toLowerCase(),);if (onChange instanceof Function && findIndex === -1) {@@ -171,21 +200,35 @@ const TagSelector: FC<IProps> = ({};const handleSearch = async (e: React.ChangeEvent<HTMLInputElement>) => {+ console.log('handleSearch');const searchStr = e.currentTarget.value.replace(';', '');setSearchValue(searchStr);+ const ele = document.querySelector('.a-input-width') as HTMLElement;+ if (ele.offsetWidth > 60) {+ inputRef.current?.setAttribute(+ 'style',+ `width:${ele.offsetWidth + 16}px`,+ );+ } else {+ inputRef.current?.setAttribute('style', 'width: 60px');+ }fetchTags(searchStr);};- const handleSelect = (eventKey) => {- setCurrentIndex(eventKey);- };const handleKeyDown = (e) => {e.stopPropagation();+ const { keyCode } = e;+ if (keyCode === 9) {+ handleTagSelectorBlur();+ return;+ }+ if (value.length > 0 && keyCode === 8 && !searchValue) {+ handleRemove(value[value.length - 1]);+ }if (!tags) {return;}- const { keyCode } = e;if (keyCode === 38 && currentIndex > 0) {setCurrentIndex(currentIndex - 1);@@ -196,8 +239,7 @@ const TagSelector: FC<IProps> = ({if (keyCode === 13 && currentIndex > -1) {e.preventDefault();-- if (tags.length === 0) {+ if (tags.length === 0 && searchValue) {tagModal.onShow(searchValue);return;}@@ -222,92 +264,160 @@ const TagSelector: FC<IProps> = ({}};+ const handleClickToggle = () => {+ const menuHasContent =+ (tags && tags?.length > 0) ||+ (searchValue && tags?.length === 0) ||+ (searchValue && !hiddenCreateBtn);+ if (canAddTag && menuHasContent) {+ handleMenuShow(true);+ } else {+ handleMenuShow(false);+ }+ };++ useEffect(() => {+ if (canAddTag) {+ const tagArray: Type.Tag[] = filterTags(requiredTags);+ setTags(tagArray.length > 0 ? tagArray : []);+ } else {+ setTags([]);+ }+ }, [value]);++ useEffect(() => {+ if (focusState && showRequiredTag) {+ fetchTags(searchValue);+ inputRef.current?.focus();+ }+ }, [focusState]);++ useEffect(() => {+ setInitialized(true);+ }, []);++ useEffect(() => {+ const handleOutsideClick = (event) => {+ if (+ initialized &&+ containerRef.current &&+ !containerRef.current?.contains(event.target)+ ) {+ handleTagSelectorBlur();+ }+ };+ document.addEventListener('click', handleOutsideClick);+ return () => {+ document.removeEventListener('click', handleOutsideClick);+ };+ }, [initialized]);++ useEffect(() => {+ // menu show+ const menuHasContent =+ (tags && tags?.length > 0) ||+ (searchValue && tags?.length === 0) ||+ (searchValue && !hiddenCreateBtn);+ if (focusState) {+ if (canAddTag && menuHasContent) {+ handleMenuShow(true);+ } else {+ handleMenuShow(false);+ }++ if ((tags && tags?.length < 5) || maxTagLength === 0) {+ inputRef.current?.focus();+ }+ }+ }, [focusState, tags, hiddenCreateBtn, searchValue, maxTagLength]);+return (- <div- className="tag-selector-wrap"- onFocus={onFocus}- onBlur={onBlur}- onKeyDown={handleKeyDown}>- <div className="d-flex flex-wrap m-n1">- {initialValue?.map((item, index) => {- return (+ <div ref={containerRef} className="position-relative">+ <div+ tabIndex={0}+ className={classNames(+ 'tag-selector-wrap form-control position-relative p-0',+ focusState ? 'tag-selector-wrap--focus' : '',+ )}+ onFocus={handleTagSelectorFocus}+ onKeyDown={handleKeyDown}>+ <div onClick={handleClickToggle}>+ <div+ className="d-flex flex-wrap m-n1"+ style={{ padding: '0.375rem 0.75rem' }}>+ {value?.map((item, index) => {+ return (+ <span+ key={item.slug_name}+ className={classNames(+ 'badge-tag rounded-1 m-1 flex-shrink-0',+ item.reserved && 'badge-tag-reserved',+ item.recommend && 'badge-tag-required',+ index === repeatIndex && 'bg-fade-out',+ )}>+ {item.display_name}+ <span+ className="ms-1 hover-hand"+ onMouseUp={() => handleRemove(item)}>+ ×+ </span>+ </span>+ );+ })}+ {canAddTag ? (+ <Form.Control+ // autoFocus+ autoComplete="off"+ style={{ width: '60px' }}+ ref={inputRef}+ className="a-input m-1"+ placeholder={t('add_btn')}+ value={searchValue}+ onChange={handleSearch}+ />+ ) : (+ <Form.Control+ autoComplete="off"+ className="a-input"+ style={{ width: '60px', position: 'absolute', zIndex: -1 }}+ autoFocus+ />+ )}+ <span className="a-input-width">{searchValue}</span>+ </div>+ </div>+ <Dropdown.Menu id="a-dropdown-menu" className="w-100" show={showMenu}>+ {!searchValue &&+ showRequiredTag &&+ tags &&+ tags.filter((v) => v.recommend)?.length > 0 && (+ <h6 className="dropdown-header">{t('tag_required_text')}</h6>+ )}++ {tags?.map((item, index) => {+ return (+ <Dropdown.Item+ key={item.slug_name}+ active={index === currentIndex}+ onClick={() => handleClick(item)}>+ {item.display_name}+ </Dropdown.Item>+ );+ })}+ {searchValue && tags?.length === 0 && (+ <Dropdown.Item disabled className="text-secondary">+ {t('no_result')}+ </Dropdown.Item>+ )}+ {!hiddenCreateBtn && searchValue && (<Button- key={item.slug_name}- className={classNames(- 'm-1 text-nowrap d-flex align-items-center',- index === repeatIndex && 'bg-fade-out',- )}- variant={`outline-${- item.reserved ? 'danger' : item.recommend ? 'dark' : 'secondary'- }`}- size="sm">- {item.display_name}- <span className="ms-1" onMouseUp={() => handleRemove(item)}>- ×- </span>+ variant="link"+ className="px-3 btn-no-border w-100 text-start"+ onClick={handleCreate}>+ + {t('create_btn')}</Button>- );- })}- {initialValue?.length < 5 || alwaysShowAddBtn ? (- <Dropdown onSelect={handleSelect} onToggle={setVisibleMenu}>- <Dropdown.Toggle- className={classNames('m-1')}- variant="outline-secondary"- size="sm">- <span className="me-1">+</span>- {t('add_btn')}- </Dropdown.Toggle>- <Dropdown.Menu>- {visibleMenu && (- <Dropdown.Header>- <Form- onSubmit={(e) => {- e.preventDefault();- }}>- <FormControl- autoFocus- type="search"- placeholder={t('search_tag')}- value={searchValue}- onChange={handleSearch}- />- </Form>- </Dropdown.Header>- )}- {!searchValue &&- showRequiredTagText &&- tags &&- tags.filter((v) => v.recommend)?.length > 0 && (- <h6 className="dropdown-header">{t('tag_required_text')}</h6>- )}-- {tags?.map((item, index) => {- return (- <Dropdown.Item- key={item.slug_name}- eventKey={index}- active={index === currentIndex}- onClick={() => handleClick(item)}>- {item.display_name}- </Dropdown.Item>- );- })}- {searchValue && tags && tags.length === 0 && (- <Dropdown.Item disabled className="text-secondary">- {t('no_result')}- </Dropdown.Item>- )}- {!hiddenCreateBtn && searchValue && (- <Button- variant="link"- className="px-3 btn-no-border w-100 text-start"- onClick={handleCreate}>- + {t('create_btn')}- </Button>- )}- </Dropdown.Menu>- </Dropdown>- ) : null}+ )}+ </Dropdown.Menu></div>{!hiddenDescription && <Form.Text>{t('hint')}</Form.Text>}</div>diff --git a/ui/src/hooks/useTagModal/index.tsx b/ui/src/hooks/useTagModal/index.tsxindex fd04e79c..50cbbe27 100644--- a/ui/src/hooks/useTagModal/index.tsx+++ b/ui/src/hooks/useTagModal/index.tsx@@ -23,10 +23,11 @@ import { useTranslation } from 'react-i18next';import ReactDOM from 'react-dom/client';+import { TAG_SLUG_NAME_MAX_LENGTH } from '@/common/constants';+const div = document.createElement('div');const root = ReactDOM.createRoot(div);-const MAX_LENGTH = 35;interface IProps {title?: string;onConfirm?: (formData: any) => void;@@ -85,7 +86,7 @@ const useTagModal = (props: IProps = {}) => {isInvalid: true,errorMsg: t('form.fields.display_name.msg.empty'),};- } else if (displayName.value.length > MAX_LENGTH) {+ } else if (displayName.value.length > TAG_SLUG_NAME_MAX_LENGTH) {bol = false;formData.displayName = {value: displayName.value,@@ -107,7 +108,7 @@ const useTagModal = (props: IProps = {}) => {isInvalid: true,errorMsg: t('form.fields.slug_name.msg.empty'),};- } else if (slugName.value.length > MAX_LENGTH) {+ } else if (slugName.value.length > TAG_SLUG_NAME_MAX_LENGTH) {bol = false;formData.slugName = {value: slugName.value,diff --git a/ui/src/index.scss b/ui/src/index.scssindex e9535748..8dd77087 100644--- a/ui/src/index.scss+++ b/ui/src/index.scss@@ -20,9 +20,10 @@@import 'common/variable';@import '~bootstrap/scss/bootstrap';@import '~bootstrap-icons';+@import 'common/color';.bg-gray-300 {- background-color: $gray-300;+ background-color: var(--an-gray-300);}.focus {@@ -132,7 +133,7 @@ img[src=""] {}.bg-f5 {- background-color: #f5f5f5;+ background-color: var(--an-f5);}.btn-no-border,@@ -198,7 +199,7 @@ img[src=""] {}.warning {- background-color: #fff3cd80;+ background-color: var(--an-inbox-warning);}.fit-content {@@ -246,14 +247,14 @@ img[src=""] {}p {> code {- background-color: #e9ecef;- color: #212529;+ background-color: var(--an-e9ecef);+ color: var(--an-212529);padding: 2px 4px;border-radius: 0.25rem;}}pre {- background-color: #e9ecef;+ background-color: var(--an-e9ecef);border-radius: 0.25rem;padding: 1rem;}@@ -261,9 +262,9 @@ img[src=""] {border-left: 0.25rem solid #ced4da;padding: 1rem;color: #6c757d;- background-color: #e9ecef;+ background-color: var(--an-e9ecef);p {- color: $body-color;+ color: var(--bs-body-color);}> p:last-child {margin-bottom: 0;@@ -275,6 +276,9 @@ img[src=""] {word-break: initial;}}+ ol ol,ol ul,ul ol,ul ul {+ margin-bottom: 1rem;+ }}.upload-img-wrap {diff --git a/ui/src/pages/Admin/Login/index.tsx b/ui/src/pages/Admin/Login/index.tsxindex 7355a23e..c58a293b 100644--- a/ui/src/pages/Admin/Login/index.tsx+++ b/ui/src/pages/Admin/Login/index.tsx@@ -39,7 +39,7 @@ const Index: FC = () => {type: 'boolean',title: t('membership.title'),description: t('membership.text'),- default: false,+ default: true,},allow_email_registrations: {type: 'boolean',diff --git a/ui/src/pages/Admin/Privileges/index.tsx b/ui/src/pages/Admin/Privileges/index.tsxindex 4bbf573d..dbe58f0c 100644--- a/ui/src/pages/Admin/Privileges/index.tsx+++ b/ui/src/pages/Admin/Privileges/index.tsx@@ -27,8 +27,10 @@ import {getPrivilegeSetting,putPrivilegeSetting,AdminSettingsPrivilege,+ AdminSettingsPrivilegeReq,} from '@/services';import { handleFormError } from '@/utils';+import { ADMIN_PRIVILEGE_CUSTOM_LEVEL } from '@/common/constants';const Index: FC = () => {const { t } = useTranslation('translation', {@@ -47,8 +49,8 @@ const Index: FC = () => {});const [formData, setFormData] = useState<FormDataType>(initFormData(schema));- const setFormConfig = (selectedLevel: number = 1) => {- selectedLevel = Number(selectedLevel);+ const setFormConfig = (state: FormDataType) => {+ const selectedLevel = Number(state.level.value);const levelOptions = privilege?.options;const curLevel = levelOptions?.find((li) => {return li.level === selectedLevel;@@ -77,7 +79,17 @@ const Index: FC = () => {};uiState[li.key] = {'ui:options': {- readOnly: true,+ readOnly: curLevel.level !== ADMIN_PRIVILEGE_CUSTOM_LEVEL,+ validator: (value: string) => {+ const val = Number(value);+ if (Number.isNaN(val)) {+ return 'the input should be number';+ }+ if (val < 1) {+ return 'number should be equal or larger than 1';+ }+ return true;+ },},};});@@ -101,13 +113,36 @@ const Index: FC = () => {const onSubmit = (evt: FormEvent) => {evt.preventDefault();evt.stopPropagation();- const lv = Number(formData.level.value);- putPrivilegeSetting(lv)++ const reqParams: AdminSettingsPrivilegeReq = {+ level: Number(formData.level.value),+ custom_privileges: [],+ };++ if (reqParams.level === ADMIN_PRIVILEGE_CUSTOM_LEVEL) {+ // construct custom level request data+ Object.entries(formData).forEach(([key, value]) => {+ if (key === 'level') {+ return;+ }+ reqParams.custom_privileges?.push({+ key,+ value: Number(value.value),+ });+ });+ }++ putPrivilegeSetting(reqParams).then(() => {Toast.onShow({msg: t('update', { keyPrefix: 'toast' }),variant: 'success',});+ if (reqParams.level === ADMIN_PRIVILEGE_CUSTOM_LEVEL) {+ getPrivilegeSetting().then((resp) => {+ setPrivilege(resp);+ });+ }}).catch((err) => {if (err.isError) {@@ -121,7 +156,13 @@ const Index: FC = () => {if (!privilege) {return;}- setFormConfig(privilege.selected_level);+ setFormConfig({+ level: {+ value: privilege.selected_level,+ isInvalid: false,+ errorMsg: '',+ },+ });}, [privilege]);useEffect(() => {getPrivilegeSetting().then((resp) => {@@ -129,7 +170,15 @@ const Index: FC = () => {});}, []);const handleOnChange = (state) => {- setFormConfig(state.level.value);+ // if updated values in Custom form+ if (+ state.level.value === ADMIN_PRIVILEGE_CUSTOM_LEVEL &&+ formData?.level?.value === state.level.value+ ) {+ setFormData(state);+ } else {+ setFormConfig(state);+ }};return (diff --git a/ui/src/pages/Admin/SettingsUsers/index.tsx b/ui/src/pages/Admin/SettingsUsers/index.tsxindex 106c5923..a83c2e3b 100644--- a/ui/src/pages/Admin/SettingsUsers/index.tsx+++ b/ui/src/pages/Admin/SettingsUsers/index.tsx@@ -137,7 +137,7 @@ const Index: FC = () => {'ui:widget': 'switch','ui:options': {label: t('allow_update_location.label'),- fieldClassName: 'mb-3',+ field_class_name: 'mb-3',simplify: true,},},diff --git a/ui/src/pages/Admin/Themes/index.tsx b/ui/src/pages/Admin/Themes/index.tsxindex 34cb42d9..346e2e05 100644--- a/ui/src/pages/Admin/Themes/index.tsx+++ b/ui/src/pages/Admin/Themes/index.tsx@@ -26,6 +26,7 @@ import { SchemaForm, JSONSchema, initFormData, UISchema } from '@/components';import { useToast } from '@/hooks';import { handleFormError } from '@/utils';import { themeSettingStore } from '@/stores';+import { setupAppTheme } from '@/utils/localize';const Index: FC = () => {const { t } = useTranslation('translation', {@@ -44,10 +45,20 @@ const Index: FC = () => {enumNames: themeSetting?.theme_options?.map((_) => _.label),default: themeSetting?.theme_options?.[0]?.value,},+ color_scheme: {+ type: 'string',+ title: t('color_scheme.label'),+ enum: ['system', 'light', 'dark'],+ enumNames: [+ t('system_setting', { keyPrefix: 'btns' }),+ t('light', { keyPrefix: 'btns' }),+ t('dark', { keyPrefix: 'btns' }),+ ],+ default: themeSetting?.color_scheme,+ },navbar_style: {type: 'string',title: t('navbar_style.label'),- description: t('navbar_style.text'),enum: ['colored', 'light'],enumNames: ['Colored', 'Light'],default: 'colored',@@ -64,23 +75,45 @@ const Index: FC = () => {themes: {'ui:widget': 'select',},+ color_scheme: {+ 'ui:widget': 'select',+ },navbar_style: {'ui:widget': 'select',},primary_color: {+ 'ui:widget': 'input_group','ui:options': {inputType: 'color',+ suffixBtnOptions: {+ text: '',+ variant: 'outline-secondary',+ iconName: 'arrow-counterclockwise',+ actionType: 'click',+ title: t('reset', { keyPrefix: 'btns' }),+ // eslint-disable-next-line @typescript-eslint/no-use-before-define+ clickCallback: () => resetPrimaryScheme(),+ },},},};+const [formData, setFormData] = useState(initFormData(schema));const { update: updateThemeSetting } = themeSettingStore((_) => _);++ const resetPrimaryScheme = () => {+ const formMeta = { ...formData };+ formMeta.primary_color.value = '#0033FF';+ setFormData({ ...formMeta });+ };+const onSubmit = (evt) => {evt.preventDefault();evt.stopPropagation();const themeName = formData.themes.value;const reqParams: Type.AdminSettingsTheme = {theme: themeName,+ color_scheme: formData.color_scheme.value,theme_config: {[themeName]: {navbar_style: formData.navbar_style.value,@@ -96,6 +129,7 @@ const Index: FC = () => {variant: 'success',});updateThemeSetting(reqParams);+ setupAppTheme();}).catch((err) => {if (err.isError) {@@ -115,6 +149,7 @@ const Index: FC = () => {formMeta.themes.value = themeName;formMeta.navbar_style.value = themeConfig?.navbar_style;formMeta.primary_color.value = themeConfig?.primary_color;+ formData.color_scheme.value = setting?.color_scheme || 'system';setFormData({ ...formMeta });}});diff --git a/ui/src/pages/Install/components/FourthStep/index.tsx b/ui/src/pages/Install/components/FourthStep/index.tsxindex 7a4a3fca..65ffd9d5 100644--- a/ui/src/pages/Install/components/FourthStep/index.tsx+++ b/ui/src/pages/Install/components/FourthStep/index.tsx@@ -259,7 +259,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {label={t('login_required.switch')}checked={data.login_required.value}onChange={(e) => {- console.log(e.target.checked);changeCallback({login_required: {value: e.target.checked,diff --git a/ui/src/pages/Layout/index.tsx b/ui/src/pages/Layout/index.tsxindex 1be44d9d..f0a061bd 100644--- a/ui/src/pages/Layout/index.tsx+++ b/ui/src/pages/Layout/index.tsx@@ -34,6 +34,7 @@ import {HttpErrorContent,} from '@/components';import { LoginToContinueModal } from '@/components/Modal';+import { changeTheme } from '@/utils';const Layout: FC = () => {const location = useLocation();@@ -47,6 +48,23 @@ const Layout: FC = () => {useEffect(() => {httpStatusReset();}, [location]);++ useEffect(() => {+ const systemThemeQuery = window.matchMedia('(prefers-color-scheme: dark)');+ function handleSystemThemeChange(event) {+ if (event.matches) {+ changeTheme('dark');+ } else {+ changeTheme('light');+ }+ }++ systemThemeQuery.addListener(handleSystemThemeChange);++ return () => {+ systemThemeQuery.removeListener(handleSystemThemeChange);+ };+ }, []);return (<HelmetProvider><PageTags />diff --git a/ui/src/pages/Questions/Ask/index.tsx b/ui/src/pages/Questions/Ask/index.tsxindex 1a852f11..165e061a 100644--- a/ui/src/pages/Questions/Ask/index.tsx+++ b/ui/src/pages/Questions/Ask/index.tsx@@ -417,6 +417,7 @@ const Ask = () => {onChange={handleTitleChange}placeholder={t('form.fields.title.placeholder')}autoFocus+ contentEditable/><Form.Control.Feedback type="invalid">@@ -460,7 +461,8 @@ const Ask = () => {<TagSelectorvalue={formData.tags.value}onChange={handleTagsChange}- showRequiredTagText+ showRequiredTag+ maxTagLength={5}/><Form.Control.Feedback type="invalid">{formData.tags.errorMsg}@@ -475,6 +477,7 @@ const Ask = () => {isInvalid={formData.edit_summary.isInvalid}placeholder={t('form.fields.edit_summary.placeholder')}onChange={handleSummaryChange}+ contentEditable/><Form.Control.Feedback type="invalid">{formData.edit_summary.errorMsg}diff --git a/ui/src/pages/Questions/Detail/components/Alert/index.tsx b/ui/src/pages/Questions/Detail/components/Alert/index.tsxindex c854bf35..14973373 100644--- a/ui/src/pages/Questions/Detail/components/Alert/index.tsx+++ b/ui/src/pages/Questions/Detail/components/Alert/index.tsx@@ -35,7 +35,7 @@ const Index: FC<Props> = ({ data }) => {{data.msg.indexOf('http') > -1 ? (<p>{data.description}{' '}- <a href={data.msg} style={{ color: '#055160' }}>+ <a href={data.msg} className="alert-exist"><strong>{t('question_detail.show_exist')}</strong></a></p>diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.scss b/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.scssindex 1ea373dc..ad72a4d1 100644--- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.scss+++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.scss@@ -18,12 +18,22 @@*/.people-dropdown {- .dropdown-menu {- width: 15rem;- }+ position: absolute;+ top: 34px;+ left: 0;+ width: 100%;.dropdown-item.active {- color: #212529;- background-color: #e9ecef;+ color: var(--bs-body-color);+ background-color: var(--an-invite-answer-item-active);+ }+ .check-cover {+ width: 18px;+ height: 18px;+ position: absolute;+ top: 0;+ bottom: 0;+ left: 0;+ margin: auto 0;}}diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.tsx b/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.tsxindex 2ff288f7..130dd5dc 100644--- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.tsx+++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/PeopleDropdown.tsx@@ -30,42 +30,48 @@ import './PeopleDropdown.scss';interface Props {selectedPeople: Type.UserInfoBase[] | undefined;onSelect: (people: Type.UserInfoBase) => void;+ saveInviteUsers: () => void;visible?: boolean;}+interface UserInfoCheck extends Type.UserInfoBase {+ checked?: boolean;+}+const Index: FC<Props> = ({selectedPeople = [],visible = false,onSelect,+ saveInviteUsers,}) => {const { user: currentUser } = loggedUserInfoStore();const { t } = useTranslation('translation', {keyPrefix: 'invite_to_answer',});- const [toggleState, setToggleState] = useState(false);- const [peopleList, setPeopleList] = useState<Type.UserInfoBase[]>([]);- const [currentIndex, setCurrentIndex] = useState(0);+ const [peopleList, setPeopleList] = useState<UserInfoCheck[]>([]);+ const [currentIndex, setCurrentIndex] = useState(-1);const [searchValue, setSearchValue] = useState('');const filterAndSetPeople = (source) => {- if (!toggleState) {- return;- }const filteredPeople: Type.UserInfoBase[] = [];source.forEach((p) => {- if (currentUser && currentUser.username === p.username) {+ if (+ currentUser &&+ currentUser.role_id === 1 &&+ currentUser.username === p.username+ ) {return;}- if (selectedPeople.find((_) => _.username === p.username)) {+ if (selectedPeople?.find((_) => _.username === p.username)) {return;}filteredPeople.push(p);});- setPeopleList(filteredPeople);+ setPeopleList([...selectedPeople, ...filteredPeople]);};const searchPeople = (s) => {if (!s) {- setPeopleList([]);+ setPeopleList([...selectedPeople]);return;}userSearchByName(s).then((resp) => {@@ -79,7 +85,7 @@ const Index: FC<Props> = ({};const resetSearch = () => {- setCurrentIndex(0);+ setCurrentIndex(-1);setSearchValue('');setPeopleList([]);};@@ -92,8 +98,6 @@ const Index: FC<Props> = ({if (people) {onSelect(people);}-- resetSearch();};const handleKeyDown = (evt) => {@@ -117,69 +121,83 @@ const Index: FC<Props> = ({};useEffect(() => {- filterAndSetPeople(peopleList);- }, [selectedPeople]);-- useEffect(() => {- searchPeople(searchValue);- }, [toggleState]);-- useEffect(() => {- if (!visible && toggleState) {- setToggleState(false);+ if (visible && selectedPeople.length > 0) {+ setPeopleList(selectedPeople);+ }+ if (!visible) {+ resetSearch();}}, [visible]);return visible ? (<Dropdown- className="d-inline-flex people-dropdown"+ autoClose="outside"+ show+ className="people-dropdown"onSelect={handleSelect}onKeyDown={handleKeyDown}- onToggle={setToggleState}>- <Dropdown.Toggle- className="m-1 no-toggle"- size="sm"- variant="outline-secondary">- <span className="me-1">+</span>- {t('add')}- </Dropdown.Toggle>-- <Dropdown.Menu show={toggleState}>- <Dropdown.Header className="px-2 py-0">- {toggleState ? (- <Form.Control- autoFocus- type="search"- placeholder={t('search')}- value={searchValue}- onChange={handleSearch}- />- ) : null}- </Dropdown.Header>- {peopleList.map((p, idx) => {- return (- <Dropdown.Item- key={p.username}- eventKey={idx}- active={idx === currentIndex}- className={idx === 0 ? 'mt-2' : ''}>- <div className="d-flex align-items-center text-nowrap">- <Avatar- avatar={p.avatar}- size="24"- alt={p.display_name}- className="rounded-1"- />- <div className="d-flex flex-wrap text-truncate">- <span className="ms-2 text-truncate">{p.display_name}</span>- <small className="text-secondary text-truncate ms-2">- @{p.username}- </small>- </div>- </div>- </Dropdown.Item>- );- })}+ onToggle={(state) => {+ if (!state) {+ saveInviteUsers();+ }+ }}>+ <Dropdown.Menu+ renderOnMount+ show+ className="w-100 py-0 position-relative">+ <div className="p-3">+ <Form.Control+ type="search"+ autoFocus+ placeholder={t('search')}+ value={searchValue}+ onChange={handleSearch}+ />+ </div>+ <div className={`${peopleList.length > 0 ? 'py-2 border-top' : ''}`}>+ {peopleList.map((p, idx) => {+ return (+ <Dropdown.Item+ key={p.username}+ eventKey={idx}+ onFocus={() => {+ setCurrentIndex(idx);+ }}+ active={idx === currentIndex}>+ <Form.Check+ type="checkbox"+ id={p.username}+ className="position-relative">+ <Form.Check.Input+ type="checkbox"+ tabIndex={-1}+ checked={Boolean(+ selectedPeople?.find((v) => v.id === p.id),+ )}+ onChange={() => {}}+ />+ <div className="check-cover" />+ <Form.Check.Label className="d-flex align-items-center text-nowrap">+ <Avatar+ avatar={p.avatar}+ size="24"+ alt={p.display_name}+ className="rounded-1"+ />+ <div className="d-flex flex-wrap text-truncate">+ <span className="ms-2 text-truncate">+ {p.display_name}+ </span>+ <small className="text-secondary text-truncate ms-2">+ @{p.username}+ </small>+ </div>+ </Form.Check.Label>+ </Form.Check>+ </Dropdown.Item>+ );+ })}+ </div></Dropdown.Menu></Dropdown>) : null;diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.scss b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.scssnew file mode 100644index 00000000..0f3739e0--- /dev/null+++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.scss@@ -0,0 +1,32 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++.invite-answer-card {+ .card-header {+ border: var(--bs-border-width) solid var(--bs-border-color-translucent);+ }++ .card-body {+ border: var(--bs-border-width) solid var(--bs-border-color-translucent);+ border-top: 0;+ border-bottom-left-radius: var(--bs-border-radius);+ border-bottom-right-radius: var(--bs-border-radius);++ }+}diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsxindex b959ff0e..82f9fa27 100644--- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx+++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx@@ -31,6 +31,8 @@ import { useCaptchaModal } from '@/hooks';import PeopleDropdown from './PeopleDropdown';+import './index.scss';+interface Props {questionId: string;readOnly?: boolean;@@ -39,9 +41,9 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {const { t } = useTranslation('translation', {keyPrefix: 'invite_to_answer',});- const MAX_ASK_NUMBER = 5;+const [editing, setEditing] = useState(false);- const [users, setUsers] = useState<Type.UserInfoBase[]>();+ const [users, setUsers] = useState<Type.UserInfoBase[]>([]);const iaCaptcha = useCaptchaModal('invitation_answer');const initInviteUsers = () => {@@ -60,20 +62,18 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {};const updateInviteUsers = (user: Type.UserInfoBase) => {- let userList = [user];- if (users?.length) {- userList = [...users, user];+ const userID = users?.find((_) => _.id === user.id);+ let userList: any = [...(users || [])];+ if (userID) {+ userList = userList?.filter((_) => {+ return _.id !== user.id;+ });+ } else {+ userList.push(user);}setUsers(userList);};- const removeInviteUser = (user: Type.UserInfoBase) => {- const inviteUsers = users!.filter((_) => {- return _.username !== user.username;- });- setUsers(inviteUsers);- };-const saveInviteUsers = () => {if (!users) {return;@@ -93,7 +93,7 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {if (ex.isError) {iaCaptcha.handleCaptchaError(ex.list);}- console.log('ex: ', ex);+ console.error('putInviteUser error: ', ex);});});};@@ -102,11 +102,6 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {initInviteUsers();}, [questionId]);- const showAddButton = editing && (!users || users.length < MAX_ASK_NUMBER);- const showInviteFeat = !editing && users?.length === 0;- const showInviteButton = showInviteFeat && !readOnly;- const showEditButton = !readOnly && !editing && users?.length;- const showSaveButton = !readOnly && editing;const showEmpty = readOnly && users?.length === 0;if (showEmpty) {@@ -114,53 +109,21 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {}return (- <Card className="mt-4">+ <Card className="invite-answer-card position-relative border-0 mb-4"><Card.Header className="text-nowrap d-flex justify-content-between text-capitalize">{t('title')}- {showSaveButton ? (- <Button onClick={saveInviteUsers} variant="link" className="p-0">- {t('save', { keyPrefix: 'btns' })}- </Button>- ) : null}- {showEditButton ? (+ {!readOnly && (<ButtononClick={() => setEditing(true)}variant="link"className="p-0">{t('edit', { keyPrefix: 'btns' })}</Button>- ) : null}+ )}</Card.Header>- <Card.Body>- <div- className={classNames(- 'd-flex align-items-center flex-wrap',- editing ? 'm-n1' : ' mx-n2 my-n1',- )}>+ <Card.Body className={classNames('position-relative')}>+ <div className={classNames('d-flex align-items-center flex-wrap m-n1')}>{users?.map((user) => {- if (editing) {- return (- <Button- key={user.username}- className="m-1 d-inline-flex flex-nowrap"- size="sm"- variant="outline-secondary">- <Avatar- avatar={user.avatar}- size="20"- className="rounded-1"- alt={user.display_name}- />- <span className="text-break ms-2">{user.display_name}</span>- {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}- <span- className="px-1 me-n1"- onClick={() => removeInviteUser(user)}>- ×- </span>- </Button>- );- }return (<Linkkey={user.username}@@ -176,27 +139,19 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {</Link>);})}- <PeopleDropdown- visible={showAddButton}- selectedPeople={users}- onSelect={updateInviteUsers}- />- </div>- {showInviteFeat ? (- <>+ {users?.length === 0 ? (<div className="text-muted">{t('desc')}</div>- {showInviteButton ? (- <Button- size="sm"- variant="outline-primary"- className="mt-3"- onClick={() => setEditing(true)}>- {t('invite')}- </Button>- ) : null}- </>- ) : null}+ ) : null}+ </div></Card.Body>+ {editing && (+ <PeopleDropdown+ visible={editing}+ selectedPeople={users}+ onSelect={updateInviteUsers}+ saveInviteUsers={saveInviteUsers}+ />+ )}</Card>);};diff --git a/ui/src/pages/Questions/Detail/index.scss b/ui/src/pages/Questions/Detail/index.scssindex 925ac9f3..5db9050b 100644--- a/ui/src/pages/Questions/Detail/index.scss+++ b/ui/src/pages/Questions/Detail/index.scss@@ -18,7 +18,10 @@*/.answer-item {- border-top: 1px solid rgba(33, 37, 41, 0.25);+ border-top: 1px solid var(--an-answer-item-border-top);+}+.alert-exist {+ color: var(--an-alert-exist-color);}@media screen and (max-width: 768px) {diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsxindex 3729fc8f..aac8e184 100644--- a/ui/src/pages/Questions/Detail/index.tsx+++ b/ui/src/pages/Questions/Detail/index.tsx@@ -294,13 +294,13 @@ const Index = () => {</Col><Col className="page-right-side mt-4 mt-xl-0"><CustomSidebar />- <RelatedQuestions id={question?.id || ''} />{showInviteToAnswer ? (<InviteToAnswerquestionId={question.id}readOnly={!canInvitePeople}/>) : null}+ <RelatedQuestions id={question?.id || ''} /></Col></Row>);diff --git a/ui/src/pages/Questions/EditAnswer/index.scss b/ui/src/pages/Questions/EditAnswer/index.scssindex 9bae8ebe..0d7ce9c6 100644--- a/ui/src/pages/Questions/EditAnswer/index.scss+++ b/ui/src/pages/Questions/EditAnswer/index.scss@@ -27,6 +27,10 @@height: calc(100% - 12px);overflow-y: scroll;z-index: 1;+ background: var(--an-white);+ }+ img {+ max-width: 100%;}.scroll-bar {height: 12px;@@ -46,6 +50,9 @@transform: scale(110, 1);height: 100%;}+ .resize-bottom::-webkit-resizer {+ border: none;+ }.resize-bottom + .line {left: 0;width: 100%;diff --git a/ui/src/pages/Questions/EditAnswer/index.tsx b/ui/src/pages/Questions/EditAnswer/index.tsxindex d693794d..fbb3e327 100644--- a/ui/src/pages/Questions/EditAnswer/index.tsx+++ b/ui/src/pages/Questions/EditAnswer/index.tsx@@ -73,7 +73,7 @@ const Index = () => {const [contentChanged, setContentChanged] = useState(false);const editCaptcha = useCaptchaModal('edit');- useLayoutEffect(() => {+ useEffect(() => {if (data?.info?.content) {setFormData({...formData,@@ -227,7 +227,7 @@ const Index = () => {<div className="question-content-wrap"><divref={questionContentRef}- className="content position-absolute top-0 w-100 bg-white"+ className="content position-absolute top-0 w-100"dangerouslySetInnerHTML={{ __html: data?.question.html }}/><div@@ -297,6 +297,7 @@ const Index = () => {defaultValue={formData.description.value}isInvalid={formData.description.isInvalid}placeholder={t('form.fields.edit_summary.placeholder')}+ contentEditable/><Form.Control.Feedback type="invalid">{formData.description.errorMsg}diff --git a/ui/src/pages/Review/index.tsx b/ui/src/pages/Review/index.tsxindex 087ecad7..927e95a1 100644--- a/ui/src/pages/Review/index.tsx+++ b/ui/src/pages/Review/index.tsx@@ -68,7 +68,7 @@ const Index: FC = () => {resolveNextOne(resp, pageNumber);}).catch((ex) => {- console.log('ex: ', ex);+ console.error('review next error: ', ex);});};const reviewInfo = unreviewed_info?.content;@@ -85,7 +85,7 @@ const Index: FC = () => {queryNextOne(page);}).catch((ex) => {- console.log('ex: ', ex);+ console.error('revisionAudit approve error: ', ex);}).finally(() => {setIsLoading(false);@@ -101,7 +101,7 @@ const Index: FC = () => {queryNextOne(page);}).catch((ex) => {- console.log('ex: ', ex);+ console.error('revisionAudit reject error: ', ex);}).finally(() => {setIsLoading(false);diff --git a/ui/src/pages/Tags/Create/index.tsx b/ui/src/pages/Tags/Create/index.tsxindex 485c7cd6..8b3b12bf 100644--- a/ui/src/pages/Tags/Create/index.tsx+++ b/ui/src/pages/Tags/Create/index.tsx@@ -30,6 +30,7 @@ import { loggedUserInfoStore } from '@/stores';import type * as Type from '@/common/interface';import { createTag } from '@/services';import { handleFormError } from '@/utils';+import { TAG_SLUG_NAME_MAX_LENGTH } from '@/common/constants';interface FormDataItem {displayName: Type.FormValue<string>;@@ -104,10 +105,69 @@ const Index = () => {description: { ...formData.description, value, isInvalid: false },});+ const checkValidated = (): boolean => {+ let bol = true;+ const { displayName, slugName } = formData;++ if (!displayName.value) {+ bol = false;+ formData.displayName = {+ value: '',+ isInvalid: true,+ errorMsg: t('form.fields.display_name.msg.empty'),+ };+ } else if (displayName.value.length > TAG_SLUG_NAME_MAX_LENGTH) {+ bol = false;+ formData.displayName = {+ value: displayName.value,+ isInvalid: true,+ errorMsg: t('form.fields.display_name.msg.range'),+ };+ } else {+ formData.displayName = {+ value: displayName.value,+ isInvalid: false,+ errorMsg: '',+ };+ }++ if (!slugName.value) {+ bol = false;+ formData.slugName = {+ value: '',+ isInvalid: true,+ errorMsg: t('form.fields.slug_name.msg.empty'),+ };+ } else if (slugName.value.length > TAG_SLUG_NAME_MAX_LENGTH) {+ bol = false;+ formData.slugName = {+ value: slugName.value,+ isInvalid: true,+ errorMsg: t('form.fields.slug_name.msg.range'),+ };+ } else {+ formData.slugName = {+ value: slugName.value,+ isInvalid: false,+ errorMsg: '',+ };+ }++ setFormData({+ ...formData,+ });+ return bol;+ };+const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {event.preventDefault();event.stopPropagation();setContentChanged(false);++ if (!checkValidated()) {+ return;+ }+const params = {display_name: formData.displayName.value,slug_name: formData.slugName.value,diff --git a/ui/src/pages/Tags/Edit/index.tsx b/ui/src/pages/Tags/Edit/index.tsxindex e5ddc4b2..0670b946 100644--- a/ui/src/pages/Tags/Edit/index.tsx+++ b/ui/src/pages/Tags/Edit/index.tsx@@ -29,6 +29,7 @@ import { usePageTags, usePromptWithUnload } from '@/hooks';import { Editor, EditorRef } from '@/components';import { loggedUserInfoStore } from '@/stores';import type * as Type from '@/common/interface';+import { TAG_SLUG_NAME_MAX_LENGTH } from '@/common/constants';import { useTagInfo, modifyTag, useQueryRevisions } from '@/services';interface FormDataItem {@@ -123,14 +124,51 @@ const Index = () => {const checkValidated = (): boolean => {let bol = true;- const { slugName } = formData;+ const { displayName, slugName } = formData;++ if (!displayName.value) {+ bol = false;+ formData.displayName = {+ value: '',+ isInvalid: true,+ errorMsg: t('form.fields.display_name.msg.empty', {+ keyPrefix: 'tag_modal',+ }),+ };+ } else if (displayName.value.length > TAG_SLUG_NAME_MAX_LENGTH) {+ bol = false;+ formData.displayName = {+ value: displayName.value,+ isInvalid: true,+ errorMsg: t('form.fields.display_name.msg.range', {+ keyPrefix: 'tag_modal',+ }),+ };+ } else {+ formData.displayName = {+ value: displayName.value,+ isInvalid: false,+ errorMsg: '',+ };+ }if (!slugName.value) {bol = false;formData.slugName = {value: '',isInvalid: true,- errorMsg: '标题不能为空',+ errorMsg: t('form.fields.slug_name.msg.empty', {+ keyPrefix: 'tag_modal',+ }),+ };+ } else if (slugName.value.length > TAG_SLUG_NAME_MAX_LENGTH) {+ bol = false;+ formData.slugName = {+ value: slugName.value,+ isInvalid: true,+ errorMsg: t('form.fields.slug_name.msg.range', {+ keyPrefix: 'tag_modal',+ }),};} else {formData.slugName = {@@ -215,7 +253,9 @@ const Index = () => {<Col className="page-main flex-auto"><Form noValidate onSubmit={handleSubmit}><Form.Group controlId="revision" className="mb-3">- <Form.Label>{t('form.fields.revision.label')}</Form.Label>+ <Form.Label>+ {t('form.fields.revision.label', { keyPrefix: 'tag_modal' })}+ </Form.Label><Form.Select onChange={handleSelectedRevision}>{revisions.map(({ create_at, reason, user_info }, index) => {const date = dayjs(create_at * 1000)@@ -235,7 +275,11 @@ const Index = () => {</Form.Select></Form.Group><Form.Group controlId="display_name" className="mb-3">- <Form.Label>{t('form.fields.display_name.label')}</Form.Label>+ <Form.Label>+ {t('form.fields.display_name.label', {+ keyPrefix: 'tag_modal',+ })}+ </Form.Label><Form.Controlvalue={formData.displayName.value}isInvalid={formData.displayName.isInvalid}@@ -248,21 +292,27 @@ const Index = () => {</Form.Control.Feedback></Form.Group><Form.Group controlId="slug_name" className="mb-3">- <Form.Label>{t('form.fields.slug_name.label')}</Form.Label>+ <Form.Label>+ {t('form.fields.slug_name.label', { keyPrefix: 'tag_modal' })}+ </Form.Label><Form.Controlvalue={formData.slugName.value}isInvalid={formData.slugName.isInvalid}disabled={role_id !== 2 && role_id !== 3}onChange={handleSlugNameChange}/>- <Form.Text as="div">{t('form.fields.slug_name.info')}</Form.Text>+ <Form.Text as="div">+ {t('form.fields.slug_name.desc', { keyPrefix: 'tag_modal' })}+ </Form.Text><Form.Control.Feedback type="invalid">{formData.slugName.errorMsg}</Form.Control.Feedback></Form.Group><Form.Group controlId="description" className="mt-4">- <Form.Label>{t('form.fields.desc.label')}</Form.Label>+ <Form.Label>+ {t('form.fields.desc.label', { keyPrefix: 'tag_modal' })}+ </Form.Label><Editorvalue={formData.description.value}onChange={handleDescriptionChange}@@ -290,13 +340,19 @@ const Index = () => {</Form.Control.Feedback></Form.Group><Form.Group controlId="edit_summary" className="my-3">- <Form.Label>{t('form.fields.edit_summary.label')}</Form.Label>+ <Form.Label>+ {t('form.fields.edit_summary.label', {+ keyPrefix: 'tag_modal',+ })}+ </Form.Label><Form.Controltype="text"defaultValue={formData.editSummary.value}isInvalid={formData.editSummary.isInvalid}onChange={handleEditSummaryChange}- placeholder={t('form.fields.edit_summary.placeholder')}+ placeholder={t('form.fields.edit_summary.placeholder', {+ keyPrefix: 'tag_modal',+ })}/><Form.Control.Feedback type="invalid">{formData.editSummary.errorMsg}diff --git a/ui/src/pages/Timeline/index.tsx b/ui/src/pages/Timeline/index.tsxindex e20d50ef..0a7816fa 100644--- a/ui/src/pages/Timeline/index.tsx+++ b/ui/src/pages/Timeline/index.tsx@@ -98,8 +98,6 @@ const Index: FC = () => {usePageTags({title: pageTitle,});-- console.log('timelineData', linkUrl);return (<div className="py-4 mb-5"><h5 className="mb-4">diff --git a/ui/src/pages/Users/Login/index.tsx b/ui/src/pages/Users/Login/index.tsxindex 549808bd..bbb1f67f 100644--- a/ui/src/pages/Users/Login/index.tsx+++ b/ui/src/pages/Users/Login/index.tsx@@ -32,6 +32,7 @@ import {} from '@/stores';import { floppyNavigation, guard, handleFormError, userCenter } from '@/utils';import { login, UcAgent } from '@/services';+import { setupAppTheme } from '@/utils/localize';const Index: React.FC = () => {const { t } = useTranslation('translation', { keyPrefix: 'login' });@@ -116,6 +117,7 @@ const Index: React.FC = () => {.then(async (res) => {await passwordCaptcha.close();updateUser(res);+ setupAppTheme();const userStat = guard.deriveLoginState();if (userStat.isNotActivated) {// inactivediff --git a/ui/src/pages/Users/Notifications/index.scss b/ui/src/pages/Users/Notifications/index.scssindex 6b2d2c36..f4c930dc 100644--- a/ui/src/pages/Users/Notifications/index.scss+++ b/ui/src/pages/Users/Notifications/index.scss@@ -18,6 +18,6 @@*/.inbox-nav {- border-top: 1px solid rgba(0, 0, 0, .125);+ border-top: 1px solid var(--an-answer-item-border-top);padding: .5rem 0;}diff --git a/ui/src/pages/Users/Settings/Account/components/MyLogins/index.tsx b/ui/src/pages/Users/Settings/Account/components/MyLogins/index.tsxindex 12e186b3..353115f1 100644--- a/ui/src/pages/Users/Settings/Account/components/MyLogins/index.tsx+++ b/ui/src/pages/Users/Settings/Account/components/MyLogins/index.tsx@@ -79,7 +79,7 @@ const Index = () => {onClick={(e) => deleteLogins(e, item)}><spandangerouslySetInnerHTML={{- __html: base64ToSvg(item.icon),+ __html: base64ToSvg(item.icon, 'btnSvg me-2'),}}/><span>diff --git a/ui/src/pages/Users/Settings/Interface/index.tsx b/ui/src/pages/Users/Settings/Interface/index.tsxindex 4164394f..575995ed 100644--- a/ui/src/pages/Users/Settings/Interface/index.tsx+++ b/ui/src/pages/Users/Settings/Interface/index.tsx@@ -25,7 +25,7 @@ import { useToast } from '@/hooks';import { updateUserInterface } from '@/services';import { localize } from '@/utils';import { loggedUserInfoStore } from '@/stores';-import { SchemaForm, JSONSchema, UISchema, initFormData } from '@/components';+import { SchemaForm, JSONSchema, UISchema } from '@/components';const Index = () => {const { t } = useTranslation('translation', {@@ -34,10 +34,22 @@ const Index = () => {const loggedUserInfo = loggedUserInfoStore.getState().user;const toast = useToast();const [langs, setLangs] = useState<LangsType[]>();+ const [formData, setFormData] = useState<FormDataType>({+ language: {+ value: loggedUserInfo.language,+ isInvalid: false,+ errorMsg: '',+ },+ color_scheme: {+ value: loggedUserInfo.color_scheme || 'default',+ isInvalid: false,+ errorMsg: '',+ },+ });const schema: JSONSchema = {title: t('heading'),properties: {- lang: {+ language: {type: 'string',title: t('lang.label'),description: t('lang.text'),@@ -45,17 +57,38 @@ const Index = () => {enumNames: langs?.map((_) => _.label),default: loggedUserInfo.language,},+ color_scheme: {+ type: 'string',+ title: t('color_scheme.label', { keyPrefix: 'admin.themes' }),+ enum: ['default', 'system', 'light', 'dark'],+ enumNames: [+ t('default', { keyPrefix: 'btns' }),+ t('system_setting', { keyPrefix: 'btns' }),+ t('light', { keyPrefix: 'btns' }),+ t('dark', { keyPrefix: 'btns' }),+ ],+ default: loggedUserInfo.color_scheme,+ },},};const uiSchema: UISchema = {- lang: {+ language: {+ 'ui:widget': 'select',+ },+ color_scheme: {'ui:widget': 'select',},};- const [formData, setFormData] = useState<FormDataType>(initFormData(schema));const getLangs = async () => {const res: LangsType[] = await localize.loadLanguageOptions();+ setFormData({+ ...formData,+ language: {+ ...formData.language,+ value: res[0].value,+ },+ });setLangs(res);};@@ -64,13 +97,17 @@ const Index = () => {};const handleSubmit = (event: FormEvent) => {event.preventDefault();- const lang = formData.lang.value;- updateUserInterface(lang).then(() => {+ const params = {+ language: formData.language.value,+ color_scheme: formData.color_scheme.value,+ };+ updateUserInterface(params).then(() => {loggedUserInfoStore.getState().update({...loggedUserInfo,- language: lang,+ ...params,});localize.setupAppLanguage();+ localize.setupAppTheme();toast.onShow({msg: t('update', { keyPrefix: 'toast' }),variant: 'success',diff --git a/ui/src/pages/Users/Settings/Notification/index.tsx b/ui/src/pages/Users/Settings/Notification/index.tsxindex f368564b..c0aa4061 100644--- a/ui/src/pages/Users/Settings/Notification/index.tsx+++ b/ui/src/pages/Users/Settings/Notification/index.tsx@@ -39,51 +39,39 @@ const Index = () => {type: 'boolean',title: t('inbox.label'),description: t('inbox.description'),- enum: configData?.inbox?.map((v) => v.enable),- default: configData?.inbox?.map((v) => v.enable),- enumNames: configData?.inbox?.map((v) => t(v.key)),+ default: configData?.inbox.enable,},all_new_question: {type: 'boolean',title: t('all_new_question.label'),description: t('all_new_question.description'),- enum: configData?.all_new_question?.map((v) => v.enable),- default: configData?.all_new_question?.map((v) => v.enable),- enumNames: configData?.all_new_question?.map((v) => t(v.key)),+ default: configData?.all_new_question.enable,},all_new_question_for_following_tags: {type: 'boolean',title: t('all_new_question_for_following_tags.label'),description: t('all_new_question_for_following_tags.description'),- enum: configData?.all_new_question_for_following_tags?.map(- (v) => v.enable,- ),- default: configData?.all_new_question_for_following_tags?.map(- (v) => v.enable,- ),- enumNames: configData?.all_new_question_for_following_tags?.map((v) =>- t(v.key),- ),+ default: configData?.all_new_question_for_following_tags.enable,},},};const uiSchema: UISchema = {inbox: {- 'ui:widget': 'checkbox',+ 'ui:widget': 'switch','ui:options': {- label: t('email'),+ label: t('turn_on'),},},all_new_question: {- 'ui:widget': 'checkbox',+ 'ui:widget': 'switch','ui:options': {- label: t('email'),+ label: t('turn_on'),},},all_new_question_for_following_tags: {- 'ui:widget': 'checkbox',+ 'ui:widget': 'switch','ui:options': {- label: t('email'),+ label: t('turn_on'),text: t('all_new_question_for_following_tags.description'),},},@@ -98,19 +86,18 @@ const Index = () => {event.preventDefault();event.stopPropagation();const params = {- inbox: configData?.inbox.map((v, index) => {- return { enable: formData.inbox.value[index], key: v.key };- }),- all_new_question: configData?.all_new_question.map((v, index) => {- return { enable: formData.all_new_question.value[index], key: v.key };- }),- all_new_question_for_following_tags:- configData?.all_new_question_for_following_tags.map((v, index) => {- return {- enable: formData.all_new_question_for_following_tags.value[index],- key: v.key,- };- }),+ inbox: {+ enable: formData.inbox.value,+ key: configData?.inbox.key,+ },+ all_new_question: {+ enable: formData.all_new_question.value,+ key: configData?.all_new_question.key,+ },+ all_new_question_for_following_tags: {+ enable: formData.all_new_question_for_following_tags.value,+ key: configData?.all_new_question_for_following_tags.key,+ },} as NotificationConfig;putNotificationConfig(params).then(() => {diff --git a/ui/src/pages/Users/Settings/Plugins/index.tsx b/ui/src/pages/Users/Settings/Plugins/index.tsxnew file mode 100644index 00000000..4fbe3ee9--- /dev/null+++ b/ui/src/pages/Users/Settings/Plugins/index.tsx@@ -0,0 +1,134 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++import { useState, useEffect } from 'react';+import { useTranslation } from 'react-i18next';+import { useParams } from 'react-router-dom';++import { useToast } from '@/hooks';+import type * as Types from '@/common/interface';+import { SchemaForm, JSONSchema, UISchema } from '@/components';+import { useGetUserPluginConfig, updateUserPluginConfig } from '@/services';+import {+ InputOptions,+ FormKit,+ initFormData,+ mergeFormData,+} from '@/components/SchemaForm';++const Config = () => {+ const { t } = useTranslation('translation');+ const { slug_name } = useParams<{ slug_name: string }>();+ const { data, mutate: refreshPluginConfig } = useGetUserPluginConfig({+ plugin_slug_name: slug_name,+ });+ const Toast = useToast();+ const [schema, setSchema] = useState<JSONSchema | null>(null);+ const [uiSchema, setUISchema] = useState<UISchema>();+ const required: string[] = [];++ const [formData, setFormData] = useState<Types.FormDataType | null>(null);++ useEffect(() => {+ if (!data) {+ return;+ }+ const properties: JSONSchema['properties'] = {};+ const uiConf: UISchema = {};+ data.config_fields?.forEach((item) => {+ properties[item.name] = {+ type: 'string',+ title: item.title,+ description: item.description,+ default: item.value,+ };++ if (item.options instanceof Array) {+ properties[item.name].enum = item.options.map((option) => option.value);+ properties[item.name].enumNames = item.options.map(+ (option) => option.label,+ );+ }+ uiConf[item.name] = {};+ uiConf[item.name]['ui:widget'] = item.type;+ if (item.ui_options) {+ if ((item.ui_options as InputOptions & { input_type })?.input_type) {+ (item.ui_options as InputOptions).inputType = (+ item.ui_options as InputOptions & { input_type }+ ).input_type;+ }+ uiConf[item.name]['ui:options'] = item.ui_options;+ }+ if (item.required) {+ required.push(item.name);+ }+ });+ const result = {+ title: data?.name || '',+ required,+ properties,+ };+ setSchema(result);+ setUISchema(uiConf);+ setFormData(mergeFormData(formData, initFormData(result)));+ }, [data?.config_fields]);++ const onSubmit = (evt) => {+ if (!formData) {+ return;+ }+ evt.preventDefault();+ evt.stopPropagation();+ const config_fields = {};+ Object.keys(formData).forEach((key) => {+ config_fields[key] = formData[key].value;+ });+ const params = {+ plugin_slug_name: slug_name,+ config_fields,+ };+ updateUserPluginConfig(params).then(() => {+ Toast.onShow({+ msg: t('update', { keyPrefix: 'toast' }),+ variant: 'success',+ });+ });+ };+ const refreshConfig: FormKit['refreshConfig'] = async () => {+ refreshPluginConfig();+ };+ const handleOnChange = (form) => {+ setFormData(form);+ };+ return (+ <>+ <h3 className="mb-4">{data?.name}</h3>+ <SchemaForm+ schema={schema}+ uiSchema={uiSchema}+ refreshConfig={refreshConfig}+ formData={formData}+ onSubmit={onSubmit}+ onChange={handleOnChange}+ />+ </>+ );+};++export default Config;diff --git a/ui/src/pages/Users/Settings/components/Nav/index.tsx b/ui/src/pages/Users/Settings/components/Nav/index.tsxindex d7c84ba0..6e2b0c07 100644--- a/ui/src/pages/Users/Settings/components/Nav/index.tsx+++ b/ui/src/pages/Users/Settings/components/Nav/index.tsx@@ -22,9 +22,13 @@ import { Nav } from 'react-bootstrap';import { useTranslation } from 'react-i18next';import { NavLink, useMatch } from 'react-router-dom';+import { useGetUserPluginList } from '@/services';+const Index: FC = () => {const { t } = useTranslation('translation', { keyPrefix: 'settings.nav' });const settingMatch = useMatch('/users/settings/:setting');+ const { data } = useGetUserPluginList();+return (<Nav variant="pills" className="flex-column"><NavLink@@ -43,6 +47,16 @@ const Index: FC = () => {<NavLink className="nav-link" to="/users/settings/interface">{t('interface')}</NavLink>+ {data?.map((item) => {+ return (+ <NavLink+ key={item.slug_name}+ className="nav-link w-100 text-truncate"+ to={`/users/settings/${item.slug_name}`}>+ {item.name}+ </NavLink>+ );+ })}</Nav>);};diff --git a/ui/src/router/routes.ts b/ui/src/router/routes.tsindex be558746..bab8b34b 100644--- a/ui/src/router/routes.ts+++ b/ui/src/router/routes.ts@@ -181,6 +181,10 @@ const routes: RouteNode[] = [path: 'interface',page: 'pages/Users/Settings/Interface',},+ {+ path: ':slug_name',+ page: 'pages/Users/Settings/Plugins',+ },],},{diff --git a/ui/src/services/admin/settings.ts b/ui/src/services/admin/settings.tsindex 8fcced97..7ce57ade 100644--- a/ui/src/services/admin/settings.ts+++ b/ui/src/services/admin/settings.ts@@ -47,6 +47,15 @@ export interface AdminSettingsPrivilege {options: PrivilegeLevel[];}+export interface AdminSettingsPrivilegeReq {+ level: number;+ custom_privileges?: {+ label?: string;+ value: number;+ key: string;+ }[];+}+export const useGeneralSetting = () => {const apiUrl = `/answer/admin/api/siteinfo/general`;const { data, error } = useSWR<Type.AdminSettingsGeneral, Error>(@@ -185,8 +194,6 @@ export const getPrivilegeSetting = () => {);};-export const putPrivilegeSetting = (level: number) => {- return request.put('/answer/admin/api/setting/privileges', {- level,- });+export const putPrivilegeSetting = (params: AdminSettingsPrivilegeReq) => {+ return request.put('/answer/admin/api/setting/privileges', params);};diff --git a/ui/src/services/client/settings.ts b/ui/src/services/client/settings.tsindex 51b3a6a1..0111c2da 100644--- a/ui/src/services/client/settings.ts+++ b/ui/src/services/client/settings.ts@@ -17,10 +17,12 @@* under the License.*/+import qs from 'qs';import useSWR from 'swr';import request from '@/utils/request';import type * as Type from '@/common/interface';+import type { PluginConfig } from '@/services/admin/plugins';export const getLanguageConfig = () => {return request.get('/answer/api/v1/language/config');@@ -30,10 +32,12 @@ export const getLanguageOptions = () => {return request.get<Type.LangsType[]>('/answer/api/v1/language/options');};-export const updateUserInterface = (lang: string) => {- return request.put('/answer/api/v1/user/interface', {- language: lang,- });+interface userSettingInterface {+ language: '';+ color_scheme: '';+}+export const updateUserInterface = (data: userSettingInterface) => {+ return request.put('/answer/api/v1/user/interface', data);};export const useGetNotificationConfig = () => {@@ -46,3 +50,28 @@ export const useGetNotificationConfig = () => {export const putNotificationConfig = (data: Type.NotificationConfig) => {return request.put('/answer/api/v1/user/notification/config', data);};++export const useGetUserPluginList = () => {+ return useSWR<Type.UserPluginsConfigRes[]>(+ '/answer/api/v1/user/plugin/configs',+ request.instance.get,+ );+};++export const useGetUserPluginConfig = (params) => {+ const apiUrl = `/answer/api/v1/user/plugin/config?${qs.stringify(params)}`;+ const { data, error, mutate } = useSWR<PluginConfig, Error>(+ apiUrl,+ request.instance.get,+ );+ return {+ data,+ isLoading: !data && !error,+ error,+ mutate,+ };+};++export const updateUserPluginConfig = (params) => {+ return request.put('/answer/api/v1/user/plugin/config', params);+};diff --git a/ui/src/services/common.ts b/ui/src/services/common.tsindex 0130d69b..0676cc71 100644--- a/ui/src/services/common.ts+++ b/ui/src/services/common.ts@@ -62,6 +62,7 @@ export const useQueryComments = (params) => {params.page = 1;} else {// only first page need commentId+ params.query_cond = '';delete params.comment_id;}return useSWR<Type.ListResult>(diff --git a/ui/src/stores/loggedUserInfo.ts b/ui/src/stores/loggedUserInfo.tsindex e1d5e4af..806c0993 100644--- a/ui/src/stores/loggedUserInfo.ts+++ b/ui/src/stores/loggedUserInfo.ts@@ -42,6 +42,7 @@ const initUser: UserInfoRes = {status: 'normal',mail_status: 1,language: 'Default',+ color_scheme: 'default',is_admin: false,have_password: true,role_id: 1,@@ -56,6 +57,9 @@ const loggedUserInfo = create<UserInfoStore>((set) => ({if (!params?.language) {params.language = 'Default';}+ if (!params?.color_scheme) {+ params.color_scheme = 'default';+ }set(() => {Storage.set(LOGGED_TOKEN_STORAGE_KEY, params.access_token);return { user: params };diff --git a/ui/src/stores/themeSetting.ts b/ui/src/stores/themeSetting.tsindex 1100a027..d0788cc8 100644--- a/ui/src/stores/themeSetting.ts+++ b/ui/src/stores/themeSetting.ts@@ -25,11 +25,13 @@ interface IType {theme: AdminSettingsTheme['theme'];theme_config: AdminSettingsTheme['theme_config'];theme_options: AdminSettingsTheme['theme_options'];+ color_scheme: AdminSettingsTheme['color_scheme'];update: (params: AdminSettingsTheme) => void;}const store = create<IType>((set) => ({theme: 'default',+ color_scheme: 'system',theme_options: [{ label: 'Default', value: 'default' }],theme_config: {default: {diff --git a/ui/src/utils/color.ts b/ui/src/utils/color.tsindex f799fb0f..52cdfc1d 100644--- a/ui/src/utils/color.ts+++ b/ui/src/utils/color.ts@@ -58,5 +58,5 @@ export const shiftColor = (color, weight) => {if (weight > 0) {return shadeColor(color, weight);}- return tintColor(color, weight);+ return tintColor(color, -weight);};diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.tsindex b6382a4e..07dc3400 100644--- a/ui/src/utils/common.ts+++ b/ui/src/utils/common.ts@@ -208,26 +208,30 @@ function diffText(newText: string, oldText?: string): string {}function base64ToSvg(base64: string, svgClassName?: string) {- // base64 to svg xml- const svgxml = atob(base64);+ try {+ // base64 to svg xml+ const svgxml = atob(base64);- // svg add class- const parser = new DOMParser();- const doc = parser.parseFromString(svgxml, 'image/svg+xml');- const parseError = doc.querySelector('parsererror');- const svg = doc.querySelector('svg');- let str = '';- if (svg && !parseError) {- if (svgClassName) {- svg.setAttribute('class', svgClassName);- }- // svg.classList.add('me-2');+ // svg add class+ const parser = new DOMParser();+ const doc = parser.parseFromString(svgxml, 'image/svg+xml');+ const parseError = doc.querySelector('parsererror');+ const svg = doc.querySelector('svg');+ let str = '';+ if (svg && !parseError) {+ if (svgClassName) {+ svg.setAttribute('class', svgClassName);+ }+ // svg.classList.add('me-2');- // transform svg to string- const serializer = new XMLSerializer();- str = serializer.serializeToString(doc);+ // transform svg to string+ const serializer = new XMLSerializer();+ str = serializer.serializeToString(doc);+ }+ return str;+ } catch (error) {+ return '';}- return str;}// Determine whether the user is in WeChat or Enterprise WeChat or DingTalk, and return the corresponding type@@ -246,6 +250,21 @@ function getUaType() {return null;}+function changeTheme(mode: 'default' | 'light' | 'dark' | 'system') {+ const htmlTag = document.querySelector('html') as HTMLHtmlElement;+ if (mode === 'system') {+ const systemThemeQuery = window.matchMedia('(prefers-color-scheme: dark)');++ if (systemThemeQuery.matches) {+ htmlTag.setAttribute('data-bs-theme', 'dark');+ } else {+ htmlTag.setAttribute('data-bs-theme', 'light');+ }+ } else {+ htmlTag.setAttribute('data-bs-theme', mode);+ }+}+export {thousandthDivision,formatCount,@@ -260,4 +279,5 @@ export {diffText,base64ToSvg,getUaType,+ changeTheme,};diff --git a/ui/src/utils/guard.ts b/ui/src/utils/guard.tsindex b424b87f..5f2e7b52 100644--- a/ui/src/utils/guard.ts+++ b/ui/src/utils/guard.ts@@ -38,7 +38,7 @@ import {} from '@/common/constants';import Storage from '@/utils/storage';-import { setupAppLanguage, setupAppTimeZone } from './localize';+import { setupAppLanguage, setupAppTimeZone, setupAppTheme } from './localize';import { floppyNavigation, NavigateConfig } from './floppyNavigation';import { pullUcAgent, getSignUpUrl } from './userCenter';@@ -144,10 +144,9 @@ export const pullLoggedUser = async (isInitPull = false) => {pluTimestamp = Date.now();const loggedUserInfo = await getLoggedUserInfo({passingError: true,- }).catch((ex) => {+ }).catch(() => {pluTimestamp = 0;loggedUserInfoStore.getState().clear(false);- console.error(ex);});if (loggedUserInfo) {loggedUserInfoStore.getState().update(loggedUserInfo);@@ -424,7 +423,6 @@ export const googleSnapshotRedirect = () => {if (searchStr.indexOf('cache:') === 0 && searchStr.includes(':http')) {const redirectUrl = `http${searchStr.split(':http')[1]}`;const pathname = redirectUrl.replace(new URL(redirectUrl).origin, '');- console.log('googleSnapshotUrl', window.location.href);gr.ok = false;gr.redirect = pathname || '/';@@ -453,6 +451,7 @@ export const setupApp = async () => {await Promise.allSettled([pullUcAgent()]);setupAppLanguage();setupAppTimeZone();+ setupAppTheme();/*** WARN:* Initialization must be completed after all initialization actions,diff --git a/ui/src/utils/localize.ts b/ui/src/utils/localize.tsindex 760b7967..cfebb684 100644--- a/ui/src/utils/localize.ts+++ b/ui/src/utils/localize.ts@@ -22,17 +22,23 @@ import i18next from 'i18next';import utc from 'dayjs/plugin/utc';import timezone from 'dayjs/plugin/timezone';-import { interfaceStore, loggedUserInfoStore } from '@/stores';+import {+ interfaceStore,+ loggedUserInfoStore,+ themeSettingStore,+} from '@/stores';import {CURRENT_LANG_STORAGE_KEY,DEFAULT_LANG,LANG_RESOURCE_STORAGE_KEY,+ DEFAULT_THEME,} from '@/common/constants';import {getAdminLanguageOptions,getLanguageConfig,getLanguageOptions,} from '@/services';+import { changeTheme } from '@/utils/common';import Storage from './storage';@@ -70,7 +76,7 @@ const addI18nResource = async (langName) => {const { default: resConf } = await import(`@i18n/${langName}.yaml`);res.resources = resConf.ui;} catch (ex) {- console.log('ex: ', ex);+ console.error('addI18nResource error: ', ex);}} else if (storageResource && storageResource.lng === res.lng) {res.resources = storageResource.resources;@@ -103,6 +109,18 @@ export const getCurrentLang = () => {return currentLang;};+export const getCurrentTheme = () => {+ const loggedUser = loggedUserInfoStore.getState().user;+ const adminTheme = themeSettingStore.getState().color_scheme;+ const fallbackTheme = DEFAULT_THEME;+ let currentTheme = loggedUser.color_scheme;+ if (/default/i.test(currentTheme)) {+ currentTheme = adminTheme;+ }+ currentTheme ||= fallbackTheme;+ return currentTheme;+};+/*** localize for Day.js*/@@ -128,3 +146,8 @@ export const setupAppTimeZone = () => {dayjs.tz.setDefault(adminInterface.time_zone);}};++export const setupAppTheme = () => {+ const theme = getCurrentTheme();+ changeTheme(theme);+};diff --git a/ui/template/header.html b/ui/template/header.htmlindex 5471391d..85425674 100644--- a/ui/template/header.html+++ b/ui/template/header.html@@ -29,6 +29,7 @@<meta name="description" content="{{.description}}" data-rh="true" /><meta name="generator" content="Answer {{.Version}} - https://github.com/apache/incubator-answer version {{.Revision}}">{{if .keywords }}<meta name="keywords" content="{{.keywords}}" data-rh="true" />{{end}}+ {{if .noindex }}<meta name="robots" content="noindex">{{end}}<link rel="canonical" href="{{.siteinfo.Canonical}}" /><link rel="manifest" href="/manifest.json" />