Pinned Images#1519
Conversation
| function imageActions() { | ||
| return { | ||
| errorMessage: '', | ||
| setPinned(pinned) { |
There was a problem hiding this comment.
This should just be an async function, using await and try...catch instead of .then and .catch.
There was a problem hiding this comment.
Rebased on #1527, addressing that refactoring here and in all other places that use .then
| window.location.reload(); | ||
| }).catch(function(error) { | ||
| if (error.response && error.response.data && error.response.data.error) { | ||
| alert(error.response.data.error); |
There was a problem hiding this comment.
I'm not sure if we need to be so aggressive about error catching. We have Sentry, so we can just get an immediate report if something fails in prod.
Even if we do want to keep the user-facing error message, we should re-throw the exception, so it ultimately bubbles up uncaught and Sentry picks it up.
There was a problem hiding this comment.
Rebased on #1527; error handling is more consistent now. We raise a generic error and rethrow the exception so Sentry can pick it up.
| response={200: None, 400: dict, 403: dict}, | ||
| include_in_schema=False, | ||
| ) | ||
| def image_set_pinned(request, id: int, payload: SetPinned): |
There was a problem hiding this comment.
Should this just be a form endpoint instead? That's a real question, not a suggestion.
@danlamanna Thoughts?
|
@brianhelba Thanks for the suggestions. I can definitely make these changes, but I'll first ask if we should make the same changes in the following places:
I had copied code from each of these places so I could mimic the pinning behavior of collections. Should we try to keep them the same? |
|
Good point. Since this is already getting to be a larger PR, I'd say is actually fine to keep here as-is, then make a follow-up PR to improve all these places. |
26b76b1 to
550dd78
Compare
7568855 to
5194c33
Compare
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Brian Helba <brian.helba@kitware.com>
550dd78 to
3ea0baa
Compare
This PR does the following:
pinnedboolean field to the Image modelpinnedfield on an Image. Only staff users are permitted to set the pinned state.("-pinned", "created")so that pinned Images are shown first.DynamicOrderCursorPagination, which extendsCursorPagination. Using this pagination class allows the user to specify the ordering with theorder_byquery parameter. Theimage_listandimage_searchendpoints now use this pagination class. This will allow us to prioritize pinned images in the gallery by specifying?order_by=-pinned,created.CursorPaginationclass, where only the first field in the ordering was honored during pagination.