This commit is contained in:
undefined committed 2021-04-23 00:14:01 +08:00
1 parent 00dcf3864f
commit ab12ca8526
10 files changed
+115 -97

No files matched your search

@@ -3,6 +3,7 @@ import classNames from 'classnames';
export default function DataInputComponent(props) {
const {
html,
title,
value,
onChange,
@@ -12,16 +13,20 @@ export default function DataInputComponent(props) {
const cn = classNames(className, 'flex-col flex-fill');
return (
<div {...rest} className={cn}>
<textarea
className="scratchpad__data-input"
wrap="off"
value={value}
onChange={(ev) => {
ev.stopPropagation();
onChange(ev.target.value);
}}
placeholder={title}
/>
{html // eslint-disable-next-line react/no-danger
? <div className="scratchpad__data-input" wrap="off" dangerouslySetInnerHTML={{ __html: value }} />
: (
<textarea
className="scratchpad__data-input"
wrap="off"
value={value}
onChange={(ev) => {
ev.stopPropagation();
onChange(ev.target.value);
}}
placeholder={title}
/>
)}
</div>
);
}
@@ -45,6 +45,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadPret
<DataInput
title={i18n('Output')}
value={this.props.output}
html
/>
</div>
</Panel>
@@ -1,3 +1,5 @@
import { STATUS_TEXTS } from '@hydrooj/utils/lib/status';
export default function reducer(state = {
input: '',
output: '',
@@ -12,10 +14,13 @@ export default function reducer(state = {
}
if (action.type === 'SCRATCHPAD_RECORDS_PUSH') {
const { rdoc } = action.payload;
if (rdoc._id === state.rid && rdoc.testCases[0]) {
if (rdoc._id === state.rid) {
const output = [`${STATUS_TEXTS[rdoc.status]} ${rdoc.time}ms ${rdoc.memory}MiB`];
if (rdoc.compilerTexts.length) output.push(rdoc.compilerTexts.join('\n'));
if (rdoc.testCases.length) output.push(rdoc.testCases[0].message || '');
return {
...state,
output: rdoc.testCases[0].message,
output: output.join('\n'),
};
}
}