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 %}