ui: fix fileio pretest

This commit is contained in:
undefined committed 2021-10-10 20:08:10 +08:00
1 parent dc4464c19a
commit 603f2938fb
6 files changed
+16 -18

No files matched your search

-5
View File
@@ -1,5 +0,0 @@
const { spawnSync } = require('child_process');
const os = require('os');
if (os.platform() === 'linux') {
spawnSync('bash download.sh');
}
+1 -1
View File
@@ -10,7 +10,7 @@
}, },
"preferUnplugged": true, "preferUnplugged": true,
"scripts": { "scripts": {
"prepublish": "node download.js" "prepublish": "./download.sh"
}, },
"peerDependencies": { "peerDependencies": {
"hydrooj": "*" "hydrooj": "*"
@@ -114,18 +114,12 @@ class DiscussionNodeHandler extends DiscussionHandler {
user.getList(domainId, uids), user.getList(domainId, uids),
discussion.getNodes(domainId), discussion.getNodes(domainId),
]); ]);
const path = [
['Hydro', 'homepage'],
['discussion_main', 'discussion_main'],
[this.vnode.title, null, true],
];
const vndict = { [typeMapper[type]]: { [name.toString()]: this.vnode } }; const vndict = { [typeMapper[type]]: { [name.toString()]: this.vnode } };
this.response.template = 'discussion_main_or_node.html'; this.response.template = 'discussion_main_or_node.html';
this.response.body = { this.response.body = {
ddocs, ddocs,
dpcount, dpcount,
udict, udict,
path,
page, page,
vndict, vndict,
vnode: this.vnode, vnode: this.vnode,
@@ -13,9 +13,17 @@ export default function DataInputComponent(props) {
const cn = classNames(className, 'flex-col flex-fill'); const cn = classNames(className, 'flex-col flex-fill');
return ( return (
<div {...rest} className={cn}> <div {...rest} className={cn}>
{html // eslint-disable-next-line react/no-danger {html ? (
? <div className="scratchpad__data-input" wrap="off"><pre dangerouslySetInnerHTML={{ __html: value }} /></div> <div
: ( className="scratchpad__data-input"
style={{ overflowY: 'scroll' }}
wrap="off"
contentEditable
>
{/* eslint-disable-next-line react/no-danger */}
<pre dangerouslySetInnerHTML={{ __html: value }} />
</div>
) : (
<textarea <textarea
className="scratchpad__data-input" className="scratchpad__data-input"
wrap="off" wrap="off"
@@ -90,9 +90,10 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
} }
const keys = Object.keys(LANGS); const keys = Object.keys(LANGS);
if (!keys.includes(this.props.editorLang)) this.props.setEditorLanguage(keys[0]); if (!keys.includes(this.props.editorLang)) this.props.setEditorLanguage(keys[0]);
const canUsePretest = ['default', 'fileio'].includes(UiContext.pdoc.config?.type);
return ( return (
<Toolbar> <Toolbar>
{UiContext.pdoc.config?.type === 'default' && ( {canUsePretest && (
<ToolbarButton <ToolbarButton
disabled={this.props.isPosting || this.props.isRunning} disabled={this.props.isPosting || this.props.isRunning}
className="scratchpad__toolbar__pretest" className="scratchpad__toolbar__pretest"
@@ -156,7 +157,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
</select> </select>
</ToolbarItem> </ToolbarItem>
<ToolbarSplit /> <ToolbarSplit />
{['default', 'fileio'].includes(UiContext.pdoc.config?.type) && ( {canUsePretest && (
<ToolbarButton <ToolbarButton
activated={this.props.pretestVisible} activated={this.props.pretestVisible}
onClick={() => this.props.togglePanel('pretest')} onClick={() => this.props.togglePanel('pretest')}
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.24.1", "version": "4.24.2",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",