-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Feature: Timetracking #2211
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
Merged
Merged
Feature: Timetracking #2211
Changes from 91 commits
Commits
Show all changes
102 commits
Select commit
Hold shift + click to select a range
74774a4
Added comment's hashtag to url for mail notifications.
jonasfranz f385727
Added comment's hashtag to url for mail notifications.
jonasfranz e05eb96
Added comment's hashtag to url for mail notifications.
jonasfranz 5cb36ca
Added comment's hashtag to url for mail notifications.
jonasfranz 2dd674e
Replacing in-line link generation with HTMLURL. (+gofmt)
jonasfranz 716bf81
Replaced action-based model with nil-based model. (+gofmt)
jonasfranz edaa576
Replaced mailIssueActionToParticipants with mailIssueCommentToPartici…
jonasfranz b0e22ab
Updating comment for mailIssueCommentToParticipants
jonasfranz fd70385
Merge branch 'master' of github.com:JonasFranzDEV/gitea
jonasfranz 3c6d4fc
Merge branch 'master' of https://github.com/JonasFranzDEV/gitea
jonasfranz 36ae732
Added link to comment in "Dashboard"
jonasfranz 1826b2b
Added migration
jonasfranz bb33f2e
Added improved migration to add a CommentID column to action.
jonasfranz 3f1c85c
Added improved migration to add a CommentID column to action.
jonasfranz 5791853
Added improved migration to add a CommentID column to action.
jonasfranz deddcda
Added improved migration to add a CommentID column to action.
jonasfranz 70d8dd9
Added improved migration to add a CommentID column to action.
jonasfranz 3b99726
Added improved migration to add a CommentID column to action.
jonasfranz 9e18513
Added improved migration to add a CommentID column to action.
jonasfranz 0e20e81
Added improved migration to add a CommentID column to action.
jonasfranz 8818bc7
Added improved links to comments in feed entries. (+ gofmt) Signed-o…
jonasfranz 3e1241c
Fixes #1956 by filtering for deleted comments that are referenced in …
jonasfranz 3ee3dc3
Fixes #1956 by filtering for deleted comments.
jonasfranz 56a64e3
Fixes #1956 by filtering for deleted comments.
jonasfranz ce6de8a
Merge remote-tracking branch 'root/master'
jonasfranz c8d270b
Adding design draft (not functional)
jonasfranz 6db864a
Adding design draft (not functional)
jonasfranz b213c99
Adding translations and improving design
jonasfranz 79d5c74
Implementing stopwatch (for timetracking)
jonasfranz 286dd9b
Implementing timetracking feature
jonasfranz cff9234
Only showing total time spent if theire is something to show.
jonasfranz 615b3dd
Adding license headers.
jonasfranz a1dff21
Improved error handling for "Add Time Manual"
jonasfranz 251d50e
Improved error handling for "Add Time Manual"
jonasfranz 3945c0e
Adding @sapks 's changes, refactoring
jonasfranz 0347bb3
Adding API for feature tracking
jonasfranz c1943c1
Adding DISABLE/ENABLE option to Repository settings page
jonasfranz edf850d
Improving translations + adding German translation
jonasfranz 9bd4821
Removing repo_unit and using IssuesSetting for disabling/enabling tim…
jonasfranz d26f4da
Merge pull request #1 from JonasFranzDEV/feature/timetracking
jonasfranz 8675986
Fixing vendor/ folder
jonasfranz 47d3187
Changing timtracking routes by adding subgroups /times and /times/sto…
jonasfranz ce3c380
Restricting write access to timetracking based on the repo settings
jonasfranz 871a6eb
Restricting write access to timetracking based on the repo settings
jonasfranz 15faf72
Fixed minor permissions bug.
jonasfranz 906b4c9
Removed German translations
jonasfranz 08b0e63
Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo
jonasfranz 3b25d8e
Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo
jonasfranz b1dfaa7
Removing unused Get...ByID functions
jonasfranz fcec528
Moving IsTimetrackerEnabled from context.Repository to models.Repository
jonasfranz 2fa55de
Adding a seperate file for issue related repo functions
jonasfranz 4ed6614
Fixed GetUserByParams return 404
jonasfranz 078f59f
Moving /users/:username/times to /repos/:username/:reponame/times/:us…
jonasfranz 3d3b94a
Updating sdk-dependency
jonasfranz c3b5ecc
Updating swagger.v1.json
jonasfranz 13fb0e3
Adding warning if user has already a running stopwatch (auto-timetrac…
jonasfranz 497f214
Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrack…
jonasfranz 43762a0
Merge branch 'master' into feature/timetracking
jonasfranz 6563b5b
Correcting spelling mistake
jonasfranz b42380c
Updating code.gitea.io/sdk
jonasfranz 4a97d69
Updating vendor.json
jonasfranz a69b5cd
Updating vendor.json
jonasfranz 9023d24
Changing GET stopwatch/toggle to POST stopwatch/toggle
jonasfranz 2f97858
Changing GET stopwatch/cancel to POST stopwatch/cancel
jonasfranz 6eb51db
Added migration for stopwatches/timetracking
jonasfranz 88d1167
Fixed migration by chaging x.Iterate to x.Find
jonasfranz f50e0d2
Resorted imports
jonasfranz 55ee4e4
Moved Add Time Manually form to repo_form.go
jonasfranz 10be62f
Added integration test
jonasfranz 77db940
Resorted imports
jonasfranz 76d7509
gofmt
jonasfranz f051c45
Adding integration test by @lafriks
jonasfranz c2fa07b
Using last event instead of a fixed event
jonasfranz 0d8d3d5
Adding another integration test by @lafriks
jonasfranz a8eba6a
Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" wa…
jonasfranz 48e8365
Returning TrackedTime instead of AddTimeOption at AddTime.
jonasfranz abea9a7
Updating SDK from go-gitea/go-sdk#69
jonasfranz ba3895a
Merge branch 'master' into feature/timetracking
jonasfranz 17a9a6b
Resetting Go-SDK back to default repository
jonasfranz 44f9898
Merge branch 'master' of https://github.com/go-gitea/gitea into featu…
jonasfranz 36db650
Merge branch 'master' of https://github.com/go-gitea/gitea into featu…
jonasfranz 28cdef6
Fixing test-vendor by changing ini back to original repository
jonasfranz 2dabf41
Adding "tags" to swagger spec
jonasfranz 4063041
govendor sync
jonasfranz 3222a0f
Removed duplicate
jonasfranz 3840adf
Merge branches 'feature/timetracking' and 'master' of https://github.…
jonasfranz 4727c4b
Formatting templates
jonasfranz b502d9b
Merge branch 'master' of https://github.com/go-gitea/gitea into featu…
jonasfranz 528dd2d
Updating swagger spec
jonasfranz 16de1d2
Fixing integration test caused be translation-changes
jonasfranz 83a73d4
Removed encoding issues in local_en-US.ini.
jonasfranz 3d117fc
Moved unit.IssuesConfig().EnableTimetracker into a != nil check
jonasfranz e2244a8
Improved javascript by checking if data-context exists
jonasfranz 52be3f5
Replaced manual comment creation with CreateComment
jonasfranz 17684f5
Replaced int>string>duration parsing with int>duration parsing
jonasfranz 3142af3
Fixed encoding issues
jonasfranz 3e08048
Removed unused imports
jonasfranz 63a47bc
Merge branch 'master' into feature/timetracking
bkcsoft c8ed915
Merge branch 'master' of https://github.com/go-gitea/gitea into featu…
jonasfranz 8cb778c
Merge branch 'master' of https://github.com/go-gitea/gitea into featu…
jonasfranz 86346e6
Merge branch 'master' of https://github.com/go-gitea/gitea into featu…
jonasfranz d73b085
Merge branch 'master' of https://github.com/go-gitea/gitea into featu…
jonasfranz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2017 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package integrations | ||
|
||
import ( | ||
"net/http" | ||
"path" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestViewTimetrackingControls(t *testing.T) { | ||
prepareTestEnv(t) | ||
session := loginUser(t, "user2") | ||
testViewTimetrackingControls(t, session, "user2", "repo1", "1", true) | ||
//user2/repo1 | ||
} | ||
|
||
func TestNotViewTimetrackingControls(t *testing.T) { | ||
prepareTestEnv(t) | ||
session := loginUser(t, "user5") | ||
testViewTimetrackingControls(t, session, "user2", "repo1", "1", false) | ||
//user2/repo1 | ||
} | ||
func TestViewTimetrackingControlsDisabled(t *testing.T) { | ||
prepareTestEnv(t) | ||
session := loginUser(t, "user2") | ||
testViewTimetrackingControls(t, session, "user3", "repo3", "1", false) | ||
} | ||
|
||
func testViewTimetrackingControls(t *testing.T, session *TestSession, user, repo, issue string, canTrackTime bool) { | ||
req := NewRequest(t, "GET", path.Join(user, repo, "issues", issue)) | ||
resp := session.MakeRequest(t, req, http.StatusOK) | ||
|
||
htmlDoc := NewHTMLParser(t, resp.Body) | ||
|
||
htmlDoc.AssertElement(t, ".timetrack .start-add .start", canTrackTime) | ||
htmlDoc.AssertElement(t, ".timetrack .start-add .add-time", canTrackTime) | ||
|
||
req = NewRequestWithValues(t, "POST", path.Join(user, repo, "issues", issue, "times", "stopwatch", "toggle"), map[string]string{ | ||
"_csrf": htmlDoc.GetCSRF(), | ||
}) | ||
if canTrackTime { | ||
resp = session.MakeRequest(t, req, http.StatusSeeOther) | ||
|
||
req = NewRequest(t, "GET", RedirectURL(t, resp)) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
htmlDoc = NewHTMLParser(t, resp.Body) | ||
|
||
events := htmlDoc.doc.Find(".event > span.text") | ||
assert.Contains(t, events.Last().Text(), "started working") | ||
|
||
htmlDoc.AssertElement(t, ".timetrack .stop-cancel .stop", true) | ||
htmlDoc.AssertElement(t, ".timetrack .stop-cancel .cancel", true) | ||
|
||
req = NewRequestWithValues(t, "POST", path.Join(user, repo, "issues", issue, "times", "stopwatch", "toggle"), map[string]string{ | ||
"_csrf": htmlDoc.GetCSRF(), | ||
}) | ||
resp = session.MakeRequest(t, req, http.StatusSeeOther) | ||
|
||
req = NewRequest(t, "GET", RedirectURL(t, resp)) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
htmlDoc = NewHTMLParser(t, resp.Body) | ||
|
||
events = htmlDoc.doc.Find(".event > span.text") | ||
assert.Contains(t, events.Last().Text(), "stopped working") | ||
htmlDoc.AssertElement(t, ".event .detail .octicon-clock", true) | ||
} else { | ||
session.MakeRequest(t, req, http.StatusNotFound) | ||
} | ||
} | ||
|
||
// AssertElement check if element by selector exists or does not exist depending on checkExists | ||
func (doc *HTMLDoc) AssertElement(t testing.TB, selector string, checkExists bool) { | ||
sel := doc.doc.Find(selector) | ||
if checkExists { | ||
assert.Equal(t, 1, sel.Length()) | ||
} else { | ||
assert.Equal(t, 0, sel.Length()) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
- | ||
id: 1 | ||
user_id: 1 | ||
issue_id: 1 | ||
created_unix: 1500988502 | ||
|
||
- | ||
id: 2 | ||
user_id: 2 | ||
issue_id: 2 | ||
created_unix: 1500988502 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
- | ||
id: 1 | ||
user_id: 1 | ||
issue_id: 1 | ||
time: 400 | ||
created_unix: 946684800 | ||
|
||
- | ||
id: 2 | ||
user_id: 2 | ||
issue_id: 2 | ||
time: 3661 | ||
created_unix: 946684801 | ||
|
||
- | ||
id: 3 | ||
user_id: 2 | ||
issue_id: 2 | ||
time: 1 | ||
created_unix: 946684802 | ||
|
||
- | ||
id: 4 | ||
user_id: -1 | ||
issue_id: 4 | ||
time: 1 | ||
created_unix: 946684802 | ||
|
||
- | ||
id: 5 | ||
user_id: 2 | ||
issue_id: 5 | ||
time: 1 | ||
created_unix: 946684802 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,14 @@ const ( | |
CommentTypeChangeTitle | ||
// Delete Branch | ||
CommentTypeDeleteBranch | ||
// Start a stopwatch for time tracking | ||
CommentTypeStartTracking | ||
// Stop a stopwatch for time tracking | ||
CommentTypeStopTracking | ||
// Add time manual for time tracking | ||
CommentTypeAddTimeManual | ||
// Cancel a stopwatch for time tracking | ||
CommentTypeCancelTracking | ||
) | ||
|
||
// CommentTag defines comment tag type | ||
|
@@ -672,7 +680,6 @@ func DeleteComment(comment *Comment) error { | |
return err | ||
} | ||
} | ||
|
||
if _, err := sess.Where("comment_id = ?", comment.ID).Cols("is_deleted").Update(&Action{IsDeleted: true}); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems duplicated with line 683? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, line 683 is not needed. Line 685 already has same code |
||
return err | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reusable helper, could we move it to
integrations/html_helper.go
?