Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/components/operation-set/OperationSetEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ function OperationSetForm({ operationSet, onSubmit }: FormProps) {

const localOnSubmit = handleSubmit(async (values) => {
try {

// 方便以后拓展关键字
const titleHasPersonal = values.name.includes('自用')

// 标题含“自用”,但未勾选“自用”(status !== PRIVATE) → 提示
if (titleHasPersonal && values.status !== 'PRIVATE') {
setGlobalError(
t.components.operationSet.OperationSetEditor.personal_use_warning
)
return
}

await onSubmit(
{
...values,
Expand Down Expand Up @@ -288,17 +300,15 @@ function OperationSetForm({ operationSet, onSubmit }: FormProps) {
<Checkbox
{...field}
value={undefined}
checked={field.value === 'PUBLIC'}
checked={field.value === 'PRIVATE'}
onChange={(e) =>
field.onChange(
(e.target as HTMLInputElement).checked
? 'PUBLIC'
: 'PRIVATE',
? 'PRIVATE'
: 'PUBLIC'
)
}
label={
t.components.operationSet.OperationSetEditor.visible_to_all
}
label={t.components.operationSet.OperationSetEditor.for_personal_use}
/>
)}
/>
Expand Down
18 changes: 15 additions & 3 deletions src/i18n/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -2498,9 +2498,13 @@
"cn": "描述",
"en": "Description"
},
"visible_to_all": {
"cn": "对所有人可见",
"en": "Visible to everyone"
"for_personal_use": {
"cn": "仅对自己可见(自用)",
"en": "For Personal Use"
},
"personal_use_warning": {
"cn": "自用作业集请勾选「仅对自己可见(自用)」哦",
"en": "Personal use job sets should be marked as 'For Personal Use'"
},
"click_save": {
"cn": "修改后请点击保存按钮",
Expand Down Expand Up @@ -2545,6 +2549,14 @@
"reverse_list": {
"cn": "反转列表",
"en": "Reverse List"
},
"private_usage_warning": {
"cn": "自用作业集请勾选「自用」哦",
"en": "Personal use job sets should be marked as 'For Personal Use'"
},
"private_usage_public_warning": {
"cn": "标题含有「自用」关键字且勾选了公开,请取消勾选公开再次提交",
"en": "Title contains 'personal use' keyword and is marked as public, please uncheck public and submit again"
}
}
},
Expand Down