2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
2018-01-29 07:23:21 -05:00
|
|
|
import axios from './lib/utils/axios_utils';
|
|
|
|
import flash from './flash';
|
2019-05-02 10:49:16 -04:00
|
|
|
import { s__, __ } from './locale';
|
2017-05-15 18:12:43 -04:00
|
|
|
import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar';
|
|
|
|
import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
|
2016-12-13 22:01:05 -05:00
|
|
|
|
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,
|
2016-08-24 07:46:07 -04:00
|
|
|
});
|
2016-10-18 14:03:31 -04:00
|
|
|
|
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');
|
|
|
|
|
2018-10-10 03:13:34 -04:00
|
|
|
$resetToken.on('click', e => {
|
2017-10-26 14:03:48 -04:00
|
|
|
e.preventDefault();
|
|
|
|
|
2019-05-02 10:49:16 -04:00
|
|
|
$resetToken.text(s__('EmailToken|resetting...'));
|
2018-01-29 07:23:21 -05:00
|
|
|
|
2018-10-10 03:13:34 -04:00
|
|
|
axios
|
|
|
|
.put($resetToken.attr('href'))
|
2018-01-29 07:23:21 -05:00
|
|
|
.then(({ data }) => {
|
2018-10-10 03:13:34 -04:00
|
|
|
$('#issuable_email')
|
|
|
|
.val(data.new_address)
|
|
|
|
.focus();
|
2018-01-29 07:23:21 -05:00
|
|
|
|
2019-05-02 10:49:16 -04:00
|
|
|
$resetToken.text(s__('EmailToken|reset it'));
|
2018-01-29 07:23:21 -05:00
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
flash(__('There was an error when reseting email token.'));
|
|
|
|
|
2019-05-02 10:49:16 -04:00
|
|
|
$resetToken.text(s__('EmailToken|reset it'));
|
2018-01-29 07:23:21 -05:00
|
|
|
});
|
2017-10-26 14:03:48 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|