Skip to content

Commit

Permalink
ui: Add a route to view integration content
Browse files Browse the repository at this point in the history
  • Loading branch information
nemunaire committed Jun 1, 2023
1 parent 43fd913 commit 67e77d2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/ui/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/ddvk/rmfakecloud/internal/common"
"github.com/ddvk/rmfakecloud/internal/integrations"
"github.com/ddvk/rmfakecloud/internal/model"
"github.com/ddvk/rmfakecloud/internal/storage"
"github.com/ddvk/rmfakecloud/internal/ui/viewmodel"
Expand Down Expand Up @@ -647,3 +648,30 @@ func (app *ReactAppWrapper) deleteIntegration(c *gin.Context) {

c.AbortWithStatus(http.StatusNotFound)
}

func (app *ReactAppWrapper) exploreIntegration(c *gin.Context) {
uid := c.GetString(userIDContextKey)

integrationID := common.ParamS(intIDParam, c)

integrationProvider, err := integrations.GetIntegrationProvider(app.userStorer, uid, integrationID)
if err != nil {
log.Error(err)
c.AbortWithStatus(http.StatusInternalServerError)
return
}

folder := common.ParamS("path", c)
if folder == "" {
folder = "root"
}

response, err := integrationProvider.List(folder, 2)
if err != nil {
log.Error(err)
c.AbortWithStatus(http.StatusInternalServerError)
return
}

c.JSON(http.StatusOK, response)
}
2 changes: 2 additions & 0 deletions internal/ui/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func (app *ReactAppWrapper) RegisterRoutes(router *gin.Engine) {
auth.PUT("integrations/:intid", app.updateIntegration)
auth.DELETE("integrations/:intid", app.deleteIntegration)

auth.GET("integrations/:intid/explore/*path", app.exploreIntegration)

//admin
admin := auth.Group("")
admin.Use(app.adminMiddleware())
Expand Down

0 comments on commit 67e77d2

Please sign in to comment.