-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathconsensus-settings-tab.tsx
55 lines (48 loc) · 1.58 KB
/
consensus-settings-tab.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2023-2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
import React, { useCallback } from 'react';
import Text from 'antd/lib/typography/Text';
import Form from 'antd/lib/form';
import { ConsensusSettings } from 'cvat-core-wrapper';
import CVATLoadingSpinner from 'components/common/loading-spinner';
import ConsensusSettingsForm from './task-consensus/consensus-settings-form';
interface Props {
fetching: boolean;
settings: ConsensusSettings | null;
setSettings: (settings: ConsensusSettings) => void;
}
function ConsensusSettingsTab(props: Readonly<Props>): JSX.Element | null {
const {
fetching,
settings,
setSettings,
} = props;
const [form] = Form.useForm();
const onSave = useCallback(() => {
form.validateFields().then((values) => {
setSettings(values);
}).catch(() => { /* do nothing */ });
}, [form, setSettings]);
if (fetching) {
return (
<div className='cvat-consensus-management-settings-tab'>
<div className='cvat-consensus-management-loading'>
<CVATLoadingSpinner />
</div>
</div>
);
}
return (
<div className='cvat-consensus-management-settings-tab'>
{ settings ? (
<ConsensusSettingsForm
form={form}
settings={settings}
onSave={onSave}
/>
) : <Text>No consensus settings found</Text> }
</div>
);
}
export default React.memo(ConsensusSettingsTab);