Skip to content
Snippets Groups Projects
Commit 275a1758 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu :basketball:
Browse files

Rename to time_tracking_limit_to_hours

Changes migration and all other places the attribute is used
parent 4e283ee7
No related branches found
No related tags found
No related merge requests found
Showing
with 63 additions and 25 deletions
Loading
Loading
@@ -38,6 +38,7 @@ export default Vue.extend({
issue: {},
list: {},
loadingAssignees: false,
timeTrackingLimitToHours: boardsStore.timeTracking.limitToHours,
};
},
computed: {
Loading
Loading
Loading
Loading
@@ -2,6 +2,7 @@
import { GlTooltip } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
import { parseSeconds, stringifyTime } from '~/lib/utils/datetime_utility';
import boardsStore from '../stores/boards_store';
 
export default {
components: {
Loading
Loading
@@ -14,17 +15,17 @@ export default {
required: true,
},
},
data() {
return {
limitToHours: boardsStore.timeTracking.limitToHours,
};
},
computed: {
title() {
return stringifyTime(
parseSeconds(this.estimate, { limitToHours: gon.time_tracking_display_hours_only }),
true
);
return stringifyTime(parseSeconds(this.estimate, { limitToHours: this.limitToHours }), true);
},
timeEstimate() {
return stringifyTime(
parseSeconds(this.estimate, { limitToHours: gon.time_tracking_display_hours_only })
);
return stringifyTime(parseSeconds(this.estimate, { limitToHours: this.limitToHours }));
},
},
};
Loading
Loading
Loading
Loading
@@ -49,6 +49,7 @@ export default () => {
}
 
boardsStore.create();
boardsStore.setTimeTrackingLimitToHours($boardApp.dataset.timeTrackingLimitToHours);
 
issueBoardsApp = new Vue({
el: $boardApp,
Loading
Loading
Loading
Loading
@@ -12,6 +12,9 @@ import eventHub from '../eventhub';
 
const boardsStore = {
disabled: false,
timeTracking: {
limitToHours: false,
},
scopedLabels: {
helpLink: '',
enabled: false,
Loading
Loading
@@ -222,6 +225,10 @@ const boardsStore = {
setIssueDetail(issueDetail) {
this.detail.issue = issueDetail;
},
setTimeTrackingLimitToHours(limitToHours) {
this.timeTracking.limitToHours = parseBoolean(limitToHours);
},
};
 
BoardsStoreEE.initEESpecific(boardsStore);
Loading
Loading
Loading
Loading
@@ -485,6 +485,7 @@ export const parseSeconds = (
) => {
const DAYS_PER_WEEK = daysPerWeek;
const HOURS_PER_DAY = hoursPerDay;
const SECONDS_PER_MINUTE = 60;
const MINUTES_PER_HOUR = 60;
const MINUTES_PER_WEEK = DAYS_PER_WEEK * HOURS_PER_DAY * MINUTES_PER_HOUR;
const MINUTES_PER_DAY = HOURS_PER_DAY * MINUTES_PER_HOUR;
Loading
Loading
@@ -496,10 +497,15 @@ export const parseSeconds = (
minutes: 1,
};
 
let unorderedMinutes = Math.abs(seconds / MINUTES_PER_HOUR);
if (limitToHours) {
timePeriodConstraints.weeks = 0;
timePeriodConstraints.days = 0;
}
let unorderedMinutes = Math.abs(seconds / SECONDS_PER_MINUTE);
 
return _.mapObject(timePeriodConstraints, minutesPerPeriod => {
if (limitToHours && minutesPerPeriod > MINUTES_PER_HOUR) {
if (minutesPerPeriod === 0) {
return 0;
}
 
Loading
Loading
Loading
Loading
@@ -28,11 +28,16 @@ export default {
type: String,
required: true,
},
limitToHours: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
parsedTimeRemaining() {
const diffSeconds = this.timeEstimate - this.timeSpent;
return parseSeconds(diffSeconds, { limitToHours: gon.time_tracking_display_hours_only });
return parseSeconds(diffSeconds, { limitToHours: this.limitToHours });
},
timeRemainingHumanReadable() {
return stringifyTime(this.parsedTimeRemaining);
Loading
Loading
Loading
Loading
@@ -53,6 +53,7 @@ export default {
:time-spent="store.totalTimeSpent"
:human-time-estimate="store.humanTimeEstimate"
:human-time-spent="store.humanTotalTimeSpent"
:limit-to-hours="store.timeTrackingLimitToHours"
:root-path="store.rootPath"
/>
</div>
Loading
Loading
Loading
Loading
@@ -37,6 +37,10 @@ export default {
required: false,
default: '',
},
limitToHours: {
type: Boolean,
default: false,
},
rootPath: {
type: String,
required: true,
Loading
Loading
@@ -129,6 +133,7 @@ export default {
:time-spent="timeSpent"
:time-spent-human-readable="humanTimeSpent"
:time-estimate-human-readable="humanTimeEstimate"
:limit-to-hours="limitToHours"
/>
<transition name="help-state-toggle">
<time-tracking-help-state v-if="showHelpState" :root-path="rootPath" />
Loading
Loading
import Vue from 'vue';
import timeTracker from './components/time_tracking/time_tracker.vue';
import { parseBoolean } from '~/lib/utils/common_utils';
 
export default class SidebarMilestone {
constructor() {
Loading
Loading
@@ -7,7 +8,7 @@ export default class SidebarMilestone {
 
if (!el) return;
 
const { timeEstimate, timeSpent, humanTimeEstimate, humanTimeSpent } = el.dataset;
const { timeEstimate, timeSpent, humanTimeEstimate, humanTimeSpent, limitToHours } = el.dataset;
 
// eslint-disable-next-line no-new
new Vue({
Loading
Loading
@@ -22,6 +23,7 @@ export default class SidebarMilestone {
timeSpent: parseInt(timeSpent, 10),
humanTimeEstimate,
humanTimeSpent,
limitToHours: parseBoolean(limitToHours),
rootPath: '/',
},
}),
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ export default class SidebarStore {
}
 
initSingleton(options) {
const { currentUser, rootPath, editable } = options;
const { currentUser, rootPath, editable, timeTrackingLimitToHours } = options;
this.currentUser = currentUser;
this.rootPath = rootPath;
this.editable = editable;
Loading
Loading
@@ -16,6 +16,7 @@ export default class SidebarStore {
this.totalTimeSpent = 0;
this.humanTimeEstimate = '';
this.humanTimeSpent = '';
this.timeTrackingLimitToHours = timeTrackingLimitToHours;
this.assignees = [];
this.isFetching = {
assignees: true,
Loading
Loading
Loading
Loading
@@ -253,7 +253,7 @@ module ApplicationSettingsHelper
:throttle_unauthenticated_enabled,
:throttle_unauthenticated_period_in_seconds,
:throttle_unauthenticated_requests_per_period,
:time_tracking_display_hours_only,
:time_tracking_limit_to_hours,
:two_factor_grace_period,
:unique_ips_limit_enabled,
:unique_ips_limit_per_user,
Loading
Loading
Loading
Loading
@@ -14,7 +14,8 @@ module BoardsHelper
issue_link_base: build_issue_link_base,
root_path: root_path,
bulk_update_path: @bulk_issues_path,
default_avatar: image_path(default_avatar)
default_avatar: image_path(default_avatar),
time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s
}
end
 
Loading
Loading
Loading
Loading
@@ -430,7 +430,8 @@ module IssuablesHelper
editable: issuable.dig(:current_user, :can_edit),
currentUser: issuable[:current_user],
rootPath: root_path,
fullPath: issuable[:project_full_path]
fullPath: issuable[:project_full_path],
timeTrackingLimitToHours: Gitlab::CurrentSettings.time_tracking_limit_to_hours
}
end
 
Loading
Loading
Loading
Loading
@@ -82,7 +82,7 @@ module ApplicationSettingImplementation
throttle_unauthenticated_enabled: false,
throttle_unauthenticated_period_in_seconds: 3600,
throttle_unauthenticated_requests_per_period: 3600,
time_tracking_display_hours_only: false,
time_tracking_limit_to_hours: false,
two_factor_grace_period: 48,
unique_ips_limit_enabled: false,
unique_ips_limit_per_user: 10,
Loading
Loading
Loading
Loading
@@ -9,9 +9,10 @@
= _('Default first day of the week in calendars and date pickers.')
 
.form-group
= f.label :time_tracking, _('Time tracking'), class: 'label-bold'
.form-check
= f.check_box :time_tracking_display_hours_only, class: 'form-check-input'
= f.label :time_tracking_display_hours_only, class: 'form-check-label' do
_('Limit time tracking display to hours.')
= f.check_box :time_tracking_limit_to_hours, class: 'form-check-input'
= f.label :time_tracking_limit_to_hours, class: 'form-check-label' do
= _('Limit display of time tracking units to hours.')
 
= f.submit _('Save changes'), class: "btn btn-success"
Loading
Loading
@@ -3,4 +3,5 @@
":time-spent" => "issue.timeSpent || 0",
":human-time-estimate" => "issue.humanTimeEstimate",
":human-time-spent" => "issue.humanTimeSpent",
":limit-to-hours" => "timeTrackingLimitToHours",
"root-path" => "#{root_url}" }
Loading
Loading
@@ -93,7 +93,11 @@
= milestone.issues_visible_to_user(current_user).closed.count
 
.block
#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 } }
#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,
limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s } }
// Fallback while content is loading
.title.hide-collapsed
= _('Time tracking')
Loading
Loading
---
title: Add option to show time tracking values in hours only
title: Add option to limit time tracking units to hours
merge_request: 29469
author: Jon Kolb
type: added
Loading
Loading
@@ -3,7 +3,7 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
 
class AddTimeTrackingDisplayHoursOnlyToApplicationSettings < ActiveRecord::Migration[5.1]
class AddTimeTrackingLimitToHoursToApplicationSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
 
# Set this constant to true if this migration requires downtime.
Loading
Loading
@@ -12,10 +12,10 @@ class AddTimeTrackingDisplayHoursOnlyToApplicationSettings < ActiveRecord::Migra
disable_ddl_transaction!
 
def up
add_column_with_default :application_settings, :time_tracking_display_hours_only, :boolean, default: false, allow_null: false
add_column_with_default :application_settings, :time_tracking_limit_to_hours, :boolean, default: false, allow_null: false
end
 
def down
remove_column :application_settings, :time_tracking_display_hours_only
remove_column :application_settings, :time_tracking_limit_to_hours
end
end
Loading
Loading
@@ -229,7 +229,7 @@ ActiveRecord::Schema.define(version: 20190620112608) do
t.integer "custom_project_templates_group_id"
t.boolean "elasticsearch_limit_indexing", default: false, null: false
t.string "geo_node_allowed_ips", default: "0.0.0.0/0, ::/0"
t.boolean "time_tracking_display_hours_only", default: false, null: false
t.boolean "time_tracking_limit_to_hours", default: false, null: false
t.index ["custom_project_templates_group_id"], name: "index_application_settings_on_custom_project_templates_group_id", using: :btree
t.index ["file_template_project_id"], name: "index_application_settings_on_file_template_project_id", using: :btree
t.index ["usage_stats_set_by_user_id"], name: "index_application_settings_on_usage_stats_set_by_user_id", using: :btree
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment