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

home.go 17 kB

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