issuable_index.js 1.2 KB
Newer Older
1 2
import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
3

Filipa Lacerda's avatar
Filipa Lacerda committed
4 5 6 7 8 9 10 11 12 13 14 15
export default class IssuableIndex {
  constructor(pagePrefix) {
    this.initBulkUpdate(pagePrefix);
    IssuableIndex.resetIncomingEmailToken();
  }
  initBulkUpdate(pagePrefix) {
    const userCanBulkUpdate = $('.issues-bulk-update').length > 0;
    const alreadyInitialized = !!this.bulkUpdateSidebar;

    if (userCanBulkUpdate && !alreadyInitialized) {
      IssuableBulkUpdateActions.init({
        prefixId: pagePrefix,
16
      });
17

Filipa Lacerda's avatar
Filipa Lacerda committed
18
      this.bulkUpdateSidebar = new IssuableBulkUpdateSidebar();
Fatih Acet's avatar
Fatih Acet committed
19
    }
Filipa Lacerda's avatar
Filipa Lacerda committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  }

  static resetIncomingEmailToken() {
    $('.incoming-email-token-reset').on('click', (e) => {
      e.preventDefault();

      $.ajax({
        type: 'PUT',
        url: $('.incoming-email-token-reset').attr('href'),
        dataType: 'json',
        success(response) {
          $('#issue_email').val(response.new_issue_address).focus();
        },
        beforeSend() {
          $('.incoming-email-token-reset').text('resetting...');
        },
        complete() {
          $('.incoming-email-token-reset').text('reset it');
        },
      });
    });
  }
}