From 6ae28e23062190cf8d1c952d487498c7e7c8bd9c Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 16 Oct 2023 14:55:21 +0300 Subject: [PATCH] satellite/{web,console}: enable/disable billing features depending on config value Added client side logic to disable billing features depending on config value. Disabled billing endpoints if billing is disabled. Issue: https://github.com/storj/storj-private/issues/464 Change-Id: I6e70dc5e2372953b613ddab9f19cb94f008935ce --- satellite/console/consoleweb/server.go | 48 ++++++++++--------- .../modals/CreateProjectPromptModal.vue | 13 +++-- .../src/components/navigation/AccountArea.vue | 33 ++++++++----- .../navigation/MobileNavigation.vue | 26 ++++++---- .../project/dashboard/DateRangeSelection.vue | 3 +- .../project/dashboard/LimitsArea.vue | 14 +++++- .../project/dashboard/ProjectDashboard.vue | 33 +++++++++---- web/satellite/src/router/index.ts | 6 +++ .../views/all-dashboard/AllDashboardArea.vue | 27 +++++++---- .../AllProjectsDashboardBanners.vue | 16 +++++-- .../all-dashboard/components/Heading.vue | 13 +++-- .../components/MyAccountButton.vue | 7 ++- .../src/views/dashboard/DashboardArea.vue | 47 +++++++++--------- web/satellite/vite.config.js | 5 +- 14 files changed, 191 insertions(+), 100 deletions(-) diff --git a/satellite/console/consoleweb/server.go b/satellite/console/consoleweb/server.go index 58b742055e4c..c5d3fe3a37f8 100644 --- a/satellite/console/consoleweb/server.go +++ b/satellite/console/consoleweb/server.go @@ -336,29 +336,31 @@ func NewServer(logger *zap.Logger, config Config, service *console.Service, oidc abRouter.Handle("/hit/{action}", http.HandlerFunc(abController.SendHit)).Methods(http.MethodPost, http.MethodOptions) } - paymentController := consoleapi.NewPayments(logger, service, accountFreezeService, packagePlans) - paymentsRouter := router.PathPrefix("/api/v0/payments").Subrouter() - paymentsRouter.Use(server.withCORS) - paymentsRouter.Use(server.withAuth) - paymentsRouter.Handle("/cards", server.userIDRateLimiter.Limit(http.HandlerFunc(paymentController.AddCreditCard))).Methods(http.MethodPost, http.MethodOptions) - paymentsRouter.HandleFunc("/cards", paymentController.MakeCreditCardDefault).Methods(http.MethodPatch, http.MethodOptions) - paymentsRouter.HandleFunc("/cards", paymentController.ListCreditCards).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.HandleFunc("/cards/{cardId}", paymentController.RemoveCreditCard).Methods(http.MethodDelete, http.MethodOptions) - paymentsRouter.HandleFunc("/account/charges", paymentController.ProjectsCharges).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.HandleFunc("/account/balance", paymentController.AccountBalance).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.HandleFunc("/account", paymentController.SetupAccount).Methods(http.MethodPost, http.MethodOptions) - paymentsRouter.HandleFunc("/wallet", paymentController.GetWallet).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.HandleFunc("/wallet", paymentController.ClaimWallet).Methods(http.MethodPost, http.MethodOptions) - paymentsRouter.HandleFunc("/wallet/payments", paymentController.WalletPayments).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.HandleFunc("/wallet/payments-with-confirmations", paymentController.WalletPaymentsWithConfirmations).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.HandleFunc("/billing-history", paymentController.BillingHistory).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.HandleFunc("/invoice-history", paymentController.InvoiceHistory).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.Handle("/coupon/apply", server.userIDRateLimiter.Limit(http.HandlerFunc(paymentController.ApplyCouponCode))).Methods(http.MethodPatch, http.MethodOptions) - paymentsRouter.HandleFunc("/coupon", paymentController.GetCoupon).Methods(http.MethodGet, http.MethodOptions) - paymentsRouter.HandleFunc("/pricing", paymentController.GetProjectUsagePriceModel).Methods(http.MethodGet, http.MethodOptions) - if config.PricingPackagesEnabled { - paymentsRouter.HandleFunc("/purchase-package", paymentController.PurchasePackage).Methods(http.MethodPost, http.MethodOptions) - paymentsRouter.HandleFunc("/package-available", paymentController.PackageAvailable).Methods(http.MethodGet, http.MethodOptions) + if config.BillingFeaturesEnabled { + paymentController := consoleapi.NewPayments(logger, service, accountFreezeService, packagePlans) + paymentsRouter := router.PathPrefix("/api/v0/payments").Subrouter() + paymentsRouter.Use(server.withCORS) + paymentsRouter.Use(server.withAuth) + paymentsRouter.Handle("/cards", server.userIDRateLimiter.Limit(http.HandlerFunc(paymentController.AddCreditCard))).Methods(http.MethodPost, http.MethodOptions) + paymentsRouter.HandleFunc("/cards", paymentController.MakeCreditCardDefault).Methods(http.MethodPatch, http.MethodOptions) + paymentsRouter.HandleFunc("/cards", paymentController.ListCreditCards).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.HandleFunc("/cards/{cardId}", paymentController.RemoveCreditCard).Methods(http.MethodDelete, http.MethodOptions) + paymentsRouter.HandleFunc("/account/charges", paymentController.ProjectsCharges).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.HandleFunc("/account/balance", paymentController.AccountBalance).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.HandleFunc("/account", paymentController.SetupAccount).Methods(http.MethodPost, http.MethodOptions) + paymentsRouter.HandleFunc("/wallet", paymentController.GetWallet).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.HandleFunc("/wallet", paymentController.ClaimWallet).Methods(http.MethodPost, http.MethodOptions) + paymentsRouter.HandleFunc("/wallet/payments", paymentController.WalletPayments).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.HandleFunc("/wallet/payments-with-confirmations", paymentController.WalletPaymentsWithConfirmations).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.HandleFunc("/billing-history", paymentController.BillingHistory).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.HandleFunc("/invoice-history", paymentController.InvoiceHistory).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.Handle("/coupon/apply", server.userIDRateLimiter.Limit(http.HandlerFunc(paymentController.ApplyCouponCode))).Methods(http.MethodPatch, http.MethodOptions) + paymentsRouter.HandleFunc("/coupon", paymentController.GetCoupon).Methods(http.MethodGet, http.MethodOptions) + paymentsRouter.HandleFunc("/pricing", paymentController.GetProjectUsagePriceModel).Methods(http.MethodGet, http.MethodOptions) + if config.PricingPackagesEnabled { + paymentsRouter.HandleFunc("/purchase-package", paymentController.PurchasePackage).Methods(http.MethodPost, http.MethodOptions) + paymentsRouter.HandleFunc("/package-available", paymentController.PackageAvailable).Methods(http.MethodGet, http.MethodOptions) + } } bucketsController := consoleapi.NewBuckets(logger, service) diff --git a/web/satellite/src/components/modals/CreateProjectPromptModal.vue b/web/satellite/src/components/modals/CreateProjectPromptModal.vue index 6f43a7d2880e..34e596be5950 100644 --- a/web/satellite/src/components/modals/CreateProjectPromptModal.vue +++ b/web/satellite/src/components/modals/CreateProjectPromptModal.vue @@ -9,7 +9,7 @@

Get more projects

- -