Explorar o código

Merge pull request #1631 from porter-dev/nico/add-env-var-disable-billing-to-prod

[IMPROVEMENT] Add env var disable billing to prod
Nicolas Frati %!s(int64=4) %!d(string=hai) anos
pai
achega
d219aff2ac

+ 1 - 0
.github/workflows/production.yaml

@@ -40,6 +40,7 @@ jobs:
           ENABLE_SENTRY=true
           ENABLE_SENTRY=true
           SENTRY_DSN=${{secrets.SENTRY_DSN}}
           SENTRY_DSN=${{secrets.SENTRY_DSN}}
           SENTRY_ENV=production
           SENTRY_ENV=production
+          DISABLE_BILLING=true
           EOL
           EOL
       - name: Build
       - name: Build
         run: |
         run: |

+ 1 - 0
.github/workflows/staging.yaml

@@ -39,6 +39,7 @@ jobs:
           ENABLE_SENTRY=true
           ENABLE_SENTRY=true
           SENTRY_DSN=${{secrets.SENTRY_DSN}}
           SENTRY_DSN=${{secrets.SENTRY_DSN}}
           SENTRY_ENV=staging
           SENTRY_ENV=staging
+          DISABLE_BILLING=true
           EOL
           EOL
       - name: Build
       - name: Build
         run: |
         run: |

+ 25 - 23
dashboard/src/main/home/Home.tsx

@@ -27,7 +27,6 @@ import discordLogo from "../../assets/discord.svg";
 import Onboarding from "./onboarding/Onboarding";
 import Onboarding from "./onboarding/Onboarding";
 import ModalHandler from "./ModalHandler";
 import ModalHandler from "./ModalHandler";
 import { NewProjectFC } from "./new-project/NewProject";
 import { NewProjectFC } from "./new-project/NewProject";
-import { BuildpackSelection } from "components/repo-selector/ActionDetails";
 
 
 // Guarded components
 // Guarded components
 const GuardedProjectSettings = fakeGuardedRoute("settings", "", [
 const GuardedProjectSettings = fakeGuardedRoute("settings", "", [
@@ -253,28 +252,31 @@ class Home extends Component<PropsType, StateType> {
 
 
     if (prevProps.currentProject?.id !== this.props.currentProject?.id) {
     if (prevProps.currentProject?.id !== this.props.currentProject?.id) {
       this.checkOnboarding();
       this.checkOnboarding();
-      this.checkIfProjectHasBilling(this?.context?.currentProject?.id)
-        .then((isBillingEnabled) => {
-          if (isBillingEnabled) {
-            api
-              .getUsage(
-                "<token>",
-                {},
-                { project_id: this.context?.currentProject?.id }
-              )
-              .then((res) => {
-                const usage = res.data;
-                this.context.setUsage(usage);
-                if (usage.exceeded) {
-                  this.context.setCurrentModal("UsageWarningModal", {
-                    usage,
-                  });
-                }
-              })
-              .catch(console.log);
-          }
-        })
-        .catch(console.log);
+
+      if (!process.env.DISABLE_BILLING) {
+        this.checkIfProjectHasBilling(this?.context?.currentProject?.id)
+          .then((isBillingEnabled) => {
+            if (isBillingEnabled) {
+              api
+                .getUsage(
+                  "<token>",
+                  {},
+                  { project_id: this.context?.currentProject?.id }
+                )
+                .then((res) => {
+                  const usage = res.data;
+                  this.context.setUsage(usage);
+                  if (usage.exceeded) {
+                    this.context.setCurrentModal("UsageWarningModal", {
+                      usage,
+                    });
+                  }
+                })
+                .catch(console.log);
+            }
+          })
+          .catch(console.log);
+      }
     }
     }
 
 
     if (
     if (