Commit c2fc9e8e authored by jerasmus's avatar jerasmus

Update default branch name in divergence graph

Updated the default branch name in the divergence graph
parent 724e6da4
...@@ -4,13 +4,13 @@ import axios from '../lib/utils/axios_utils'; ...@@ -4,13 +4,13 @@ import axios from '../lib/utils/axios_utils';
import { __ } from '../locale'; import { __ } from '../locale';
import DivergenceGraph from './components/divergence_graph.vue'; import DivergenceGraph from './components/divergence_graph.vue';
export function createGraphVueApp(el, data, maxCommits) { export function createGraphVueApp(el, data, maxCommits, defaultBranch) {
return new Vue({ return new Vue({
el, el,
render(h) { render(h) {
return h(DivergenceGraph, { return h(DivergenceGraph, {
props: { props: {
defaultBranch: 'master', defaultBranch,
distance: data.distance ? parseInt(data.distance, 10) : null, distance: data.distance ? parseInt(data.distance, 10) : null,
aheadCount: parseInt(data.ahead, 10), aheadCount: parseInt(data.ahead, 10),
behindCount: parseInt(data.behind, 10), behindCount: parseInt(data.behind, 10),
...@@ -21,7 +21,7 @@ export function createGraphVueApp(el, data, maxCommits) { ...@@ -21,7 +21,7 @@ export function createGraphVueApp(el, data, maxCommits) {
}); });
} }
export default (endpoint) => { export default (endpoint, defaultBranch) => {
const names = [...document.querySelectorAll('.js-branch-item')].map( const names = [...document.querySelectorAll('.js-branch-item')].map(
({ dataset }) => dataset.name, ({ dataset }) => dataset.name,
); );
...@@ -47,7 +47,7 @@ export default (endpoint) => { ...@@ -47,7 +47,7 @@ export default (endpoint) => {
if (!el) return; if (!el) return;
createGraphVueApp(el, val, maxCommits); createGraphVueApp(el, val, maxCommits, defaultBranch);
}); });
}) })
.catch(() => .catch(() =>
......
...@@ -5,5 +5,10 @@ import initDiverganceGraph from '~/branches/divergence_graph'; ...@@ -5,5 +5,10 @@ import initDiverganceGraph from '~/branches/divergence_graph';
AjaxLoadingSpinner.init(); AjaxLoadingSpinner.init();
new DeleteModal(); // eslint-disable-line no-new new DeleteModal(); // eslint-disable-line no-new
initDiverganceGraph(document.querySelector('.js-branch-list').dataset.divergingCountsEndpoint);
const { divergingCountsEndpoint, defaultBranch } = document.querySelector(
'.js-branch-list',
).dataset;
initDiverganceGraph(divergingCountsEndpoint, defaultBranch);
BranchSortDropdown(); BranchSortDropdown();
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
= render_if_exists 'projects/commits/mirror_status' = render_if_exists 'projects/commits/mirror_status'
.js-branch-list{ data: { diverging_counts_endpoint: diverging_commit_counts_namespace_project_branches_path(@project.namespace, @project, format: :json) } } .js-branch-list{ data: { diverging_counts_endpoint: diverging_commit_counts_namespace_project_branches_path(@project.namespace, @project, format: :json), default_branch: @project.default_branch } }
- if can?(current_user, :admin_project, @project) - if can?(current_user, :admin_project, @project)
- project_settings_link = link_to s_('Branches|project settings'), project_protected_branches_path(@project) - project_settings_link = link_to s_('Branches|project settings'), project_protected_branches_path(@project)
.row-content-block .row-content-block
......
---
title: Update default branch in divergence graph
merge_request: 58871
author:
type: changed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment