Skip to content

Commit

Permalink
Reactify email sending dialog (indico#5547)
Browse files Browse the repository at this point in the history
Co-authored-by: Pedro Lourenço <[email protected]>
Co-authored-by: Adrian Moennich <[email protected]>
  • Loading branch information
3 people authored Nov 24, 2022
1 parent 3b7a87c commit f0f318c
Show file tree
Hide file tree
Showing 19 changed files with 706 additions and 125 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ settings:
- ['indico/modules/events/reviewing', './indico/modules/events/client/js/reviewing']
- ['indico/modules/events/editing', './indico/modules/events/editing/client/js']
- ['indico/modules/events/management', './indico/modules/events/management/client/js']
- ['indico/modules/events/persons', './indico/modules/events/persons/client/js']
- ['indico/modules/events', './indico/modules/events/client/js']
- ['indico', './indico/web/client/js']
extensions: [.js, .jsx, .json]
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Bugfixes
on someone's behalf (:pr:`5574`)
- Disallow nonsensical retention periods and visibility durations (:pr:`5576`)

Internal Changes
^^^^^^^^^^^^^^^^

- Refactor email-sending dialog using React (:pr:`5547`)


Version 3.2.1
-------------
Expand Down
24 changes: 24 additions & 0 deletions indico/modules/events/management/client/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,37 @@ import 'indico/modules/events/util/static_filters';

import './badges';

import {EmailButton} from 'indico/modules/events/persons/Email';
import {$T} from 'indico/utils/i18n';
import {natSortCompare} from 'indico/utils/sort';

import {SingleEventMove, EventPublish} from './EventMove';
import {SeriesManagement} from './SeriesManagement';

(function(global) {
global.setupEmailButton = function setupEmailButton(field, trigger) {
const element = document.querySelector(field);
const {eventId, roleId, personSelector, userSelector} = element.dataset;
const extraParams = {};
if (element.dataset.noAccount !== undefined) {
extraParams.noAccount = true;
}
if (element.dataset.notInvitedOnly !== undefined) {
extraParams.notInvitedOnly = true;
}
ReactDOM.render(
<EmailButton
eventId={+eventId}
roleId={roleId && +roleId}
personSelector={personSelector}
userSelector={userSelector}
triggerSelector={trigger}
{...extraParams}
/>,
element
);
};

global.setupEventManagementActionMenu = function setupEventManagementActionMenu() {
const moveContainer = document.querySelector('#event-action-move-container');
if (moveContainer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
</table>
</div>
<div class="form-group-mail hide-if-locked">
<button class="i-button icon-mail right highlight disabled js-requires-selected-row"
{% block send_email_href %}
data-href="{{ url_for('persons.email_event_persons', event) }}"
{% endblock %}
data-title="{% trans %}Send email{% endtrans %}"
data-method="POST"
data-params-selector="#person-list-table input[name=person_id]:checkbox:checked:visible, #person-list-table input[name=user_id]:checkbox:checked:visible"
data-ajax-dialog>
<div id="persons-email"
data-event-id="{{ event.id }}"
data-user-selector="#person-list-table input[name=user_id][type=checkbox]:checked"
data-person-selector="#person-list-table input[name=person_id][type=checkbox]:checked">
</div>
<button id="persons-email-trigger"
class="i-button icon-mail right highlight disabled js-requires-selected-row">
{%- trans %}Send emails{% endtrans -%}
</button>
</div>
</div>
<script>
setupEventPersonsList();
setupEmailButton('#persons-email', '#persons-email-trigger');
</script>
10 changes: 8 additions & 2 deletions indico/modules/events/persons/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.

from indico.modules.events.persons.controllers import (RHDeleteUnusedEventPerson, RHEmailEventPersons,
from indico.modules.events.persons.controllers import (RHAPIEmailEventPersonsMetadata, RHAPIEmailEventPersonsSend,
RHDeleteUnusedEventPerson, RHEmailEventPersonsPreview,
RHEventPersonSearch, RHGrantModificationRights,
RHGrantSubmissionRights, RHManagePersonLists, RHPersonsList,
RHRevokeSubmissionRights, RHUpdateEventPerson)
Expand All @@ -16,7 +17,12 @@
url_prefix='/event/<int:event_id>/manage')

_bp.add_url_rule('/persons/', 'person_list', RHPersonsList)
_bp.add_url_rule('/persons/email', 'email_event_persons', RHEmailEventPersons, methods=('POST',))
_bp.add_url_rule('/api/persons/email/send', 'api_email_event_persons_send', RHAPIEmailEventPersonsSend,
methods=('POST',))
_bp.add_url_rule('/api/persons/email/metadata', 'api_email_event_persons_metadata', RHAPIEmailEventPersonsMetadata,
methods=('POST',))
_bp.add_url_rule('/api/persons/email/preview', 'email_event_persons_preview', RHEmailEventPersonsPreview,
methods=('POST',))
_bp.add_url_rule('/persons/grant-submission', 'grant_submission_rights', RHGrantSubmissionRights, methods=('POST',))
_bp.add_url_rule('/persons/grant-modification', 'grant_modification_rights', RHGrantModificationRights,
methods=('POST',))
Expand Down
Loading

0 comments on commit f0f318c

Please sign in to comment.