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

38 lines
1 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 { deprecatedCreateFlash as flash } from './flash';
import { s__, __ } from './locale';
import issuableInitBulkUpdateSidebar from './issuable_init_bulk_update_sidebar';
2017-10-26 14:03:48 -04:00
export default class IssuableIndex {
constructor(pagePrefix) {
issuableInitBulkUpdateSidebar.init(pagePrefix);
2017-10-26 14:03:48 -04:00
IssuableIndex.resetIncomingEmailToken();
}
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();
$resetToken.text(s__('EmailToken|resetting...'));
2018-01-29 07:23:21 -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-29 07:23:21 -05: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.'));
$resetToken.text(s__('EmailToken|reset it'));
2018-01-29 07:23:21 -05:00
});
2017-10-26 14:03:48 -04:00
});
}
}