gitlab-org--gitlab-foss/app/assets/javascripts/issuable_index.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

import $ from 'jquery';
2018-01-29 07:23:21 -05:00
import axios from './lib/utils/axios_utils';
import flash from './flash';
import { __ } from './locale';
import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
2017-10-26 14:03:48 -04:00
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,
});
2017-10-26 14:03:48 -04:00
this.bulkUpdateSidebar = new IssuableBulkUpdateSidebar();
2016-07-24 16:45:11 -04:00
}
2017-10-26 14:03:48 -04:00
}
static resetIncomingEmailToken() {
2018-01-30 05:57:00 -05:00
const $resetToken = $('.incoming-email-token-reset');
$resetToken.on('click', (e) => {
2017-10-26 14:03:48 -04:00
e.preventDefault();
2018-01-30 05:57:00 -05:00
$resetToken.text('resetting...');
2018-01-29 07:23:21 -05:00
2018-01-30 05:57:00 -05:00
axios.put($resetToken.attr('href'))
2018-01-29 07:23:21 -05:00
.then(({ data }) => {
$('#issuable_email').val(data.new_address).focus();
2018-01-30 05:57:00 -05:00
$resetToken.text('reset it');
2018-01-29 07:23:21 -05:00
})
.catch(() => {
flash(__('There was an error when reseting email token.'));
2018-01-30 05:57:00 -05:00
$resetToken.text('reset it');
2018-01-29 07:23:21 -05:00
});
2017-10-26 14:03:48 -04:00
});
}
}