Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue time estimate, meaningful time tracking #23113

Open
wants to merge 102 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
1363205
Commit
Feb 24, 2023
d11ba9f
Commit
Feb 24, 2023
c783692
Commit
Feb 24, 2023
a8778f4
Commit
Feb 24, 2023
d944662
Commit
Feb 24, 2023
7ed86ff
Commit
Feb 24, 2023
c248042
Commit
Feb 24, 2023
d75b7ac
Commit
Feb 24, 2023
4be8c50
Commit
Feb 24, 2023
5f3edad
Update services/issue/issue.go
stuzer05 Feb 24, 2023
f7a4c9e
Update services/issue/issue.go
stuzer05 Feb 24, 2023
e187364
Commit
Feb 24, 2023
f33b0a0
Commit
Feb 24, 2023
4e1aed8
Merge branch 'main' into add-issue-planned-time
stuzer05 Feb 24, 2023
2fc2f63
Commit
Feb 24, 2023
b062fc9
Commit
Feb 24, 2023
870bb92
Commit
Feb 24, 2023
d247b0f
Commit
Feb 24, 2023
09c05e8
Commit
Feb 24, 2023
0f5b609
Commit
Feb 24, 2023
11b9719
Commit
Feb 24, 2023
1b7ba41
Commit
Feb 24, 2023
f7427d8
Commit
Feb 24, 2023
1cff1a9
Commit
Feb 24, 2023
e155495
Commit
Feb 24, 2023
f463765
Commit
Feb 24, 2023
7a57044
Commit
Feb 24, 2023
79f507b
Commit
Feb 24, 2023
5c4dc87
Commit
Feb 24, 2023
0ab85af
Commit
Feb 24, 2023
5eea230
Commit
Feb 24, 2023
db3c697
Commit
Feb 24, 2023
775c663
Merge branch 'main' into add-issue-planned-time
stuzer05 Feb 24, 2023
8750870
Commit
Feb 24, 2023
29dd617
Commit
Feb 24, 2023
7be748f
Commit
Feb 24, 2023
b9cdc7c
Commit
Feb 26, 2023
8c0bf88
Merge branch 'main' into add-issue-planned-time
stuzer05 Feb 27, 2023
e20e23b
Commit
stuzer05 Feb 27, 2023
37e8e8d
Commit
stuzer05 Feb 27, 2023
8ef3a47
Commit
stuzer05 Feb 27, 2023
49a176d
Commit
stuzer05 Feb 28, 2023
79e18c6
Commit
stuzer05 Feb 28, 2023
deddce5
Commit
stuzer05 Feb 28, 2023
fb81260
Update models/issues/issue.go
stuzer05 Feb 28, 2023
bf323cf
Commit
stuzer05 Feb 28, 2023
57a3664
Commit
stuzer05 Feb 28, 2023
fd5adc5
Merge branch 'main' into add-issue-planned-time
stuzer05 Feb 28, 2023
879d96f
Merge branch 'main' into add-issue-planned-time
stuzer05 Mar 4, 2023
fc93006
Merge branch 'main' into add-issue-planned-time
stuzer05 Apr 18, 2023
bf4fa11
Merge branch 'main' into add-issue-planned-time
stuzer05 Jun 3, 2023
40e1373
Merge branch 'main' into add-issue-planned-time
stuzer05 Jun 6, 2023
e9afd60
Refactor helper functions
stuzer05 Jun 11, 2023
3924cb0
Merge branch 'go-gitea:main' into add-issue-planned-time
stuzer05 Jun 11, 2023
748bd67
Fix displaying issue estimation
stuzer05 Jun 14, 2023
015ad01
Merge branch 'main' into add-issue-planned-time
stuzer05 Jun 18, 2023
cef496a
Remove unused code
stuzer05 Jun 18, 2023
ffaa4ba
Format
stuzer05 Jun 18, 2023
b211b9e
Merge branch 'main' into add-issue-planned-time
silverwind Jun 18, 2023
598e2d5
Merge branch 'main' into add-issue-planned-time
stuzer05 Jun 19, 2023
3310440
Hide time tracking
stuzer05 Jun 23, 2023
721069d
Merge branch 'main' into add-issue-planned-time
stuzer05 Jun 23, 2023
a45c1e9
Merge branch 'main' into add-issue-planned-time
stuzer05 Jun 24, 2023
db49783
Commit
stuzer05 Jun 24, 2023
e933a89
Delete serviceworker.js
stuzer05 Jun 24, 2023
62094d8
Merge branch 'main' into add-issue-planned-time
stuzer05 Jun 26, 2023
fa662ec
Merge branch 'main' into add-issue-planned-time
stuzer05 Jul 10, 2023
64de74d
Merge branch 'main' into add-issue-planned-time
stuzer05 Sep 11, 2023
349b959
Merge branch 'main' into add-issue-planned-time
stuzer05 Oct 7, 2023
3037d6c
Merge branch 'main' into add-issue-planned-time
stuzer05 Oct 8, 2023
2a9009f
Merge branch 'main' into add-issue-planned-time
stuzer05 Oct 16, 2023
a6fa4c3
Merge branch 'main' into add-issue-planned-time
stuzer05 Jan 15, 2024
a999055
Merge branch 'main' into add-issue-planned-time
stuzer05 Jan 17, 2024
39b8b19
Merge branch 'main' into add-issue-planned-time
stuzer05 Jan 22, 2024
92dc2cd
Merge branch 'main' into add-issue-planned-time
stuzer05 Feb 11, 2024
a737a8c
Merge branch 'main' into add-issue-planned-time
stuzer05 Feb 19, 2024
bb5ca4c
Merge branch 'main' into add-issue-planned-time
stuzer05 Feb 28, 2024
805af19
Merge branch 'main' into add-issue-planned-time
stuzer05 Mar 4, 2024
0c4b2df
Commit
stuzer05 Mar 4, 2024
c272512
Merge branch 'main' into add-issue-planned-time
stuzer05 Mar 4, 2024
09723c5
Merge branch 'main' into add-issue-planned-time
stuzer05 Mar 17, 2024
0820db0
Merge branch 'main' into add-issue-planned-time
stuzer05 Mar 28, 2024
93d09fa
Merge branch 'main' into add-issue-planned-time
stuzer05 Mar 29, 2024
1e22cc2
Merge branch 'main' into add-issue-planned-time
stuzer05 Apr 13, 2024
e92bedc
Commit
stuzer05 Apr 13, 2024
b452e13
Commit
stuzer05 Apr 13, 2024
b97139b
Merge branch 'main' into add-issue-planned-time
stuzer05 Apr 15, 2024
12553d7
Merge branch 'main' into add-issue-planned-time
stuzer05 Apr 22, 2024
0a8fd35
Merge branch 'main' into add-issue-planned-time
stuzer05 Apr 25, 2024
8c92f46
Merge branch 'main' into add-issue-planned-time
stuzer05 Apr 30, 2024
0c44cf7
Commit
stuzer05 Apr 30, 2024
a71b457
Commit
stuzer05 May 2, 2024
52d62fb
Merge branch 'main' into add-issue-planned-time
stuzer05 May 17, 2024
ff60376
Merge branch 'main' into add-issue-planned-time
stuzer05 May 30, 2024
be18b73
Merge branch 'main' into add-issue-planned-time
stuzer05 Jun 17, 2024
84d9dee
Merge branch 'main' into add-issue-planned-time
6543 Jul 5, 2024
823d67f
pass context down
6543 Jul 5, 2024
4ff958b
Merge branch 'main' into add-issue-planned-time
stuzer05 Jul 8, 2024
3499c44
Use RenderedContent
stuzer05 Jul 8, 2024
bf7fcba
Merge branch 'main' into add-issue-planned-time
stuzer05 Aug 1, 2024
392fa48
Merge branch 'main' into add-issue-planned-time
stuzer05 Aug 26, 2024
66b2c4a
Merge branch 'main' into add-issue-planned-time
stuzer05 Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions models/issues/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const (
CommentTypePRScheduledToAutoMerge
// 35 pr was un scheduled to auto merge when checks succeed
CommentTypePRUnScheduledToAutoMerge
// 36 Change plan time
CommentTypeChangePlanTime
)

var commentStrings = []string{
Expand All @@ -144,6 +146,7 @@ var commentStrings = []string{
"milestone",
"assignees",
"change_title",
"change_plan_time",
"delete_branch",
"start_tracking",
"stop_tracking",
Expand Down Expand Up @@ -301,6 +304,9 @@ type Comment struct {
NewCommit string `xorm:"-"`
CommitsNum int64 `xorm:"-"`
IsForcePush bool `xorm:"-"`

PlanTimeHours int
PlanTimeMinutes int
stuzer05 marked this conversation as resolved.
Show resolved Hide resolved
}

func init() {
Expand Down Expand Up @@ -819,6 +825,8 @@ func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment,
RefIsPull: opts.RefIsPull,
IsForcePush: opts.IsForcePush,
Invalidated: opts.Invalidated,
PlanTimeHours: opts.PlanTimeHours,
PlanTimeMinutes: opts.PlanTimeMinutes,
}
if _, err = e.Insert(comment); err != nil {
return nil, err
Expand Down Expand Up @@ -990,6 +998,8 @@ type CreateCommentOptions struct {
RefIsPull bool
IsForcePush bool
Invalidated bool
PlanTimeHours int
PlanTimeMinutes int
}

// GetCommentByID returns the comment by given ID.
Expand Down
35 changes: 35 additions & 0 deletions models/issues/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ type Issue struct {

// For view issue page.
ShowRole RoleDescriptor `xorm:"-"`

// Plan time
PlanTimeHours int
PlanTimeMinutes int
}

var (
Expand Down Expand Up @@ -774,6 +778,37 @@ func ChangeIssueTitle(issue *Issue, doer *user_model.User, oldTitle string) (err
return committer.Commit()
}

// ChangeIssuePlanTime changes the plan time of this issue, as the given user.
func ChangeIssuePlanTime(issue *Issue, doer *user_model.User, planTimeHours int, planTimeMinutes int) (err error) {
ctx, committer, err := db.TxContext(db.DefaultContext)
if err != nil {
return err
}
defer committer.Close()

if err = UpdateIssueCols(ctx, &Issue{ID: issue.ID, PlanTimeHours: planTimeHours, PlanTimeMinutes: planTimeMinutes}, "plan_time_hours", "plan_time_minutes"); err != nil {
return fmt.Errorf("updateIssueCols: %w", err)
}

if err = issue.LoadRepo(ctx); err != nil {
return fmt.Errorf("loadRepo: %w", err)
}

opts := &CreateCommentOptions{
Type: CommentTypeChangePlanTime,
Doer: doer,
Repo: issue.Repo,
Issue: issue,
PlanTimeHours: planTimeHours,
PlanTimeMinutes: planTimeMinutes,
}
if _, err = CreateComment(ctx, opts); err != nil {
return fmt.Errorf("createComment: %w", err)
}

return committer.Commit()
}

// ChangeIssueRef changes the branch of this issue, as the given user.
func ChangeIssueRef(issue *Issue, doer *user_model.User, oldRef string) (err error) {
ctx, committer, err := db.TxContext(db.DefaultContext)
Expand Down
8 changes: 6 additions & 2 deletions modules/structs/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type Issue struct {
Attachments []*Attachment `json:"assets"`
Labels []*Label `json:"labels"`
Milestone *Milestone `json:"milestone"`
PlanTimeHours int64 `json:"plan_time_hours"`
PlanTimeMinutes int64 `json:"plan_time_minutes"`
// deprecated
Assignee *User `json:"assignee"`
Assignees []*User `json:"assignees"`
Expand Down Expand Up @@ -106,8 +108,10 @@ type EditIssueOption struct {
Milestone *int64 `json:"milestone"`
State *string `json:"state"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_date"`
RemoveDeadline *bool `json:"unset_due_date"`
Deadline *time.Time `json:"due_date"`
PlanTimeHours int `json:"plan_time_hours"`
PlanTimeMinutes int `json:"plan_time_minutes"`
RemoveDeadline *bool `json:"unset_due_date"`
}

// EditDeadlineOption options for creating a deadline
Expand Down
3 changes: 3 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,9 @@ issues.add_assignee_at = `was assigned by <b>%s</b> %s`
issues.remove_assignee_at = `was unassigned by <b>%s</b> %s`
issues.remove_self_assignment = `removed their assignment %s`
issues.change_title_at = `changed title from <b><strike>%s</strike></b> to <b>%s</b> %s`
issues.tracker_plan_time = `Planned time`
issues.change_plan_time_at = `changed planned time to <b>%d hour %d minutes</b> %s`
issues.remove_plan_time = `removed planned time %s`
issues.change_ref_at = `changed reference from <b><strike>%s</strike></b> to <b>%s</b> %s`
issues.remove_ref_at = `removed reference <b>%s</b> %s`
issues.add_ref_at = `added reference <b>%s</b> %s`
Expand Down
3 changes: 3 additions & 0 deletions options/locale/locale_ru-RU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,9 @@ issues.add_assignee_at=`был(а) назначен(а) <b>%s</b> %s`
issues.remove_assignee_at=`был снят с назначения <b>%s</b> %s`
issues.remove_self_assignment=`убрал(а) их назначение %s`
issues.change_title_at=`изменил(а) заголовок с <b><strike>%s</strike></b> на <b>%s</b> %s`
issues.tracker_plan_time = `Запланированное время`
issues.change_plan_time_at=`изменил(а) запланированное время на <b>%d час(ов) %d минут</b> %s`
issues.remove_plan_time = `убрал(а) запланированное время %s`
stuzer05 marked this conversation as resolved.
Show resolved Hide resolved
issues.change_ref_at=`изменил(а) ссылку с <b><strike>%s</strike></b> на <b>%s</b> %s`
issues.remove_ref_at=`убрал(а) ссылку <b>%s</b> %s`
issues.add_ref_at=`добавил(а) ссылку <b>%s</b> %s`
Expand Down
5 changes: 4 additions & 1 deletion options/locale/locale_uk-UA.ini
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ delete_email=Видалити
email_deletion=Видалити адресу електронної пошти
email_deletion_desc=Електронна адреса та пов'язана з нею інформація буде видалена з вашого облікового запису. Git коміти, здійснені через цю електронну адресу, залишиться без змін. Продовжити?
email_deletion_success=Адресу електронної пошти було видалено.
theme_update_success=Тему оновлено.
theme_update_success=Тему оновлено.
theme_update_error=Вибрана тема не існує.
openid_deletion=Видалити адресу OpenID
openid_deletion_desc=Видалення цієї OpenID-адреси з вашого облікового запису забороняє вам входити з ним. Продовжити?
Expand Down Expand Up @@ -1160,6 +1160,9 @@ issues.add_assignee_at=`був призначений <b>%s</b> %s`
issues.remove_assignee_at=`був знятий з призначення <b>%s</b> %s`
issues.remove_self_assignment=`видалено призначення %s`
issues.change_title_at=`змінився заголовок з <b><strike>%s</strike></b> на <b>%s</b> %s`
issues.tracker_plan_time = `Запланований час`
issues.change_plan_time_at=`змінив запланований час на <b>%d годин %d хвилин</b> %s`
issues.remove_plan_time = `видалив запланований час %s`
stuzer05 marked this conversation as resolved.
Show resolved Hide resolved
issues.change_ref_at=`змінив посилання з <b><strike>%s</strike></b> на <b>%s</b> %s`
issues.remove_ref_at=`видалив посилання <b>%s</b> %s`
issues.add_ref_at=`додав посилання <b>%s</b> %s`
Expand Down
32 changes: 32 additions & 0 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,38 @@ func UpdateIssueTitle(ctx *context.Context) {
})
}

// UpdateIssuePlanTime change issue's title
stuzer05 marked this conversation as resolved.
Show resolved Hide resolved
func UpdateIssuePlanTime(ctx *context.Context) {
issue := GetActionIssue(ctx)
if ctx.Written() {
return
}

if !ctx.IsSigned || (!issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
ctx.Error(http.StatusForbidden)
return
}

planTimeHours := ctx.FormInt("plan_time_hours")
planTimeMinutes := ctx.FormInt("plan_time_minutes")

if issue.PlanTimeHours == planTimeHours && issue.PlanTimeMinutes == planTimeMinutes {
ctx.JSON(http.StatusOK, map[string]interface{}{
"status": "ok",
})
return
}

if err := issue_service.ChangePlanTime(issue, ctx.Doer, planTimeHours, planTimeMinutes); err != nil {
ctx.ServerError("ChangePlanTime", err)
return
}

ctx.JSON(http.StatusOK, map[string]interface{}{
"status": "ok",
})
}

// UpdateIssueRef change issue's ref (branch)
func UpdateIssueRef(ctx *context.Context) {
issue := GetActionIssue(ctx)
Expand Down
1 change: 1 addition & 0 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,7 @@ func RegisterRoutes(m *web.Route) {
// So they can apply their own enable/disable logic on routers.
m.Group("/{type:issues|pulls}", func() {
m.Group("/{index}", func() {
m.Post("/plan_time", repo.UpdateIssuePlanTime)
m.Post("/title", repo.UpdateIssueTitle)
m.Post("/content", repo.UpdateIssueContent)
m.Post("/deadline", web.Bind(structs.EditDeadlineOption{}), repo.UpdateIssueDeadline)
Expand Down
15 changes: 15 additions & 0 deletions services/issue/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ func ChangeTitle(issue *issues_model.Issue, doer *user_model.User, title string)
return nil
}

// ChangeTitle changes the title of this issue, as the given user.
stuzer05 marked this conversation as resolved.
Show resolved Hide resolved
func ChangePlanTime(issue *issues_model.Issue, doer *user_model.User, planTimeHours int, planTimeMinutes int) (err error) {
//oldTitle := issue.Title
stuzer05 marked this conversation as resolved.
Show resolved Hide resolved
issue.PlanTimeHours = planTimeHours
issue.PlanTimeMinutes = planTimeMinutes

if err = issues_model.ChangeIssuePlanTime(issue, doer, planTimeHours, planTimeMinutes); err != nil {
return
}

//notification.NotifyIssueChangeTitle(db.DefaultContext, doer, issue, oldTitle)
stuzer05 marked this conversation as resolved.
Show resolved Hide resolved

return nil
}

// ChangeIssueRef changes the branch of this issue, as the given user.
func ChangeIssueRef(issue *issues_model.Issue, doer *user_model.User, ref string) error {
oldRef := issue.Ref
Expand Down
13 changes: 13 additions & 0 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,19 @@
{{else}}{{$.locale.Tr "repo.pulls.auto_merge_canceled_schedule_comment" $createdStr | Safe}}{{end}}
</span>
</div>
{{else if eq .Type 1001}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
{{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if and (eq .PlanTimeHours 0) (eq .PlanTimeMinutes 0)}}
{{$.locale.Tr "repo.issues.remove_plan_time" $createdStr | Safe}}
{{else}}
{{$.locale.Tr "repo.issues.change_plan_time_at" (.PlanTimeHours) (.PlanTimeMinutes) $createdStr | Safe}}
{{end}}
</span>
</div>
{{end}}
{{end}}
{{end}}
15 changes: 15 additions & 0 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,21 @@
{{end}}
{{if .Repository.IsTimetrackerEnabled $.Context}}
{{if and .CanUseTimetracker (not .Repository.IsArchived)}}
<div class="ui divider"></div>
<div>
<span class="text"><strong>{{.locale.Tr "repo.issues.tracker_plan_time"}}</strong></span>

<form method="POST" id="set_plan_time_form" class="gt-mt-3" action="{{.Issue.Link}}/plan_time">
{{$.CsrfTokenHtml}}
<div class="ui action input fluid">
<input placeholder='{{.locale.Tr "repo.issues.add_time_hours"}}' type="number" min="0" value="{{ ($.Issue.PlanTimeHours) }}" name="plan_time_hours">
<input placeholder='{{.locale.Tr "repo.issues.add_time_minutes"}}' type="number" min="0" max="59" value="{{ ($.Issue.PlanTimeMinutes) }}" name="plan_time_minutes" class="ui compact">
</div>
<button class="ui fluid button green tooltip gt-mt-3">
{{.locale.Tr "repo.issues.save"}}
</button>
</form>
</div>
<div class="ui divider"></div>
<div class="ui timetrack">
<span class="text"><strong>{{.locale.Tr "repo.issues.tracker"}}</strong></span>
Expand Down
19 changes: 19 additions & 0 deletions web_src/js/features/repo-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,25 @@ export function initRepoIssueTitleEdit() {
});
}

export function initRepoIssuePlanTimeEdit() {
$('#set_plan_time_form').on('submit', function(e) {
e.preventDefault();

const planTimeHours = $(this).find('[name=plan_time_hours]').val();
const planTimeMinutes = $(this).find('[name=plan_time_minutes]').val();

$.post($(this).attr('action'), {
_csrf: csrfToken,
plan_time_hours: planTimeHours,
plan_time_minutes: planTimeMinutes,
}).always(() => {
window.location.reload();
});

return false;
});
}

export function initRepoIssueBranchSelect() {
const changeBranchSelect = function () {
const selectionTextField = $('#pull-target-branch');
Expand Down
3 changes: 2 additions & 1 deletion web_src/js/features/repo-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
import {initEasyMDEImagePaste} from './comp/ImagePaste.js';
import {
initRepoIssueBranchSelect, initRepoIssueCodeCommentCancel, initRepoIssueCommentDelete,
initRepoIssueComments, initRepoIssueDependencyDelete, initRepoIssueReferenceIssue,
initRepoIssueComments, initRepoIssueDependencyDelete, initRepoIssuePlanTimeEdit, initRepoIssueReferenceIssue,
initRepoIssueStatusButton, initRepoIssueTitleEdit, initRepoIssueWipToggle,
initRepoPullRequestUpdate, updateIssuesMeta,
} from './repo-issue.js';
Expand Down Expand Up @@ -562,6 +562,7 @@ export function initRepository() {
initRepoIssueTitleEdit();
initRepoIssueWipToggle();
initRepoIssueComments();
initRepoIssuePlanTimeEdit();

initRepoDiffConversationNav();
initRepoIssueReferenceIssue();
Expand Down