Beispiel #1
0
export default mrNewCompareNode => {
  const { sourceBranchUrl, targetBranchUrl } = mrNewCompareNode.dataset;
  initTargetProjectDropdown();

  const updateSourceBranchCommitList = () =>
    updateCommitList(
      sourceBranchUrl,
      $(mrNewCompareNode).find('.js-source-loading'),
      $(mrNewCompareNode).find('.mr_source_commit'),
      {
        ref: $(mrNewCompareNode)
          .find("input[name='merge_request[source_branch]']")
          .val(),
      },
    );
  const updateTargetBranchCommitList = () =>
    updateCommitList(
      targetBranchUrl,
      $(mrNewCompareNode).find('.js-target-loading'),
      $(mrNewCompareNode).find('.mr_target_commit'),
      {
        target_project_id: $(mrNewCompareNode)
          .find("input[name='merge_request[target_project_id]']")
          .val(),
        ref: $(mrNewCompareNode)
          .find("input[name='merge_request[target_branch]']")
          .val(),
      },
    );
  initCompareAutocomplete('branches', $dropdown => {
    if ($dropdown.is('.js-target-branch')) {
      updateTargetBranchCommitList();
    } else if ($dropdown.is('.js-source-branch')) {
      updateSourceBranchCommitList();
    }
  });
  updateSourceBranchCommitList();
  updateTargetBranchCommitList();
};
Beispiel #2
0
document.addEventListener('DOMContentLoaded', () => initCompareAutocomplete());