-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
I think the UI should be adjusted |
We should probably limit number of allowed pinned repositories per user/org |
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 |
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? |
@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 |
And I would say: So I would rather people see my highlight Gitea repos first instead of some test repos I made.
Well, just because one platform has it that way, not means every others must copy-cat it in the same way. |
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]>
7f94e75
to
156635a
Compare
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... |
A close button or operation icons on the right top is better than the current design. |
* remove unnecessary INDEX * fix transfer
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. |
I'm sorry, But I can't understand the meanning of |
A button that removes the pinned entry basically. |
Could you resolve the conflicts? |
@a1012112796 I think we need a new design. Current one needs some improvements. |
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. |
options/locale/locale_en-US.ini
Outdated
pinned_repo_success = pinned repo success | ||
unpinned_repo_success = unpinned repo success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pinned_repo_success = pinned repo success | |
unpinned_repo_success = unpinned repo success | |
pinned_repo_success = Successfully pinned repo | |
unpinned_repo_success = Successfully unpinned repo |
There was a problem hiding this comment.
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
routers/org/home.go
Outdated
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 | ||
} | ||
} |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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
routers/user/profile.go
Outdated
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 | ||
} | ||
} |
There was a problem hiding this comment.
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.
routers/user/profile.go
Outdated
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...) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...) | |
} |
$('.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()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ...
There was a problem hiding this comment.
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.
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 |
@a1012112796 Let's move this to v1.14 so that you have enough time to improve the UI. |
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. |
@a1012112796 would be nice if you have time to resolve conflicts :) |
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
similar with github, use card ui to show pinned repos.
example view: