debian-mirror-gitlab/app/assets/javascripts/issuable_index.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import axios from './lib/utils/axios_utils';
import flash from './flash';
import { __ } from './locale';
2017-09-10 17:25:29 +05:30
import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
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-09-13 17:45:13 +05:30
});
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
this.bulkUpdateSidebar = new IssuableBulkUpdateSidebar();
}
}
2016-09-29 09:46:39 +05:30
2018-03-17 18:26:18 +05:30
static resetIncomingEmailToken() {
const $resetToken = $('.incoming-email-token-reset');
2016-09-29 09:46:39 +05:30
2018-03-17 18:26:18 +05:30
$resetToken.on('click', (e) => {
e.preventDefault();
2016-09-29 09:46:39 +05:30
2018-03-17 18:26:18 +05:30
$resetToken.text('resetting...');
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
axios.put($resetToken.attr('href'))
.then(({ data }) => {
$('#issuable_email').val(data.new_address).focus();
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
$resetToken.text('reset it');
})
.catch(() => {
flash(__('There was an error when reseting email token.'));
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
$resetToken.text('reset it');
2017-08-17 22:00:37 +05:30
});
2018-03-17 18:26:18 +05:30
});
}
}