From 4052fa691ecca7e9499952b09154340c55214bc8 Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 18 May 2021 12:28:02 +0800 Subject: [PATCH] =?UTF-8?q?ui:=20=E4=BF=AE=E5=A4=8D=20og:url=20=E6=B3=84?= =?UTF-8?q?=E6=BC=8F=E6=BA=90=E7=AB=99ip=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui-default/package.json | 2 +- .../ui-default/pages/problem_files.page.js | 27 ++++++++++--------- .../ui-default/templates/layout/html5.html | 5 ++-- .../ui-default/templates/problem_files.html | 6 +++-- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index a42206180..aadda825e 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.8.24", + "version": "4.8.25", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", diff --git a/packages/ui-default/pages/problem_files.page.js b/packages/ui-default/pages/problem_files.page.js index 76d62d8f6..ad209a35a 100644 --- a/packages/ui-default/pages/problem_files.page.js +++ b/packages/ui-default/pages/problem_files.page.js @@ -198,6 +198,7 @@ const page = new NamedPage('problem_files', () => { let content = ''; if (ev) { const link = $(ev.currentTarget).find('a').attr('href'); + if (!link) return; if (filesize > 8 * 1024 * 1024) Notification.error(i18n('file too large')); Notification.info(i18n('Loading file...')); const res = await request.get(link); @@ -217,20 +218,22 @@ const page = new NamedPage('problem_files', () => { await pjax.request({ push: false }); } - $('.problem-files-testdata .col--name').on('click', (ev) => handleEdit('testdata', ev)); - $('.problem-files-additional_file .col--name').on('click', (ev) => handleEdit('additional_file', ev)); - $('.problem-files-testdata').on('dragover', (ev) => handleDragOver('testdata', ev)); - $('.problem-files-additional_file').on('dragover', (ev) => handleDragOver('additional_file', ev)); - $('.problem-files-testdata').on('drop', (ev) => handleDrop('testdata', ev)); - $('.problem-files-additional_file').on('drop', (ev) => handleDrop('additional_file', ev)); - $('[name="upload_testdata"]').on('click', () => handleClickUpload('testdata')); - $('[name="create_testdata"]').on('click', () => handleEdit('testdata')); + if ($('[name="remove_selected_testdata"]').length) { + $('.problem-files-testdata .col--name').on('click', (ev) => handleEdit('testdata', ev)); + $('.problem-files-additional_file .col--name').on('click', (ev) => handleEdit('additional_file', ev)); + $('.problem-files-testdata').on('dragover', (ev) => handleDragOver('testdata', ev)); + $('.problem-files-additional_file').on('dragover', (ev) => handleDragOver('additional_file', ev)); + $('.problem-files-testdata').on('drop', (ev) => handleDrop('testdata', ev)); + $('.problem-files-additional_file').on('drop', (ev) => handleDrop('additional_file', ev)); + $('[name="upload_testdata"]').on('click', () => handleClickUpload('testdata')); + $('[name="upload_file"]').on('click', () => handleClickUpload('additional_file')); + $('[name="create_testdata"]').on('click', () => handleEdit('testdata')); + $('[name="create_file"]').on('click', () => handleEdit('additional_file')); + $('[name="remove_selected_testdata"]').on('click', () => handleClickRemoveSelected('testdata')); + $('[name="remove_selected_file"]').on('click', () => handleClickRemoveSelected('additional_file')); + } $('[name="download_selected_testdata"]').on('click', () => handleClickDownloadSelected('testdata')); - $('[name="remove_selected_testdata"]').on('click', () => handleClickRemoveSelected('testdata')); - $('[name="upload_file"]').on('click', () => handleClickUpload('additional_file')); - $('[name="create_file"]').on('click', () => handleEdit('additional_file')); $('[name="download_selected_file"]').on('click', () => handleClickDownloadSelected('additional_file')); - $('[name="remove_selected_file"]').on('click', () => handleClickRemoveSelected('additional_file')); }); export default page; diff --git a/packages/ui-default/templates/layout/html5.html b/packages/ui-default/templates/layout/html5.html index a35beb86f..acdbc0cc9 100644 --- a/packages/ui-default/templates/layout/html5.html +++ b/packages/ui-default/templates/layout/html5.html @@ -23,7 +23,7 @@ {% block ogp %} - + {% endblock %} {% if not isIE(handler.request.headers['user-agent']) %} @@ -40,13 +40,12 @@ {% endif %} - {{ handler.request.headers.hmr|default('')|safe }} {% block body %}{% endblock %} {% if not isIE(handler.request.headers['user-agent']) %} + diff --git a/packages/ui-default/templates/problem_files.html b/packages/ui-default/templates/problem_files.html index b49dd2580..33dde88da 100644 --- a/packages/ui-default/templates/problem_files.html +++ b/packages/ui-default/templates/problem_files.html @@ -14,11 +14,13 @@ {{ noscript_note.render() }} {% include "partials/problem_files-testdata.html" %} - {% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %} + {% if handler.user.own(pdoc) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA) %} {% if testdata.length %}
- + {% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %} + + {% endif %}
{% endif %} {% endif %}