Skip to content

[need-help] Add pinned mod for repo #12498

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

Closed
wants to merge 25 commits into from

Conversation

a1012112796
Copy link
Member

@a1012112796 a1012112796 commented Aug 16, 2020

similar with github, use card ui to show pinned repos.

example view:

image


image

@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2020

Codecov Report

Merging #12498 into master will decrease coverage by 0.02%.
The diff coverage is 36.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12498      +/-   ##
==========================================
- Coverage   43.23%   43.21%   -0.03%     
==========================================
  Files         650      652       +2     
  Lines       72041    72234     +193     
==========================================
+ Hits        31150    31217      +67     
- Misses      35844    35959     +115     
- Partials     5047     5058      +11     
Impacted Files Coverage Δ
models/migrations/migrations.go 2.46% <ø> (ø)
models/migrations/v150.go 0.00% <0.00%> (ø)
modules/auth/user_form.go 39.65% <ø> (ø)
modules/migrations/gitlab.go 1.04% <0.00%> (-0.03%) ⬇️
routers/org/setting.go 0.00% <0.00%> (ø)
routers/user/setting/profile.go 30.40% <0.00%> (-11.20%) ⬇️
routers/org/home.go 55.00% <25.00%> (-10.91%) ⬇️
models/error.go 34.89% <40.00%> (-0.43%) ⬇️
routers/user/profile.go 51.75% <71.87%> (+3.28%) ⬆️
models/user_pinnedrepo.go 83.33% <83.33%> (ø)
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7354efe...56b6f99. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 16, 2020
@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Aug 16, 2020
@lunny
Copy link
Member

lunny commented Aug 16, 2020

I think the UI should be adjusted

@lafriks lafriks added this to the 1.13.0 milestone Aug 16, 2020
@lafriks
Copy link
Member

lafriks commented Aug 16, 2020

We should probably limit number of allowed pinned repositories per user/org

@mrsdizzie
Copy link
Member

Cool : )

I think this should be a user (and org) setting and not repo. Github lets you pin repos you don't own but contribute to. Then user could also pin an org repo on their personal page too.

So a user would store a list of repos they have personally pinned instead of a repo being marked as pinned

Screen Shot 2020-08-16 at 4 34 52 PM

@a1012112796
Copy link
Member Author

Cool : )

I think this should be a user (and org) setting and not repo. Github lets you pin repos you don't own but contribute to. Then user could also pin an org repo on their personal page too.

So a user would store a list of repos they have personally pinned instead of a repo being marked as pinned

Screen Shot 2020-08-16 at 4 34 52 PM

Your suggestion is reasonable, but unfortunately we do not have a mechanism to find out whether a user has contribution in another repository, so we are not able to achieve the same effect with Github now, but I will adjust it to the user's property and wait for the introduction of the contribution statistics mechanism.

@a1012112796 a1012112796 marked this pull request as draft August 17, 2020 00:57
@gsantner
Copy link

gsantner commented Aug 17, 2020

My thought: Why not allow to pin any repository? Independent to whether or not you developed on it, or own it.

Just an example: Gitea org or a gitea developer could Pin gitnex android client, even though it's not under it's org, and the org/user didn't contribute to the project. To highlight a project is the main purpose after all, right?

@mrsdizzie
Copy link
Member

@gsantner The main purpose for the page is to show an overview of repos and contributions made by a user and not to highlight just any project. Pinning just allows you to control what shows at the top when you have a large list that would move off screen. So if I would rather people see my Gitea contribution first instead of some test repos I made.

See Github pinning which this feature says to be based off of

@gsantner
Copy link

gsantner commented Aug 17, 2020

So if I would rather people see my Gitea contribution first instead of some test repos I made.

And I would say: So I would rather people see my highlight Gitea repos first instead of some test repos I made.

See Github pinning which this feature says to be based off of

Well, just because one platform has it that way, not means every others must copy-cat it in the same way.

@mrsdizzie
Copy link
Member

Changing/breaking the behavior of the repository page which exists now with the intentional purpose of only showing a users repositories would be outside the scope of this PR.

There is already the stars page for listing unrelated repos that you like/want to highlight. Perhaps in the future a more general overview type page that has a favorites section as well with some pinned starred repos.

similar with github, use card ui to show pinned repos.

Signed-off-by: a1012112796 <[email protected]>
@a1012112796 a1012112796 marked this pull request as ready for review August 19, 2020 02:10
@silverwind
Copy link
Member

UI looks weird to me, especially the pin icon. Maybe make it a bit closer to what GH has?

@a1012112796
Copy link
Member Author

UI looks weird to me, especially the pin icon. Maybe make it a bit closer to what GH has?

Thounds great, but it means we should load all repo data to show config modal ui like gh which will break the original intention for split pages. Maybe the best way is to load data when press the "config button". But it's hard work for me(Sadly I have little knowledge about ui), and now maybe only heatmap uses this way in gitea. Or maybe we can add an individual page for configuring "pinnde repos". I wonder...

@lunny
Copy link
Member

lunny commented Aug 25, 2020

A close button or operation icons on the right top is better than the current design.

@silverwind
Copy link
Member

I can probably do a few style tweaks once the basic functionality is there. Are you planning to add a close button?

Drag-and-Drop might also be nice but would probably require a JS library.

@a1012112796
Copy link
Member Author

Are you planning to add a close button?

I'm sorry, But I can't understand the meanning of close button, Can you give me more detial? Thanks.

@silverwind
Copy link
Member

A button that removes the pinned entry basically.

@lunny
Copy link
Member

lunny commented Sep 9, 2020

Could you resolve the conflicts?

@lunny
Copy link
Member

lunny commented Sep 10, 2020

@a1012112796 I think we need a new design. Current one needs some improvements.

@silverwind
Copy link
Member

Yes, I think we should attempt to do it similar to GitHub, e.g. add primary language circle, remove the grey tag (it's already obvious that it's pinned based on the title above) and a small icon-button on the top-right to un-pin.

Comment on lines 460 to 461
pinned_repo_success = pinned repo success
unpinned_repo_success = unpinned repo success
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pinned_repo_success = pinned repo success
unpinned_repo_success = unpinned repo success
pinned_repo_success = Successfully pinned repo
unpinned_repo_success = Successfully unpinned repo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These also don't appear to be being used anywhere

Comment on lines 124 to 134
for _, repo := range repos {
if has, err = org.IsPinnedRepoExist(repo.ID); err != nil {
ctx.ServerError("IsPinnedRepoExist", err)
return
}

if has {
pinnedRepos = append(pinnedRepos, repo)
repo.IsPinned = true
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is highly inefficient.

This code involves doing len(repos) individual queries against the db. We would be better off with a single query that returns all the pinned repos for an organization, putting them in a map and then checking each repo id in that set.

We know that the number of pinned repos is in general going to be smaller than the total number of repos in an organization. (certainly it's possible that a perverse organization might decide to pin all of their private repos and none of the public ones but that would be rare.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, It's really a hard thing to balance memory usage and run-efficiency here. How about this? Thanks. 73ab596

Comment on lines 251 to 261
for _, repo := range repos {
if has, err = ctxUser.IsPinnedRepoExist(repo.ID); err != nil {
ctx.ServerError("IsPinnedRepoExist", err)
return
}

if has {
pinnedRepos = append(pinnedRepos, repo)
repo.IsPinned = true
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the above comment. Not efficient.

Comment on lines 263 to 281
exitsPinnedRepoIDs := make([]int64, 0, len(pinnedRepos))
for _, repo := range pinnedRepos {
exitsPinnedRepoIDs = append(exitsPinnedRepoIDs, repo.ID)
}

var pinnedRepos2 []*models.Repository

pinnedRepos2, err = ctxUser.GetPinnedRepos(ctx.User, exitsPinnedRepoIDs, true)
if err != nil {
ctx.ServerError("GetPinnedRepos(true)", err)
return
}

if len(pinnedRepos2) > 0 {
for _, repo := range pinnedRepos2 {
repo.IsPinned = true
}
pinnedRepos = append(pinnedRepos, pinnedRepos2...)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exitsPinnedRepoIDs := make([]int64, 0, len(pinnedRepos))
for _, repo := range pinnedRepos {
exitsPinnedRepoIDs = append(exitsPinnedRepoIDs, repo.ID)
}
var pinnedRepos2 []*models.Repository
pinnedRepos2, err = ctxUser.GetPinnedRepos(ctx.User, exitsPinnedRepoIDs, true)
if err != nil {
ctx.ServerError("GetPinnedRepos(true)", err)
return
}
if len(pinnedRepos2) > 0 {
for _, repo := range pinnedRepos2 {
repo.IsPinned = true
}
pinnedRepos = append(pinnedRepos, pinnedRepos2...)
}
// Now add the ctxUsers other pinned repos that we can see.
// - but we should exclude all of the currently obtained repos as we don't want to get duplicates
excludeRepoIDs := make([]int64, 0, len(pinnedRepos))
for _, repo := range pinnedRepos {
excludeRepoIDs = append(excludeRepoIDs, repo.ID)
}
additionalPinnedRepos, err := ctxUser.GetPinnedRepos(ctx.User, excludeRepoIDs, true)
if err != nil {
ctx.ServerError("GetPinnedRepos(true)", err)
return
}
if len(additionalPinnedRepos) > 0 {
for _, repo := range additionalPinnedRepos {
repo.IsPinned = true
}
pinnedRepos = append(pinnedRepos, additionalPinnedRepos...)
}

Comment on lines +2377 to +2385
$('.pinned-repo-btn').on('click', function (e) {
const $this = $(this);
e.preventDefault();
$.post($this.data('url'), {
_csrf: csrf,
name: $this.data('name'),
status: $this.data('status'),
is_btn: true,
}).done(reload());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could return the new state of the button at the end of this and just update the button.... It seems strange to go to the effort of using a javascript to replace a form when you're not going to prevent a reload.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, unless the changes after the POST are significant work (button update is not), just update the DOM in JS without a reload, it's a much better user experience.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, unless the changes after the POST are significant work (button update is not), just update the DOM in JS without a reload, it's a much better user experience.

But It will not only change the button, but also will change the pinned repos list ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's fine but sub-optimal. I know that in other parts of the UI we sometimes respond with HTML in the POST which is then replaced in JS, maybe that is an option.

@mrsdizzie
Copy link
Member

Having another look since changes have been made -- the very large "UnPinned" button doesn't look very good here and the entire top area looks pretty cluttered now with 2 search bars on top of each other.

Again I think the Github UI is much better/cleaner for this

@lunny lunny modified the milestones: 1.13.0, 1.14.0 Sep 18, 2020
@lunny
Copy link
Member

lunny commented Sep 18, 2020

@a1012112796 Let's move this to v1.14 so that you have enough time to improve the UI.

@stale
Copy link

stale bot commented Nov 24, 2020

This pull request 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 months. Thank you for your contributions.

@stale stale bot added the issue/stale label Nov 24, 2020
@6543
Copy link
Member

6543 commented Nov 24, 2020

@a1012112796 would be nice if you have time to resolve conflicts :)

@stale stale bot removed the issue/stale label Nov 24, 2020
@a1012112796 a1012112796 changed the title Add pinned mod for repo [need-help] Add pinned mod for repo Nov 26, 2020
@codecov-io
Copy link

Codecov Report

Merging #12498 (e1f22fe) into master (03fa2ec) will increase coverage by 0.00%.
The diff coverage is 38.04%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #12498    +/-   ##
========================================
  Coverage   42.24%   42.24%            
========================================
  Files         697      699     +2     
  Lines       76630    76814   +184     
========================================
+ Hits        32370    32452    +82     
- Misses      38937    39035    +98     
- Partials     5323     5327     +4     
Impacted Files Coverage Δ
models/migrations/migrations.go 2.44% <ø> (ø)
models/migrations/v160.go 0.00% <0.00%> (ø)
modules/auth/user_form.go 39.65% <ø> (ø)
routers/org/setting.go 0.00% <0.00%> (ø)
routers/user/setting/profile.go 31.50% <0.00%> (-8.38%) ⬇️
routers/org/home.go 55.20% <25.00%> (-10.40%) ⬇️
models/error.go 36.80% <40.00%> (+0.05%) ⬆️
routers/user/profile.go 51.29% <71.87%> (+3.29%) ⬆️
models/user_pinnedrepo.go 83.33% <83.33%> (ø)
models/models.go 56.15% <100.00%> (+0.21%) ⬆️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03fa2ec...e1f22fe. Read the comment docs.

@a1012112796 a1012112796 removed this from the 1.14.0 milestone Jan 27, 2021
@a1012112796 a1012112796 closed this May 1, 2023
@a1012112796 a1012112796 deleted the feature/Pinned_repo branch May 1, 2023 06:30
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.