A fork of Gitea (see branch `mj`) adding Majority Judgment Polls 𐄷 over Issues and Merge Requests. https://git.mieuxvoter.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

903 lines
25 KiB

8 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
API add/generalize pagination (#9452) * paginate results * fixed deadlock * prevented breaking change * updated swagger * go fmt * fixed find topic * go mod tidy * go mod vendor with go1.13.5 * fixed repo find topics * fixed unit test * added Limit method to Engine struct; use engine variable when provided; fixed gitignore * use ItemsPerPage for default pagesize; fix GetWatchers, getOrgUsersByOrgID and GetStargazers; fix GetAllCommits headers; reverted some changed behaviors * set Page value on Home route * improved memory allocations * fixed response headers * removed logfiles * fixed import order * import order * improved swagger * added function to get models.ListOptions from context * removed pagesize diff on unit test * fixed imports * removed unnecessary struct field * fixed go fmt * scoped PR * code improvements * code improvements * go mod tidy * fixed import order * fixed commit statuses session * fixed files headers * fixed headers; added pagination for notifications * go mod tidy * go fmt * removed Private from user search options; added setting.UI.IssuePagingNum as default valeu on repo's issues list * Apply suggestions from code review Co-Authored-By: 6543 <6543@obermui.de> Co-Authored-By: zeripath <art27@cantab.net> * fixed build error * CI.restart() * fixed merge conflicts resolve * fixed conflicts resolve * improved FindTrackedTimesOptions.ToOptions() method * added backwards compatibility on ListReleases request; fixed issue tracked time ToSession * fixed build error; fixed swagger template * fixed swagger template * fixed ListReleases backwards compatibility * added page to user search route Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
3 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
Restricted users (#6274) * Restricted users (#4334): initial implementation * Add User.IsRestricted & UI to edit it * Pass user object instead of user id to places where IsRestricted flag matters * Restricted users: maintain access rows for all referenced repos (incl public) * Take logged in user & IsRestricted flag into account in org/repo listings, searches and accesses * Add basic repo access tests for restricted users Signed-off-by: Manush Dodunekov <manush@stendahls.se> * Mention restricted users in the faq Signed-off-by: Manush Dodunekov <manush@stendahls.se> * Revert unnecessary change `.isUserPartOfOrg` -> `.IsUserPartOfOrg` Signed-off-by: Manush Dodunekov <manush@stendahls.se> * Remove unnecessary `org.IsOrganization()` call Signed-off-by: Manush Dodunekov <manush@stendahls.se> * Revert to an `int64` keyed `accessMap` * Add type `userAccess` * Add convenience func updateUserAccess() * Turn accessMap into a `map[int64]userAccess` Signed-off-by: Manush Dodunekov <manush@stendahls.se> * or even better: `map[int64]*userAccess` * updateUserAccess(): use tighter syntax as suggested by lafriks * even tighter * Avoid extra loop * Don't disclose limited orgs to unauthenticated users * Don't assume block only applies to orgs * Use an array of `VisibleType` for filtering * fix yet another thinko * Ok - no need for u * Revert "Ok - no need for u" This reverts commit 5c3e886aabd5acd997a3b35687d322439732c200. Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com> Co-authored-by: Lauris BH <lauris@nix.lv>
3 years ago
7 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
issue search on my related repositories (#9758) * adding search capability to user's issues dashboard * global issue search * placement of search bar on issues dashboard * fixed some bugs in the issue dashboard search * added unit test because IssueIDs option was added to UserIssueStatsOptions * some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter * added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging * fix issue with all count showing incorrectly * removed todo comment left in by mistake * typo pulling wrong count * fxied all count being off when selecting repositories * setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats * added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to * added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000 * fixed unit test * using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues) Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
3 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
3 years ago
6 years ago
API add/generalize pagination (#9452) * paginate results * fixed deadlock * prevented breaking change * updated swagger * go fmt * fixed find topic * go mod tidy * go mod vendor with go1.13.5 * fixed repo find topics * fixed unit test * added Limit method to Engine struct; use engine variable when provided; fixed gitignore * use ItemsPerPage for default pagesize; fix GetWatchers, getOrgUsersByOrgID and GetStargazers; fix GetAllCommits headers; reverted some changed behaviors * set Page value on Home route * improved memory allocations * fixed response headers * removed logfiles * fixed import order * import order * improved swagger * added function to get models.ListOptions from context * removed pagesize diff on unit test * fixed imports * removed unnecessary struct field * fixed go fmt * scoped PR * code improvements * code improvements * go mod tidy * fixed import order * fixed commit statuses session * fixed files headers * fixed headers; added pagination for notifications * go mod tidy * go fmt * removed Private from user search options; added setting.UI.IssuePagingNum as default valeu on repo's issues list * Apply suggestions from code review Co-Authored-By: 6543 <6543@obermui.de> Co-Authored-By: zeripath <art27@cantab.net> * fixed build error * CI.restart() * fixed merge conflicts resolve * fixed conflicts resolve * improved FindTrackedTimesOptions.ToOptions() method * added backwards compatibility on ListReleases request; fixed issue tracked time ToSession * fixed build error; fixed swagger template * fixed swagger template * fixed ListReleases backwards compatibility * added page to user search route Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
3 years ago
8 years ago
8 years ago
8 years ago
8 years ago
API add/generalize pagination (#9452) * paginate results * fixed deadlock * prevented breaking change * updated swagger * go fmt * fixed find topic * go mod tidy * go mod vendor with go1.13.5 * fixed repo find topics * fixed unit test * added Limit method to Engine struct; use engine variable when provided; fixed gitignore * use ItemsPerPage for default pagesize; fix GetWatchers, getOrgUsersByOrgID and GetStargazers; fix GetAllCommits headers; reverted some changed behaviors * set Page value on Home route * improved memory allocations * fixed response headers * removed logfiles * fixed import order * import order * improved swagger * added function to get models.ListOptions from context * removed pagesize diff on unit test * fixed imports * removed unnecessary struct field * fixed go fmt * scoped PR * code improvements * code improvements * go mod tidy * fixed import order * fixed commit statuses session * fixed files headers * fixed headers; added pagination for notifications * go mod tidy * go fmt * removed Private from user search options; added setting.UI.IssuePagingNum as default valeu on repo's issues list * Apply suggestions from code review Co-Authored-By: 6543 <6543@obermui.de> Co-Authored-By: zeripath <art27@cantab.net> * fixed build error * CI.restart() * fixed merge conflicts resolve * fixed conflicts resolve * improved FindTrackedTimesOptions.ToOptions() method * added backwards compatibility on ListReleases request; fixed issue tracked time ToSession * fixed build error; fixed swagger template * fixed swagger template * fixed ListReleases backwards compatibility * added page to user search route Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
3 years ago
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 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 user
  6. import (
  7. "bytes"
  8. "fmt"
  9. "regexp"
  10. "sort"
  11. "strconv"
  12. "strings"
  13. "code.gitea.io/gitea/models"
  14. "code.gitea.io/gitea/modules/base"
  15. "code.gitea.io/gitea/modules/context"
  16. issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
  17. "code.gitea.io/gitea/modules/log"
  18. "code.gitea.io/gitea/modules/markup/markdown"
  19. "code.gitea.io/gitea/modules/setting"
  20. "code.gitea.io/gitea/modules/util"
  21. issue_service "code.gitea.io/gitea/services/issue"
  22. pull_service "code.gitea.io/gitea/services/pull"
  23. jsoniter "github.com/json-iterator/go"
  24. "github.com/keybase/go-crypto/openpgp"
  25. "github.com/keybase/go-crypto/openpgp/armor"
  26. "xorm.io/builder"
  27. )
  28. const (
  29. tplDashboard base.TplName = "user/dashboard/dashboard"
  30. tplIssues base.TplName = "user/dashboard/issues"
  31. tplMilestones base.TplName = "user/dashboard/milestones"
  32. tplProfile base.TplName = "user/profile"
  33. )
  34. // getDashboardContextUser finds out which context user dashboard is being viewed as .
  35. func getDashboardContextUser(ctx *context.Context) *models.User {
  36. ctxUser := ctx.User
  37. orgName := ctx.Params(":org")
  38. if len(orgName) > 0 {
  39. ctxUser = ctx.Org.Organization
  40. ctx.Data["Teams"] = ctx.Org.Organization.Teams
  41. }
  42. ctx.Data["ContextUser"] = ctxUser
  43. if err := ctx.User.GetOrganizations(&models.SearchOrganizationsOptions{All: true}); err != nil {
  44. ctx.ServerError("GetOrganizations", err)
  45. return nil
  46. }
  47. ctx.Data["Orgs"] = ctx.User.Orgs
  48. return ctxUser
  49. }
  50. // retrieveFeeds loads feeds for the specified user
  51. func retrieveFeeds(ctx *context.Context, options models.GetFeedsOptions) {
  52. actions, err := models.GetFeeds(options)
  53. if err != nil {
  54. ctx.ServerError("GetFeeds", err)
  55. return
  56. }
  57. userCache := map[int64]*models.User{options.RequestedUser.ID: options.RequestedUser}
  58. if ctx.User != nil {
  59. userCache[ctx.User.ID] = ctx.User
  60. }
  61. for _, act := range actions {
  62. if act.ActUser != nil {
  63. userCache[act.ActUserID] = act.ActUser
  64. }
  65. }
  66. for _, act := range actions {
  67. repoOwner, ok := userCache[act.Repo.OwnerID]
  68. if !ok {
  69. repoOwner, err = models.GetUserByID(act.Repo.OwnerID)
  70. if err != nil {
  71. if models.IsErrUserNotExist(err) {
  72. continue
  73. }
  74. ctx.ServerError("GetUserByID", err)
  75. return
  76. }
  77. userCache[repoOwner.ID] = repoOwner
  78. }
  79. act.Repo.Owner = repoOwner
  80. }
  81. ctx.Data["Feeds"] = actions
  82. }
  83. // Dashboard render the dashboard page
  84. func Dashboard(ctx *context.Context) {
  85. ctxUser := getDashboardContextUser(ctx)
  86. if ctx.Written() {
  87. return
  88. }
  89. ctx.Data["Title"] = ctxUser.DisplayName() + " - " + ctx.Tr("dashboard")
  90. ctx.Data["PageIsDashboard"] = true
  91. ctx.Data["PageIsNews"] = true
  92. ctx.Data["SearchLimit"] = setting.UI.User.RepoPagingNum
  93. if setting.Service.EnableUserHeatmap {
  94. data, err := models.GetUserHeatmapDataByUserTeam(ctxUser, ctx.Org.Team, ctx.User)
  95. if err != nil {
  96. ctx.ServerError("GetUserHeatmapDataByUserTeam", err)
  97. return
  98. }
  99. ctx.Data["HeatmapData"] = data
  100. }
  101. var err error
  102. var mirrors []*models.Repository
  103. if ctxUser.IsOrganization() {
  104. var env models.AccessibleReposEnvironment
  105. if ctx.Org.Team != nil {
  106. env = ctxUser.AccessibleTeamReposEnv(ctx.Org.Team)
  107. } else {
  108. env, err = ctxUser.AccessibleReposEnv(ctx.User.ID)
  109. if err != nil {
  110. ctx.ServerError("AccessibleReposEnv", err)
  111. return
  112. }
  113. }
  114. mirrors, err = env.MirrorRepos()
  115. if err != nil {
  116. ctx.ServerError("env.MirrorRepos", err)
  117. return
  118. }
  119. } else {
  120. mirrors, err = ctxUser.GetMirrorRepositories()
  121. if err != nil {
  122. ctx.ServerError("GetMirrorRepositories", err)
  123. return
  124. }
  125. }
  126. ctx.Data["MaxShowRepoNum"] = setting.UI.User.RepoPagingNum
  127. if err := models.MirrorRepositoryList(mirrors).LoadAttributes(); err != nil {
  128. ctx.ServerError("MirrorRepositoryList.LoadAttributes", err)
  129. return
  130. }
  131. ctx.Data["MirrorCount"] = len(mirrors)
  132. ctx.Data["Mirrors"] = mirrors
  133. retrieveFeeds(ctx, models.GetFeedsOptions{
  134. RequestedUser: ctxUser,
  135. RequestedTeam: ctx.Org.Team,
  136. Actor: ctx.User,
  137. IncludePrivate: true,
  138. OnlyPerformedBy: false,
  139. IncludeDeleted: false,
  140. Date: ctx.Query("date"),
  141. })
  142. if ctx.Written() {
  143. return
  144. }
  145. ctx.HTML(200, tplDashboard)
  146. }
  147. // Milestones render the user milestones page
  148. func Milestones(ctx *context.Context) {
  149. if models.UnitTypeIssues.UnitGlobalDisabled() && models.UnitTypePullRequests.UnitGlobalDisabled() {
  150. log.Debug("Milestones overview page not available as both issues and pull requests are globally disabled")
  151. ctx.Status(404)
  152. return
  153. }
  154. ctx.Data["Title"] = ctx.Tr("milestones")
  155. ctx.Data["PageIsMilestonesDashboard"] = true
  156. ctxUser := getDashboardContextUser(ctx)
  157. if ctx.Written() {
  158. return
  159. }
  160. repoOpts := models.SearchRepoOptions{
  161. Actor: ctxUser,
  162. OwnerID: ctxUser.ID,
  163. Private: true,
  164. AllPublic: false, // Include also all public repositories of users and public organisations
  165. AllLimited: false, // Include also all public repositories of limited organisations
  166. HasMilestones: util.OptionalBoolTrue, // Just needs display repos has milestones
  167. }
  168. if ctxUser.IsOrganization() && ctx.Org.Team != nil {
  169. repoOpts.TeamID = ctx.Org.Team.ID
  170. }
  171. var (
  172. userRepoCond = models.SearchRepositoryCondition(&repoOpts) // all repo condition user could visit
  173. repoCond = userRepoCond
  174. repoIDs []int64
  175. reposQuery = ctx.Query("repos")
  176. isShowClosed = ctx.Query("state") == "closed"
  177. sortType = ctx.Query("sort")
  178. page = ctx.QueryInt("page")
  179. )
  180. if page <= 1 {
  181. page = 1
  182. }
  183. if len(reposQuery) != 0 {
  184. if issueReposQueryPattern.MatchString(reposQuery) {
  185. // remove "[" and "]" from string
  186. reposQuery = reposQuery[1 : len(reposQuery)-1]
  187. //for each ID (delimiter ",") add to int to repoIDs
  188. for _, rID := range strings.Split(reposQuery, ",") {
  189. // Ensure nonempty string entries
  190. if rID != "" && rID != "0" {
  191. rIDint64, err := strconv.ParseInt(rID, 10, 64)
  192. // If the repo id specified by query is not parseable or not accessible by user, just ignore it.
  193. if err == nil {
  194. repoIDs = append(repoIDs, rIDint64)
  195. }
  196. }
  197. }
  198. if len(repoIDs) > 0 {
  199. // Don't just let repoCond = builder.In("id", repoIDs) because user may has no permission on repoIDs
  200. // But the original repoCond has a limitation
  201. repoCond = repoCond.And(builder.In("id", repoIDs))
  202. }
  203. } else {
  204. log.Warn("issueReposQueryPattern not match with query")
  205. }
  206. }
  207. counts, err := models.CountMilestonesByRepoCond(userRepoCond, isShowClosed)
  208. if err != nil {
  209. ctx.ServerError("CountMilestonesByRepoIDs", err)
  210. return
  211. }
  212. milestones, err := models.SearchMilestones(repoCond, page, isShowClosed, sortType)
  213. if err != nil {
  214. ctx.ServerError("GetMilestonesByRepoIDs", err)
  215. return
  216. }
  217. showRepos, _, err := models.SearchRepositoryByCondition(&repoOpts, userRepoCond, false)
  218. if err != nil {
  219. ctx.ServerError("SearchRepositoryByCondition", err)
  220. return
  221. }
  222. sort.Sort(showRepos)
  223. for i := 0; i < len(milestones); {
  224. for _, repo := range showRepos {
  225. if milestones[i].RepoID == repo.ID {
  226. milestones[i].Repo = repo
  227. break
  228. }
  229. }
  230. if milestones[i].Repo == nil {
  231. log.Warn("Cannot find milestone %d 's repository %d", milestones[i].ID, milestones[i].RepoID)
  232. milestones = append(milestones[:i], milestones[i+1:]...)
  233. continue
  234. }
  235. milestones[i].RenderedContent = string(markdown.Render([]byte(milestones[i].Content), milestones[i].Repo.Link(), milestones[i].Repo.ComposeMetas()))
  236. if milestones[i].Repo.IsTimetrackerEnabled() {
  237. err := milestones[i].LoadTotalTrackedTime()
  238. if err != nil {
  239. ctx.ServerError("LoadTotalTrackedTime", err)
  240. return
  241. }
  242. }
  243. i++
  244. }
  245. milestoneStats, err := models.GetMilestonesStatsByRepoCond(repoCond)
  246. if err != nil {
  247. ctx.ServerError("GetMilestoneStats", err)
  248. return
  249. }
  250. var totalMilestoneStats *models.MilestonesStats
  251. if len(repoIDs) == 0 {
  252. totalMilestoneStats = milestoneStats
  253. } else {
  254. totalMilestoneStats, err = models.GetMilestonesStatsByRepoCond(userRepoCond)
  255. if err != nil {
  256. ctx.ServerError("GetMilestoneStats", err)
  257. return
  258. }
  259. }
  260. var pagerCount int
  261. if isShowClosed {
  262. ctx.Data["State"] = "closed"
  263. ctx.Data["Total"] = totalMilestoneStats.ClosedCount
  264. pagerCount = int(milestoneStats.ClosedCount)
  265. } else {
  266. ctx.Data["State"] = "open"
  267. ctx.Data["Total"] = totalMilestoneStats.OpenCount
  268. pagerCount = int(milestoneStats.OpenCount)
  269. }
  270. ctx.Data["Milestones"] = milestones
  271. ctx.Data["Repos"] = showRepos
  272. ctx.Data["Counts"] = counts
  273. ctx.Data["MilestoneStats"] = milestoneStats
  274. ctx.Data["SortType"] = sortType
  275. if milestoneStats.Total() != totalMilestoneStats.Total() {
  276. ctx.Data["RepoIDs"] = repoIDs
  277. }
  278. ctx.Data["IsShowClosed"] = isShowClosed
  279. pager := context.NewPagination(pagerCount, setting.UI.IssuePagingNum, page, 5)
  280. pager.AddParam(ctx, "repos", "RepoIDs")
  281. pager.AddParam(ctx, "sort", "SortType")
  282. pager.AddParam(ctx, "state", "State")
  283. ctx.Data["Page"] = pager
  284. ctx.HTML(200, tplMilestones)
  285. }
  286. // Pulls renders the user's pull request overview page
  287. func Pulls(ctx *context.Context) {
  288. if models.UnitTypePullRequests.UnitGlobalDisabled() {
  289. log.Debug("Pull request overview page not available as it is globally disabled.")
  290. ctx.Status(404)
  291. return
  292. }
  293. ctx.Data["Title"] = ctx.Tr("pull_requests")
  294. ctx.Data["PageIsPulls"] = true
  295. buildIssueOverview(ctx, models.UnitTypePullRequests)
  296. }
  297. // Issues renders the user's issues overview page
  298. func Issues(ctx *context.Context) {
  299. if models.UnitTypeIssues.UnitGlobalDisabled() {
  300. log.Debug("Issues overview page not available as it is globally disabled.")
  301. ctx.Status(404)
  302. return
  303. }
  304. ctx.Data["Title"] = ctx.Tr("issues")
  305. ctx.Data["PageIsIssues"] = true
  306. buildIssueOverview(ctx, models.UnitTypeIssues)
  307. }
  308. // Regexp for repos query
  309. var issueReposQueryPattern = regexp.MustCompile(`^\[\d+(,\d+)*,?\]$`)
  310. func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
  311. // ----------------------------------------------------
  312. // Determine user; can be either user or organization.
  313. // Return with NotFound or ServerError if unsuccessful.
  314. // ----------------------------------------------------
  315. ctxUser := getDashboardContextUser(ctx)
  316. if ctx.Written() {
  317. return
  318. }
  319. var (
  320. viewType string
  321. sortType = ctx.Query("sort")
  322. filterMode = models.FilterModeAll
  323. )
  324. // --------------------------------------------------------------------------------
  325. // Distinguish User from Organization.
  326. // Org:
  327. // - Remember pre-determined viewType string for later. Will be posted to ctx.Data.
  328. // Organization does not have view type and filter mode.
  329. // User:
  330. // - Use ctx.Query("type") to determine filterMode.
  331. // The type is set when clicking for example "assigned to me" on the overview page.
  332. // - Remember either this or a fallback. Will be posted to ctx.Data.
  333. // --------------------------------------------------------------------------------
  334. // TODO: distinguish during routing
  335. viewType = ctx.Query("type")
  336. switch viewType {
  337. case "assigned":
  338. filterMode = models.FilterModeAssign
  339. case "created_by":
  340. filterMode = models.FilterModeCreate
  341. case "mentioned":
  342. filterMode = models.FilterModeMention
  343. case "review_requested":
  344. filterMode = models.FilterModeReviewRequested
  345. case "your_repositories": // filterMode already set to All
  346. default:
  347. viewType = "your_repositories"
  348. }
  349. // --------------------------------------------------------------------------
  350. // Build opts (IssuesOptions), which contains filter information.
  351. // Will eventually be used to retrieve issues relevant for the overview page.
  352. // Note: Non-final states of opts are used in-between, namely for:
  353. // - Keyword search
  354. // - Count Issues by repo
  355. // --------------------------------------------------------------------------
  356. isPullList := unitType == models.UnitTypePullRequests
  357. opts := &models.IssuesOptions{
  358. IsPull: util.OptionalBoolOf(isPullList),
  359. SortType: sortType,
  360. IsArchived: util.OptionalBoolFalse,
  361. }
  362. // Get repository IDs where User/Org/Team has access.
  363. var team *models.Team
  364. if ctx.Org != nil {
  365. team = ctx.Org.Team
  366. }
  367. userRepoIDs, err := getActiveUserRepoIDs(ctxUser, team, unitType)
  368. if err != nil {
  369. ctx.ServerError("userRepoIDs", err)
  370. return
  371. }
  372. switch filterMode {
  373. case models.FilterModeAll:
  374. opts.RepoIDs = userRepoIDs
  375. case models.FilterModeAssign:
  376. opts.AssigneeID = ctx.User.ID
  377. case models.FilterModeCreate:
  378. opts.PosterID = ctx.User.ID
  379. case models.FilterModeMention:
  380. opts.MentionedID = ctx.User.ID
  381. case models.FilterModeReviewRequested:
  382. opts.ReviewRequestedID = ctx.User.ID
  383. }
  384. if ctxUser.IsOrganization() {
  385. opts.RepoIDs = userRepoIDs
  386. }
  387. // keyword holds the search term entered into the search field.
  388. keyword := strings.Trim(ctx.Query("q"), " ")
  389. ctx.Data["Keyword"] = keyword
  390. // Execute keyword search for issues.
  391. // USING NON-FINAL STATE OF opts FOR A QUERY.
  392. issueIDsFromSearch, err := issueIDsFromSearch(ctxUser, keyword, opts)
  393. if err != nil {
  394. ctx.ServerError("issueIDsFromSearch", err)
  395. return
  396. }
  397. // Ensure no issues are returned if a keyword was provided that didn't match any issues.
  398. var forceEmpty bool
  399. if len(issueIDsFromSearch) > 0 {
  400. opts.IssueIDs = issueIDsFromSearch
  401. } else if len(keyword) > 0 {
  402. forceEmpty = true
  403. }
  404. // Educated guess: Do or don't show closed issues.
  405. isShowClosed := ctx.Query("state") == "closed"
  406. opts.IsClosed = util.OptionalBoolOf(isShowClosed)
  407. // Filter repos and count issues in them. Count will be used later.
  408. // USING NON-FINAL STATE OF opts FOR A QUERY.
  409. var issueCountByRepo map[int64]int64
  410. if !forceEmpty {
  411. issueCountByRepo, err = models.CountIssuesByRepo(opts)
  412. if err != nil {
  413. ctx.ServerError("CountIssuesByRepo", err)
  414. return
  415. }
  416. }
  417. // Make sure page number is at least 1. Will be posted to ctx.Data.
  418. page := ctx.QueryInt("page")
  419. if page <= 1 {
  420. page = 1
  421. }
  422. opts.Page = page
  423. opts.PageSize = setting.UI.IssuePagingNum
  424. // Get IDs for labels (a filter option for issues/pulls).
  425. // Required for IssuesOptions.
  426. var labelIDs []int64
  427. selectedLabels := ctx.Query("labels")
  428. if len(selectedLabels) > 0 && selectedLabels != "0" {
  429. labelIDs, err = base.StringsToInt64s(strings.Split(selectedLabels, ","))
  430. if err != nil {
  431. ctx.ServerError("StringsToInt64s", err)
  432. return
  433. }
  434. }
  435. opts.LabelIDs = labelIDs
  436. // Parse ctx.Query("repos") and remember matched repo IDs for later.
  437. // Gets set when clicking filters on the issues overview page.
  438. repoIDs := getRepoIDs(ctx.Query("repos"))
  439. if len(repoIDs) > 0 {
  440. opts.RepoIDs = repoIDs
  441. }
  442. // ------------------------------
  443. // Get issues as defined by opts.
  444. // ------------------------------
  445. // Slice of Issues that will be displayed on the overview page
  446. // USING FINAL STATE OF opts FOR A QUERY.
  447. var issues []*models.Issue
  448. if !forceEmpty {
  449. issues, err = models.Issues(opts)
  450. if err != nil {
  451. ctx.ServerError("Issues", err)
  452. return
  453. }
  454. } else {
  455. issues = []*models.Issue{}
  456. }
  457. // ----------------------------------
  458. // Add repository pointers to Issues.
  459. // ----------------------------------
  460. // showReposMap maps repository IDs to their Repository pointers.
  461. showReposMap, err := repoIDMap(ctxUser, issueCountByRepo, unitType)
  462. if err != nil {
  463. if models.IsErrRepoNotExist(err) {
  464. ctx.NotFound("GetRepositoryByID", err)
  465. return
  466. }
  467. ctx.ServerError("repoIDMap", err)
  468. return
  469. }
  470. // a RepositoryList
  471. showRepos := models.RepositoryListOfMap(showReposMap)
  472. sort.Sort(showRepos)
  473. if err = showRepos.LoadAttributes(); err != nil {
  474. ctx.ServerError("LoadAttributes", err)
  475. return
  476. }
  477. // maps pull request IDs to their CommitStatus. Will be posted to ctx.Data.
  478. var commitStatus = make(map[int64]*models.CommitStatus, len(issues))
  479. for _, issue := range issues {
  480. issue.Repo = showReposMap[issue.RepoID]
  481. if isPullList {
  482. var statuses, _ = pull_service.GetLastCommitStatus(issue.PullRequest)
  483. commitStatus[issue.PullRequest.ID] = models.CalcCommitStatus(statuses)
  484. }
  485. }
  486. // -------------------------------
  487. // Fill stats to post to ctx.Data.
  488. // -------------------------------
  489. userIssueStatsOpts := models.UserIssueStatsOptions{
  490. UserID: ctx.User.ID,
  491. UserRepoIDs: userRepoIDs,
  492. FilterMode: filterMode,
  493. IsPull: isPullList,
  494. IsClosed: isShowClosed,
  495. IsArchived: util.OptionalBoolFalse,
  496. LabelIDs: opts.LabelIDs,
  497. }
  498. if len(repoIDs) > 0 {
  499. userIssueStatsOpts.UserRepoIDs = repoIDs
  500. }
  501. if ctxUser.IsOrganization() {
  502. userIssueStatsOpts.RepoIDs = userRepoIDs
  503. }
  504. userIssueStats, err := models.GetUserIssueStats(userIssueStatsOpts)
  505. if err != nil {
  506. ctx.ServerError("GetUserIssueStats User", err)
  507. return
  508. }
  509. var shownIssueStats *models.IssueStats
  510. if !forceEmpty {
  511. statsOpts := models.UserIssueStatsOptions{
  512. UserID: ctx.User.ID,
  513. UserRepoIDs: userRepoIDs,
  514. FilterMode: filterMode,
  515. IsPull: isPullList,
  516. IsClosed: isShowClosed,
  517. IssueIDs: issueIDsFromSearch,
  518. IsArchived: util.OptionalBoolFalse,
  519. LabelIDs: opts.LabelIDs,
  520. }
  521. if len(repoIDs) > 0 {
  522. statsOpts.RepoIDs = repoIDs
  523. } else if ctxUser.IsOrganization() {
  524. statsOpts.RepoIDs = userRepoIDs
  525. }
  526. shownIssueStats, err = models.GetUserIssueStats(statsOpts)
  527. if err != nil {
  528. ctx.ServerError("GetUserIssueStats Shown", err)
  529. return
  530. }
  531. } else {
  532. shownIssueStats = &models.IssueStats{}
  533. }
  534. var allIssueStats *models.IssueStats
  535. if !forceEmpty {
  536. allIssueStatsOpts := models.UserIssueStatsOptions{
  537. UserID: ctx.User.ID,
  538. UserRepoIDs: userRepoIDs,
  539. FilterMode: filterMode,
  540. IsPull: isPullList,
  541. IsClosed: isShowClosed,
  542. IssueIDs: issueIDsFromSearch,
  543. IsArchived: util.OptionalBoolFalse,
  544. LabelIDs: opts.LabelIDs,
  545. }
  546. if ctxUser.IsOrganization() {
  547. allIssueStatsOpts.RepoIDs = userRepoIDs
  548. }
  549. allIssueStats, err = models.GetUserIssueStats(allIssueStatsOpts)
  550. if err != nil {
  551. ctx.ServerError("GetUserIssueStats All", err)
  552. return
  553. }
  554. } else {
  555. allIssueStats = &models.IssueStats{}
  556. }
  557. // Will be posted to ctx.Data.
  558. var shownIssues int
  559. if !isShowClosed {
  560. shownIssues = int(shownIssueStats.OpenCount)
  561. ctx.Data["TotalIssueCount"] = int(allIssueStats.OpenCount)
  562. } else {
  563. shownIssues = int(shownIssueStats.ClosedCount)
  564. ctx.Data["TotalIssueCount"] = int(allIssueStats.ClosedCount)
  565. }
  566. ctx.Data["IsShowClosed"] = isShowClosed
  567. ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] =
  568. issue_service.GetRefEndNamesAndURLs(issues, ctx.Query("RepoLink"))
  569. ctx.Data["Issues"] = issues
  570. approvalCounts, err := models.IssueList(issues).GetApprovalCounts()
  571. if err != nil {
  572. ctx.ServerError("ApprovalCounts", err)
  573. return
  574. }
  575. ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 {
  576. counts, ok := approvalCounts[issueID]
  577. if !ok || len(counts) == 0 {
  578. return 0
  579. }
  580. reviewTyp := models.ReviewTypeApprove
  581. if typ == "reject" {
  582. reviewTyp = models.ReviewTypeReject
  583. } else if typ == "waiting" {
  584. reviewTyp = models.ReviewTypeRequest
  585. }
  586. for _, count := range counts {
  587. if count.Type == reviewTyp {
  588. return count.Count
  589. }
  590. }
  591. return 0
  592. }
  593. ctx.Data["CommitStatus"] = commitStatus
  594. ctx.Data["Repos"] = showRepos
  595. ctx.Data["Counts"] = issueCountByRepo
  596. ctx.Data["IssueStats"] = userIssueStats
  597. ctx.Data["ShownIssueStats"] = shownIssueStats
  598. ctx.Data["ViewType"] = viewType
  599. ctx.Data["SortType"] = sortType
  600. ctx.Data["RepoIDs"] = repoIDs
  601. ctx.Data["IsShowClosed"] = isShowClosed
  602. ctx.Data["SelectLabels"] = selectedLabels
  603. if isShowClosed {
  604. ctx.Data["State"] = "closed"
  605. } else {
  606. ctx.Data["State"] = "open"
  607. }
  608. // Convert []int64 to string
  609. json := jsoniter.ConfigCompatibleWithStandardLibrary
  610. reposParam, _ := json.Marshal(repoIDs)
  611. ctx.Data["ReposParam"] = string(reposParam)
  612. pager := context.NewPagination(shownIssues, setting.UI.IssuePagingNum, page, 5)
  613. pager.AddParam(ctx, "q", "Keyword")
  614. pager.AddParam(ctx, "type", "ViewType")
  615. pager.AddParam(ctx, "repos", "ReposParam")
  616. pager.AddParam(ctx, "sort", "SortType")
  617. pager.AddParam(ctx, "state", "State")
  618. pager.AddParam(ctx, "labels", "SelectLabels")
  619. pager.AddParam(ctx, "milestone", "MilestoneID")
  620. pager.AddParam(ctx, "assignee", "AssigneeID")
  621. ctx.Data["Page"] = pager
  622. ctx.HTML(200, tplIssues)
  623. }
  624. func getRepoIDs(reposQuery string) []int64 {
  625. if len(reposQuery) == 0 || reposQuery == "[]" {
  626. return []int64{}
  627. }
  628. if !issueReposQueryPattern.MatchString(reposQuery) {
  629. log.Warn("issueReposQueryPattern does not match query")
  630. return []int64{}
  631. }
  632. var repoIDs []int64
  633. // remove "[" and "]" from string
  634. reposQuery = reposQuery[1 : len(reposQuery)-1]
  635. //for each ID (delimiter ",") add to int to repoIDs
  636. for _, rID := range strings.Split(reposQuery, ",") {
  637. // Ensure nonempty string entries
  638. if rID != "" && rID != "0" {
  639. rIDint64, err := strconv.ParseInt(rID, 10, 64)
  640. if err == nil {
  641. repoIDs = append(repoIDs, rIDint64)
  642. }
  643. }
  644. }
  645. return repoIDs
  646. }
  647. func getActiveUserRepoIDs(ctxUser *models.User, team *models.Team, unitType models.UnitType) ([]int64, error) {
  648. var userRepoIDs []int64
  649. var err error
  650. if ctxUser.IsOrganization() {
  651. userRepoIDs, err = getActiveTeamOrOrgRepoIds(ctxUser, team, unitType)
  652. if err != nil {
  653. return nil, fmt.Errorf("orgRepoIds: %v", err)
  654. }
  655. } else {
  656. userRepoIDs, err = ctxUser.GetActiveAccessRepoIDs(unitType)
  657. if err != nil {
  658. return nil, fmt.Errorf("ctxUser.GetAccessRepoIDs: %v", err)
  659. }
  660. }
  661. if len(userRepoIDs) == 0 {
  662. userRepoIDs = []int64{-1}
  663. }
  664. return userRepoIDs, nil
  665. }
  666. // getActiveTeamOrOrgRepoIds gets RepoIDs for ctxUser as Organization.
  667. // Should be called if and only if ctxUser.IsOrganization == true.
  668. func getActiveTeamOrOrgRepoIds(ctxUser *models.User, team *models.Team, unitType models.UnitType) ([]int64, error) {
  669. var orgRepoIDs []int64
  670. var err error
  671. var env models.AccessibleReposEnvironment
  672. if team != nil {
  673. env = ctxUser.AccessibleTeamReposEnv(team)
  674. if err != nil {
  675. return nil, fmt.Errorf("AccessibleTeamReposEnv: %v", err)
  676. }
  677. } else {
  678. env, err = ctxUser.AccessibleReposEnv(ctxUser.ID)
  679. if err != nil {
  680. return nil, fmt.Errorf("AccessibleReposEnv: %v", err)
  681. }
  682. }
  683. orgRepoIDs, err = env.RepoIDs(1, ctxUser.NumRepos)
  684. if err != nil {
  685. return nil, fmt.Errorf("env.RepoIDs: %v", err)
  686. }
  687. orgRepoIDs, err = models.FilterOutRepoIdsWithoutUnitAccess(ctxUser, orgRepoIDs, unitType)
  688. if err != nil {
  689. return nil, fmt.Errorf("FilterOutRepoIdsWithoutUnitAccess: %v", err)
  690. }
  691. return orgRepoIDs, nil
  692. }
  693. func issueIDsFromSearch(ctxUser *models.User, keyword string, opts *models.IssuesOptions) ([]int64, error) {
  694. if len(keyword) == 0 {
  695. return []int64{}, nil
  696. }
  697. searchRepoIDs, err := models.GetRepoIDsForIssuesOptions(opts, ctxUser)
  698. if err != nil {
  699. return nil, fmt.Errorf("GetRepoIDsForIssuesOptions: %v", err)
  700. }
  701. issueIDsFromSearch, err := issue_indexer.SearchIssuesByKeyword(searchRepoIDs, keyword)
  702. if err != nil {
  703. return nil, fmt.Errorf("SearchIssuesByKeyword: %v", err)
  704. }
  705. return issueIDsFromSearch, nil
  706. }
  707. func repoIDMap(ctxUser *models.User, issueCountByRepo map[int64]int64, unitType models.UnitType) (map[int64]*models.Repository, error) {
  708. repoByID := make(map[int64]*models.Repository, len(issueCountByRepo))
  709. for id := range issueCountByRepo {
  710. if id <= 0 {
  711. continue
  712. }
  713. if _, ok := repoByID[id]; !ok {
  714. repo, err := models.GetRepositoryByID(id)
  715. if models.IsErrRepoNotExist(err) {
  716. return nil, err
  717. } else if err != nil {
  718. return nil, fmt.Errorf("GetRepositoryByID: [%d]%v", id, err)
  719. }
  720. repoByID[id] = repo
  721. }
  722. repo := repoByID[id]
  723. // Check if user has access to given repository.
  724. perm, err := models.GetUserRepoPermission(repo, ctxUser)
  725. if err != nil {
  726. return nil, fmt.Errorf("GetUserRepoPermission: [%d]%v", id, err)
  727. }
  728. if !perm.CanRead(unitType) {
  729. log.Debug("User created Issues in Repository which they no longer have access to: [%d]", id)
  730. }
  731. }
  732. return repoByID, nil
  733. }
  734. // ShowSSHKeys output all the ssh keys of user by uid
  735. func ShowSSHKeys(ctx *context.Context, uid int64) {
  736. keys, err := models.ListPublicKeys(uid, models.ListOptions{})
  737. if err != nil {
  738. ctx.ServerError("ListPublicKeys", err)
  739. return
  740. }
  741. var buf bytes.Buffer
  742. for i := range keys {
  743. buf.WriteString(keys[i].OmitEmail())
  744. buf.WriteString("\n")
  745. }
  746. ctx.PlainText(200, buf.Bytes())
  747. }
  748. // ShowGPGKeys output all the public GPG keys of user by uid
  749. func ShowGPGKeys(ctx *context.Context, uid int64) {
  750. keys, err := models.ListGPGKeys(uid, models.ListOptions{})
  751. if err != nil {
  752. ctx.ServerError("ListGPGKeys", err)
  753. return
  754. }
  755. entities := make([]*openpgp.Entity, 0)
  756. failedEntitiesID := make([]string, 0)
  757. for _, k := range keys {
  758. e, err := models.GPGKeyToEntity(k)
  759. if err != nil {
  760. if models.IsErrGPGKeyImportNotExist(err) {
  761. failedEntitiesID = append(failedEntitiesID, k.KeyID)
  762. continue //Skip previous import without backup of imported armored key
  763. }
  764. ctx.ServerError("ShowGPGKeys", err)
  765. return
  766. }
  767. entities = append(entities, e)
  768. }
  769. var buf bytes.Buffer
  770. headers := make(map[string]string)
  771. if len(failedEntitiesID) > 0 { //If some key need re-import to be exported
  772. headers["Note"] = fmt.Sprintf("The keys with the following IDs couldn't be exported and need to be reuploaded %s", strings.Join(failedEntitiesID, ", "))
  773. }
  774. writer, _ := armor.Encode(&buf, "PGP PUBLIC KEY BLOCK", headers)
  775. for _, e := range entities {
  776. err = e.Serialize(writer) //TODO find why key are exported with a different cipherTypeByte as original (should not be blocking but strange)
  777. if err != nil {
  778. ctx.ServerError("ShowGPGKeys", err)
  779. return
  780. }
  781. }
  782. writer.Close()
  783. ctx.PlainText(200, buf.Bytes())
  784. }
  785. // Email2User show user page via email
  786. func Email2User(ctx *context.Context) {
  787. u, err := models.GetUserByEmail(ctx.Query("email"))
  788. if err != nil {
  789. if models.IsErrUserNotExist(err) {
  790. ctx.NotFound("GetUserByEmail", err)
  791. } else {
  792. ctx.ServerError("GetUserByEmail", err)
  793. }
  794. return
  795. }
  796. ctx.Redirect(setting.AppSubURL + "/user/" + u.Name)
  797. }