2021-03-11 19:13:27 +05:30
|
|
|
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
|
2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2022-04-04 11:22:00 +05:30
|
|
|
import { setCookie } from '~/lib/utils/common_utils';
|
2022-01-26 12:08:38 +05:30
|
|
|
import UsersSelect from '~/users_select';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
export default class IssuableContext {
|
|
|
|
constructor(currentUser) {
|
|
|
|
this.userSelect = new UsersSelect(currentUser);
|
2021-01-03 14:25:43 +05:30
|
|
|
this.reviewersSelect = new UsersSelect(currentUser, '.js-reviewer-search');
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
$('.issuable-sidebar .inline-update').on('change', 'select', function onClickSelect() {
|
|
|
|
return $(this).submit();
|
|
|
|
});
|
|
|
|
$('.issuable-sidebar .inline-update').on('change', '.js-assignee', function onClickAssignee() {
|
|
|
|
return $(this).submit();
|
|
|
|
});
|
|
|
|
$(document)
|
|
|
|
.off('click', '.issuable-sidebar .dropdown-content a')
|
2021-03-08 18:12:59 +05:30
|
|
|
.on('click', '.issuable-sidebar .dropdown-content a', (e) => e.preventDefault());
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
$(document)
|
|
|
|
.off('click', '.edit-link')
|
|
|
|
.on('click', '.edit-link', function onClickEdit(e) {
|
2016-09-13 17:45:13 +05:30
|
|
|
e.preventDefault();
|
2018-03-17 18:26:18 +05:30
|
|
|
const $block = $(this).parents('.block');
|
|
|
|
const $selectbox = $block.find('.selectbox');
|
2016-09-13 17:45:13 +05:30
|
|
|
if ($selectbox.is(':visible')) {
|
|
|
|
$selectbox.hide();
|
2018-10-15 14:42:47 +05:30
|
|
|
$block.find('.value:not(.dont-hide)').show();
|
2016-09-13 17:45:13 +05:30
|
|
|
} else {
|
|
|
|
$selectbox.show();
|
2018-10-15 14:42:47 +05:30
|
|
|
$block.find('.value:not(.dont-hide)').hide();
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
if ($selectbox.is(':visible')) {
|
|
|
|
setTimeout(() => $block.find('.dropdown-menu-toggle').trigger('click'), 0);
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
window.addEventListener('beforeunload', () => {
|
|
|
|
// collapsed_gutter cookie hides the sidebar
|
|
|
|
const bpBreakpoint = bp.getBreakpointSize();
|
2020-03-13 15:44:24 +05:30
|
|
|
const supportedSizes = ['xs', 'sm', 'md'];
|
|
|
|
|
|
|
|
if (supportedSizes.includes(bpBreakpoint)) {
|
2022-04-04 11:22:00 +05:30
|
|
|
setCookie('collapsed_gutter', true);
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|