ui: add confirm dialog (#226)

This commit is contained in:
undefined committed 2021-10-06 13:36:42 +08:00
1 parent 8b9a3c6410
commit c696f51789
15 files changed
+46 -32

No files matched your search

+2 -2
View File
@@ -16,14 +16,14 @@
"mongodb": "^3.7.1",
"p-queue": "^7.1.0",
"shell-quote": "^1.7.2",
"ws": "^8.2.2"
"ws": "^8.2.3"
},
"preferUnplugged": true,
"license": "AGPL-3.0-or-later",
"devDependencies": {
"@types/fs-extra": "^9.0.13",
"@types/js-yaml": "^4.0.3",
"@types/lodash": "^4.14.174",
"@types/lodash": "^4.14.175",
"@types/shell-quote": "^1.7.1",
"@types/ws": "^7.4.7"
},
+4 -4
View File
@@ -31,11 +31,11 @@
"koa-static-cache": "^5.1.4",
"lodash": "^4.17.21",
"lru-cache": "^6.0.0",
"mime-types": "^2.1.32",
"mime-types": "^2.1.33",
"minio": "7.0.19",
"moment-timezone": "^0.5.33",
"mongodb": "^3.7.1",
"nanoid": "^3.1.25",
"nanoid": "^3.1.28",
"nodemailer": "^6.6.5",
"p-queue": "^7.1.0",
"reflect-metadata": "^0.1.13",
@@ -53,7 +53,7 @@
"@types/koa-compress": "^4.0.3",
"@types/koa-router": "^7.4.4",
"@types/koa-static-cache": "^5.1.1",
"@types/lodash": "^4.14.174",
"@types/lodash": "^4.14.175",
"@types/lru-cache": "^5.1.1",
"@types/mime-types": "^2.1.1",
"@types/minio": "^7.0.10",
@@ -65,7 +65,7 @@
"@types/superagent": "^4.1.13",
"formidable": "^1.2.2",
"moment": "^2.29.1",
"pm2": "^5.1.1"
"pm2": "^5.1.2"
},
"peerDependencies": {
"pm2": "*"
+1 -1
View File
@@ -7,7 +7,7 @@
"license": "AGPL-3.0-or-later",
"preferUnplugged": true,
"dependencies": {
"ws": "^8.2.2"
"ws": "^8.2.3"
},
"devDependencies": {
"@types/ws": "^7.4.7"
@@ -165,10 +165,7 @@ async function onCommentClickDelete(type, ev) {
? 'Confirm deleting this comment? Its replies will be deleted as well.'
: 'Confirm deleting this reply?';
const action = await new ConfirmDialog({
$body: tpl`
<div class="typo">
<p>${i18n(message)}</p>
</div>`,
$body: tpl.typoMsg(i18n(message)),
}).open();
if (action !== 'yes') return;
+1
View File
@@ -134,6 +134,7 @@ Completed: 已完成
Confirm deleting the selected roles?: 您确定删除所选角色吗?
Confirm deleting this comment? Its replies will be deleted as well.: 确认删除这个评论吗?回复会被同时删除。
Confirm deleting this reply?: 确认删除这个回复吗?
Confirm rejudge this problem?: 确定要重测这道题吗?
Confirm removing the selected users?: 您确定将所选用户移除吗?
Confirm to delete the selected files?: 确认删除所选文件吗?
Confirmation mail has been sent to your new email.: 确认邮件已经发送到您的新电子邮箱。
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.22.10",
"version": "4.22.11",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -11,9 +11,9 @@
},
"devDependencies": {
"@blockly/block-extension-tooltip": "^1.0.19",
"@blueprintjs/core": "^3.50.2",
"@blueprintjs/icons": "^3.30.1",
"@blueprintjs/select": "^3.18.4",
"@blueprintjs/core": "^3.50.4",
"@blueprintjs/icons": "^3.30.2",
"@blueprintjs/select": "^3.18.6",
"@hydrooj/utils": "workspace:*",
"@types/jquery": "^3.5.6",
"@types/json-schema": "^7.0.9",
@@ -21,7 +21,7 @@
"@types/sockjs-client": "^1.5.1",
"@undefined-moe/monaco-yaml": "^2.5.0",
"ansi_up": "^5.0.1",
"autoprefixer": "^9.8.6",
"autoprefixer": "^9.8.8",
"blockly": "^6.20210701.0",
"chalk": "^4.1.2",
"classnames": "^2.3.1",
@@ -40,7 +40,7 @@
"eslint-import-resolver-webpack": "^0.13.1",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.26.0",
"eslint-plugin-react": "^7.26.1",
"fancy-log": "^1.3.3",
"file-loader": "^6.2.0",
"friendly-errors-webpack-plugin": "^1.7.0",
@@ -61,7 +61,7 @@
"moment": "^2.29.1",
"monaco-editor": "^0.27.0",
"monaco-editor-webpack-plugin": "^4.1.2",
"nanoid": "^3.1.25",
"nanoid": "^3.1.28",
"normalize.css": "^8.0.1",
"nprogress": "^0.2.0",
"pickadate": "^3.6.4",
@@ -18,10 +18,7 @@ const page = new NamedPage(['contest_edit', 'contest_create', 'homework_create',
}
const message = `Confirm deleting this ${pagename.split('_')[0]}? Its status will be deleted as well.`;
return new ConfirmDialog({
$body: tpl`
<div class="typo">
<p>${i18n(message)}</p>
</div>`,
$body: tpl.typoMsg(i18n(message)),
}).open().then((action) => {
if (action !== 'yes') return;
confirmed = true;
@@ -1,6 +1,9 @@
import yaml from 'js-yaml';
import { getScoreColor } from '@hydrooj/utils/lib/status';
import { NamedPage } from 'vj/misc/Page';
import tpl from 'vj/utils/tpl';
import i18n from 'vj/utils/i18n';
import { ConfirmDialog } from 'vj/components/dialog';
import { downloadProblemSet } from 'vj/components/zipDownloader';
import loadReactRedux from 'vj/utils/loadReactRedux';
import delay from 'vj/utils/delay';
@@ -260,6 +263,15 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
leaveScratchpadMode();
ev.preventDefault();
});
$(document).on('click', '[name="problem-sidebar__rejudge"]', (ev) => {
ev.preventDefault();
new ConfirmDialog({
$body: tpl.typoMsg(i18n('Confirm rejudge this problem?')),
}).open().then((action) => {
if (action !== 'yes') return;
$(ev.currentTarget).closest('form').trigger('submit');
});
});
$(document).on('click', '[name="show_tags"]', (ev) => {
$(ev.currentTarget).hide();
$('span.tags').css('display', 'inline-block');
@@ -56,7 +56,7 @@
<form method="post" action="{{ url('problem_detail', pid=pdoc.docId) }}">
<input type="hidden" name="operation" value="rejudge">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
<button type="submit" class="menu__link">
<button type="submit" class="menu__link" name="problem-sidebar__rejudge">
<span class="icon icon-refresh"></span> {{ _('Rejudge all submissions') }}
</button>
</form>
+8
View File
@@ -13,6 +13,14 @@ export default function tpl(pieces, ...substitutions) {
return result;
}
tpl.typoMsg = function (msg) {
return tpl`
<div class="typo">
<p>${msg}</p>
</div>
`;
};
export function rawHtml(html) {
return {
templateRaw: true,
+1 -1
View File
@@ -224,7 +224,7 @@ export function bufferToStream(buffer: Buffer): NodeJS.ReadableStream {
export function sleep(timeout: number) {
return new Promise((resolve) => {
setTimeout(resolve, timeout);
setTimeout(() => resolve(true), timeout);
});
}
+1 -1
View File
@@ -12,7 +12,7 @@
"js-yaml": "^4.1.0",
"moment": "^2.29.1",
"mongodb": "^3.7.1",
"systeminformation": "^5.9.3"
"systeminformation": "^5.9.4"
},
"devDependencies": {
"@types/fs-extra": "^9.0.13",
+1 -1
View File
@@ -16,7 +16,7 @@
},
"devDependencies": {
"@types/jsdom": "^16.2.13",
"@types/lodash": "^4.14.174",
"@types/lodash": "^4.14.175",
"@types/superagent": "^4.1.13",
"@types/superagent-proxy": "^2.0.1"
}
+1 -2
View File
@@ -11,7 +11,7 @@ import * as setting from 'hydrooj/src/model/setting';
import { IBasicProvider, RemoteAccount } from '../interface';
proxy(superagent);
const logger = new Logger('codeforces');
const logger = new Logger('remote/codeforces');
const VERDICT = {
RUNTIME_ERROR: STATUS.STATUS_RUNTIME_ERROR,
@@ -100,7 +100,6 @@ export default class CodeforcesProvider implements IBasicProvider {
password: this.account.password,
remember: 'on',
});
console.log(res.header);
const cookie = res.header['set-cookie'];
if (cookie) {
await this.save({ cookie });