You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo-issue.js 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. import {htmlEscape} from 'escape-goat';
  2. import attachTribute from './tribute.js';
  3. import {createCommentSimpleMDE} from './comp/CommentSimpleMDE.js';
  4. import {initCompImagePaste} from './comp/ImagePaste.js';
  5. import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
  6. const {appSubUrl, csrfToken} = window.config;
  7. export function initRepoIssueTimeTracking() {
  8. $(document).on('click', '.issue-add-time', () => {
  9. $('.issue-start-time-modal').modal({
  10. duration: 200,
  11. onApprove() {
  12. $('#add_time_manual_form').trigger('submit');
  13. },
  14. }).modal('show');
  15. $('.issue-start-time-modal input').on('keydown', (e) => {
  16. if ((e.keyCode || e.key) === 13) {
  17. $('#add_time_manual_form').trigger('submit');
  18. }
  19. });
  20. });
  21. $(document).on('click', '.issue-start-time, .issue-stop-time', () => {
  22. $('#toggle_stopwatch_form').trigger('submit');
  23. });
  24. $(document).on('click', '.issue-cancel-time', () => {
  25. $('#cancel_stopwatch_form').trigger('submit');
  26. });
  27. $(document).on('click', 'button.issue-delete-time', function () {
  28. const sel = `.issue-delete-time-modal[data-id="${$(this).data('id')}"]`;
  29. $(sel).modal({
  30. duration: 200,
  31. onApprove() {
  32. $(`${sel} form`).trigger('submit');
  33. },
  34. }).modal('show');
  35. });
  36. }
  37. function updateDeadline(deadlineString) {
  38. $('#deadline-err-invalid-date').hide();
  39. $('#deadline-loader').addClass('loading');
  40. let realDeadline = null;
  41. if (deadlineString !== '') {
  42. const newDate = Date.parse(deadlineString);
  43. if (Number.isNaN(newDate)) {
  44. $('#deadline-loader').removeClass('loading');
  45. $('#deadline-err-invalid-date').show();
  46. return false;
  47. }
  48. realDeadline = new Date(newDate);
  49. }
  50. $.ajax(`${$('#update-issue-deadline-form').attr('action')}/deadline`, {
  51. data: JSON.stringify({
  52. due_date: realDeadline,
  53. }),
  54. headers: {
  55. 'X-Csrf-Token': csrfToken,
  56. 'X-Remote': true,
  57. },
  58. contentType: 'application/json',
  59. type: 'POST',
  60. success() {
  61. window.location.reload();
  62. },
  63. error() {
  64. $('#deadline-loader').removeClass('loading');
  65. $('#deadline-err-invalid-date').show();
  66. },
  67. });
  68. }
  69. export function initRepoIssueDue() {
  70. $(document).on('click', '.issue-due-edit', () => {
  71. $('#deadlineForm').fadeToggle(150);
  72. });
  73. $(document).on('click', '.issue-due-remove', () => {
  74. updateDeadline('');
  75. });
  76. $(document).on('submit', '.issue-due-form', () => {
  77. updateDeadline($('#deadlineDate').val());
  78. return false;
  79. });
  80. }
  81. export function initRepoIssueList() {
  82. const repolink = $('#repolink').val();
  83. const repoId = $('#repoId').val();
  84. const crossRepoSearch = $('#crossRepoSearch').val();
  85. const tp = $('#type').val();
  86. let issueSearchUrl = `${appSubUrl}/api/v1/repos/${repolink}/issues?q={query}&type=${tp}`;
  87. if (crossRepoSearch === 'true') {
  88. issueSearchUrl = `${appSubUrl}/api/v1/repos/issues/search?q={query}&priority_repo_id=${repoId}&type=${tp}`;
  89. }
  90. $('#new-dependency-drop-list')
  91. .dropdown({
  92. apiSettings: {
  93. url: issueSearchUrl,
  94. onResponse(response) {
  95. const filteredResponse = {success: true, results: []};
  96. const currIssueId = $('#new-dependency-drop-list').data('issue-id');
  97. // Parse the response from the api to work with our dropdown
  98. $.each(response, (_i, issue) => {
  99. // Don't list current issue in the dependency list.
  100. if (issue.id === currIssueId) {
  101. return;
  102. }
  103. filteredResponse.results.push({
  104. name: `#${issue.number} ${htmlEscape(issue.title)
  105. }<div class="text small dont-break-out">${htmlEscape(issue.repository.full_name)}</div>`,
  106. value: issue.id,
  107. });
  108. });
  109. return filteredResponse;
  110. },
  111. cache: false,
  112. },
  113. fullTextSearch: true,
  114. });
  115. function excludeLabel(item) {
  116. const href = $(item).attr('href');
  117. const id = $(item).data('label-id');
  118. const regStr = `labels=((?:-?[0-9]+%2c)*)(${id})((?:%2c-?[0-9]+)*)&`;
  119. const newStr = 'labels=$1-$2$3&';
  120. window.location = href.replace(new RegExp(regStr), newStr);
  121. }
  122. $('.menu a.label-filter-item').each(function () {
  123. $(this).on('click', function (e) {
  124. if (e.altKey) {
  125. e.preventDefault();
  126. excludeLabel(this);
  127. }
  128. });
  129. });
  130. $('.menu .ui.dropdown.label-filter').on('keydown', (e) => {
  131. if (e.altKey && e.keyCode === 13) {
  132. const selectedItems = $('.menu .ui.dropdown.label-filter .menu .item.selected');
  133. if (selectedItems.length > 0) {
  134. excludeLabel($(selectedItems[0]));
  135. }
  136. }
  137. });
  138. }
  139. export function initRepoIssueCommentDelete() {
  140. // Delete comment
  141. $(document).on('click', '.delete-comment', function () {
  142. const $this = $(this);
  143. if (window.confirm($this.data('locale'))) {
  144. $.post($this.data('url'), {
  145. _csrf: csrfToken,
  146. }).done(() => {
  147. const $conversationHolder = $this.closest('.conversation-holder');
  148. $(`#${$this.data('comment-id')}`).remove();
  149. if ($conversationHolder.length && !$conversationHolder.find('.comment').length) {
  150. const path = $conversationHolder.data('path');
  151. const side = $conversationHolder.data('side');
  152. const idx = $conversationHolder.data('idx');
  153. const lineType = $conversationHolder.closest('tr').data('line-type');
  154. if (lineType === 'same') {
  155. $(`[data-path="${path}"] a.add-code-comment[data-idx="${idx}"]`).removeClass('invisible');
  156. } else {
  157. $(`[data-path="${path}"] a.add-code-comment[data-side="${side}"][data-idx="${idx}"]`).removeClass('invisible');
  158. }
  159. $conversationHolder.remove();
  160. }
  161. });
  162. }
  163. return false;
  164. });
  165. }
  166. export function initRepoIssueDependencyDelete() {
  167. // Delete Issue dependency
  168. $(document).on('click', '.delete-dependency-button', (e) => {
  169. const id = e.currentTarget.getAttribute('data-id');
  170. const type = e.currentTarget.getAttribute('data-type');
  171. $('.remove-dependency').modal({
  172. closable: false,
  173. duration: 200,
  174. onApprove: () => {
  175. $('#removeDependencyID').val(id);
  176. $('#dependencyType').val(type);
  177. $('#removeDependencyForm').trigger('submit');
  178. },
  179. }).modal('show');
  180. });
  181. }
  182. export function initRepoIssueCodeCommentCancel() {
  183. // Cancel inline code comment
  184. $(document).on('click', '.cancel-code-comment', (e) => {
  185. const form = $(e.currentTarget).closest('form');
  186. if (form.length > 0 && form.hasClass('comment-form')) {
  187. form.addClass('hide');
  188. form.closest('.comment-code-cloud').find('button.comment-form-reply').show();
  189. } else {
  190. form.closest('.comment-code-cloud').remove();
  191. }
  192. });
  193. }
  194. export function initRepoIssueStatusButton() {
  195. // Change status
  196. const $statusButton = $('#status-button');
  197. $('#comment-form textarea').on('keyup', function () {
  198. const $simplemde = $(this).data('simplemde');
  199. const value = ($simplemde && $simplemde.value()) ? $simplemde.value() : $(this).val();
  200. $statusButton.text($statusButton.data(value.length === 0 ? 'status' : 'status-and-comment'));
  201. });
  202. $statusButton.on('click', () => {
  203. $('#status').val($statusButton.data('status-val'));
  204. $('#comment-form').trigger('submit');
  205. });
  206. }
  207. export function initRepoPullRequestMerge() {
  208. // Pull Request merge button
  209. const $mergeButton = $('.merge-button > button');
  210. $mergeButton.on('click', function (e) {
  211. e.preventDefault();
  212. $(`.${$(this).data('do')}-fields`).show();
  213. $(this).parent().hide();
  214. $('.instruct-toggle').hide();
  215. $('.instruct-content').hide();
  216. });
  217. $('.merge-button > .dropdown').dropdown({
  218. onChange(_text, _value, $choice) {
  219. if ($choice.data('do')) {
  220. $mergeButton.find('.button-text').text($choice.text());
  221. $mergeButton.data('do', $choice.data('do'));
  222. }
  223. }
  224. });
  225. $('.merge-cancel').on('click', function (e) {
  226. e.preventDefault();
  227. $(this).closest('.form').hide();
  228. $mergeButton.parent().show();
  229. $('.instruct-toggle').show();
  230. });
  231. }
  232. export function initRepoPullRequestUpdate() {
  233. // Pull Request update button
  234. const $pullUpdateButton = $('.update-button > button');
  235. $pullUpdateButton.on('click', function (e) {
  236. e.preventDefault();
  237. const $this = $(this);
  238. const redirect = $this.data('redirect');
  239. $this.addClass('loading');
  240. $.post($this.data('do'), {
  241. _csrf: csrfToken
  242. }).done((data) => {
  243. if (data.redirect) {
  244. window.location.href = data.redirect;
  245. } else if (redirect) {
  246. window.location.href = redirect;
  247. } else {
  248. window.location.reload();
  249. }
  250. });
  251. });
  252. $('.update-button > .dropdown').dropdown({
  253. onChange(_text, _value, $choice) {
  254. const $url = $choice.data('do');
  255. if ($url) {
  256. $pullUpdateButton.find('.button-text').text($choice.text());
  257. $pullUpdateButton.data('do', $url);
  258. }
  259. }
  260. });
  261. }
  262. export function initRepoPullRequestMergeInstruction() {
  263. $('.show-instruction').on('click', () => {
  264. $('.instruct-content').toggle();
  265. });
  266. }
  267. export function initRepoIssueReferenceRepositorySearch() {
  268. $('.issue_reference_repository_search')
  269. .dropdown({
  270. apiSettings: {
  271. url: `${appSubUrl}/api/v1/repos/search?q={query}&limit=20`,
  272. onResponse(response) {
  273. const filteredResponse = {success: true, results: []};
  274. $.each(response.data, (_r, repo) => {
  275. filteredResponse.results.push({
  276. name: htmlEscape(repo.full_name),
  277. value: repo.full_name
  278. });
  279. });
  280. return filteredResponse;
  281. },
  282. cache: false,
  283. },
  284. onChange(_value, _text, $choice) {
  285. const $form = $choice.closest('form');
  286. $form.attr('action', `${appSubUrl}/${_text}/issues/new`);
  287. },
  288. fullTextSearch: true
  289. });
  290. }
  291. export function initRepoIssueWipTitle() {
  292. $('.title_wip_desc > a').on('click', (e) => {
  293. e.preventDefault();
  294. const $issueTitle = $('#issue_title');
  295. $issueTitle.focus();
  296. const value = $issueTitle.val().trim().toUpperCase();
  297. const wipPrefixes = $('.title_wip_desc').data('wip-prefixes');
  298. for (const prefix of wipPrefixes) {
  299. if (value.startsWith(prefix.toUpperCase())) {
  300. return;
  301. }
  302. }
  303. $issueTitle.val(`${wipPrefixes[0]} ${$issueTitle.val()}`);
  304. });
  305. }
  306. export async function updateIssuesMeta(url, action, issueIds, elementId) {
  307. return $.ajax({
  308. type: 'POST',
  309. url,
  310. data: {
  311. _csrf: csrfToken,
  312. action,
  313. issue_ids: issueIds,
  314. id: elementId,
  315. },
  316. });
  317. }
  318. export function initRepoIssueComments() {
  319. if ($('.repository.view.issue .timeline').length === 0) return;
  320. $('.re-request-review').on('click', function (e) {
  321. e.preventDefault();
  322. const url = $(this).data('update-url');
  323. const issueId = $(this).data('issue-id');
  324. const id = $(this).data('id');
  325. const isChecked = $(this).hasClass('checked');
  326. updateIssuesMeta(
  327. url,
  328. isChecked ? 'detach' : 'attach',
  329. issueId,
  330. id,
  331. ).then(() => window.location.reload()); // eslint-disable-line github/no-then
  332. });
  333. $('.dismiss-review-btn').on('click', function (e) {
  334. e.preventDefault();
  335. const $this = $(this);
  336. const $dismissReviewModal = $this.next();
  337. $dismissReviewModal.modal('show');
  338. });
  339. $(document).on('click', (event) => {
  340. const urlTarget = $(':target');
  341. if (urlTarget.length === 0) return;
  342. const urlTargetId = urlTarget.attr('id');
  343. if (!urlTargetId) return;
  344. if (!/^(issue|pull)(comment)?-\d+$/.test(urlTargetId)) return;
  345. const $target = $(event.target);
  346. if ($target.closest(`#${urlTargetId}`).length === 0) {
  347. const scrollPosition = $(window).scrollTop();
  348. window.location.hash = '';
  349. $(window).scrollTop(scrollPosition);
  350. window.history.pushState(null, null, ' ');
  351. }
  352. });
  353. }
  354. function assignMenuAttributes(menu) {
  355. const id = Math.floor(Math.random() * Math.floor(1000000));
  356. menu.attr('data-write', menu.attr('data-write') + id);
  357. menu.attr('data-preview', menu.attr('data-preview') + id);
  358. menu.find('.item').each(function () {
  359. const tab = $(this).attr('data-tab') + id;
  360. $(this).attr('data-tab', tab);
  361. });
  362. menu.parent().find("*[data-tab='write']").attr('data-tab', `write${id}`);
  363. menu.parent().find("*[data-tab='preview']").attr('data-tab', `preview${id}`);
  364. initCompMarkupContentPreviewTab(menu.parent('.form'));
  365. return id;
  366. }
  367. export function initRepoPullRequestReview() {
  368. if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) {
  369. const commentDiv = $(window.location.hash);
  370. if (commentDiv) {
  371. // get the name of the parent id
  372. const groupID = commentDiv.closest('div[id^="code-comments-"]').attr('id');
  373. if (groupID && groupID.startsWith('code-comments-')) {
  374. const id = groupID.substr(14);
  375. $(`#show-outdated-${id}`).addClass('hide');
  376. $(`#code-comments-${id}`).removeClass('hide');
  377. $(`#code-preview-${id}`).removeClass('hide');
  378. $(`#hide-outdated-${id}`).removeClass('hide');
  379. commentDiv[0].scrollIntoView();
  380. }
  381. }
  382. }
  383. $(document).on('click', '.show-outdated', function (e) {
  384. e.preventDefault();
  385. const id = $(this).data('comment');
  386. $(this).addClass('hide');
  387. $(`#code-comments-${id}`).removeClass('hide');
  388. $(`#code-preview-${id}`).removeClass('hide');
  389. $(`#hide-outdated-${id}`).removeClass('hide');
  390. });
  391. $(document).on('click', '.hide-outdated', function (e) {
  392. e.preventDefault();
  393. const id = $(this).data('comment');
  394. $(this).addClass('hide');
  395. $(`#code-comments-${id}`).addClass('hide');
  396. $(`#code-preview-${id}`).addClass('hide');
  397. $(`#show-outdated-${id}`).removeClass('hide');
  398. });
  399. $(document).on('click', 'button.comment-form-reply', function (e) {
  400. e.preventDefault();
  401. $(this).hide();
  402. const form = $(this).closest('.comment-code-cloud').find('.comment-form');
  403. form.removeClass('hide');
  404. const $textarea = form.find('textarea');
  405. let $simplemde;
  406. if ($textarea.data('simplemde')) {
  407. $simplemde = $textarea.data('simplemde');
  408. } else {
  409. attachTribute($textarea.get(), {mentions: true, emoji: true});
  410. $simplemde = createCommentSimpleMDE($textarea);
  411. $textarea.data('simplemde', $simplemde);
  412. }
  413. $textarea.focus();
  414. $simplemde.codemirror.focus();
  415. assignMenuAttributes(form.find('.menu'));
  416. });
  417. const $reviewBox = $('.review-box');
  418. if ($reviewBox.length === 1) {
  419. createCommentSimpleMDE($reviewBox.find('textarea'));
  420. initCompImagePaste($reviewBox);
  421. }
  422. // The following part is only for diff views
  423. if ($('.repository.pull.diff').length === 0) {
  424. return;
  425. }
  426. $('.btn-review').on('click', function (e) {
  427. e.preventDefault();
  428. $(this).closest('.dropdown').find('.menu').toggle('visible');
  429. }).closest('.dropdown').find('.close').on('click', function (e) {
  430. e.preventDefault();
  431. $(this).closest('.menu').toggle('visible');
  432. });
  433. $(document).on('click', 'a.add-code-comment', async function (e) {
  434. if ($(e.target).hasClass('btn-add-single')) return; // https://github.com/go-gitea/gitea/issues/4745
  435. e.preventDefault();
  436. const isSplit = $(this).closest('.code-diff').hasClass('code-diff-split');
  437. const side = $(this).data('side');
  438. const idx = $(this).data('idx');
  439. const path = $(this).closest('[data-path]').data('path');
  440. const tr = $(this).closest('tr');
  441. const lineType = tr.data('line-type');
  442. let ntr = tr.next();
  443. if (!ntr.hasClass('add-comment')) {
  444. ntr = $(`
  445. <tr class="add-comment" data-line-type="${lineType}">
  446. ${isSplit ? `
  447. <td class="lines-num"></td>
  448. <td class="lines-type-marker"></td>
  449. <td class="add-comment-left"></td>
  450. <td class="lines-num"></td>
  451. <td class="lines-type-marker"></td>
  452. <td class="add-comment-right"></td>
  453. ` : `
  454. <td colspan="2" class="lines-num"></td>
  455. <td class="add-comment-left add-comment-right" colspan="2"></td>
  456. `}
  457. </tr>`);
  458. tr.after(ntr);
  459. }
  460. const td = ntr.find(`.add-comment-${side}`);
  461. let commentCloud = td.find('.comment-code-cloud');
  462. if (commentCloud.length === 0 && !ntr.find('button[name="is_review"]').length) {
  463. const data = await $.get($(this).closest('[data-new-comment-url]').data('new-comment-url'));
  464. td.html(data);
  465. commentCloud = td.find('.comment-code-cloud');
  466. assignMenuAttributes(commentCloud.find('.menu'));
  467. td.find("input[name='line']").val(idx);
  468. td.find("input[name='side']").val(side === 'left' ? 'previous' : 'proposed');
  469. td.find("input[name='path']").val(path);
  470. const $textarea = commentCloud.find('textarea');
  471. attachTribute($textarea.get(), {mentions: true, emoji: true});
  472. const $simplemde = createCommentSimpleMDE($textarea);
  473. $textarea.focus();
  474. $simplemde.codemirror.focus();
  475. }
  476. });
  477. }
  478. export function initRepoIssueReferenceIssue() {
  479. // Reference issue
  480. $(document).on('click', '.reference-issue', function (event) {
  481. const $this = $(this);
  482. $this.closest('.dropdown').find('.menu').toggle('visible');
  483. const content = $(`#comment-${$this.data('target')}`).text();
  484. const poster = $this.data('poster-username');
  485. const reference = $this.data('reference');
  486. const $modal = $($this.data('modal'));
  487. $modal.find('textarea[name="content"]').val(`${content}\n\n_Originally posted by @${poster} in ${reference}_`);
  488. $modal.modal('show');
  489. event.preventDefault();
  490. });
  491. }
  492. export function initRepoIssueWipToggle() {
  493. // Toggle WIP
  494. $('.toggle-wip a, .toggle-wip button').on('click', async (e) => {
  495. e.preventDefault();
  496. const toggleWip = e.currentTarget.closest('.toggle-wip');
  497. const title = toggleWip.getAttribute('data-title');
  498. const wipPrefix = toggleWip.getAttribute('data-wip-prefix');
  499. const updateUrl = toggleWip.getAttribute('data-update-url');
  500. await $.post(updateUrl, {
  501. _csrf: csrfToken,
  502. title: title?.startsWith(wipPrefix) ? title.substr(wipPrefix.length).trim() : `${wipPrefix.trim()} ${title}`,
  503. });
  504. window.location.reload();
  505. });
  506. }
  507. export function initRepoIssueTitleEdit() {
  508. // Edit issue title
  509. const $issueTitle = $('#issue-title');
  510. const $editInput = $('#edit-title-input input');
  511. const editTitleToggle = function () {
  512. $issueTitle.toggle();
  513. $('.not-in-edit').toggle();
  514. $('#edit-title-input').toggle();
  515. $('#pull-desc').toggle();
  516. $('#pull-desc-edit').toggle();
  517. $('.in-edit').toggle();
  518. $('#issue-title-wrapper').toggleClass('edit-active');
  519. $editInput.focus();
  520. return false;
  521. };
  522. $('#edit-title').on('click', editTitleToggle);
  523. $('#cancel-edit-title').on('click', editTitleToggle);
  524. $('#save-edit-title').on('click', editTitleToggle).on('click', function () {
  525. const pullrequest_targetbranch_change = function (update_url) {
  526. const targetBranch = $('#pull-target-branch').data('branch');
  527. const $branchTarget = $('#branch_target');
  528. if (targetBranch === $branchTarget.text()) {
  529. return false;
  530. }
  531. $.post(update_url, {
  532. _csrf: csrfToken,
  533. target_branch: targetBranch
  534. }).done((data) => {
  535. $branchTarget.text(data.base_branch);
  536. }).always(() => {
  537. window.location.reload();
  538. });
  539. };
  540. const pullrequest_target_update_url = $(this).data('target-update-url');
  541. if ($editInput.val().length === 0 || $editInput.val() === $issueTitle.text()) {
  542. $editInput.val($issueTitle.text());
  543. pullrequest_targetbranch_change(pullrequest_target_update_url);
  544. } else {
  545. $.post($(this).data('update-url'), {
  546. _csrf: csrfToken,
  547. title: $editInput.val()
  548. }, (data) => {
  549. $editInput.val(data.title);
  550. $issueTitle.text(data.title);
  551. pullrequest_targetbranch_change(pullrequest_target_update_url);
  552. window.location.reload();
  553. });
  554. }
  555. return false;
  556. });
  557. }
  558. export function initRepoIssueBranchSelect() {
  559. const changeBranchSelect = function () {
  560. const selectionTextField = $('#pull-target-branch');
  561. const baseName = selectionTextField.data('basename');
  562. const branchNameNew = $(this).data('branch');
  563. const branchNameOld = selectionTextField.data('branch');
  564. // Replace branch name to keep translation from HTML template
  565. selectionTextField.html(selectionTextField.html().replace(
  566. `${baseName}:${branchNameOld}`,
  567. `${baseName}:${branchNameNew}`
  568. ));
  569. selectionTextField.data('branch', branchNameNew); // update branch name in setting
  570. };
  571. $('#branch-select > .item').on('click', changeBranchSelect);
  572. }