diff options
Diffstat (limited to 'app/assets/javascripts/search/under_topbar/index.js')
-rw-r--r-- | app/assets/javascripts/search/under_topbar/index.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/assets/javascripts/search/under_topbar/index.js b/app/assets/javascripts/search/under_topbar/index.js new file mode 100644 index 00000000000..8e50c6655dd --- /dev/null +++ b/app/assets/javascripts/search/under_topbar/index.js @@ -0,0 +1,31 @@ +import Vue from 'vue'; +import Translate from '~/vue_shared/translate'; +import RefSelector from '~/ref/components/ref_selector.vue'; +import { setUrlParams, visitUrl } from '~/lib/utils/url_utility'; + +Vue.use(Translate); + +export const initBlobRefSwitcher = () => { + const el = document.getElementById('js-blob-ref-switcher'); + + if (!el) return false; + + const { projectId, ref, fieldName } = el.dataset; + + return new Vue({ + el, + render(createElement) { + return createElement(RefSelector, { + props: { + projectId, + value: ref, + }, + on: { + input(selected) { + visitUrl(setUrlParams({ [fieldName]: selected })); + }, + }, + }); + }, + }); +}; |