Skip to content

Commit

Permalink
satellite/console: feature flag to toggle v2 as default UI
Browse files Browse the repository at this point in the history
This change adds a flag to toggle between serving the v1 or the v2 app
on the root path, especially making it the default satellite UI. It is
false by default, maintaining the current behavior, i.e. v1 app on root
path and v2 app on root path/v2.

Issue: #6681

Change-Id: Ifd48175e3c9f00d6187187f572f0c16fd30e09b6
  • Loading branch information
wilfred-asomanii authored and Storj Robot committed Jan 16, 2024
1 parent 270a2eb commit 37189fd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions satellite/console/consoleweb/config.go
Expand Up @@ -58,6 +58,7 @@ type FrontendConfig struct {
SignupActivationCodeEnabled bool `json:"signupActivationCodeEnabled"`
NewSignupFlowEnabled bool `json:"newSignupFlowEnabled"`
AllowedUsageReportDateRange time.Duration `json:"allowedUsageReportDateRange"`
PrefixVuetifyUI bool `json:"prefixVuetifyUI"`
}

// Satellites is a configuration value that contains a list of satellite names and addresses.
Expand Down
23 changes: 16 additions & 7 deletions satellite/console/consoleweb/server.go
Expand Up @@ -100,6 +100,7 @@ type Config struct {
PricingPackagesEnabled bool `help:"whether to allow purchasing pricing packages" default:"false" devDefault:"true"`
GalleryViewEnabled bool `help:"whether to show new gallery view" default:"true"`
UseVuetifyProject bool `help:"whether to use vuetify POC project" default:"false"`
PrefixVuetifyUI bool `help:"whether to prefix the v2 UI with '/v2/'" default:"true"`
VuetifyHost string `help:"the subdomain the vuetify POC project should be hosted on" default:""`
ObjectBrowserPaginationEnabled bool `help:"whether to use object browser pagination" default:"false"`
LimitIncreaseRequestEnabled bool `help:"whether to allow request limit increases directly from the UI" default:"false"`
Expand Down Expand Up @@ -404,15 +405,22 @@ func NewServer(logger *zap.Logger, config Config, service *console.Service, oidc
fs := http.FileServer(http.Dir(server.config.StaticDir))
router.PathPrefix("/static/").Handler(server.withCORS(server.brotliMiddleware(http.StripPrefix("/static", fs))))

if server.config.UseVuetifyProject {
if server.config.VuetifyHost != "" {
router.Host(server.config.VuetifyHost).Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
} else {
// if not using a custom subdomain for vuetify, use a path prefix on the same domain as the production app
router.PathPrefix("/v2").Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
if server.config.PrefixVuetifyUI {
if server.config.UseVuetifyProject {
if server.config.VuetifyHost != "" {
router.Host(server.config.VuetifyHost).Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
} else {
// if not using a custom subdomain for vuetify, use a path prefix on the same domain as the production app
router.PathPrefix("/v2").Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
}
}
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.appHandler)))
} else {
router.PathPrefix("/v2").Handler(server.withCORS(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, strings.TrimPrefix(r.URL.Path, "/v2"), http.StatusMovedPermanently)
})))
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.vuetifyAppHandler)))
}
router.PathPrefix("/").Handler(server.withCORS(http.HandlerFunc(server.appHandler)))
}

server.server = http.Server{
Expand Down Expand Up @@ -776,6 +784,7 @@ func (server *Server) frontendConfigHandler(w http.ResponseWriter, r *http.Reque
SignupActivationCodeEnabled: server.config.SignupActivationCodeEnabled,
NewSignupFlowEnabled: server.config.NewSignupFlowEnabled,
AllowedUsageReportDateRange: server.config.AllowedUsageReportDateRange,
PrefixVuetifyUI: server.config.PrefixVuetifyUI,
}

err := json.NewEncoder(w).Encode(&cfg)
Expand Down
3 changes: 3 additions & 0 deletions satellite/satellite-config.yaml.lock
Expand Up @@ -391,6 +391,9 @@ compensation.withheld-percents: 75,75,75,50,50,50,25,25,25,0,0,0,0,0,0
# placement-specific edge service URL overrides in the format {"placementID": {"authService": "...", "publicLinksharing": "...", "internalLinksharing": "..."}, "placementID2": ...}
# console.placement-edge-url-overrides: ""

# whether to prefix the v2 UI with '/v2/'
# console.prefix-vuetify-ui: true

# whether to allow purchasing pricing packages
# console.pricing-packages-enabled: false

Expand Down
1 change: 1 addition & 0 deletions web/satellite/src/types/config.gen.ts
Expand Up @@ -54,6 +54,7 @@ export class FrontendConfig {
signupActivationCodeEnabled: boolean;
newSignupFlowEnabled: boolean;
allowedUsageReportDateRange: number;
prefixVuetifyUI: boolean;
}

export class MultiCaptchaConfig {
Expand Down

0 comments on commit 37189fd

Please sign in to comment.