From a9ccd18b3d1f1009055155a33723d6ed226b110b Mon Sep 17 00:00:00 2001 From: Javier Ferrer Date: Fri, 25 Jun 2021 18:11:22 +0200 Subject: [PATCH] VC/Zoom: Confirm making yourself alternative host (#149) --- .tx/config | 6 +++++ vc_zoom/indico_vc_zoom/client/index.js | 27 ++++++++++++------- vc_zoom/indico_vc_zoom/templates/buttons.html | 2 +- .../translations/messages-js.pot | 27 +++++++++++++++++++ .../indico_vc_zoom/translations/messages.pot | 2 +- 5 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 vc_zoom/indico_vc_zoom/translations/messages-js.pot diff --git a/.tx/config b/.tx/config index 41ecfbd..2a1a981 100644 --- a/.tx/config +++ b/.tx/config @@ -7,6 +7,12 @@ source_file = vc_zoom/indico_vc_zoom/translations/messages.pot source_lang = en type = PO +[indico.vc-zoom-messages-js] +file_filter = vc_zoom/indico_vc_zoom/translations//LC_MESSAGES/messages-js.po +source_file = vc_zoom/indico_vc_zoom/translations/messages-js.pot +source_lang = en +type = PO + [indico.piwik-messages] file_filter = piwik/indico_piwik/translations//LC_MESSAGES/messages.po source_file = piwik/indico_piwik/translations/messages.pot diff --git a/vc_zoom/indico_vc_zoom/client/index.js b/vc_zoom/indico_vc_zoom/client/index.js index 7021a60..c5617e2 100644 --- a/vc_zoom/indico_vc_zoom/client/index.js +++ b/vc_zoom/indico_vc_zoom/client/index.js @@ -5,8 +5,12 @@ // them and/or modify them under the terms of the MIT License; // see the LICENSE file for more details. +/* global confirmPrompt:false, $T:false */ + import {handleAxiosError, indicoAxios} from 'indico/utils/axios'; +const $t = $T.domain('vc_zoom'); + document.addEventListener('DOMContentLoaded', async () => { $('.vc-toolbar').dropdown({ positioning: { @@ -15,15 +19,20 @@ document.addEventListener('DOMContentLoaded', async () => { }); document.querySelectorAll('.vc-toolbar .action-make-host').forEach(elem => { - elem.addEventListener('click', async () => { - const killProgress = IndicoUI.Dialogs.Util.progress(); - try { - await indicoAxios.post(elem.dataset.href); - window.location.reload(); - } catch (error) { - handleAxiosError(error); - killProgress(); - } + elem.addEventListener('click', () => { + confirmPrompt( + $t.gettext('Are you sure you want to be added as an alternative host?'), + $t.gettext('Make me an alternative host') + ).then(async () => { + const killProgress = IndicoUI.Dialogs.Util.progress(); + try { + await indicoAxios.post(elem.dataset.href); + window.location.reload(); + } catch (error) { + handleAxiosError(error); + killProgress(); + } + }); }); }); }); diff --git a/vc_zoom/indico_vc_zoom/templates/buttons.html b/vc_zoom/indico_vc_zoom/templates/buttons.html index 53f9f54..157dea3 100644 --- a/vc_zoom/indico_vc_zoom/templates/buttons.html +++ b/vc_zoom/indico_vc_zoom/templates/buttons.html @@ -7,7 +7,7 @@
  • {% trans %}Make me alternative host{% endtrans %} diff --git a/vc_zoom/indico_vc_zoom/translations/messages-js.pot b/vc_zoom/indico_vc_zoom/translations/messages-js.pot new file mode 100644 index 0000000..5d4a27c --- /dev/null +++ b/vc_zoom/indico_vc_zoom/translations/messages-js.pot @@ -0,0 +1,27 @@ +# Translations template for PROJECT. +# Copyright (C) 2021 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 2021. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2021-06-25 18:04+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.9.1\n" + +#: indico_vc_zoom/client/index.js:24 +msgid "Are you sure you want to be added as an alternative host?" +msgstr "" + +#: indico_vc_zoom/client/index.js:25 +msgid "Make me an alternative host" +msgstr "" + diff --git a/vc_zoom/indico_vc_zoom/translations/messages.pot b/vc_zoom/indico_vc_zoom/translations/messages.pot index a782c6d..9a45da0 100644 --- a/vc_zoom/indico_vc_zoom/translations/messages.pot +++ b/vc_zoom/indico_vc_zoom/translations/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-05-26 17:54+0200\n" +"POT-Creation-Date: 2021-06-25 18:04+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n"