Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature proposal] Multiple repositories selectable @ issues/PR page #6355

Closed
oscarlofwenhamn opened this issue Mar 18, 2019 · 9 comments · Fixed by #8741
Closed

[Feature proposal] Multiple repositories selectable @ issues/PR page #6355

oscarlofwenhamn opened this issue Mar 18, 2019 · 9 comments · Fixed by #8741
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/enhancement An improvement of existing functionality
Milestone

Comments

@oscarlofwenhamn
Copy link
Contributor

Description

As a user, I would like to be have the option to view issues and pull-requests from multiple repositories on their respective pages. Currently, selecting one repository removes the other repos from the list. This feels unnecessarily limiting, and not very intuitive. My suggestion is to use a similar style, but not remove the repos and also allow multiple selections.

Possible method

Currently, the page identifies what repo should be used by defining a number of variables including repo (e.g. ?type=all&repo=17&sort=&state=open). Passing multiple repo entries here could make multiple selection possible, something like
?type=all&repos[]=17&repos[]=21&repos[]=22&sort=&state=open.

I will test out a local fix, and post my findings here.

Illustration

multiple-repo-select

@oscarlofwenhamn oscarlofwenhamn changed the title [Feature request] Multiple repositories selectable @ issues/PR page [Feature proposal] Multiple repositories selectable @ issues/PR page Mar 18, 2019
@lunny lunny added the type/enhancement An improvement of existing functionality label Mar 18, 2019
@oscarlofwenhamn
Copy link
Contributor Author

A local fix for persisting the repo list was achieved by simply moving the three lines

if repoID > 0 {
    opts.RepoIDs = []int64{repoID}
}

in routers/user/home.go:Issues down from before the call

counts, err := models.CountIssuesByRepo(opts)

to right before

issues, err := models.Issues(opts)

This keeps the list of repositories, whilst still making the selected one highlighted and only showing its issues/PR's.

The next step is to enable multiple selections.

I'm not really sure if there exists a function for querying a list of integers similar to how the repo id is currently queried using repoID := ctx.QueryInt64("repo"), any suggestions are very welcome.

@oscarlofwenhamn
Copy link
Contributor Author

In gitea\routers\admin\notice.go something similar is achieved which is looking promising, using

strs := ctx.QueryStrings("ids[]")
ids := make([]int64, 0, len(strs))

@lunny
Copy link
Member

lunny commented Mar 19, 2019

@oscarlofwenhamn Could you send a PR for that?

@oscarlofwenhamn
Copy link
Contributor Author

I've started working on multiple selection, though if available I could use a tip on finding documentation regarding what functions are available in the tmpl, specifically for finding if a repo ID is in the list of selected repos. I'm thinking something like {{if in .RepoIDs .ID}}..., but I'm not aware of what functionality is available.

@jolheiser
Copy link
Member

The helper functions that Gitea provides can be found in modules/templates/helper.go

Things like and, or, etc. should be in the Go template documentation
There is technically a template package specifically for HTML, but most of the actions, pipelines, etc. are defined in the text package.

@oscarlofwenhamn
Copy link
Contributor Author

Thanks, @jolheiser. I managed to come across them, so it's good to know I'm not sniffing up the wrong tree.

I think I am quite close to a local fix, though it is pretty clunky to be honest. I will post it when I confirm it works, maybe we can find a way to slim it down.

@oscarlofwenhamn
Copy link
Contributor Author

There, it seems to be working.

In order to pass all other selected RepoIDs when selecting/deselecting a repo, I've constructed the following snippet, which is added to the href-attribute of the repo links instead of the old &repo part. I'm not sure if you think I should try to write a helper function, or if anyone has another idea of how to put it together, but either way I will look it over a few more times to make sure there's no slimmer way of doing it.

Basically, I want to include all elements of repos[], adding the selected repo to the list if it's not there and removing it from the list if it is there (selecting unselected repos, delesecting selected repos).

First draft:
$Repo corresponds to each element in {{range .Repos}}

{{with $include := true}}
	{{range $.RepoIDs}}
		{{if eq . $Repo.ID}}
			{{$include = false}}
		{{else}}
			&repos[]={{.}}
		{{end}}
	{{end}}
	{{if eq $include true}}
		&repos[]={{$Repo.ID}}
	{{end}}
{{end}}

@stale
Copy link

stale bot commented May 18, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label May 18, 2019
@oscarlofwenhamn
Copy link
Contributor Author

Still working on this in #6369 though not completely finished yet.

@stale stale bot removed the issue/stale label May 19, 2019
@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label May 19, 2019
techknowlogick pushed a commit that referenced this issue Dec 2, 2019
* 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()
@lunny lunny added this to the 1.11.0 milestone Dec 2, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/enhancement An improvement of existing functionality
Projects
None yet
3 participants