Skip to content

Commit fb438b9

Browse files
committed
Merge branch '#51699-time-tracker-naming' into 'master'
Fix props name casing in time time tracker vue component Closes #45977 and #51699 See merge request gitlab-org/gitlab-ce!21889
2 parents 474231e + 65d7bf2 commit fb438b9

File tree

4 files changed

+44
-53
lines changed

4 files changed

+44
-53
lines changed

app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ export default {
5151
<template>
5252
<div class="block">
5353
<issuable-time-tracker
54-
:time_estimate="store.timeEstimate"
55-
:time_spent="store.totalTimeSpent"
56-
:human_time_estimate="store.humanTimeEstimate"
57-
:human_time_spent="store.humanTotalTimeSpent"
54+
:time-estimate="store.timeEstimate"
55+
:time-spent="store.totalTimeSpent"
56+
:human-time-estimate="store.humanTimeEstimate"
57+
:human-time-spent="store.humanTotalTimeSpent"
5858
:root-path="store.rootPath"
5959
/>
6060
</div>

app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,20 @@ export default {
1919
TimeTrackingHelpState,
2020
},
2121
props: {
22-
// eslint-disable-next-line vue/prop-name-casing
23-
time_estimate: {
22+
timeEstimate: {
2423
type: Number,
2524
required: true,
2625
},
27-
// eslint-disable-next-line vue/prop-name-casing
28-
time_spent: {
26+
timeSpent: {
2927
type: Number,
3028
required: true,
3129
},
32-
// eslint-disable-next-line vue/prop-name-casing
33-
human_time_estimate: {
30+
humanTimeEstimate: {
3431
type: String,
3532
required: false,
3633
default: '',
3734
},
38-
// eslint-disable-next-line vue/prop-name-casing
39-
human_time_spent: {
35+
humanTimeSpent: {
4036
type: String,
4137
required: false,
4238
default: '',
@@ -52,18 +48,6 @@ export default {
5248
};
5349
},
5450
computed: {
55-
timeSpent() {
56-
return this.time_spent;
57-
},
58-
timeEstimate() {
59-
return this.time_estimate;
60-
},
61-
timeEstimateHumanReadable() {
62-
return this.human_time_estimate;
63-
},
64-
timeSpentHumanReadable() {
65-
return this.human_time_spent;
66-
},
6751
hasTimeSpent() {
6852
return !!this.timeSpent;
6953
},
@@ -94,10 +78,12 @@ export default {
9478
this.showHelp = show;
9579
},
9680
update(data) {
97-
this.time_estimate = data.time_estimate;
98-
this.time_spent = data.time_spent;
99-
this.human_time_estimate = data.human_time_estimate;
100-
this.human_time_spent = data.human_time_spent;
81+
const { timeEstimate, timeSpent, humanTimeEstimate, humanTimeSpent } = data;
82+
83+
this.timeEstimate = timeEstimate;
84+
this.timeSpent = timeSpent;
85+
this.humanTimeEstimate = humanTimeEstimate;
86+
this.humanTimeSpent = humanTimeSpent;
10187
},
10288
},
10389
};
@@ -114,8 +100,8 @@ export default {
114100
:show-help-state="showHelpState"
115101
:show-spent-only-state="showSpentOnlyState"
116102
:show-estimate-only-state="showEstimateOnlyState"
117-
:time-spent-human-readable="timeSpentHumanReadable"
118-
:time-estimate-human-readable="timeEstimateHumanReadable"
103+
:time-spent-human-readable="humanTimeSpent"
104+
:time-estimate-human-readable="humanTimeEstimate"
119105
/>
120106
<div class="title hide-collapsed">
121107
{{ __('Time tracking') }}
@@ -145,11 +131,11 @@ export default {
145131
<div class="time-tracking-content hide-collapsed">
146132
<time-tracking-estimate-only-pane
147133
v-if="showEstimateOnlyState"
148-
:time-estimate-human-readable="timeEstimateHumanReadable"
134+
:time-estimate-human-readable="humanTimeEstimate"
149135
/>
150136
<time-tracking-spent-only-pane
151137
v-if="showSpentOnlyState"
152-
:time-spent-human-readable="timeSpentHumanReadable"
138+
:time-spent-human-readable="humanTimeSpent"
153139
/>
154140
<time-tracking-no-tracking-pane
155141
v-if="showNoTimeTrackingState"
@@ -158,8 +144,8 @@ export default {
158144
v-if="showComparisonState"
159145
:time-estimate="timeEstimate"
160146
:time-spent="timeSpent"
161-
:time-spent-human-readable="timeSpentHumanReadable"
162-
:time-estimate-human-readable="timeEstimateHumanReadable"
147+
:time-spent-human-readable="humanTimeSpent"
148+
:time-estimate-human-readable="humanTimeEstimate"
163149
/>
164150
<transition name="help-state-toggle">
165151
<time-tracking-help-state

app/assets/javascripts/sidebar/mount_milestone_sidebar.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export default class SidebarMilestone {
77

88
if (!el) return;
99

10+
const { timeEstimate, timeSpent, humanTimeEstimate, humanTimeSpent } = el.dataset;
11+
1012
// eslint-disable-next-line no-new
1113
new Vue({
1214
el,
@@ -15,10 +17,10 @@ export default class SidebarMilestone {
1517
},
1618
render: createElement => createElement('timeTracker', {
1719
props: {
18-
time_estimate: parseInt(el.dataset.timeEstimate, 10),
19-
time_spent: parseInt(el.dataset.timeSpent, 10),
20-
human_time_estimate: el.dataset.humanTimeEstimate,
21-
human_time_spent: el.dataset.humanTimeSpent,
20+
timeEstimate: parseInt(timeEstimate, 10),
21+
timeSpent: parseInt(timeSpent, 10),
22+
humanTimeEstimate,
23+
humanTimeSpent,
2224
rootPath: '/',
2325
},
2426
}),

spec/javascripts/sidebar/components/time_tracking/time_tracker_spec.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ describe('Issuable Time Tracker', () => {
88
let initialData;
99
let vm;
1010

11-
const initTimeTrackingComponent = opts => {
11+
const initTimeTrackingComponent = ({ timeEstimate,
12+
timeSpent,
13+
timeEstimateHumanReadable,
14+
timeSpentHumanReadable }) => {
1215
setFixtures(`
1316
<div>
1417
<div id="mock-container"></div>
1518
</div>
1619
`);
1720

1821
initialData = {
19-
time_estimate: opts.timeEstimate,
20-
time_spent: opts.timeSpent,
21-
human_time_estimate: opts.timeEstimateHumanReadable,
22-
human_time_spent: opts.timeSpentHumanReadable,
22+
timeEstimate,
23+
timeSpent,
24+
humanTimeEstimate: timeEstimateHumanReadable,
25+
humanTimeSpent: timeSpentHumanReadable,
2326
rootPath: '/',
2427
};
2528

@@ -43,8 +46,8 @@ describe('Issuable Time Tracker', () => {
4346
describe('Initialization', () => {
4447
beforeEach(() => {
4548
initTimeTrackingComponent({
46-
timeEstimate: 100000,
47-
timeSpent: 5000,
49+
timeEstimate: 10000, // 2h 46m
50+
timeSpent: 5000, // 1h 23m
4851
timeEstimateHumanReadable: '2h 46m',
4952
timeSpentHumanReadable: '1h 23m',
5053
});
@@ -56,14 +59,14 @@ describe('Issuable Time Tracker', () => {
5659

5760
it('should correctly set timeEstimate', done => {
5861
Vue.nextTick(() => {
59-
expect(vm.timeEstimate).toBe(initialData.time_estimate);
62+
expect(vm.timeEstimate).toBe(initialData.timeEstimate);
6063
done();
6164
});
6265
});
6366

6467
it('should correctly set time_spent', done => {
6568
Vue.nextTick(() => {
66-
expect(vm.timeSpent).toBe(initialData.time_spent);
69+
expect(vm.timeSpent).toBe(initialData.timeSpent);
6770
done();
6871
});
6972
});
@@ -74,8 +77,8 @@ describe('Issuable Time Tracker', () => {
7477
describe('Comparison pane', () => {
7578
beforeEach(() => {
7679
initTimeTrackingComponent({
77-
timeEstimate: 100000,
78-
timeSpent: 5000,
80+
timeEstimate: 100000, // 1d 3h
81+
timeSpent: 5000, // 1h 23m
7982
timeEstimateHumanReadable: '',
8083
timeSpentHumanReadable: '',
8184
});
@@ -106,8 +109,8 @@ describe('Issuable Time Tracker', () => {
106109
});
107110

108111
it('should display the remaining meter with the correct background color when over estimate', done => {
109-
vm.time_estimate = 100000;
110-
vm.time_spent = 20000000;
112+
vm.timeEstimate = 10000; // 2h 46m
113+
vm.timeSpent = 20000000; // 231 days
111114
Vue.nextTick(() => {
112115
expect(vm.$el.querySelector('.time-tracking-comparison-pane .progress[variant="danger"]')).not.toBeNull();
113116
done();
@@ -119,7 +122,7 @@ describe('Issuable Time Tracker', () => {
119122
describe('Estimate only pane', () => {
120123
beforeEach(() => {
121124
initTimeTrackingComponent({
122-
timeEstimate: 100000,
125+
timeEstimate: 10000, // 2h 46m
123126
timeSpent: 0,
124127
timeEstimateHumanReadable: '2h 46m',
125128
timeSpentHumanReadable: '',
@@ -142,7 +145,7 @@ describe('Issuable Time Tracker', () => {
142145
beforeEach(() => {
143146
initTimeTrackingComponent({
144147
timeEstimate: 0,
145-
timeSpent: 5000,
148+
timeSpent: 5000, // 1h 23m
146149
timeEstimateHumanReadable: '2h 46m',
147150
timeSpentHumanReadable: '1h 23m',
148151
});

0 commit comments

Comments
 (0)