You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

issue.go 40 kB

11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
10 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
9 years ago
9 years ago
9 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
10 years ago
10 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package repo
  6. import (
  7. "bytes"
  8. "errors"
  9. "fmt"
  10. "io"
  11. "io/ioutil"
  12. "net/http"
  13. "strconv"
  14. "strings"
  15. "github.com/Unknwon/com"
  16. "github.com/Unknwon/paginater"
  17. "code.gitea.io/git"
  18. "code.gitea.io/gitea/models"
  19. "code.gitea.io/gitea/modules/auth"
  20. "code.gitea.io/gitea/modules/base"
  21. "code.gitea.io/gitea/modules/context"
  22. "code.gitea.io/gitea/modules/indexer"
  23. "code.gitea.io/gitea/modules/log"
  24. "code.gitea.io/gitea/modules/markup/markdown"
  25. "code.gitea.io/gitea/modules/notification"
  26. "code.gitea.io/gitea/modules/setting"
  27. "code.gitea.io/gitea/modules/util"
  28. )
  29. const (
  30. tplIssues base.TplName = "repo/issue/list"
  31. tplIssueNew base.TplName = "repo/issue/new"
  32. tplIssueView base.TplName = "repo/issue/view"
  33. tplReactions base.TplName = "repo/issue/view_content/reactions"
  34. issueTemplateKey = "IssueTemplate"
  35. )
  36. var (
  37. // ErrFileTypeForbidden not allowed file type error
  38. ErrFileTypeForbidden = errors.New("File type is not allowed")
  39. // ErrTooManyFiles upload too many files
  40. ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
  41. // IssueTemplateCandidates issue templates
  42. IssueTemplateCandidates = []string{
  43. "ISSUE_TEMPLATE.md",
  44. "issue_template.md",
  45. ".gitea/ISSUE_TEMPLATE.md",
  46. ".gitea/issue_template.md",
  47. ".github/ISSUE_TEMPLATE.md",
  48. ".github/issue_template.md",
  49. }
  50. )
  51. // MustEnableIssues check if repository enable internal issues
  52. func MustEnableIssues(ctx *context.Context) {
  53. if !ctx.Repo.CanRead(models.UnitTypeIssues) &&
  54. !ctx.Repo.CanRead(models.UnitTypeExternalTracker) {
  55. ctx.NotFound("MustEnableIssues", nil)
  56. return
  57. }
  58. unit, err := ctx.Repo.Repository.GetUnit(models.UnitTypeExternalTracker)
  59. if err == nil {
  60. ctx.Redirect(unit.ExternalTrackerConfig().ExternalTrackerURL)
  61. return
  62. }
  63. }
  64. // MustAllowPulls check if repository enable pull requests and user have right to do that
  65. func MustAllowPulls(ctx *context.Context) {
  66. if !ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(models.UnitTypePullRequests) {
  67. ctx.NotFound("MustAllowPulls", nil)
  68. return
  69. }
  70. // User can send pull request if owns a forked repository.
  71. if ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID) {
  72. ctx.Repo.PullRequest.Allowed = true
  73. ctx.Repo.PullRequest.HeadInfo = ctx.User.Name + ":" + ctx.Repo.BranchName
  74. }
  75. }
  76. func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalBool) {
  77. var err error
  78. viewType := ctx.Query("type")
  79. sortType := ctx.Query("sort")
  80. types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned"}
  81. if !com.IsSliceContainsStr(types, viewType) {
  82. viewType = "all"
  83. }
  84. var (
  85. assigneeID = ctx.QueryInt64("assignee")
  86. posterID int64
  87. mentionedID int64
  88. forceEmpty bool
  89. )
  90. if ctx.IsSigned {
  91. switch viewType {
  92. case "created_by":
  93. posterID = ctx.User.ID
  94. case "mentioned":
  95. mentionedID = ctx.User.ID
  96. }
  97. }
  98. repo := ctx.Repo.Repository
  99. var labelIDs []int64
  100. selectLabels := ctx.Query("labels")
  101. if len(selectLabels) > 0 && selectLabels != "0" {
  102. labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
  103. if err != nil {
  104. ctx.ServerError("StringsToInt64s", err)
  105. return
  106. }
  107. }
  108. isShowClosed := ctx.Query("state") == "closed"
  109. keyword := strings.Trim(ctx.Query("q"), " ")
  110. if bytes.Contains([]byte(keyword), []byte{0x00}) {
  111. keyword = ""
  112. }
  113. var issueIDs []int64
  114. if len(keyword) > 0 {
  115. issueIDs, err = indexer.SearchIssuesByKeyword(repo.ID, keyword)
  116. if len(issueIDs) == 0 {
  117. forceEmpty = true
  118. }
  119. }
  120. var issueStats *models.IssueStats
  121. if forceEmpty {
  122. issueStats = &models.IssueStats{}
  123. } else {
  124. issueStats, err = models.GetIssueStats(&models.IssueStatsOptions{
  125. RepoID: repo.ID,
  126. Labels: selectLabels,
  127. MilestoneID: milestoneID,
  128. AssigneeID: assigneeID,
  129. MentionedID: mentionedID,
  130. PosterID: posterID,
  131. IsPull: isPullOption,
  132. IssueIDs: issueIDs,
  133. })
  134. if err != nil {
  135. ctx.ServerError("GetIssueStats", err)
  136. return
  137. }
  138. }
  139. page := ctx.QueryInt("page")
  140. if page <= 1 {
  141. page = 1
  142. }
  143. var total int
  144. if !isShowClosed {
  145. total = int(issueStats.OpenCount)
  146. } else {
  147. total = int(issueStats.ClosedCount)
  148. }
  149. pager := paginater.New(total, setting.UI.IssuePagingNum, page, 5)
  150. ctx.Data["Page"] = pager
  151. var issues []*models.Issue
  152. if forceEmpty {
  153. issues = []*models.Issue{}
  154. } else {
  155. issues, err = models.Issues(&models.IssuesOptions{
  156. RepoIDs: []int64{repo.ID},
  157. AssigneeID: assigneeID,
  158. PosterID: posterID,
  159. MentionedID: mentionedID,
  160. MilestoneID: milestoneID,
  161. Page: pager.Current(),
  162. PageSize: setting.UI.IssuePagingNum,
  163. IsClosed: util.OptionalBoolOf(isShowClosed),
  164. IsPull: isPullOption,
  165. LabelIDs: labelIDs,
  166. SortType: sortType,
  167. IssueIDs: issueIDs,
  168. })
  169. if err != nil {
  170. ctx.ServerError("Issues", err)
  171. return
  172. }
  173. }
  174. // Get posters.
  175. for i := range issues {
  176. // Check read status
  177. if !ctx.IsSigned {
  178. issues[i].IsRead = true
  179. } else if err = issues[i].GetIsRead(ctx.User.ID); err != nil {
  180. ctx.ServerError("GetIsRead", err)
  181. return
  182. }
  183. }
  184. ctx.Data["Issues"] = issues
  185. // Get assignees.
  186. ctx.Data["Assignees"], err = repo.GetAssignees()
  187. if err != nil {
  188. ctx.ServerError("GetAssignees", err)
  189. return
  190. }
  191. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  192. if err != nil {
  193. ctx.ServerError("GetLabelsByRepoID", err)
  194. return
  195. }
  196. for _, l := range labels {
  197. l.LoadSelectedLabelsAfterClick(labelIDs)
  198. }
  199. ctx.Data["Labels"] = labels
  200. ctx.Data["NumLabels"] = len(labels)
  201. if ctx.QueryInt64("assignee") == 0 {
  202. assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
  203. }
  204. ctx.Data["IssueStats"] = issueStats
  205. ctx.Data["SelectLabels"] = com.StrTo(selectLabels).MustInt64()
  206. ctx.Data["ViewType"] = viewType
  207. ctx.Data["SortType"] = sortType
  208. ctx.Data["MilestoneID"] = milestoneID
  209. ctx.Data["AssigneeID"] = assigneeID
  210. ctx.Data["IsShowClosed"] = isShowClosed
  211. ctx.Data["Keyword"] = keyword
  212. if isShowClosed {
  213. ctx.Data["State"] = "closed"
  214. } else {
  215. ctx.Data["State"] = "open"
  216. }
  217. }
  218. // Issues render issues page
  219. func Issues(ctx *context.Context) {
  220. isPullList := ctx.Params(":type") == "pulls"
  221. if isPullList {
  222. MustAllowPulls(ctx)
  223. if ctx.Written() {
  224. return
  225. }
  226. ctx.Data["Title"] = ctx.Tr("repo.pulls")
  227. ctx.Data["PageIsPullList"] = true
  228. } else {
  229. MustEnableIssues(ctx)
  230. if ctx.Written() {
  231. return
  232. }
  233. ctx.Data["Title"] = ctx.Tr("repo.issues")
  234. ctx.Data["PageIsIssueList"] = true
  235. }
  236. issues(ctx, ctx.QueryInt64("milestone"), util.OptionalBoolOf(isPullList))
  237. var err error
  238. // Get milestones.
  239. ctx.Data["Milestones"], err = models.GetMilestonesByRepoID(ctx.Repo.Repository.ID)
  240. if err != nil {
  241. ctx.ServerError("GetAllRepoMilestones", err)
  242. return
  243. }
  244. ctx.HTML(200, tplIssues)
  245. }
  246. // RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository
  247. func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repository) {
  248. var err error
  249. ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false, "")
  250. if err != nil {
  251. ctx.ServerError("GetMilestones", err)
  252. return
  253. }
  254. ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true, "")
  255. if err != nil {
  256. ctx.ServerError("GetMilestones", err)
  257. return
  258. }
  259. ctx.Data["Assignees"], err = repo.GetAssignees()
  260. if err != nil {
  261. ctx.ServerError("GetAssignees", err)
  262. return
  263. }
  264. }
  265. // RetrieveRepoMetas find all the meta information of a repository
  266. func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.Label {
  267. if !ctx.Repo.CanWrite(models.UnitTypeIssues) {
  268. return nil
  269. }
  270. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  271. if err != nil {
  272. ctx.ServerError("GetLabelsByRepoID", err)
  273. return nil
  274. }
  275. ctx.Data["Labels"] = labels
  276. RetrieveRepoMilestonesAndAssignees(ctx, repo)
  277. if ctx.Written() {
  278. return nil
  279. }
  280. brs, err := ctx.Repo.GitRepo.GetBranches()
  281. if err != nil {
  282. ctx.ServerError("GetBranches", err)
  283. return nil
  284. }
  285. ctx.Data["Branches"] = brs
  286. // Contains true if the user can create issue dependencies
  287. ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
  288. return labels
  289. }
  290. func getFileContentFromDefaultBranch(ctx *context.Context, filename string) (string, bool) {
  291. var r io.Reader
  292. var bytes []byte
  293. if ctx.Repo.Commit == nil {
  294. var err error
  295. ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
  296. if err != nil {
  297. return "", false
  298. }
  299. }
  300. entry, err := ctx.Repo.Commit.GetTreeEntryByPath(filename)
  301. if err != nil {
  302. return "", false
  303. }
  304. if entry.Blob().Size() >= setting.UI.MaxDisplayFileSize {
  305. return "", false
  306. }
  307. r, err = entry.Blob().Data()
  308. if err != nil {
  309. return "", false
  310. }
  311. bytes, err = ioutil.ReadAll(r)
  312. if err != nil {
  313. return "", false
  314. }
  315. return string(bytes), true
  316. }
  317. func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles []string) {
  318. for _, filename := range possibleFiles {
  319. content, found := getFileContentFromDefaultBranch(ctx, filename)
  320. if found {
  321. ctx.Data[ctxDataKey] = content
  322. return
  323. }
  324. }
  325. }
  326. // NewIssue render creating issue page
  327. func NewIssue(ctx *context.Context) {
  328. ctx.Data["Title"] = ctx.Tr("repo.issues.new")
  329. ctx.Data["PageIsIssueList"] = true
  330. ctx.Data["RequireHighlightJS"] = true
  331. ctx.Data["RequireSimpleMDE"] = true
  332. ctx.Data["RequireTribute"] = true
  333. ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
  334. body := ctx.Query("body")
  335. ctx.Data["BodyQuery"] = body
  336. milestoneID := ctx.QueryInt64("milestone")
  337. milestone, err := models.GetMilestoneByID(milestoneID)
  338. if err != nil {
  339. log.Error(4, "GetMilestoneByID: %d: %v", milestoneID, err)
  340. } else {
  341. ctx.Data["milestone_id"] = milestoneID
  342. ctx.Data["Milestone"] = milestone
  343. }
  344. setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
  345. renderAttachmentSettings(ctx)
  346. RetrieveRepoMetas(ctx, ctx.Repo.Repository)
  347. if ctx.Written() {
  348. return
  349. }
  350. ctx.HTML(200, tplIssueNew)
  351. }
  352. // ValidateRepoMetas check and returns repository's meta informations
  353. func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm, isPull bool) ([]int64, []int64, int64) {
  354. var (
  355. repo = ctx.Repo.Repository
  356. err error
  357. )
  358. labels := RetrieveRepoMetas(ctx, ctx.Repo.Repository)
  359. if ctx.Written() {
  360. return nil, nil, 0
  361. }
  362. var labelIDs []int64
  363. hasSelected := false
  364. // Check labels.
  365. if len(form.LabelIDs) > 0 {
  366. labelIDs, err = base.StringsToInt64s(strings.Split(form.LabelIDs, ","))
  367. if err != nil {
  368. return nil, nil, 0
  369. }
  370. labelIDMark := base.Int64sToMap(labelIDs)
  371. for i := range labels {
  372. if labelIDMark[labels[i].ID] {
  373. labels[i].IsChecked = true
  374. hasSelected = true
  375. }
  376. }
  377. }
  378. ctx.Data["Labels"] = labels
  379. ctx.Data["HasSelectedLabel"] = hasSelected
  380. ctx.Data["label_ids"] = form.LabelIDs
  381. // Check milestone.
  382. milestoneID := form.MilestoneID
  383. if milestoneID > 0 {
  384. ctx.Data["Milestone"], err = repo.GetMilestoneByID(milestoneID)
  385. if err != nil {
  386. ctx.ServerError("GetMilestoneByID", err)
  387. return nil, nil, 0
  388. }
  389. ctx.Data["milestone_id"] = milestoneID
  390. }
  391. // Check assignees
  392. var assigneeIDs []int64
  393. if len(form.AssigneeIDs) > 0 {
  394. assigneeIDs, err = base.StringsToInt64s(strings.Split(form.AssigneeIDs, ","))
  395. if err != nil {
  396. return nil, nil, 0
  397. }
  398. // Check if the passed assignees actually exists and has write access to the repo
  399. for _, aID := range assigneeIDs {
  400. user, err := models.GetUserByID(aID)
  401. if err != nil {
  402. ctx.ServerError("GetUserByID", err)
  403. return nil, nil, 0
  404. }
  405. perm, err := models.GetUserRepoPermission(repo, user)
  406. if err != nil {
  407. ctx.ServerError("GetUserRepoPermission", err)
  408. return nil, nil, 0
  409. }
  410. if !perm.CanWriteIssuesOrPulls(isPull) {
  411. ctx.ServerError("CanWriteIssuesOrPulls", fmt.Errorf("No permission for %s", user.Name))
  412. return nil, nil, 0
  413. }
  414. }
  415. }
  416. // Keep the old assignee id thingy for compatibility reasons
  417. if form.AssigneeID > 0 {
  418. assigneeIDs = append(assigneeIDs, form.AssigneeID)
  419. }
  420. return labelIDs, assigneeIDs, milestoneID
  421. }
  422. // NewIssuePost response for creating new issue
  423. func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
  424. ctx.Data["Title"] = ctx.Tr("repo.issues.new")
  425. ctx.Data["PageIsIssueList"] = true
  426. ctx.Data["RequireHighlightJS"] = true
  427. ctx.Data["RequireSimpleMDE"] = true
  428. ctx.Data["ReadOnly"] = false
  429. ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
  430. renderAttachmentSettings(ctx)
  431. var (
  432. repo = ctx.Repo.Repository
  433. attachments []string
  434. )
  435. labelIDs, assigneeIDs, milestoneID := ValidateRepoMetas(ctx, form, false)
  436. if ctx.Written() {
  437. return
  438. }
  439. if setting.AttachmentEnabled {
  440. attachments = form.Files
  441. }
  442. if ctx.HasError() {
  443. ctx.HTML(200, tplIssueNew)
  444. return
  445. }
  446. if util.IsEmptyString(form.Title) {
  447. ctx.RenderWithErr(ctx.Tr("repo.issues.new.title_empty"), tplIssueNew, form)
  448. return
  449. }
  450. issue := &models.Issue{
  451. RepoID: repo.ID,
  452. Title: form.Title,
  453. PosterID: ctx.User.ID,
  454. Poster: ctx.User,
  455. MilestoneID: milestoneID,
  456. Content: form.Content,
  457. Ref: form.Ref,
  458. }
  459. if err := models.NewIssue(repo, issue, labelIDs, assigneeIDs, attachments); err != nil {
  460. if models.IsErrUserDoesNotHaveAccessToRepo(err) {
  461. ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error())
  462. return
  463. }
  464. ctx.ServerError("NewIssue", err)
  465. return
  466. }
  467. notification.NotifyNewIssue(issue)
  468. log.Trace("Issue created: %d/%d", repo.ID, issue.ID)
  469. ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
  470. }
  471. // commentTag returns the CommentTag for a comment in/with the given repo, poster and issue
  472. func commentTag(repo *models.Repository, poster *models.User, issue *models.Issue) (models.CommentTag, error) {
  473. perm, err := models.GetUserRepoPermission(repo, poster)
  474. if err != nil {
  475. return models.CommentTagNone, err
  476. }
  477. if perm.IsOwner() {
  478. return models.CommentTagOwner, nil
  479. } else if poster.ID == issue.PosterID {
  480. return models.CommentTagPoster, nil
  481. } else if perm.CanWrite(models.UnitTypeCode) {
  482. return models.CommentTagWriter, nil
  483. }
  484. return models.CommentTagNone, nil
  485. }
  486. // ViewIssue render issue view page
  487. func ViewIssue(ctx *context.Context) {
  488. issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
  489. if err != nil {
  490. if models.IsErrIssueNotExist(err) {
  491. ctx.NotFound("GetIssueByIndex", err)
  492. } else {
  493. ctx.ServerError("GetIssueByIndex", err)
  494. }
  495. return
  496. }
  497. // Make sure type and URL matches.
  498. if ctx.Params(":type") == "issues" && issue.IsPull {
  499. ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
  500. return
  501. } else if ctx.Params(":type") == "pulls" && !issue.IsPull {
  502. ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
  503. return
  504. }
  505. if issue.IsPull {
  506. MustAllowPulls(ctx)
  507. if ctx.Written() {
  508. return
  509. }
  510. ctx.Data["PageIsPullList"] = true
  511. ctx.Data["PageIsPullConversation"] = true
  512. } else {
  513. MustEnableIssues(ctx)
  514. if ctx.Written() {
  515. return
  516. }
  517. ctx.Data["PageIsIssueList"] = true
  518. }
  519. ctx.Data["RequireHighlightJS"] = true
  520. ctx.Data["RequireDropzone"] = true
  521. ctx.Data["RequireTribute"] = true
  522. renderAttachmentSettings(ctx)
  523. err = issue.LoadAttributes()
  524. if err != nil {
  525. ctx.ServerError("GetIssueByIndex", err)
  526. return
  527. }
  528. ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
  529. var iw *models.IssueWatch
  530. var exists bool
  531. if ctx.User != nil {
  532. iw, exists, err = models.GetIssueWatch(ctx.User.ID, issue.ID)
  533. if err != nil {
  534. ctx.ServerError("GetIssueWatch", err)
  535. return
  536. }
  537. if !exists {
  538. iw = &models.IssueWatch{
  539. UserID: ctx.User.ID,
  540. IssueID: issue.ID,
  541. IsWatching: models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID),
  542. }
  543. }
  544. }
  545. ctx.Data["IssueWatch"] = iw
  546. issue.RenderedContent = string(markdown.Render([]byte(issue.Content), ctx.Repo.RepoLink,
  547. ctx.Repo.Repository.ComposeMetas()))
  548. repo := ctx.Repo.Repository
  549. // Get more information if it's a pull request.
  550. if issue.IsPull {
  551. if issue.PullRequest.HasMerged {
  552. ctx.Data["DisableStatusChange"] = issue.PullRequest.HasMerged
  553. PrepareMergedViewPullInfo(ctx, issue)
  554. } else {
  555. PrepareViewPullInfo(ctx, issue)
  556. }
  557. if ctx.Written() {
  558. return
  559. }
  560. }
  561. // Metas.
  562. // Check labels.
  563. labelIDMark := make(map[int64]bool)
  564. for i := range issue.Labels {
  565. labelIDMark[issue.Labels[i].ID] = true
  566. }
  567. labels, err := models.GetLabelsByRepoID(repo.ID, "")
  568. if err != nil {
  569. ctx.ServerError("GetLabelsByRepoID", err)
  570. return
  571. }
  572. hasSelected := false
  573. for i := range labels {
  574. if labelIDMark[labels[i].ID] {
  575. labels[i].IsChecked = true
  576. hasSelected = true
  577. }
  578. }
  579. ctx.Data["HasSelectedLabel"] = hasSelected
  580. ctx.Data["Labels"] = labels
  581. // Check milestone and assignee.
  582. if ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
  583. RetrieveRepoMilestonesAndAssignees(ctx, repo)
  584. if ctx.Written() {
  585. return
  586. }
  587. }
  588. if ctx.IsSigned {
  589. // Update issue-user.
  590. if err = issue.ReadBy(ctx.User.ID); err != nil {
  591. ctx.ServerError("ReadBy", err)
  592. return
  593. }
  594. }
  595. var (
  596. tag models.CommentTag
  597. ok bool
  598. marked = make(map[int64]models.CommentTag)
  599. comment *models.Comment
  600. participants = make([]*models.User, 1, 10)
  601. )
  602. if ctx.Repo.Repository.IsTimetrackerEnabled() {
  603. if ctx.IsSigned {
  604. // Deal with the stopwatch
  605. ctx.Data["IsStopwatchRunning"] = models.StopwatchExists(ctx.User.ID, issue.ID)
  606. if !ctx.Data["IsStopwatchRunning"].(bool) {
  607. var exists bool
  608. var sw *models.Stopwatch
  609. if exists, sw, err = models.HasUserStopwatch(ctx.User.ID); err != nil {
  610. ctx.ServerError("HasUserStopwatch", err)
  611. return
  612. }
  613. ctx.Data["HasUserStopwatch"] = exists
  614. if exists {
  615. // Add warning if the user has already a stopwatch
  616. var otherIssue *models.Issue
  617. if otherIssue, err = models.GetIssueByID(sw.IssueID); err != nil {
  618. ctx.ServerError("GetIssueByID", err)
  619. return
  620. }
  621. if err = otherIssue.LoadRepo(); err != nil {
  622. ctx.ServerError("LoadRepo", err)
  623. return
  624. }
  625. // Add link to the issue of the already running stopwatch
  626. ctx.Data["OtherStopwatchURL"] = otherIssue.HTMLURL()
  627. }
  628. }
  629. ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(issue, ctx.User)
  630. } else {
  631. ctx.Data["CanUseTimetracker"] = false
  632. }
  633. if ctx.Data["WorkingUsers"], err = models.TotalTimes(models.FindTrackedTimesOptions{IssueID: issue.ID}); err != nil {
  634. ctx.ServerError("TotalTimes", err)
  635. return
  636. }
  637. }
  638. // Check if the user can use the dependencies
  639. ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.User)
  640. // Render comments and and fetch participants.
  641. participants[0] = issue.Poster
  642. for _, comment = range issue.Comments {
  643. if err := comment.LoadPoster(); err != nil {
  644. ctx.ServerError("LoadPoster", err)
  645. return
  646. }
  647. if comment.Type == models.CommentTypeComment {
  648. if err := comment.LoadAttachments(); err != nil {
  649. ctx.ServerError("LoadAttachments", err)
  650. return
  651. }
  652. comment.RenderedContent = string(markdown.Render([]byte(comment.Content), ctx.Repo.RepoLink,
  653. ctx.Repo.Repository.ComposeMetas()))
  654. // Check tag.
  655. tag, ok = marked[comment.PosterID]
  656. if ok {
  657. comment.ShowTag = tag
  658. continue
  659. }
  660. comment.ShowTag, err = commentTag(repo, comment.Poster, issue)
  661. if err != nil {
  662. ctx.ServerError("commentTag", err)
  663. return
  664. }
  665. marked[comment.PosterID] = comment.ShowTag
  666. isAdded := false
  667. for j := range participants {
  668. if comment.Poster == participants[j] {
  669. isAdded = true
  670. break
  671. }
  672. }
  673. if !isAdded && !issue.IsPoster(comment.Poster.ID) {
  674. participants = append(participants, comment.Poster)
  675. }
  676. } else if comment.Type == models.CommentTypeLabel {
  677. if err = comment.LoadLabel(); err != nil {
  678. ctx.ServerError("LoadLabel", err)
  679. return
  680. }
  681. } else if comment.Type == models.CommentTypeMilestone {
  682. if err = comment.LoadMilestone(); err != nil {
  683. ctx.ServerError("LoadMilestone", err)
  684. return
  685. }
  686. ghostMilestone := &models.Milestone{
  687. ID: -1,
  688. Name: ctx.Tr("repo.issues.deleted_milestone"),
  689. }
  690. if comment.OldMilestoneID > 0 && comment.OldMilestone == nil {
  691. comment.OldMilestone = ghostMilestone
  692. }
  693. if comment.MilestoneID > 0 && comment.Milestone == nil {
  694. comment.Milestone = ghostMilestone
  695. }
  696. } else if comment.Type == models.CommentTypeAssignees {
  697. if err = comment.LoadAssigneeUser(); err != nil {
  698. ctx.ServerError("LoadAssigneeUser", err)
  699. return
  700. }
  701. } else if comment.Type == models.CommentTypeRemoveDependency || comment.Type == models.CommentTypeAddDependency {
  702. if err = comment.LoadDepIssueDetails(); err != nil {
  703. ctx.ServerError("LoadDepIssueDetails", err)
  704. return
  705. }
  706. } else if comment.Type == models.CommentTypeCode || comment.Type == models.CommentTypeReview {
  707. if err = comment.LoadReview(); err != nil && !models.IsErrReviewNotExist(err) {
  708. ctx.ServerError("LoadReview", err)
  709. return
  710. }
  711. if comment.Review == nil {
  712. continue
  713. }
  714. if err = comment.Review.LoadAttributes(); err != nil {
  715. ctx.ServerError("Review.LoadAttributes", err)
  716. return
  717. }
  718. if err = comment.Review.LoadCodeComments(); err != nil {
  719. ctx.ServerError("Review.LoadCodeComments", err)
  720. return
  721. }
  722. }
  723. }
  724. if issue.IsPull {
  725. pull := issue.PullRequest
  726. pull.Issue = issue
  727. canDelete := false
  728. if ctx.IsSigned {
  729. if err := pull.GetHeadRepo(); err != nil {
  730. log.Error(4, "GetHeadRepo: %v", err)
  731. } else if pull.HeadRepo != nil && pull.HeadBranch != pull.HeadRepo.DefaultBranch {
  732. perm, err := models.GetUserRepoPermission(pull.HeadRepo, ctx.User)
  733. if err != nil {
  734. ctx.ServerError("GetUserRepoPermission", err)
  735. return
  736. }
  737. if perm.CanWrite(models.UnitTypeCode) {
  738. // Check if branch is not protected
  739. if protected, err := pull.HeadRepo.IsProtectedBranch(pull.HeadBranch, ctx.User); err != nil {
  740. log.Error(4, "IsProtectedBranch: %v", err)
  741. } else if !protected {
  742. canDelete = true
  743. ctx.Data["DeleteBranchLink"] = ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index) + "/cleanup"
  744. }
  745. }
  746. }
  747. }
  748. prUnit, err := repo.GetUnit(models.UnitTypePullRequests)
  749. if err != nil {
  750. ctx.ServerError("GetUnit", err)
  751. return
  752. }
  753. prConfig := prUnit.PullRequestsConfig()
  754. ctx.Data["AllowMerge"] = ctx.Repo.CanWrite(models.UnitTypeCode)
  755. if err := pull.CheckUserAllowedToMerge(ctx.User); err != nil {
  756. if !models.IsErrNotAllowedToMerge(err) {
  757. ctx.ServerError("CheckUserAllowedToMerge", err)
  758. return
  759. }
  760. ctx.Data["AllowMerge"] = false
  761. }
  762. // Check correct values and select default
  763. if ms, ok := ctx.Data["MergeStyle"].(models.MergeStyle); !ok ||
  764. !prConfig.IsMergeStyleAllowed(ms) {
  765. if prConfig.AllowMerge {
  766. ctx.Data["MergeStyle"] = models.MergeStyleMerge
  767. } else if prConfig.AllowRebase {
  768. ctx.Data["MergeStyle"] = models.MergeStyleRebase
  769. } else if prConfig.AllowRebaseMerge {
  770. ctx.Data["MergeStyle"] = models.MergeStyleRebaseMerge
  771. } else if prConfig.AllowSquash {
  772. ctx.Data["MergeStyle"] = models.MergeStyleSquash
  773. } else {
  774. ctx.Data["MergeStyle"] = ""
  775. }
  776. }
  777. if err = pull.LoadProtectedBranch(); err != nil {
  778. ctx.ServerError("LoadProtectedBranch", err)
  779. return
  780. }
  781. if pull.ProtectedBranch != nil {
  782. cnt := pull.ProtectedBranch.GetGrantedApprovalsCount(pull)
  783. ctx.Data["IsBlockedByApprovals"] = pull.ProtectedBranch.RequiredApprovals > 0 && cnt < pull.ProtectedBranch.RequiredApprovals
  784. ctx.Data["GrantedApprovals"] = cnt
  785. }
  786. ctx.Data["IsPullBranchDeletable"] = canDelete && pull.HeadRepo != nil && git.IsBranchExist(pull.HeadRepo.RepoPath(), pull.HeadBranch)
  787. ctx.Data["PullReviewersWithType"], err = models.GetReviewersByPullID(issue.ID)
  788. if err != nil {
  789. ctx.ServerError("GetReviewersByPullID", err)
  790. return
  791. }
  792. }
  793. // Get Dependencies
  794. ctx.Data["BlockedByDependencies"], err = issue.BlockedByDependencies()
  795. ctx.Data["BlockingDependencies"], err = issue.BlockingDependencies()
  796. ctx.Data["Participants"] = participants
  797. ctx.Data["NumParticipants"] = len(participants)
  798. ctx.Data["Issue"] = issue
  799. ctx.Data["ReadOnly"] = true
  800. ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + ctx.Data["Link"].(string)
  801. ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID)
  802. ctx.Data["IsIssueWriter"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
  803. ctx.HTML(200, tplIssueView)
  804. }
  805. // GetActionIssue will return the issue which is used in the context.
  806. func GetActionIssue(ctx *context.Context) *models.Issue {
  807. issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
  808. if err != nil {
  809. ctx.NotFoundOrServerError("GetIssueByIndex", models.IsErrIssueNotExist, err)
  810. return nil
  811. }
  812. issue.Repo = ctx.Repo.Repository
  813. checkIssueRights(ctx, issue)
  814. if ctx.Written() {
  815. return nil
  816. }
  817. if err = issue.LoadAttributes(); err != nil {
  818. ctx.ServerError("LoadAttributes", nil)
  819. return nil
  820. }
  821. return issue
  822. }
  823. func checkIssueRights(ctx *context.Context, issue *models.Issue) {
  824. if issue.IsPull && !ctx.Repo.CanRead(models.UnitTypePullRequests) ||
  825. !issue.IsPull && !ctx.Repo.CanRead(models.UnitTypeIssues) {
  826. ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
  827. }
  828. }
  829. func getActionIssues(ctx *context.Context) []*models.Issue {
  830. commaSeparatedIssueIDs := ctx.Query("issue_ids")
  831. if len(commaSeparatedIssueIDs) == 0 {
  832. return nil
  833. }
  834. issueIDs := make([]int64, 0, 10)
  835. for _, stringIssueID := range strings.Split(commaSeparatedIssueIDs, ",") {
  836. issueID, err := strconv.ParseInt(stringIssueID, 10, 64)
  837. if err != nil {
  838. ctx.ServerError("ParseInt", err)
  839. return nil
  840. }
  841. issueIDs = append(issueIDs, issueID)
  842. }
  843. issues, err := models.GetIssuesByIDs(issueIDs)
  844. if err != nil {
  845. ctx.ServerError("GetIssuesByIDs", err)
  846. return nil
  847. }
  848. // Check access rights for all issues
  849. issueUnitEnabled := ctx.Repo.CanRead(models.UnitTypeIssues)
  850. prUnitEnabled := ctx.Repo.CanRead(models.UnitTypePullRequests)
  851. for _, issue := range issues {
  852. if issue.IsPull && !prUnitEnabled || !issue.IsPull && !issueUnitEnabled {
  853. ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
  854. return nil
  855. }
  856. if err = issue.LoadAttributes(); err != nil {
  857. ctx.ServerError("LoadAttributes", err)
  858. return nil
  859. }
  860. }
  861. return issues
  862. }
  863. // UpdateIssueTitle change issue's title
  864. func UpdateIssueTitle(ctx *context.Context) {
  865. issue := GetActionIssue(ctx)
  866. if ctx.Written() {
  867. return
  868. }
  869. if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
  870. ctx.Error(403)
  871. return
  872. }
  873. title := ctx.QueryTrim("title")
  874. if len(title) == 0 {
  875. ctx.Error(204)
  876. return
  877. }
  878. if err := issue.ChangeTitle(ctx.User, title); err != nil {
  879. ctx.ServerError("ChangeTitle", err)
  880. return
  881. }
  882. ctx.JSON(200, map[string]interface{}{
  883. "title": issue.Title,
  884. })
  885. }
  886. // UpdateIssueContent change issue's content
  887. func UpdateIssueContent(ctx *context.Context) {
  888. issue := GetActionIssue(ctx)
  889. if ctx.Written() {
  890. return
  891. }
  892. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
  893. ctx.Error(403)
  894. return
  895. }
  896. content := ctx.Query("content")
  897. if err := issue.ChangeContent(ctx.User, content); err != nil {
  898. ctx.ServerError("ChangeContent", err)
  899. return
  900. }
  901. ctx.JSON(200, map[string]interface{}{
  902. "content": string(markdown.Render([]byte(issue.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
  903. })
  904. }
  905. // UpdateIssueMilestone change issue's milestone
  906. func UpdateIssueMilestone(ctx *context.Context) {
  907. issues := getActionIssues(ctx)
  908. if ctx.Written() {
  909. return
  910. }
  911. milestoneID := ctx.QueryInt64("id")
  912. for _, issue := range issues {
  913. oldMilestoneID := issue.MilestoneID
  914. if oldMilestoneID == milestoneID {
  915. continue
  916. }
  917. issue.MilestoneID = milestoneID
  918. if err := models.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
  919. ctx.ServerError("ChangeMilestoneAssign", err)
  920. return
  921. }
  922. }
  923. ctx.JSON(200, map[string]interface{}{
  924. "ok": true,
  925. })
  926. }
  927. // UpdateIssueAssignee change issue's assignee
  928. func UpdateIssueAssignee(ctx *context.Context) {
  929. issues := getActionIssues(ctx)
  930. if ctx.Written() {
  931. return
  932. }
  933. assigneeID := ctx.QueryInt64("id")
  934. action := ctx.Query("action")
  935. for _, issue := range issues {
  936. switch action {
  937. case "clear":
  938. if err := models.DeleteNotPassedAssignee(issue, ctx.User, []*models.User{}); err != nil {
  939. ctx.ServerError("ClearAssignees", err)
  940. return
  941. }
  942. default:
  943. if err := issue.ChangeAssignee(ctx.User, assigneeID); err != nil {
  944. ctx.ServerError("ChangeAssignee", err)
  945. return
  946. }
  947. }
  948. }
  949. ctx.JSON(200, map[string]interface{}{
  950. "ok": true,
  951. })
  952. }
  953. // UpdateIssueStatus change issue's status
  954. func UpdateIssueStatus(ctx *context.Context) {
  955. issues := getActionIssues(ctx)
  956. if ctx.Written() {
  957. return
  958. }
  959. var isClosed bool
  960. switch action := ctx.Query("action"); action {
  961. case "open":
  962. isClosed = false
  963. case "close":
  964. isClosed = true
  965. default:
  966. log.Warn("Unrecognized action: %s", action)
  967. }
  968. if _, err := models.IssueList(issues).LoadRepositories(); err != nil {
  969. ctx.ServerError("LoadRepositories", err)
  970. return
  971. }
  972. for _, issue := range issues {
  973. if issue.IsClosed != isClosed {
  974. if err := issue.ChangeStatus(ctx.User, isClosed); err != nil {
  975. if models.IsErrDependenciesLeft(err) {
  976. ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{
  977. "error": "cannot close this issue because it still has open dependencies",
  978. })
  979. return
  980. }
  981. ctx.ServerError("ChangeStatus", err)
  982. return
  983. }
  984. notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed)
  985. }
  986. }
  987. ctx.JSON(200, map[string]interface{}{
  988. "ok": true,
  989. })
  990. }
  991. // NewComment create a comment for issue
  992. func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
  993. issue := GetActionIssue(ctx)
  994. if ctx.Written() {
  995. return
  996. }
  997. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
  998. ctx.Error(403)
  999. return
  1000. }
  1001. var attachments []string
  1002. if setting.AttachmentEnabled {
  1003. attachments = form.Files
  1004. }
  1005. if ctx.HasError() {
  1006. ctx.Flash.Error(ctx.Data["ErrorMsg"].(string))
  1007. ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index))
  1008. return
  1009. }
  1010. var comment *models.Comment
  1011. defer func() {
  1012. // Check if issue admin/poster changes the status of issue.
  1013. if (ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))) &&
  1014. (form.Status == "reopen" || form.Status == "close") &&
  1015. !(issue.IsPull && issue.PullRequest.HasMerged) {
  1016. // Duplication and conflict check should apply to reopen pull request.
  1017. var pr *models.PullRequest
  1018. if form.Status == "reopen" && issue.IsPull {
  1019. pull := issue.PullRequest
  1020. pr, err := models.GetUnmergedPullRequest(pull.HeadRepoID, pull.BaseRepoID, pull.HeadBranch, pull.BaseBranch)
  1021. if err != nil {
  1022. if !models.IsErrPullRequestNotExist(err) {
  1023. ctx.ServerError("GetUnmergedPullRequest", err)
  1024. return
  1025. }
  1026. }
  1027. // Regenerate patch and test conflict.
  1028. if pr == nil {
  1029. if err = issue.PullRequest.UpdatePatch(); err != nil {
  1030. ctx.ServerError("UpdatePatch", err)
  1031. return
  1032. }
  1033. issue.PullRequest.AddToTaskQueue()
  1034. }
  1035. }
  1036. if pr != nil {
  1037. ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
  1038. } else {
  1039. isClosed := form.Status == "close"
  1040. if err := issue.ChangeStatus(ctx.User, isClosed); err != nil {
  1041. log.Error(4, "ChangeStatus: %v", err)
  1042. if models.IsErrDependenciesLeft(err) {
  1043. if issue.IsPull {
  1044. ctx.Flash.Error(ctx.Tr("repo.issues.dependency.pr_close_blocked"))
  1045. ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index), http.StatusSeeOther)
  1046. } else {
  1047. ctx.Flash.Error(ctx.Tr("repo.issues.dependency.issue_close_blocked"))
  1048. ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index), http.StatusSeeOther)
  1049. }
  1050. return
  1051. }
  1052. } else {
  1053. if err := stopTimerIfAvailable(ctx.User, issue); err != nil {
  1054. ctx.ServerError("CreateOrStopIssueStopwatch", err)
  1055. return
  1056. }
  1057. log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
  1058. notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed)
  1059. }
  1060. }
  1061. }
  1062. // Redirect to comment hashtag if there is any actual content.
  1063. typeName := "issues"
  1064. if issue.IsPull {
  1065. typeName = "pulls"
  1066. }
  1067. if comment != nil {
  1068. ctx.Redirect(fmt.Sprintf("%s/%s/%d#%s", ctx.Repo.RepoLink, typeName, issue.Index, comment.HashTag()))
  1069. } else {
  1070. ctx.Redirect(fmt.Sprintf("%s/%s/%d", ctx.Repo.RepoLink, typeName, issue.Index))
  1071. }
  1072. }()
  1073. // Fix #321: Allow empty comments, as long as we have attachments.
  1074. if len(form.Content) == 0 && len(attachments) == 0 {
  1075. return
  1076. }
  1077. comment, err := models.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Content, attachments)
  1078. if err != nil {
  1079. ctx.ServerError("CreateIssueComment", err)
  1080. return
  1081. }
  1082. notification.NotifyCreateIssueComment(ctx.User, ctx.Repo.Repository, issue, comment)
  1083. log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
  1084. }
  1085. // UpdateCommentContent change comment of issue's content
  1086. func UpdateCommentContent(ctx *context.Context) {
  1087. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1088. if err != nil {
  1089. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1090. return
  1091. }
  1092. if err := comment.LoadIssue(); err != nil {
  1093. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1094. return
  1095. }
  1096. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
  1097. ctx.Error(403)
  1098. return
  1099. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1100. ctx.Error(204)
  1101. return
  1102. }
  1103. oldContent := comment.Content
  1104. comment.Content = ctx.Query("content")
  1105. if len(comment.Content) == 0 {
  1106. ctx.JSON(200, map[string]interface{}{
  1107. "content": "",
  1108. })
  1109. return
  1110. }
  1111. if err = models.UpdateComment(ctx.User, comment, oldContent); err != nil {
  1112. ctx.ServerError("UpdateComment", err)
  1113. return
  1114. }
  1115. notification.NotifyUpdateComment(ctx.User, comment, oldContent)
  1116. ctx.JSON(200, map[string]interface{}{
  1117. "content": string(markdown.Render([]byte(comment.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
  1118. })
  1119. }
  1120. // DeleteComment delete comment of issue
  1121. func DeleteComment(ctx *context.Context) {
  1122. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1123. if err != nil {
  1124. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1125. return
  1126. }
  1127. if err := comment.LoadIssue(); err != nil {
  1128. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1129. return
  1130. }
  1131. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
  1132. ctx.Error(403)
  1133. return
  1134. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1135. ctx.Error(204)
  1136. return
  1137. }
  1138. if err = models.DeleteComment(ctx.User, comment); err != nil {
  1139. ctx.ServerError("DeleteCommentByID", err)
  1140. return
  1141. }
  1142. notification.NotifyDeleteComment(ctx.User, comment)
  1143. ctx.Status(200)
  1144. }
  1145. // ChangeIssueReaction create a reaction for issue
  1146. func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
  1147. issue := GetActionIssue(ctx)
  1148. if ctx.Written() {
  1149. return
  1150. }
  1151. if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull)) {
  1152. ctx.Error(403)
  1153. return
  1154. }
  1155. if ctx.HasError() {
  1156. ctx.ServerError("ChangeIssueReaction", errors.New(ctx.GetErrMsg()))
  1157. return
  1158. }
  1159. switch ctx.Params(":action") {
  1160. case "react":
  1161. reaction, err := models.CreateIssueReaction(ctx.User, issue, form.Content)
  1162. if err != nil {
  1163. log.Info("CreateIssueReaction: %s", err)
  1164. break
  1165. }
  1166. // Reload new reactions
  1167. issue.Reactions = nil
  1168. if err = issue.LoadAttributes(); err != nil {
  1169. log.Info("issue.LoadAttributes: %s", err)
  1170. break
  1171. }
  1172. log.Trace("Reaction for issue created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, reaction.ID)
  1173. case "unreact":
  1174. if err := models.DeleteIssueReaction(ctx.User, issue, form.Content); err != nil {
  1175. ctx.ServerError("DeleteIssueReaction", err)
  1176. return
  1177. }
  1178. // Reload new reactions
  1179. issue.Reactions = nil
  1180. if err := issue.LoadAttributes(); err != nil {
  1181. log.Info("issue.LoadAttributes: %s", err)
  1182. break
  1183. }
  1184. log.Trace("Reaction for issue removed: %d/%d", ctx.Repo.Repository.ID, issue.ID)
  1185. default:
  1186. ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil)
  1187. return
  1188. }
  1189. if len(issue.Reactions) == 0 {
  1190. ctx.JSON(200, map[string]interface{}{
  1191. "empty": true,
  1192. "html": "",
  1193. })
  1194. return
  1195. }
  1196. html, err := ctx.HTMLString(string(tplReactions), map[string]interface{}{
  1197. "ctx": ctx.Data,
  1198. "ActionURL": fmt.Sprintf("%s/issues/%d/reactions", ctx.Repo.RepoLink, issue.Index),
  1199. "Reactions": issue.Reactions.GroupByType(),
  1200. })
  1201. if err != nil {
  1202. ctx.ServerError("ChangeIssueReaction.HTMLString", err)
  1203. return
  1204. }
  1205. ctx.JSON(200, map[string]interface{}{
  1206. "html": html,
  1207. })
  1208. }
  1209. // ChangeCommentReaction create a reaction for comment
  1210. func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
  1211. comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
  1212. if err != nil {
  1213. ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
  1214. return
  1215. }
  1216. if err := comment.LoadIssue(); err != nil {
  1217. ctx.NotFoundOrServerError("LoadIssue", models.IsErrIssueNotExist, err)
  1218. return
  1219. }
  1220. if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull)) {
  1221. ctx.Error(403)
  1222. return
  1223. } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
  1224. ctx.Error(204)
  1225. return
  1226. }
  1227. switch ctx.Params(":action") {
  1228. case "react":
  1229. reaction, err := models.CreateCommentReaction(ctx.User, comment.Issue, comment, form.Content)
  1230. if err != nil {
  1231. log.Info("CreateCommentReaction: %s", err)
  1232. break
  1233. }
  1234. // Reload new reactions
  1235. comment.Reactions = nil
  1236. if err = comment.LoadReactions(); err != nil {
  1237. log.Info("comment.LoadReactions: %s", err)
  1238. break
  1239. }
  1240. log.Trace("Reaction for comment created: %d/%d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID, reaction.ID)
  1241. case "unreact":
  1242. if err := models.DeleteCommentReaction(ctx.User, comment.Issue, comment, form.Content); err != nil {
  1243. ctx.ServerError("DeleteCommentReaction", err)
  1244. return
  1245. }
  1246. // Reload new reactions
  1247. comment.Reactions = nil
  1248. if err = comment.LoadReactions(); err != nil {
  1249. log.Info("comment.LoadReactions: %s", err)
  1250. break
  1251. }
  1252. log.Trace("Reaction for comment removed: %d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID)
  1253. default:
  1254. ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil)
  1255. return
  1256. }
  1257. if len(comment.Reactions) == 0 {
  1258. ctx.JSON(200, map[string]interface{}{
  1259. "empty": true,
  1260. "html": "",
  1261. })
  1262. return
  1263. }
  1264. html, err := ctx.HTMLString(string(tplReactions), map[string]interface{}{
  1265. "ctx": ctx.Data,
  1266. "ActionURL": fmt.Sprintf("%s/comments/%d/reactions", ctx.Repo.RepoLink, comment.ID),
  1267. "Reactions": comment.Reactions.GroupByType(),
  1268. })
  1269. if err != nil {
  1270. ctx.ServerError("ChangeCommentReaction.HTMLString", err)
  1271. return
  1272. }
  1273. ctx.JSON(200, map[string]interface{}{
  1274. "html": html,
  1275. })
  1276. }