From 9dc93a4519d9d5d7be48ff274127136236a3adb3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 20 Apr 2021 23:50:22 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-11-stable-ee --- .../javascripts/branches/branch_sort_dropdown.js | 25 ++++++ .../branches/components/sort_dropdown.vue | 88 ++++++++++++++++++++++ .../javascripts/branches/divergence_graph.js | 8 +- 3 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 app/assets/javascripts/branches/branch_sort_dropdown.js create mode 100644 app/assets/javascripts/branches/components/sort_dropdown.vue (limited to 'app/assets/javascripts/branches') diff --git a/app/assets/javascripts/branches/branch_sort_dropdown.js b/app/assets/javascripts/branches/branch_sort_dropdown.js new file mode 100644 index 00000000000..9914ce05a95 --- /dev/null +++ b/app/assets/javascripts/branches/branch_sort_dropdown.js @@ -0,0 +1,25 @@ +import Vue from 'vue'; +import SortDropdown from './components/sort_dropdown.vue'; + +const mountDropdownApp = (el) => { + const { mode, projectBranchesFilteredPath, sortOptions } = el.dataset; + + return new Vue({ + el, + name: 'SortBranchesDropdownApp', + components: { + SortDropdown, + }, + provide: { + mode, + projectBranchesFilteredPath, + sortOptions: JSON.parse(sortOptions), + }, + render: (createElement) => createElement(SortDropdown), + }); +}; + +export default () => { + const el = document.getElementById('js-branches-sort-dropdown'); + return el ? mountDropdownApp(el) : null; +}; diff --git a/app/assets/javascripts/branches/components/sort_dropdown.vue b/app/assets/javascripts/branches/components/sort_dropdown.vue new file mode 100644 index 00000000000..ddb4c5c0015 --- /dev/null +++ b/app/assets/javascripts/branches/components/sort_dropdown.vue @@ -0,0 +1,88 @@ + + diff --git a/app/assets/javascripts/branches/divergence_graph.js b/app/assets/javascripts/branches/divergence_graph.js index ca019bc4178..66e8d982113 100644 --- a/app/assets/javascripts/branches/divergence_graph.js +++ b/app/assets/javascripts/branches/divergence_graph.js @@ -4,13 +4,13 @@ import axios from '../lib/utils/axios_utils'; import { __ } from '../locale'; import DivergenceGraph from './components/divergence_graph.vue'; -export function createGraphVueApp(el, data, maxCommits) { +export function createGraphVueApp(el, data, maxCommits, defaultBranch) { return new Vue({ el, render(h) { return h(DivergenceGraph, { props: { - defaultBranch: 'master', + defaultBranch, distance: data.distance ? parseInt(data.distance, 10) : null, aheadCount: parseInt(data.ahead, 10), behindCount: parseInt(data.behind, 10), @@ -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( ({ dataset }) => dataset.name, ); @@ -47,7 +47,7 @@ export default (endpoint) => { if (!el) return; - createGraphVueApp(el, val, maxCommits); + createGraphVueApp(el, val, maxCommits, defaultBranch); }); }) .catch(() => -- cgit v1.2.1