diff --git a/backend/src/jetstream/plugins/epinio/rancherproxy/interfaces/types.go b/backend/src/jetstream/plugins/epinio/rancherproxy/interfaces/types.go index 2cadb0d..6dfa96d 100644 --- a/backend/src/jetstream/plugins/epinio/rancherproxy/interfaces/types.go +++ b/backend/src/jetstream/plugins/epinio/rancherproxy/interfaces/types.go @@ -38,14 +38,15 @@ func GetBaseURL(ec echo.Context) string { return host } -func GetSelfLink(ec echo.Context, paths ...string) string { +func GetSelfLink(ec echo.Context, additionalPaths ...string) string { host := GetBaseURL(ec) - path := strings.Join(paths, "/") + path := strings.Join(additionalPaths, "/") + if len(path) > 0 { path = fmt.Sprintf("/%s", path) } - return fmt.Sprintf("https://%s%s%s", host, ec.Request().URL.String(), path) + return fmt.Sprintf("https://%s%s%s%s", host, ec.Request().URL.Host, ec.Request().URL.Path, path) } type AuthProvider struct { diff --git a/backend/src/jetstream/plugins/epinio/rancherproxy/norman/api.go b/backend/src/jetstream/plugins/epinio/rancherproxy/norman/api.go index 3c2a2c1..1eb0cc8 100644 --- a/backend/src/jetstream/plugins/epinio/rancherproxy/norman/api.go +++ b/backend/src/jetstream/plugins/epinio/rancherproxy/norman/api.go @@ -23,7 +23,7 @@ func GetAuthProviders(ec echo.Context, p jInterfaces.PortalProxy) error { // /v3/users func GetUser(ec echo.Context) error { - user := NewUser(interfaces.GetBaseURL(ec), ec.Get("user_id").(string)) + user := NewUser(interfaces.GetSelfLink(ec), ec.Get("user_id").(string)) return api.SendResponse(ec, user) } @@ -36,7 +36,7 @@ func TokenLogout(ec echo.Context, p jInterfaces.PortalProxy) error { // /v3/principals func GetPrincipals(ec echo.Context) error { - principal := NewPrincipal(interfaces.GetBaseURL(ec), ec.Get("user_id").(string)) + principal := NewPrincipal(interfaces.GetSelfLink(ec), ec.Get("user_id").(string)) return api.SendResponse(ec, principal) } diff --git a/backend/src/jetstream/plugins/epinio/rancherproxy/steve/userprefs.go b/backend/src/jetstream/plugins/epinio/rancherproxy/steve/userprefs.go index dc0c4e2..4acb89e 100644 --- a/backend/src/jetstream/plugins/epinio/rancherproxy/steve/userprefs.go +++ b/backend/src/jetstream/plugins/epinio/rancherproxy/steve/userprefs.go @@ -38,11 +38,11 @@ func NewUserPref(userId string) *interfaces.UserPref { func GetUserPrefs(c echo.Context) error { col := NewUserPrefCollection() col.Data = make([]interface{}, 1) - pref := createPref(c) + pref := createPref(c, true) col.Data[0] = pref host := interfaces.GetBaseURL(c) - base := fmt.Sprintf("https://%s%s", host, c.Request().URL.String()) + base := fmt.Sprintf("https://%s%s%s", host, c.Request().URL.Host, c.Request().URL.Path) col.Links["self"] = base @@ -51,10 +51,10 @@ func GetUserPrefs(c echo.Context) error { // Get user profile func GetSpecificUserPrefs(c echo.Context) error { - return c.JSON(http.StatusOK, createPref(c)) + return c.JSON(http.StatusOK, createPref(c, false)) } -func createPref(c echo.Context) *interfaces.UserPref { +func createPref(c echo.Context, isList bool) *interfaces.UserPref { userID := c.Get("user_id").(string) data := json.RawMessage(DefaultUserPreferences) @@ -62,7 +62,14 @@ func createPref(c echo.Context) *interfaces.UserPref { pref.Data = data host := interfaces.GetBaseURL(c) - user := fmt.Sprintf("https://%s%s/%s", host, c.Request().URL.String(), userID) + + var user string + if isList { + user = fmt.Sprintf("https://%s%s%s/%s", host, c.Request().URL.Host, c.Request().URL.Path, userID) + } else { + // Already contains user id in url + user = fmt.Sprintf("https://%s%s%s", host, c.Request().URL.Host, c.Request().URL.Path) + } pref.Links["self"] = user pref.Links["remove"] = user diff --git a/dashboard/pkg/epinio/models/services.js b/dashboard/pkg/epinio/models/services.js index e721a9a..3498ee1 100644 --- a/dashboard/pkg/epinio/models/services.js +++ b/dashboard/pkg/epinio/models/services.js @@ -33,8 +33,25 @@ export default class EpinioServiceModel extends EpinioNamespacedResource { .filter((a) => !!a); } - // ------------------------------------------------------------------ + get serviceDetails() { + return this._serviceDetails; + } + + /** + * Return the dashboard reserved getter for `details` (shown in MastHead) + */ + get details() { + return super.details; + } + /** + * When assigning Epinio details property ensure it goes to a temp value (instead of colliding with dashboard reserved `details` getter) + */ + set details(v) { + this._serviceDetails = v; + } + + // ------------------------------------------------------------------ get state() { return this.status; } @@ -95,4 +112,19 @@ export default class EpinioServiceModel extends EpinioNamespacedResource { bulkRemove(items, opt) { return bulkRemove(items, opt); } + + // Ensure when we clone that we preserve the description + toJSON() { + const data = super.toJSON(); + + // Ensure the epinio detail gets persisted in the right property + data.details = this._serviceDetails; + delete data._serviceDetails; + + return data; + } + + toSave() { + return this.toJSON(); + } }