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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
706d99ae
Commit
706d99ae
authored
Jul 14, 2017
by
Filipa Lacerda
Committed by
Phil Hughes
Jul 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Pipeline's badge count in Merge Request and Commits view to match real-time content
parent
0618ad12
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
94 additions
and
18 deletions
+94
-18
app/assets/javascripts/commit/pipelines/pipelines_bundle.js
app/assets/javascripts/commit/pipelines/pipelines_bundle.js
+21
-8
app/assets/javascripts/commit/pipelines/pipelines_table.vue
app/assets/javascripts/commit/pipelines/pipelines_table.vue
+11
-0
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+8
-3
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+8
-3
app/views/projects/commit/_ci_menu.html.haml
app/views/projects/commit/_ci_menu.html.haml
+1
-1
app/views/projects/merge_requests/show.html.haml
app/views/projects/merge_requests/show.html.haml
+1
-1
changelogs/unreleased/34075-pipelines-count-mt.yml
changelogs/unreleased/34075-pipelines-count-mt.yml
+5
-0
spec/controllers/projects/commit_controller_spec.rb
spec/controllers/projects/commit_controller_spec.rb
+2
-1
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+2
-1
spec/javascripts/commit/pipelines/pipelines_spec.js
spec/javascripts/commit/pipelines/pipelines_spec.js
+35
-0
No files found.
app/assets/javascripts/commit/pipelines/pipelines_bundle.js
View file @
706d99ae
...
@@ -18,7 +18,19 @@ window.gl.CommitPipelinesTable = CommitPipelinesTable;
...
@@ -18,7 +18,19 @@ window.gl.CommitPipelinesTable = CommitPipelinesTable;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
pipelineTableViewEl
=
document
.
querySelector
(
'
#commit-pipeline-table-view
'
);
const
pipelineTableViewEl
=
document
.
querySelector
(
'
#commit-pipeline-table-view
'
);
if
(
pipelineTableViewEl
&&
pipelineTableViewEl
.
dataset
.
disableInitialization
===
undefined
)
{
if
(
pipelineTableViewEl
)
{
// Update MR and Commits tabs
pipelineTableViewEl
.
addEventListener
(
'
update-pipelines-count
'
,
(
event
)
=>
{
if
(
event
.
detail
.
pipelines
&&
event
.
detail
.
pipelines
.
count
&&
event
.
detail
.
pipelines
.
count
.
all
)
{
const
badge
=
document
.
querySelector
(
'
.js-pipelines-mr-count
'
);
badge
.
textContent
=
event
.
detail
.
pipelines
.
count
.
all
;
}
});
if
(
pipelineTableViewEl
.
dataset
.
disableInitialization
===
undefined
)
{
const
table
=
new
CommitPipelinesTable
({
const
table
=
new
CommitPipelinesTable
({
propsData
:
{
propsData
:
{
endpoint
:
pipelineTableViewEl
.
dataset
.
endpoint
,
endpoint
:
pipelineTableViewEl
.
dataset
.
endpoint
,
...
@@ -27,4 +39,5 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -27,4 +39,5 @@ document.addEventListener('DOMContentLoaded', () => {
}).
$mount
();
}).
$mount
();
pipelineTableViewEl
.
appendChild
(
table
.
$el
);
pipelineTableViewEl
.
appendChild
(
table
.
$el
);
}
}
}
});
});
app/assets/javascripts/commit/pipelines/pipelines_table.vue
View file @
706d99ae
...
@@ -55,6 +55,17 @@
...
@@ -55,6 +55,17 @@
// depending of the endpoint the response can either bring a `pipelines` key or not.
// depending of the endpoint the response can either bring a `pipelines` key or not.
const
pipelines
=
response
.
pipelines
||
response
;
const
pipelines
=
response
.
pipelines
||
response
;
this
.
setCommonData
(
pipelines
);
this
.
setCommonData
(
pipelines
);
const
updatePipelinesEvent
=
new
CustomEvent
(
'
update-pipelines-count
'
,
{
detail
:
{
pipelines
:
response
,
},
});
// notifiy to update the count in tabs
if
(
this
.
$el
.
parentElement
)
{
this
.
$el
.
parentElement
.
dispatchEvent
(
updatePipelinesEvent
);
}
});
});
},
},
},
},
...
...
app/controllers/projects/commit_controller.rb
View file @
706d99ae
...
@@ -38,9 +38,14 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -38,9 +38,14 @@ class Projects::CommitController < Projects::ApplicationController
format
.
json
do
format
.
json
do
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
10_000
)
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
10_000
)
render
json:
PipelineSerializer
render
json:
{
pipelines:
PipelineSerializer
.
new
(
project:
@project
,
current_user:
@current_user
)
.
new
(
project:
@project
,
current_user:
@current_user
)
.
represent
(
@pipelines
)
.
represent
(
@pipelines
),
count:
{
all:
@pipelines
.
count
}
}
end
end
end
end
end
end
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
706d99ae
...
@@ -112,9 +112,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
...
@@ -112,9 +112,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
10_000
)
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
10_000
)
render
json:
PipelineSerializer
render
json:
{
pipelines:
PipelineSerializer
.
new
(
project:
@project
,
current_user:
@current_user
)
.
new
(
project:
@project
,
current_user:
@current_user
)
.
represent
(
@pipelines
)
.
represent
(
@pipelines
),
count:
{
all:
@pipelines
.
count
}
}
end
end
def
edit
def
edit
...
...
app/views/projects/commit/_ci_menu.html.haml
View file @
706d99ae
...
@@ -7,4 +7,4 @@
...
@@ -7,4 +7,4 @@
=
nav_link
(
path:
'commit#pipelines'
)
do
=
nav_link
(
path:
'commit#pipelines'
)
do
=
link_to
pipelines_project_commit_path
(
@project
,
@commit
.
id
)
do
=
link_to
pipelines_project_commit_path
(
@project
,
@commit
.
id
)
do
Pipelines
Pipelines
%span
.badge
=
@commit
.
pipelines
.
size
%span
.badge
.js-pipelines-mr-count
=
@commit
.
pipelines
.
size
app/views/projects/merge_requests/show.html.haml
View file @
706d99ae
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
%li
.pipelines-tab
%li
.pipelines-tab
=
link_to
pipelines_project_merge_request_path
(
@project
,
@merge_request
),
data:
{
target:
'#pipelines'
,
action:
'pipelines'
,
toggle:
'tab'
}
do
=
link_to
pipelines_project_merge_request_path
(
@project
,
@merge_request
),
data:
{
target:
'#pipelines'
,
action:
'pipelines'
,
toggle:
'tab'
}
do
Pipelines
Pipelines
%span
.badge
=
@pipelines
.
size
%span
.badge
.js-pipelines-mr-count
=
@pipelines
.
size
%li
.diffs-tab
%li
.diffs-tab
=
link_to
diffs_project_merge_request_path
(
@project
,
@merge_request
),
data:
{
target:
'div#diffs'
,
action:
'diffs'
,
toggle:
'tab'
}
do
=
link_to
diffs_project_merge_request_path
(
@project
,
@merge_request
),
data:
{
target:
'div#diffs'
,
action:
'diffs'
,
toggle:
'tab'
}
do
Changes
Changes
...
...
changelogs/unreleased/34075-pipelines-count-mt.yml
0 → 100644
View file @
706d99ae
---
title
:
Update Pipeline's badge count in Merge Request and Commits view to match real-time
content
merge_request
:
author
:
spec/controllers/projects/commit_controller_spec.rb
View file @
706d99ae
...
@@ -343,7 +343,8 @@ describe Projects::CommitController do
...
@@ -343,7 +343,8 @@ describe Projects::CommitController do
get_pipelines
(
id:
commit
.
id
,
format: :json
)
get_pipelines
(
id:
commit
.
id
,
format: :json
)
expect
(
response
).
to
be_ok
expect
(
response
).
to
be_ok
expect
(
JSON
.
parse
(
response
.
body
)).
not_to
be_empty
expect
(
JSON
.
parse
(
response
.
body
)[
'pipelines'
]).
not_to
be_empty
expect
(
JSON
.
parse
(
response
.
body
)[
'count'
][
'all'
]).
to
eq
1
end
end
end
end
end
end
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
706d99ae
...
@@ -481,7 +481,8 @@ describe Projects::MergeRequestsController do
...
@@ -481,7 +481,8 @@ describe Projects::MergeRequestsController do
end
end
it
'responds with serialized pipelines'
do
it
'responds with serialized pipelines'
do
expect
(
json_response
).
not_to
be_empty
expect
(
json_response
[
'pipelines'
]).
not_to
be_empty
expect
(
json_response
[
'count'
][
'all'
]).
to
eq
1
end
end
end
end
...
...
spec/javascripts/commit/pipelines/pipelines_spec.js
View file @
706d99ae
...
@@ -85,6 +85,41 @@ describe('Pipelines table in Commits and Merge requests', () => {
...
@@ -85,6 +85,41 @@ describe('Pipelines table in Commits and Merge requests', () => {
},
0
);
},
0
);
});
});
});
});
describe
(
'
pipeline badge counts
'
,
()
=>
{
const
pipelinesResponse
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
([
pipeline
]),
{
status
:
200
,
}));
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
pipelinesResponse
);
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
pipelinesResponse
);
this
.
component
.
$destroy
();
});
it
(
'
should receive update-pipelines-count event
'
,
(
done
)
=>
{
const
element
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
element
);
element
.
addEventListener
(
'
update-pipelines-count
'
,
(
event
)
=>
{
expect
(
event
.
detail
.
pipelines
).
toEqual
([
pipeline
]);
done
();
});
this
.
component
=
new
PipelinesTable
({
propsData
:
{
endpoint
:
'
endpoint
'
,
helpPagePath
:
'
foo
'
,
},
}).
$mount
();
element
.
appendChild
(
this
.
component
.
$el
);
});
});
});
});
describe
(
'
unsuccessfull request
'
,
()
=>
{
describe
(
'
unsuccessfull request
'
,
()
=>
{
...
...
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