Skip to content

Commit

Permalink
chore: admin judger data remove git requirement by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Mar 13, 2024
1 parent 1825a6d commit c3026ae
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 41 deletions.
1 change: 1 addition & 0 deletions .umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
'process.env.CDN_URL': process.env.CDN_URL || '',
'process.env.MEDIA_URL': process.env.MEDIA_URL || '',
'process.env.PUBLIC_PATH': process.env.NODE_ENV === 'production' ? usingPublicPath : '/',
'process.env.DATA_USING_GIT': false,
},
plugins: [
[
Expand Down
102 changes: 61 additions & 41 deletions src/components/UploadJudgerDataModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { withRouter } from 'react-router';
import { getCsrfHeader } from '@/utils/misc';
import { RcFile, UploadFile } from 'antd/lib/upload/interface';
import ExtLink from './ExtLink';
import { validateFile } from '@/utils/validate';

const USING_GIT = process.env.DATA_USING_GIT;

export interface Props extends RouteProps, ReduxProps, FormProps {
problemId?: number;
Expand All @@ -34,6 +37,11 @@ class UploadJudgerDataModal extends React.Component<Props, State> {
}

beforeUpload = (file: RcFile, _fileList: RcFile[]) => {
const valid = validateFile([{ name: 'ZIP', type: 'application/zip' }], 50)(file);
if (!valid) {
console.log('Invalid file type or size');
return false;
}
this.setState({
fileList: [file],
});
Expand Down Expand Up @@ -67,9 +75,9 @@ class UploadJudgerDataModal extends React.Component<Props, State> {
formData.append('problemId', `${problemId}`);
// @ts-ignore
formData.append('data', data, `upload-data.zip`);
formData.append('commitMessage', commitMessage);
formData.append('name', name);
formData.append('email', email);
commitMessage && formData.append('commitMessage', commitMessage);
name && formData.append('name', name);
email && formData.append('email', email);
this.setState({
loading: true,
});
Expand Down Expand Up @@ -134,6 +142,7 @@ class UploadJudgerDataModal extends React.Component<Props, State> {
const { children, form } = this.props;
const { getFieldDecorator } = form;
const { loading, fileList } = this.state;
const dataUsingGit = process.env.DATA_USING_GIT;

return (
<>
Expand Down Expand Up @@ -174,21 +183,25 @@ class UploadJudgerDataModal extends React.Component<Props, State> {
</p>
</Upload.Dragger>
</Form.Item>
<Form.Item key="commitMessage" label="Commit Message">
{getFieldDecorator('commitMessage', {
rules: [{ required: true, message: 'Please input this field' }],
})(<Input />)}
</Form.Item>
<Form.Item key="gitUsername" label="Git Username">
{getFieldDecorator('gitUsername', {
rules: [{ required: true, message: 'Please input this field' }],
})(<Input />)}
</Form.Item>
<Form.Item key="email" label="Git Email">
{getFieldDecorator('email', {
rules: [{ required: true, message: 'Please input this field' }],
})(<Input />)}
</Form.Item>
{dataUsingGit && (
<>
<Form.Item key="commitMessage" label="Commit Message">
{getFieldDecorator('commitMessage', {
rules: [{ required: true, message: 'Please input this field' }],
})(<Input />)}
</Form.Item>
<Form.Item key="gitUsername" label="Git Username">
{getFieldDecorator('gitUsername', {
rules: [{ required: true, message: 'Please input this field' }],
})(<Input />)}
</Form.Item>
<Form.Item key="email" label="Git Email">
{getFieldDecorator('email', {
rules: [{ required: true, message: 'Please input this field' }],
})(<Input />)}
</Form.Item>
</>
)}
</Form>

<div>
Expand All @@ -197,29 +210,36 @@ class UploadJudgerDataModal extends React.Component<Props, State> {
archive.
</p>
<p>DO NOT use Windows Notepad and other CRLF mode editors to edit file.</p>
<p>The maximum number of test cases is 255, and the maximum archive size is 50 MiB.</p>
<p>Everytime you upload data archive, you must input all fields above.</p>
<ul>
<li>
<strong>Commit Message</strong>: briefly describe what you update
</li>
<li>
<strong>Git Username</strong>: your GitHub username (for example, if your GitHub
page URL is{' '}
<ExtLink href="https://github.com/dreamerblue">
https://github.com/dreamerblue
</ExtLink>
, your username is "dreamerblue" (without quotes)
</li>
<li>
<strong>Git Email</strong>: Your GitHub email address. If you don't know which is,
browse{' '}
<ExtLink href="https://github.com/settings/emails">
https://github.com/settings/emails
</ExtLink>{' '}
to review it
</li>
</ul>
<p>
The maximum number of test cases is <strong>100</strong>, and the maximum archive size
is <strong>50 MiB</strong>.
</p>
{dataUsingGit && (
<>
<p>Everytime you upload data archive, you must input all fields above.</p>
<ul>
<li>
<strong>Commit Message</strong>: briefly describe what you update
</li>
<li>
<strong>Git Username</strong>: your GitHub username (for example, if your GitHub
page URL is{' '}
<ExtLink href="https://github.com/dreamerblue">
https://github.com/dreamerblue
</ExtLink>
, your username is "dreamerblue" (without quotes)
</li>
<li>
<strong>Git Email</strong>: Your GitHub email address. If you don't know which
is, browse{' '}
<ExtLink href="https://github.com/settings/emails">
https://github.com/settings/emails
</ExtLink>{' '}
to review it
</li>
</ul>
</>
)}
</div>
</Modal>
</>
Expand Down

0 comments on commit c3026ae

Please sign in to comment.