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

38 lines
1.0 KiB
JavaScript
Raw Normal View History

import $ from 'jquery';
2018-01-29 12:23:21 +00:00
import axios from './lib/utils/axios_utils';
import { deprecatedCreateFlash as flash } from './flash';
import { s__, __ } from './locale';
import issuableInitBulkUpdateSidebar from './issuable_init_bulk_update_sidebar';
2017-10-26 18:03:48 +00:00
export default class IssuableIndex {
constructor(pagePrefix) {
issuableInitBulkUpdateSidebar.init(pagePrefix);
2017-10-26 18:03:48 +00:00
IssuableIndex.resetIncomingEmailToken();
}
static resetIncomingEmailToken() {
2018-01-30 10:57:00 +00:00
const $resetToken = $('.incoming-email-token-reset');
$resetToken.on('click', e => {
2017-10-26 18:03:48 +00:00
e.preventDefault();
$resetToken.text(s__('EmailToken|resetting...'));
2018-01-29 12:23:21 +00:00
axios
.put($resetToken.attr('href'))
2018-01-29 12:23:21 +00:00
.then(({ data }) => {
$('#issuable_email')
.val(data.new_address)
.focus();
2018-01-29 12:23:21 +00:00
$resetToken.text(s__('EmailToken|reset it'));
2018-01-29 12:23:21 +00:00
})
.catch(() => {
flash(__('There was an error when reseting email token.'));
$resetToken.text(s__('EmailToken|reset it'));
2018-01-29 12:23:21 +00:00
});
2017-10-26 18:03:48 +00:00
});
}
}