使用者选人(前端):选人控件按池边输入边取候选;个人渠道的实例事件改叫「我发起的实例完成 / 失败」

为什么:使用者读不到名录,选人控件只能凭记忆手填用户名,填错了服务端以前也照收(05-已知遗留 (b))。服务端已按用途给候选池、
开登录时按同一个池核对(上上个提交),前端要把候选给到人手上。另外个人渠道勾「实例完成 / 失败」以前永远收不到,服务端修好之后
(驳回那个提交里的 notify_run),名字要照实写成只推自己发起的实例(04-对外集成与触达 B1)。

做了什么:
- PrincipalPicker 加 source(CandidateSource:form 带 app_id+entry 或 task_id 和 field,review)。搭建者及以上照旧用整份名录;
  使用者开了登录、给了 source 时边输入边按开头取候选(250 毫秒防抖),列表里显示显示名、标签悬停给用户名;加的时候按同一个池
  问一次服务端,不在池里的当场说「「x」不在可选的人里」(问不到就先收下,提交时由服务端判);池要先输开头才列、列不全时照实提示。
- SchemaForm 按表单用在哪(入口、待办,同上传文件的上下文)给选人控件 source;个人应用提交审核用 purpose=review。
- typesApp:CandidateSource、Candidates、FormField 的 x-principal、FormError 的 principal 码(和服务端 FORM_ERROR_CODES 同序)。
- api.identity.candidates。termsApp 的 PRINCIPAL_TEXT 加三句。
- 设置 → 通知:范围是「仅自己」的渠道,run.finished / run.failed 写「我发起的实例完成 / 失败」(termsApp.NOTIFY_PERSONAL_EVENT_LABEL)。
- 服务端 x-principal 写法不对时的说法改成不带半角冒号接中文的写法(check-copy)。
This commit is contained in:
ThearchyHelios
2026-10-16 10:54:30 +08:00
parent 2fa2db3ea0
commit fbb671a96b
8 changed files with 132 additions and 24 deletions
+12 -2
View File
@@ -12,7 +12,7 @@
import { useEffect, useId, useState } from 'react'
import type { CSSProperties, KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react'
import clsx from 'clsx'
import type { FormError, FormField, FormSchema } from '../typesApp'
import type { CandidateSource, FormError, FormField, FormSchema } from '../typesApp'
import { FORM_TEXT } from '../lib/termsApp'
import {
fieldOfPath, fieldOrder, fileLimitsOf, localToRfc3339, optionsOf, rfc3339ToLocal, widgetOf,
@@ -88,6 +88,16 @@ export function SchemaForm({ schema, value, onChange, errors, readOnly, onSubmit
)
}
/**
* 选人控件的候选从哪个池取:表单用在入口(app_id + entry)、待办(task_id)上时,按这个字段问服务端(05-已知遗留 (b));
* 蓝图试运行之类没有应用的地方不给(搭建者用整份名录)
*/
function principalSource(context: Record<string, string> | undefined, field: string): CandidateSource | undefined {
if (context?.task_id) return { purpose: 'form', task_id: context.task_id, field }
if (context?.app_id && context.entry) return { purpose: 'form', app_id: context.app_id, entry: context.entry, field }
return undefined
}
function FieldRow({ id, name, field, required, value, error, readOnly, onChange, fileContext }: {
id: string; name: string; field: FormField; required: boolean; value: unknown; error?: FormError
readOnly: boolean; onChange: (v: unknown) => void; fileContext?: Record<string, string>
@@ -143,7 +153,7 @@ function FieldRow({ id, name, field, required, value, error, readOnly, onChange,
<div className="label">{label}</div>
{readOnly
? <div className="text-xs text-fg">{typeof value === 'string' && value ? value : '—'}</div>
: <PrincipalPicker single label={title}
: <PrincipalPicker single label={title} source={principalSource(fileContext, name)}
value={typeof value === 'string' && value ? [{ kind: 'user', name: value }] : []}
onChange={(list) => onChange(list[0]?.name || undefined)} />}
{foot}