mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix problem_config testlib select (#762)
This commit is contained in:
1 parent
1799d14953
commit
e435ddaddd
1 file changed
+14
-6
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
Card, Classes, Switch, Tab, Tabs,
|
Card, Classes, Switch, Tab, Tabs, TabsExpander,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { i18n } from 'vj/utils';
|
import { i18n } from 'vj/utils';
|
||||||
import { testlibCheckers } from '../monaco/schema/problemconfig';
|
import { testlibCheckers } from '../monaco/schema/problemconfig';
|
||||||
@@ -14,9 +14,14 @@ export default function ProblemType() {
|
|||||||
const filename = useSelector((state: RootState) => state.config.filename);
|
const filename = useSelector((state: RootState) => state.config.filename);
|
||||||
const subType = useSelector((state: RootState) => state.config.subType);
|
const subType = useSelector((state: RootState) => state.config.subType);
|
||||||
const checker = useSelector((state: RootState) => state.config.checker);
|
const checker = useSelector((state: RootState) => state.config.checker);
|
||||||
const [category, setCategory] = React.useState(checker?.includes('.') ? 'preset' : 'custom');
|
const [category, setCategory] = React.useState('');
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const dispatcher = (base) => (value) => dispatch({ ...base, value });
|
const dispatcher = (base) => (value) => dispatch({ ...base, value });
|
||||||
|
useEffect(() => {
|
||||||
|
if (category || !checker) return;
|
||||||
|
if (checker.includes('.')) setCategory('custom');
|
||||||
|
else setCategory('preset');
|
||||||
|
}, [checker]);
|
||||||
return (
|
return (
|
||||||
<FormItem columns={12} label="" disableLabel>
|
<FormItem columns={12} label="" disableLabel>
|
||||||
<Card style={{ padding: 10 }}>
|
<Card style={{ padding: 10 }}>
|
||||||
@@ -39,11 +44,14 @@ export default function ProblemType() {
|
|||||||
['strict', 'default'].includes(checkerType) || !checkerType
|
['strict', 'default'].includes(checkerType) || !checkerType
|
||||||
? 'default' : (checkerType !== 'testlib' ? 'other' : 'testlib')
|
? 'default' : (checkerType !== 'testlib' ? 'other' : 'testlib')
|
||||||
}
|
}
|
||||||
onChange={dispatcher({ type: 'CONFIG_FORM_UPDATE', key: 'checker_type' })}
|
onChange={(value) => {
|
||||||
|
dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'checker_type', value });
|
||||||
|
if (value === 'testlib' && !category) setCategory('custom');
|
||||||
|
}}
|
||||||
renderActiveTabPanelOnly
|
renderActiveTabPanelOnly
|
||||||
>
|
>
|
||||||
<span className={Classes.TAB}>{i18n('CheckerType')}</span>
|
<span className={Classes.TAB}>{i18n('CheckerType')}</span>
|
||||||
<Tabs.Expander />
|
<TabsExpander />
|
||||||
<Tab
|
<Tab
|
||||||
id="default"
|
id="default"
|
||||||
title={i18n('default')}
|
title={i18n('default')}
|
||||||
@@ -71,7 +79,7 @@ export default function ProblemType() {
|
|||||||
value={category}
|
value={category}
|
||||||
onChange={(ev) => {
|
onChange={(ev) => {
|
||||||
setCategory(ev.currentTarget.value);
|
setCategory(ev.currentTarget.value);
|
||||||
dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'checker', value: null });
|
dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'checker', value: ev.currentTarget.value === 'preset' ? 'acmp' : null });
|
||||||
}}
|
}}
|
||||||
className="select"
|
className="select"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user