feat(favorites): implement user favorites and recents functionality
Introduced a new API client for managing user favorites, allowing users to list, add, and remove starred resources. Enhanced the sidebar to display favorites and recents, improving user navigation. Updated internationalization files to include relevant labels and tooltips for the new features across multiple languages. Refs: #1303
This commit is contained in:
@@ -72,6 +72,7 @@ type RouterParams struct {
|
||||
FAQHandler *handler.FAQHandler
|
||||
TagHandler *handler.TagHandler
|
||||
CustomAgentHandler *handler.CustomAgentHandler
|
||||
UserFavoriteHandler *handler.UserResourceFavoriteHandler
|
||||
SkillHandler *handler.SkillHandler
|
||||
OrganizationHandler *handler.OrganizationHandler
|
||||
IMHandler *handler.IMHandler
|
||||
@@ -191,6 +192,7 @@ func NewRouter(params RouterParams) *gin.Engine {
|
||||
RegisterWebSearchProviderRoutes(v1, params.WebSearchProviderHandler, params.WebSearchCredentialsHandler, rbacGuards)
|
||||
RegisterVectorStoreRoutes(v1, params.VectorStoreHandler, rbacGuards)
|
||||
RegisterCustomAgentRoutes(v1, params.CustomAgentHandler, rbacGuards)
|
||||
RegisterUserFavoriteRoutes(v1, params.UserFavoriteHandler, rbacGuards)
|
||||
RegisterSkillRoutes(v1, params.SkillHandler, rbacGuards)
|
||||
RegisterOrganizationRoutes(v1, params.OrganizationHandler, rbacGuards)
|
||||
RegisterIMChannelRoutes(v1, params.IMHandler, rbacGuards)
|
||||
@@ -804,6 +806,22 @@ func RegisterCustomAgentRoutes(r *gin.RouterGroup, agentHandler *handler.CustomA
|
||||
r.GET("/agents/:id/suggested-questions", g.Viewer(), agentHandler.GetSuggestedQuestions)
|
||||
}
|
||||
|
||||
// RegisterUserFavoriteRoutes wires the per-user starred-resource endpoints.
|
||||
//
|
||||
// Authorization: the handler always derives (user_id, tenant_id) from the
|
||||
// auth context — there is no admin-style "see another user's favorites"
|
||||
// path — so a Viewer floor is the right gate. The endpoints intentionally
|
||||
// don't follow the OwnedXOrAdmin pattern: favorites aren't owned by the
|
||||
// resource's creator, they're owned by the user *doing* the starring.
|
||||
func RegisterUserFavoriteRoutes(r *gin.RouterGroup, h *handler.UserResourceFavoriteHandler, g *rbacGuards) {
|
||||
favs := r.Group("/user/favorites")
|
||||
{
|
||||
favs.GET("", g.Viewer(), h.ListFavorites)
|
||||
favs.POST("", g.Viewer(), h.AddFavorite)
|
||||
favs.DELETE("/:type/:id", g.Viewer(), h.RemoveFavorite)
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterSkillRoutes registers skill routes.
|
||||
//
|
||||
// PR 2 currently only exposes a read-only `ListSkills`; gated to
|
||||
|
||||
Reference in New Issue
Block a user