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.

659 lines
17 KiB

10 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()
5 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()
5 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()
5 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 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>
4 years ago
9 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()
5 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()
5 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()
5 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()
5 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()
5 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()
5 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()
5 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()
5 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()
5 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()
5 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()
5 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()
5 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()
5 years ago
8 years ago
10 years ago
10 years ago
10 years ago
10 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. "encoding/json"
  9. "fmt"
  10. "regexp"
  11. "sort"
  12. "strconv"
  13. "strings"
  14. "code.gitea.io/gitea/models"
  15. "code.gitea.io/gitea/modules/base"
  16. "code.gitea.io/gitea/modules/context"
  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. "github.com/keybase/go-crypto/openpgp"
  22. "github.com/keybase/go-crypto/openpgp/armor"
  23. "github.com/unknwon/com"
  24. )
  25. const (
  26. tplDashboard base.TplName = "user/dashboard/dashboard"
  27. tplIssues base.TplName = "user/dashboard/issues"
  28. tplMilestones base.TplName = "user/dashboard/milestones"
  29. tplProfile base.TplName = "user/profile"
  30. )
  31. // getDashboardContextUser finds out dashboard is viewing as which context user.
  32. func getDashboardContextUser(ctx *context.Context) *models.User {
  33. ctxUser := ctx.User
  34. orgName := ctx.Params(":org")
  35. if len(orgName) > 0 {
  36. // Organization.
  37. org, err := models.GetUserByName(orgName)
  38. if err != nil {
  39. if models.IsErrUserNotExist(err) {
  40. ctx.NotFound("GetUserByName", err)
  41. } else {
  42. ctx.ServerError("GetUserByName", err)
  43. }
  44. return nil
  45. }
  46. ctxUser = org
  47. }
  48. ctx.Data["ContextUser"] = ctxUser
  49. if err := ctx.User.GetOrganizations(true); err != nil {
  50. ctx.ServerError("GetOrganizations", err)
  51. return nil
  52. }
  53. ctx.Data["Orgs"] = ctx.User.Orgs
  54. return ctxUser
  55. }
  56. // retrieveFeeds loads feeds for the specified user
  57. func retrieveFeeds(ctx *context.Context, options models.GetFeedsOptions) {
  58. actions, err := models.GetFeeds(options)
  59. if err != nil {
  60. ctx.ServerError("GetFeeds", err)
  61. return
  62. }
  63. userCache := map[int64]*models.User{options.RequestedUser.ID: options.RequestedUser}
  64. if ctx.User != nil {
  65. userCache[ctx.User.ID] = ctx.User
  66. }
  67. for _, act := range actions {
  68. if act.ActUser != nil {
  69. userCache[act.ActUserID] = act.ActUser
  70. }
  71. }
  72. for _, act := range actions {
  73. repoOwner, ok := userCache[act.Repo.OwnerID]
  74. if !ok {
  75. repoOwner, err = models.GetUserByID(act.Repo.OwnerID)
  76. if err != nil {
  77. if models.IsErrUserNotExist(err) {
  78. continue
  79. }
  80. ctx.ServerError("GetUserByID", err)
  81. return
  82. }
  83. userCache[repoOwner.ID] = repoOwner
  84. }
  85. act.Repo.Owner = repoOwner
  86. }
  87. ctx.Data["Feeds"] = actions
  88. }
  89. // Dashboard render the dashborad page
  90. func Dashboard(ctx *context.Context) {
  91. ctxUser := getDashboardContextUser(ctx)
  92. if ctx.Written() {
  93. return
  94. }
  95. ctx.Data["Title"] = ctxUser.DisplayName() + " - " + ctx.Tr("dashboard")
  96. ctx.Data["PageIsDashboard"] = true
  97. ctx.Data["PageIsNews"] = true
  98. ctx.Data["SearchLimit"] = setting.UI.User.RepoPagingNum
  99. ctx.Data["EnableHeatmap"] = setting.Service.EnableUserHeatmap
  100. ctx.Data["HeatmapUser"] = ctxUser.Name
  101. var err error
  102. var mirrors []*models.Repository
  103. if ctxUser.IsOrganization() {
  104. env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
  105. if err != nil {
  106. ctx.ServerError("AccessibleReposEnv", err)
  107. return
  108. }
  109. mirrors, err = env.MirrorRepos()
  110. if err != nil {
  111. ctx.ServerError("env.MirrorRepos", err)
  112. return
  113. }
  114. } else {
  115. mirrors, err = ctxUser.GetMirrorRepositories()
  116. if err != nil {
  117. ctx.ServerError("GetMirrorRepositories", err)
  118. return
  119. }
  120. }
  121. ctx.Data["MaxShowRepoNum"] = setting.UI.User.RepoPagingNum
  122. if err := models.MirrorRepositoryList(mirrors).LoadAttributes(); err != nil {
  123. ctx.ServerError("MirrorRepositoryList.LoadAttributes", err)
  124. return
  125. }
  126. ctx.Data["MirrorCount"] = len(mirrors)
  127. ctx.Data["Mirrors"] = mirrors
  128. retrieveFeeds(ctx, models.GetFeedsOptions{
  129. RequestedUser: ctxUser,
  130. Actor: ctx.User,
  131. IncludePrivate: true,
  132. OnlyPerformedBy: false,
  133. IncludeDeleted: false,
  134. })
  135. if ctx.Written() {
  136. return
  137. }
  138. ctx.HTML(200, tplDashboard)
  139. }
  140. // Milestones render the user milestones page
  141. func Milestones(ctx *context.Context) {
  142. ctx.Data["Title"] = ctx.Tr("milestones")
  143. ctx.Data["PageIsMilestonesDashboard"] = true
  144. ctxUser := getDashboardContextUser(ctx)
  145. if ctx.Written() {
  146. return
  147. }
  148. sortType := ctx.Query("sort")
  149. page := ctx.QueryInt("page")
  150. if page <= 1 {
  151. page = 1
  152. }
  153. reposQuery := ctx.Query("repos")
  154. isShowClosed := ctx.Query("state") == "closed"
  155. // Get repositories.
  156. var err error
  157. var userRepoIDs []int64
  158. if ctxUser.IsOrganization() {
  159. env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
  160. if err != nil {
  161. ctx.ServerError("AccessibleReposEnv", err)
  162. return
  163. }
  164. userRepoIDs, err = env.RepoIDs(1, ctxUser.NumRepos)
  165. if err != nil {
  166. ctx.ServerError("env.RepoIDs", err)
  167. return
  168. }
  169. userRepoIDs, err = models.FilterOutRepoIdsWithoutUnitAccess(ctx.User, userRepoIDs, models.UnitTypeIssues, models.UnitTypePullRequests)
  170. if err != nil {
  171. ctx.ServerError("FilterOutRepoIdsWithoutUnitAccess", err)
  172. return
  173. }
  174. } else {
  175. userRepoIDs, err = ctxUser.GetAccessRepoIDs(models.UnitTypeIssues, models.UnitTypePullRequests)
  176. if err != nil {
  177. ctx.ServerError("ctxUser.GetAccessRepoIDs", err)
  178. return
  179. }
  180. }
  181. if len(userRepoIDs) == 0 {
  182. userRepoIDs = []int64{-1}
  183. }
  184. var repoIDs []int64
  185. if len(reposQuery) != 0 {
  186. if issueReposQueryPattern.MatchString(reposQuery) {
  187. // remove "[" and "]" from string
  188. reposQuery = reposQuery[1 : len(reposQuery)-1]
  189. //for each ID (delimiter ",") add to int to repoIDs
  190. reposSet := false
  191. for _, rID := range strings.Split(reposQuery, ",") {
  192. // Ensure nonempty string entries
  193. if rID != "" && rID != "0" {
  194. reposSet = true
  195. rIDint64, err := strconv.ParseInt(rID, 10, 64)
  196. // If the repo id specified by query is not parseable or not accessible by user, just ignore it.
  197. if err == nil && com.IsSliceContainsInt64(userRepoIDs, rIDint64) {
  198. repoIDs = append(repoIDs, rIDint64)
  199. }
  200. }
  201. }
  202. if reposSet && len(repoIDs) == 0 {
  203. // force an empty result
  204. repoIDs = []int64{-1}
  205. }
  206. } else {
  207. log.Warn("issueReposQueryPattern not match with query")
  208. }
  209. }
  210. if len(repoIDs) == 0 {
  211. repoIDs = userRepoIDs
  212. }
  213. counts, err := models.CountMilestonesByRepoIDs(userRepoIDs, isShowClosed)
  214. if err != nil {
  215. ctx.ServerError("CountMilestonesByRepoIDs", err)
  216. return
  217. }
  218. milestones, err := models.GetMilestonesByRepoIDs(repoIDs, page, isShowClosed, sortType)
  219. if err != nil {
  220. ctx.ServerError("GetMilestonesByRepoIDs", err)
  221. return
  222. }
  223. showReposMap := make(map[int64]*models.Repository, len(counts))
  224. for rID := range counts {
  225. if rID == -1 {
  226. break
  227. }
  228. repo, err := models.GetRepositoryByID(rID)
  229. if err != nil {
  230. if models.IsErrRepoNotExist(err) {
  231. ctx.NotFound("GetRepositoryByID", err)
  232. return
  233. } else if err != nil {
  234. ctx.ServerError("GetRepositoryByID", fmt.Errorf("[%d]%v", rID, err))
  235. return
  236. }
  237. }
  238. showReposMap[rID] = repo
  239. }
  240. showRepos := models.RepositoryListOfMap(showReposMap)
  241. sort.Sort(showRepos)
  242. if err = showRepos.LoadAttributes(); err != nil {
  243. ctx.ServerError("LoadAttributes", err)
  244. return
  245. }
  246. for _, m := range milestones {
  247. m.Repo = showReposMap[m.RepoID]
  248. m.RenderedContent = string(markdown.Render([]byte(m.Content), m.Repo.Link(), m.Repo.ComposeMetas()))
  249. if m.Repo.IsTimetrackerEnabled() {
  250. err := m.LoadTotalTrackedTime()
  251. if err != nil {
  252. ctx.ServerError("LoadTotalTrackedTime", err)
  253. return
  254. }
  255. }
  256. }
  257. milestoneStats, err := models.GetMilestonesStats(repoIDs)
  258. if err != nil {
  259. ctx.ServerError("GetMilestoneStats", err)
  260. return
  261. }
  262. totalMilestoneStats, err := models.GetMilestonesStats(userRepoIDs)
  263. if err != nil {
  264. ctx.ServerError("GetMilestoneStats", err)
  265. return
  266. }
  267. var pagerCount int
  268. if isShowClosed {
  269. ctx.Data["State"] = "closed"
  270. ctx.Data["Total"] = totalMilestoneStats.ClosedCount
  271. pagerCount = int(milestoneStats.ClosedCount)
  272. } else {
  273. ctx.Data["State"] = "open"
  274. ctx.Data["Total"] = totalMilestoneStats.OpenCount
  275. pagerCount = int(milestoneStats.OpenCount)
  276. }
  277. ctx.Data["Milestones"] = milestones
  278. ctx.Data["Repos"] = showRepos
  279. ctx.Data["Counts"] = counts
  280. ctx.Data["MilestoneStats"] = milestoneStats
  281. ctx.Data["SortType"] = sortType
  282. if len(repoIDs) != len(userRepoIDs) {
  283. ctx.Data["RepoIDs"] = repoIDs
  284. }
  285. ctx.Data["IsShowClosed"] = isShowClosed
  286. pager := context.NewPagination(pagerCount, setting.UI.IssuePagingNum, page, 5)
  287. pager.AddParam(ctx, "repos", "RepoIDs")
  288. pager.AddParam(ctx, "sort", "SortType")
  289. pager.AddParam(ctx, "state", "State")
  290. ctx.Data["Page"] = pager
  291. ctx.HTML(200, tplMilestones)
  292. }
  293. // Regexp for repos query
  294. var issueReposQueryPattern = regexp.MustCompile(`^\[\d+(,\d+)*,?\]$`)
  295. // Issues render the user issues page
  296. func Issues(ctx *context.Context) {
  297. isPullList := ctx.Params(":type") == "pulls"
  298. unitType := models.UnitTypeIssues
  299. if isPullList {
  300. ctx.Data["Title"] = ctx.Tr("pull_requests")
  301. ctx.Data["PageIsPulls"] = true
  302. unitType = models.UnitTypePullRequests
  303. } else {
  304. ctx.Data["Title"] = ctx.Tr("issues")
  305. ctx.Data["PageIsIssues"] = true
  306. }
  307. ctxUser := getDashboardContextUser(ctx)
  308. if ctx.Written() {
  309. return
  310. }
  311. // Organization does not have view type and filter mode.
  312. var (
  313. viewType string
  314. sortType = ctx.Query("sort")
  315. filterMode = models.FilterModeAll
  316. )
  317. if ctxUser.IsOrganization() {
  318. viewType = "your_repositories"
  319. } else {
  320. viewType = ctx.Query("type")
  321. switch viewType {
  322. case "assigned":
  323. filterMode = models.FilterModeAssign
  324. case "created_by":
  325. filterMode = models.FilterModeCreate
  326. case "mentioned":
  327. filterMode = models.FilterModeMention
  328. case "your_repositories": // filterMode already set to All
  329. default:
  330. viewType = "your_repositories"
  331. }
  332. }
  333. page := ctx.QueryInt("page")
  334. if page <= 1 {
  335. page = 1
  336. }
  337. reposQuery := ctx.Query("repos")
  338. var repoIDs []int64
  339. if len(reposQuery) != 0 {
  340. if issueReposQueryPattern.MatchString(reposQuery) {
  341. // remove "[" and "]" from string
  342. reposQuery = reposQuery[1 : len(reposQuery)-1]
  343. //for each ID (delimiter ",") add to int to repoIDs
  344. for _, rID := range strings.Split(reposQuery, ",") {
  345. // Ensure nonempty string entries
  346. if rID != "" && rID != "0" {
  347. rIDint64, err := strconv.ParseInt(rID, 10, 64)
  348. if err == nil {
  349. repoIDs = append(repoIDs, rIDint64)
  350. }
  351. }
  352. }
  353. } else {
  354. log.Warn("issueReposQueryPattern not match with query")
  355. }
  356. }
  357. isShowClosed := ctx.Query("state") == "closed"
  358. // Get repositories.
  359. var err error
  360. var userRepoIDs []int64
  361. if ctxUser.IsOrganization() {
  362. env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
  363. if err != nil {
  364. ctx.ServerError("AccessibleReposEnv", err)
  365. return
  366. }
  367. userRepoIDs, err = env.RepoIDs(1, ctxUser.NumRepos)
  368. if err != nil {
  369. ctx.ServerError("env.RepoIDs", err)
  370. return
  371. }
  372. userRepoIDs, err = models.FilterOutRepoIdsWithoutUnitAccess(ctx.User, userRepoIDs, unitType)
  373. if err != nil {
  374. ctx.ServerError("FilterOutRepoIdsWithoutUnitAccess", err)
  375. return
  376. }
  377. } else {
  378. userRepoIDs, err = ctxUser.GetAccessRepoIDs(unitType)
  379. if err != nil {
  380. ctx.ServerError("ctxUser.GetAccessRepoIDs", err)
  381. return
  382. }
  383. }
  384. if len(userRepoIDs) == 0 {
  385. userRepoIDs = []int64{-1}
  386. }
  387. opts := &models.IssuesOptions{
  388. IsClosed: util.OptionalBoolOf(isShowClosed),
  389. IsPull: util.OptionalBoolOf(isPullList),
  390. SortType: sortType,
  391. }
  392. switch filterMode {
  393. case models.FilterModeAll:
  394. opts.RepoIDs = userRepoIDs
  395. case models.FilterModeAssign:
  396. opts.AssigneeID = ctxUser.ID
  397. case models.FilterModeCreate:
  398. opts.PosterID = ctxUser.ID
  399. case models.FilterModeMention:
  400. opts.MentionedID = ctxUser.ID
  401. }
  402. counts, err := models.CountIssuesByRepo(opts)
  403. if err != nil {
  404. ctx.ServerError("CountIssuesByRepo", err)
  405. return
  406. }
  407. opts.Page = page
  408. opts.PageSize = setting.UI.IssuePagingNum
  409. var labelIDs []int64
  410. selectLabels := ctx.Query("labels")
  411. if len(selectLabels) > 0 && selectLabels != "0" {
  412. labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
  413. if err != nil {
  414. ctx.ServerError("StringsToInt64s", err)
  415. return
  416. }
  417. }
  418. opts.LabelIDs = labelIDs
  419. if len(repoIDs) > 0 {
  420. opts.RepoIDs = repoIDs
  421. }
  422. issues, err := models.Issues(opts)
  423. if err != nil {
  424. ctx.ServerError("Issues", err)
  425. return
  426. }
  427. showReposMap := make(map[int64]*models.Repository, len(counts))
  428. for repoID := range counts {
  429. if repoID > 0 {
  430. if _, ok := showReposMap[repoID]; !ok {
  431. repo, err := models.GetRepositoryByID(repoID)
  432. if models.IsErrRepoNotExist(err) {
  433. ctx.NotFound("GetRepositoryByID", err)
  434. return
  435. } else if err != nil {
  436. ctx.ServerError("GetRepositoryByID", fmt.Errorf("[%d]%v", repoID, err))
  437. return
  438. }
  439. showReposMap[repoID] = repo
  440. }
  441. repo := showReposMap[repoID]
  442. // Check if user has access to given repository.
  443. perm, err := models.GetUserRepoPermission(repo, ctxUser)
  444. if err != nil {
  445. ctx.ServerError("GetUserRepoPermission", fmt.Errorf("[%d]%v", repoID, err))
  446. return
  447. }
  448. if !perm.CanRead(models.UnitTypeIssues) {
  449. log.Error("User created Issues in Repository which they no longer have access to: [%d]", repoID)
  450. }
  451. }
  452. }
  453. showRepos := models.RepositoryListOfMap(showReposMap)
  454. sort.Sort(showRepos)
  455. if err = showRepos.LoadAttributes(); err != nil {
  456. ctx.ServerError("LoadAttributes", err)
  457. return
  458. }
  459. var commitStatus = make(map[int64]*models.CommitStatus, len(issues))
  460. for _, issue := range issues {
  461. issue.Repo = showReposMap[issue.RepoID]
  462. if isPullList {
  463. commitStatus[issue.PullRequest.ID], _ = issue.PullRequest.GetLastCommitStatus()
  464. }
  465. }
  466. issueStats, err := models.GetUserIssueStats(models.UserIssueStatsOptions{
  467. UserID: ctxUser.ID,
  468. UserRepoIDs: userRepoIDs,
  469. FilterMode: filterMode,
  470. IsPull: isPullList,
  471. IsClosed: isShowClosed,
  472. })
  473. if err != nil {
  474. ctx.ServerError("GetUserIssueStats", err)
  475. return
  476. }
  477. allIssueStats, err := models.GetUserIssueStats(models.UserIssueStatsOptions{
  478. UserID: ctxUser.ID,
  479. UserRepoIDs: userRepoIDs,
  480. FilterMode: filterMode,
  481. IsPull: isPullList,
  482. IsClosed: isShowClosed,
  483. })
  484. if err != nil {
  485. ctx.ServerError("GetUserIssueStats All", err)
  486. return
  487. }
  488. var shownIssues int
  489. var totalIssues int
  490. if !isShowClosed {
  491. shownIssues = int(issueStats.OpenCount)
  492. totalIssues = int(allIssueStats.OpenCount)
  493. } else {
  494. shownIssues = int(issueStats.ClosedCount)
  495. totalIssues = int(allIssueStats.ClosedCount)
  496. }
  497. ctx.Data["Issues"] = issues
  498. ctx.Data["CommitStatus"] = commitStatus
  499. ctx.Data["Repos"] = showRepos
  500. ctx.Data["Counts"] = counts
  501. ctx.Data["IssueStats"] = issueStats
  502. ctx.Data["ViewType"] = viewType
  503. ctx.Data["SortType"] = sortType
  504. ctx.Data["RepoIDs"] = repoIDs
  505. ctx.Data["IsShowClosed"] = isShowClosed
  506. ctx.Data["TotalIssueCount"] = totalIssues
  507. if isShowClosed {
  508. ctx.Data["State"] = "closed"
  509. } else {
  510. ctx.Data["State"] = "open"
  511. }
  512. // Convert []int64 to string
  513. reposParam, _ := json.Marshal(repoIDs)
  514. ctx.Data["ReposParam"] = string(reposParam)
  515. pager := context.NewPagination(shownIssues, setting.UI.IssuePagingNum, page, 5)
  516. pager.AddParam(ctx, "type", "ViewType")
  517. pager.AddParam(ctx, "repos", "ReposParam")
  518. pager.AddParam(ctx, "sort", "SortType")
  519. pager.AddParam(ctx, "state", "State")
  520. pager.AddParam(ctx, "labels", "SelectLabels")
  521. pager.AddParam(ctx, "milestone", "MilestoneID")
  522. pager.AddParam(ctx, "assignee", "AssigneeID")
  523. ctx.Data["Page"] = pager
  524. ctx.HTML(200, tplIssues)
  525. }
  526. // ShowSSHKeys output all the ssh keys of user by uid
  527. func ShowSSHKeys(ctx *context.Context, uid int64) {
  528. keys, err := models.ListPublicKeys(uid)
  529. if err != nil {
  530. ctx.ServerError("ListPublicKeys", err)
  531. return
  532. }
  533. var buf bytes.Buffer
  534. for i := range keys {
  535. buf.WriteString(keys[i].OmitEmail())
  536. buf.WriteString("\n")
  537. }
  538. ctx.PlainText(200, buf.Bytes())
  539. }
  540. // ShowGPGKeys output all the public GPG keys of user by uid
  541. func ShowGPGKeys(ctx *context.Context, uid int64) {
  542. keys, err := models.ListGPGKeys(uid)
  543. if err != nil {
  544. ctx.ServerError("ListGPGKeys", err)
  545. return
  546. }
  547. entities := make([]*openpgp.Entity, 0)
  548. failedEntitiesID := make([]string, 0)
  549. for _, k := range keys {
  550. e, err := models.GPGKeyToEntity(k)
  551. if err != nil {
  552. if models.IsErrGPGKeyImportNotExist(err) {
  553. failedEntitiesID = append(failedEntitiesID, k.KeyID)
  554. continue //Skip previous import without backup of imported armored key
  555. }
  556. ctx.ServerError("ShowGPGKeys", err)
  557. return
  558. }
  559. entities = append(entities, e)
  560. }
  561. var buf bytes.Buffer
  562. headers := make(map[string]string)
  563. if len(failedEntitiesID) > 0 { //If some key need re-import to be exported
  564. headers["Note"] = fmt.Sprintf("The keys with the following IDs couldn't be exported and need to be reuploaded %s", strings.Join(failedEntitiesID, ", "))
  565. }
  566. writer, _ := armor.Encode(&buf, "PGP PUBLIC KEY BLOCK", headers)
  567. for _, e := range entities {
  568. err = e.Serialize(writer) //TODO find why key are exported with a different cipherTypeByte as original (should not be blocking but strange)
  569. if err != nil {
  570. ctx.ServerError("ShowGPGKeys", err)
  571. return
  572. }
  573. }
  574. writer.Close()
  575. ctx.PlainText(200, buf.Bytes())
  576. }
  577. // Email2User show user page via email
  578. func Email2User(ctx *context.Context) {
  579. u, err := models.GetUserByEmail(ctx.Query("email"))
  580. if err != nil {
  581. if models.IsErrUserNotExist(err) {
  582. ctx.NotFound("GetUserByEmail", err)
  583. } else {
  584. ctx.ServerError("GetUserByEmail", err)
  585. }
  586. return
  587. }
  588. ctx.Redirect(setting.AppSubURL + "/user/" + u.Name)
  589. }