From cc4434a483e75dd83055fe21ef4dedadbfcdc4c7 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 24 Nov 2016 16:43:54 +0000 Subject: Fix after review Adds require statement --- app/assets/javascripts/dispatcher.js.es6 | 12 +++++++++++- app/assets/javascripts/pipelines.js.es6 | 9 ++++++++- app/views/projects/pipelines/_with_tabs.html.haml | 10 ---------- app/views/projects/pipelines/show.html.haml | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js.es6 b/app/assets/javascripts/dispatcher.js.es6 index 16df4b0b005..de205b7905b 100644 --- a/app/assets/javascripts/dispatcher.js.es6 +++ b/app/assets/javascripts/dispatcher.js.es6 @@ -135,8 +135,18 @@ new TreeView(); } break; + case 'projects:pipelines:builds': case 'projects:pipelines:show': - new gl.Pipelines(); + const controllerAction = document.querySelector('.js-pipeline-container').dataset.controllerAction; + + new gl.Pipelines({ + initTabs: true, + tabsOptions: { + action: controllerAction, + defaultAction: 'pipelines', + parentEl: '.pipelines-tabs', + }, + }); break; case 'groups:activity': new gl.Activities(); diff --git a/app/assets/javascripts/pipelines.js.es6 b/app/assets/javascripts/pipelines.js.es6 index a84db9c0233..97e06bc6d68 100644 --- a/app/assets/javascripts/pipelines.js.es6 +++ b/app/assets/javascripts/pipelines.js.es6 @@ -1,8 +1,15 @@ +//= require lib/utils/bootstrap_linked_tabs + /* eslint-disable */ ((global) => { class Pipelines { - constructor() { + constructor(options) { + + if (options.initTabs && options.tabsOptions) { + new window.gl.LinkedTabs(options.tabsOptions); + } + this.addMarginToBuildColumns(); } diff --git a/app/views/projects/pipelines/_with_tabs.html.haml b/app/views/projects/pipelines/_with_tabs.html.haml index 4cc0e116122..d4d2e360f39 100644 --- a/app/views/projects/pipelines/_with_tabs.html.haml +++ b/app/views/projects/pipelines/_with_tabs.html.haml @@ -52,13 +52,3 @@ %th - pipeline.statuses.relevant.stages.each do |stage| = render 'projects/commit/ci_stage', stage: stage, statuses: pipeline.statuses.relevant.where(stage: stage) - - -:javascript - var pipelines_tab; - - pipelines_tab = new window.gl.LinkedTabs({ - action: "#{controller.action_name}", - defaultAction: 'pipelines', - parentEl: '.pipelines-tabs' - }); diff --git a/app/views/projects/pipelines/show.html.haml b/app/views/projects/pipelines/show.html.haml index 8c6652a5f90..371ce3ae599 100644 --- a/app/views/projects/pipelines/show.html.haml +++ b/app/views/projects/pipelines/show.html.haml @@ -2,7 +2,7 @@ - page_title "Pipeline" = render "projects/pipelines/head" -%div{ class: container_class } +%div.js-pipeline-container{ class: container_class, data: {controller_action: "#{controller.action_name}"} } - if @commit = render "projects/pipelines/info" -- cgit v1.2.1