Commit 85047793 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '324100-update-initial-branch-name-contributors-graph' into 'master'

Update default branch in contributors graph

See merge request gitlab-org/gitlab!58876
parents 07ea548d 0e9b5a28
import Vue from 'vue'; import Vue from 'vue';
import ContributorsGraphs from './components/contributors.vue'; import ContributorsGraphs from './components/contributors.vue';
import store from './stores'; import { createStore } from './stores';
export default () => { export default () => {
const el = document.querySelector('.js-contributors-graph'); const el = document.querySelector('.js-contributors-graph');
if (!el) return null; if (!el) return null;
const { projectGraphPath, projectBranch, defaultBranch } = el.dataset;
const store = createStore(defaultBranch);
return new Vue({ return new Vue({
el, el,
store, store,
...@@ -14,8 +17,8 @@ export default () => { ...@@ -14,8 +17,8 @@ export default () => {
render(createElement) { render(createElement) {
return createElement(ContributorsGraphs, { return createElement(ContributorsGraphs, {
props: { props: {
endpoint: el.dataset.projectGraphPath, endpoint: projectGraphPath,
branch: el.dataset.projectBranch, branch: projectBranch,
}, },
}); });
}, },
......
...@@ -7,12 +7,12 @@ import state from './state'; ...@@ -7,12 +7,12 @@ import state from './state';
Vue.use(Vuex); Vue.use(Vuex);
export const createStore = () => export const createStore = (defaultBranch) =>
new Vuex.Store({ new Vuex.Store({
actions, actions,
mutations, mutations,
getters, getters,
state: state(), state: state(defaultBranch),
}); });
export default createStore(); export default createStore;
export default () => ({ export default (branch) => ({
loading: false, loading: false,
chartData: null, chartData: null,
branch: 'master', branch,
}); });
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
= render 'shared/ref_switcher', destination: 'graphs' = render 'shared/ref_switcher', destination: 'graphs'
= link_to s_('Commits|History'), project_commits_path(@project, current_ref), class: 'btn gl-button btn-default' = link_to s_('Commits|History'), project_commits_path(@project, current_ref), class: 'btn gl-button btn-default'
.js-contributors-graph{ class: container_class, 'data-project-graph-path': project_graph_path(@project, current_ref, format: :json), 'data-project-branch': current_ref } .js-contributors-graph{ class: container_class, data: { project_graph_path: project_graph_path(@project, current_ref, format: :json), project_branch: current_ref, default_branch: @project.default_branch } }
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