fix(MessageConfigForm): add description for user selection and improve locale support (#6424)

This commit is contained in:
Sheldon Guo 2025-03-12 05:20:49 +08:00 committed by GitHub
parent e00b294cec
commit 69a44fff1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 4 deletions

View File

@ -9,7 +9,7 @@
import React from 'react';
import { SchemaComponent, css } from '@nocobase/client';
import { useLocalTranslation } from '../../locale';
import { useLocalTranslation, NAMESPACE } from '../../locale';
import { UsersSelect } from './UsersSelect';
import { UsersAddition } from './UsersAddition';
import { tval } from '@nocobase/utils/client';
@ -26,6 +26,10 @@ export const MessageConfigForm = ({ variableOptions }) => {
receivers: {
type: 'array',
title: `{{t("Receivers")}}`,
description: tval(
'When select receivers from node result, only support ID of user (or IDs array of users). Others will not match any user.',
{ ns: NAMESPACE },
),
'x-decorator': 'FormItem',
'x-component': 'ArrayItems',
items: {

View File

@ -24,5 +24,6 @@
"Mark as read": "Mark as read",
"Support two types of links: internal links and external links. If using an internal link, the link starts with\"/\", for example, \"/m\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".": "Support two types of links: internal links and external links. If using an internal link, the link starts with \"/\", for example, \"/m\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".",
"Details page for mobile": "Details page for mobile",
"The message page has already been created.": "The message page has already been created."
"The message page has already been created.": "The message page has already been created.",
"When select receivers from node result, only support ID of user (or IDs array of users). Others will not match any user.": "When select receivers from node result, only support ID of user (or IDs array of users). Others will not match any user."
}

View File

@ -24,5 +24,6 @@
"Mark as read": "标记为已读",
"Support two types of links: internal links and external links. If using an internal link, the link starts with\"/\", for example, \"/m\". If using an external link, the link starts with \"http\", for example, \"https://example.com\".": "支持两种链接类型:内部链接和外部链接。如果使用内部链接,链接以“/”开头,例如“/m”。如果使用外部链接链接以“http”开头例如“https://example.com”。",
"Details page for mobile": "移动端详情页",
"The message page has already been created.": "站内信页面已创建。"
"The message page has already been created.": "站内信页面已创建。",
"When select receivers from node result, only support ID of user (or IDs array of users). Others will not match any user.": "从节点结果中选择接收者时仅支持用户ID或用户ID数组。其他将不匹配任何用户。"
}

View File

@ -8,6 +8,7 @@
*/
import { Repository } from '@nocobase/database';
import { isValidFilter } from '@nocobase/utils';
export async function parseUserSelectionConf(
userSelectionConfig: Array<Record<any, any> | string>,
UserRepo: Repository,
@ -16,6 +17,9 @@ export async function parseUserSelectionConf(
const users = new Set<string>();
for (const item of SelectionConfigs) {
if (typeof item === 'object') {
if (!isValidFilter(item.filter)) {
continue;
}
const result = await UserRepo.find({
...item,
fields: ['id'],

View File

@ -8,6 +8,7 @@
*/
import { Handlebars } from '@nocobase/utils';
import { isPlainObject } from '@nocobase/utils';
function deepCompile(template: unknown, data: Record<string, any>): unknown {
if (typeof template === 'string') {
@ -15,7 +16,7 @@ function deepCompile(template: unknown, data: Record<string, any>): unknown {
return c(data);
} else if (Array.isArray(template)) {
return template.map((item) => deepCompile(item, data));
} else if (typeof template === 'object') {
} else if (isPlainObject(template)) {
const result = Object.keys(template).reduce((object, key) => {
const value = deepCompile(template[key], data);
return Object.assign(object, { [key]: value });