Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
43e5009a
Commit
43e5009a
authored
Nov 23, 2016
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pipelines tabs
parent
77337a82
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
5 deletions
+140
-5
app/assets/javascripts/lib/utils/bootstrap_linked_tabs.js.es6
...assets/javascripts/lib/utils/bootstrap_linked_tabs.js.es6
+110
-0
app/controllers/projects/pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+4
-0
app/views/projects/pipelines/_with_tabs.html.haml
app/views/projects/pipelines/_with_tabs.html.haml
+18
-5
config/routes/project.rb
config/routes/project.rb
+1
-0
spec/features/projects/pipelines_spec.rb
spec/features/projects/pipelines_spec.rb
+7
-0
No files found.
app/assets/javascripts/lib/utils/bootstrap_linked_tabs.js.es6
0 → 100644
View file @
43e5009a
/**
* Linked Tabs
*
* Handles persisting and restores the current tab selection and content.
* Reusable component for static content.
*
* ### Example Markup
*
* <ul class="nav-links tab-links">
* <li class="active">
* <a data-action="tab1" data-target="#tab1" data-toggle="tab" href="/path/tab1">
* Tab 1
* </a>
* </li>
* <li class="groups-tab">
* <a data-action="tab2" data-target="#tab2" data-toggle="tab" href="/path/tab2">
* Tab 2
* </a>
* </li>
*
*
* <div class="tab-content">
* <div class="tab-pane" id="tab1">
* Tab 1 Content
* </div>
* <div class="tab-pane" id="tab2">
* Tab 2 Content
* </div>
* </div>
*
*
* ### How to use
*
* new window.gl.LinkedTabs({
* action: "#{controller.action_name}",
* defaultAction: 'tab1',
* parentEl: '.tab-links'
* });
*/
(() => {
window.gl = window.gl || {};
window.gl.LinkedTabs = class LinkedTabs {
/**
* Binds the events and activates de default tab.
*
* @param {Object} options
*/
constructor(options) {
this.options = options || {};
this.defaultAction = this.options.defaultAction;
this.action = this.options.action || this.defaultAction;
this.currentLocation = window.location;
if (this.action === 'show') {
this.action = this.defaultAction;
}
// since this is a custom event we need jQuery :(
$(document).on('shown.bs.tab', `${this.options.parentEl} a[data-toggle="tab"]`, evt => this.tabShown(evt));
this.activateTab(this.action);
}
/**
* Handles the `shown.bs.tab` event to set the currect url action.
*
* @param {type} evt
* @return {Function}
*/
tabShown(evt) {
const source = evt.target.getAttribute('href');
return this.setCurrentAction(source);
}
/**
* Updates the URL with the path that matched the given action.
*
* @param {String} source
* @return {String}
*/
setCurrentAction(source) {
const copySource = source;
copySource.replace(/\/+$/, '');
const newState = copySource + this.currentLocation.search + this.currentLocation.hash;
history.replaceState({
turbolinks: true,
url: newState,
}, document.title, newState);
return newState;
}
/**
* Given the current action activates the correct tab.
* http://getbootstrap.com/javascript/#tab-show
* Note: Will trigger `shown.bs.tab`
*/
activateTab() {
return $(`.pipelines-tabs a[data-action='${this.action}']`).tab('show');
}
};
})();
app/controllers/projects/pipelines_controller.rb
View file @
43e5009a
...
...
@@ -32,6 +32,10 @@ class Projects::PipelinesController < Projects::ApplicationController
def
show
end
def
builds
render
'show'
end
def
retry
pipeline
.
retry_failed
(
current_user
)
...
...
app/views/projects/pipelines/_with_tabs.html.haml
View file @
43e5009a
.tabs-holder
%ul
.nav-links.no-top.no-bottom
%li
.active
=
link_to
"Pipeline"
,
"#js-tab-pipeline"
,
data:
{
target:
'#js-tab-pipeline'
,
action:
'pipeline'
,
toggle:
'tab'
},
class:
'pipeline-tab'
%ul
.pipelines-tabs.nav-links.no-top.no-bottom
%li
=
link_to
"#js-tab-builds"
,
data:
{
target:
'#js-tab-builds'
,
action:
'build'
,
toggle:
'tab'
},
class:
'builds-tab'
do
=
link_to
namespace_project_pipeline_path
(
@project
.
namespace
,
@project
,
@pipeline
),
data:
{
target:
'div#js-tab-pipeline'
,
action:
'pipelines'
,
toggle:
'tab'
}
do
Pipeline
%li
=
link_to
builds_namespace_project_pipeline_path
(
@project
.
namespace
,
@project
,
@pipeline
),
data:
{
target:
'div#js-tab-builds'
,
action:
'builds'
,
toggle:
'tab'
}
do
Builds
%span
.badge
=
pipeline
.
statuses
.
count
.tab-content
#js-tab-pipeline
.tab-pane
.active
#js-tab-pipeline
.tab-pane
.build-content.middle-block.pipeline-graph
.pipeline-visualization
%ul
.stage-column-list
...
...
@@ -49,3 +52,13 @@
%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
'
});
config/routes/project.rb
View file @
43e5009a
...
...
@@ -129,6 +129,7 @@ constraints(ProjectUrlConstrainer.new) do
member
do
post
:cancel
post
:retry
get
:builds
end
end
...
...
spec/features/projects/pipelines_spec.rb
View file @
43e5009a
...
...
@@ -178,6 +178,13 @@ describe "Pipelines" do
expect
(
page
).
to
have_link
(
'Play'
)
end
context
'page tabs'
do
it
'should have two tabs'
do
expect
(
page
).
to
have_link
(
'Pipeline'
)
expect
(
page
).
to
have_link
(
'Builds'
)
end
end
context
'retrying builds'
do
it
{
expect
(
page
).
not_to
have_content
(
'retried'
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment