Commit 99b96a7b authored by Riccardo Padovani's avatar Riccardo Padovani Committed by Clement Ho

#28481: Display time tracking totals on milestone page

parent 576dd646
import Milestone from '~/milestone'; import Milestone from '~/milestone';
import Sidebar from '~/right_sidebar'; import Sidebar from '~/right_sidebar';
import MountMilestoneSidebar from '~/sidebar/mount_milestone_sidebar';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
new Milestone(); // eslint-disable-line no-new new Milestone(); // eslint-disable-line no-new
new Sidebar(); // eslint-disable-line no-new new Sidebar(); // eslint-disable-line no-new
new MountMilestoneSidebar(); // eslint-disable-line no-new
}); });
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
import Milestone from '~/milestone'; import Milestone from '~/milestone';
import Sidebar from '~/right_sidebar'; import Sidebar from '~/right_sidebar';
import MountMilestoneSidebar from '~/sidebar/mount_milestone_sidebar';
export default () => { export default () => {
new Milestone(); new Milestone();
new Sidebar(); new Sidebar();
new MountMilestoneSidebar();
}; };
import Vue from 'vue';
import timeTracker from './components/time_tracking/time_tracker.vue';
export default class SidebarMilestone {
constructor() {
const el = document.getElementById('issuable-time-tracker');
if (!el) return;
// eslint-disable-next-line no-new
new Vue({
el,
components: {
timeTracker,
},
render: createElement => createElement('timeTracker', {
props: {
time_estimate: parseInt(el.dataset.timeEstimate, 10),
time_spent: parseInt(el.dataset.timeSpent, 10),
human_time_estimate: el.dataset.humanTimeEstimate,
human_time_spent: el.dataset.humanTimeSpent,
rootPath: '/',
},
}),
});
}
}
...@@ -94,6 +94,14 @@ module Milestoneish ...@@ -94,6 +94,14 @@ module Milestoneish
Gitlab::TimeTrackingFormatter.output(total_issue_time_spent) Gitlab::TimeTrackingFormatter.output(total_issue_time_spent)
end end
def total_issue_time_estimate
@total_issue_time_estimate ||= issues.sum(:time_estimate)
end
def human_total_issue_time_estimate
Gitlab::TimeTrackingFormatter.output(total_issue_time_estimate)
end
private private
def count_issues_by_state(user) def count_issues_by_state(user)
......
- affix_offset = local_assigns.fetch(:affix_offset, "50") - affix_offset = local_assigns.fetch(:affix_offset, "50")
- project = local_assigns[:project] - project = local_assigns[:project]
- content_for :page_specific_javascripts do
= page_specific_javascript_bundle_tag('common_vue')
%aside.right-sidebar.js-right-sidebar{ data: { "offset-top" => affix_offset, "spy" => "affix", "always-show-toggle" => true }, class: sidebar_gutter_collapsed_class, 'aria-live' => 'polite' } %aside.right-sidebar.js-right-sidebar{ data: { "offset-top" => affix_offset, "spy" => "affix", "always-show-toggle" => true }, class: sidebar_gutter_collapsed_class, 'aria-live' => 'polite' }
.issuable-sidebar.milestone-sidebar .issuable-sidebar.milestone-sidebar
...@@ -85,21 +87,12 @@ ...@@ -85,21 +87,12 @@
Closed: Closed:
= milestone.issues_visible_to_user(current_user).closed.count = milestone.issues_visible_to_user(current_user).closed.count
.block.time_spent .block
.sidebar-collapsed-icon #issuable-time-tracker{ data: { time_estimate: @milestone.total_issue_time_estimate, time_spent: @milestone.total_issue_time_spent, human_time_estimate: @milestone.human_total_issue_time_estimate, human_time_spent: @milestone.human_total_issue_time_spent } }
= custom_icon('icon_hourglass') // Fallback while content is loading
%span.collapsed-milestone-total-time-spent
- if milestone.human_total_issue_time_spent
= milestone.human_total_issue_time_spent
- else
= _("None")
.title.hide-collapsed .title.hide-collapsed
= _("Total issue time spent") = _('Time tracking')
.value.hide-collapsed = icon('spinner spin')
- if milestone.human_total_issue_time_spent
%span.bold= milestone.human_total_issue_time_spent
- else
%span.no-value= _("No time spent")
.block.merge-requests .block.merge-requests
.sidebar-collapsed-icon .sidebar-collapsed-icon
......
---
title: "#28481: Display time tracking totals on milestone page"
merge_request: 16753
author: Riccardo Padovani
type: added
...@@ -66,15 +66,16 @@ feature 'Milestone' do ...@@ -66,15 +66,16 @@ feature 'Milestone' do
end end
end end
feature 'Open a milestone' do feature 'Open a milestone', :js do
scenario 'shows total issue time spent correctly when no time has been logged' do scenario 'shows total issue time spent correctly when no time has been logged' do
milestone = create(:milestone, project: project, title: 8.7) milestone = create(:milestone, project: project, title: 8.7)
visit project_milestone_path(project, milestone) visit project_milestone_path(project, milestone)
page.within('.block.time_spent') do wait_for_requests
expect(page).to have_content 'No time spent'
expect(page).to have_content 'None' page.within('.time-tracking-no-tracking-pane') do
expect(page).to have_content 'No estimate or time spent'
end end
end end
...@@ -89,8 +90,10 @@ feature 'Milestone' do ...@@ -89,8 +90,10 @@ feature 'Milestone' do
visit project_milestone_path(project, milestone) visit project_milestone_path(project, milestone)
page.within('.block.time_spent') do wait_for_requests
expect(page).to have_content '3h'
page.within('.time-tracking-spend-only-pane') do
expect(page).to have_content 'Spent: 3h'
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment