import { EnterpriseBadge, Select, Typography } from "@humansignal/ui";
|
import { useCallback, useContext } from "react";
|
import { Button } from "@humansignal/ui";
|
import { Form, Input, TextArea } from "../../components/Form";
|
import { RadioGroup } from "../../components/Form/Elements/RadioGroup/RadioGroup";
|
import { ProjectContext } from "../../providers/ProjectProvider";
|
import { cn } from "../../utils/bem";
|
import { HeidiTips } from "../../components/HeidiTips/HeidiTips";
|
import { FF_LSDV_E_297, isFF } from "../../utils/feature-flags";
|
import { createURL } from "../../components/HeidiTips/utils";
|
|
export const GeneralSettings = () => {
|
const { project, fetchProject } = useContext(ProjectContext);
|
|
const updateProject = useCallback(() => {
|
if (project.id) fetchProject(project.id, true);
|
}, [project]);
|
|
const colors = ["#FDFDFC", "#FF4C25", "#FF750F", "#ECB800", "#9AC422", "#34988D", "#617ADA", "#CC6FBE"];
|
|
const samplings = [
|
{ value: "Sequential", label: "顺序", description: "按任务 ID 排序" },
|
{ value: "Uniform", label: "随机", description: "随机选择任务" },
|
];
|
|
return (
|
<div className={cn("general-settings").toClassName()}>
|
<div className={cn("general-settings").elem("wrapper").toClassName()}>
|
<h1>通用设置</h1>
|
<div className={cn("settings-wrapper").toClassName()}>
|
<Form action="updateProject" formData={{ ...project }} params={{ pk: project.id }} onSubmit={updateProject}>
|
<Form.Row columnCount={1} rowGap="16px">
|
<Input name="title" label="项目名称" />
|
|
<TextArea name="description" label="描述" style={{ minHeight: 128 }} />
|
{isFF(FF_LSDV_E_297) && (
|
<div className={cn("workspace-placeholder").toClassName()}>
|
<div className={cn("workspace-placeholder").elem("badge-wrapper").toClassName()}>
|
<div className={cn("workspace-placeholder").elem("title").toClassName()}>工作空间</div>
|
<EnterpriseBadge className="ml-2" />
|
</div>
|
<Select placeholder="选择一个选项" disabled options={[]} />
|
<Typography size="small" className="my-tight">
|
通过将项目组织到工作空间中来简化项目管理。{" "}
|
<a
|
target="_blank"
|
href={createURL(
|
"https://docs.humansignal.com/guide/manage_projects#Create-workspaces-to-organize-projects",
|
{
|
experiment: "project_settings_tip",
|
treatment: "simplify_project_management",
|
},
|
)}
|
rel="noreferrer"
|
className="underline hover:no-underline"
|
>
|
了解更多
|
</a>
|
</Typography>
|
</div>
|
)}
|
<RadioGroup name="color" label="颜色" size="large" labelProps={{ size: "large" }}>
|
{colors.map((color) => (
|
<RadioGroup.Button key={color} value={color}>
|
<div className={cn("color").toClassName()} style={{ "--background": color }} />
|
</RadioGroup.Button>
|
))}
|
</RadioGroup>
|
|
<RadioGroup label="任务采样" labelProps={{ size: "large" }} name="sampling" simple>
|
{samplings.map(({ value, label, description }) => (
|
<RadioGroup.Button
|
key={value}
|
value={`${value} sampling`}
|
label={`${label} 采样`}
|
description={description}
|
/>
|
))}
|
{isFF(FF_LSDV_E_297) && (
|
<RadioGroup.Button
|
key="uncertainty-sampling"
|
value=""
|
label={
|
<>
|
不确定性采样 <EnterpriseBadge className="ml-2" />
|
</>
|
}
|
disabled
|
description={
|
<>
|
根据模型不确定性评分选择任务(主动学习模式)。{" "}
|
<a
|
target="_blank"
|
href={createURL("https://docs.humansignal.com/guide/active_learning", {
|
experiment: "project_settings_workspace",
|
treatment: "workspaces",
|
})}
|
rel="noreferrer"
|
>
|
了解更多
|
</a>
|
</>
|
}
|
/>
|
)}
|
</RadioGroup>
|
</Form.Row>
|
|
<Form.Actions>
|
<Form.Indicator>
|
<span case="success">已保存!</span>
|
</Form.Indicator>
|
<Button type="submit" className="w-[150px]" aria-label="保存通用设置">
|
保存
|
</Button>
|
</Form.Actions>
|
</Form>
|
</div>
|
</div>
|
{isFF(FF_LSDV_E_297) && <HeidiTips collection="projectSettings" />}
|
</div>
|
);
|
};
|
|
GeneralSettings.menuItem = "General";
|
GeneralSettings.path = "/";
|
GeneralSettings.exact = true;
|