Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check to which plan the org is changing when applying the credits #1574

Merged
merged 6 commits into from
Dec 24, 2024

Conversation

ernstmul
Copy link
Contributor

What does this PR do?

Applying credits can make an organisation switch plans. This additional check prevents an organisation from downgrading when applying credits.

Have you read the Contributing Guidelines on issues?

@ernstmul ernstmul requested a review from stnguyen90 December 20, 2024 10:12
}
}

$: billingPlan = getNewBillingPlan(selectedOrg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArmanNik and @TorstenDittmann might now more on Svelte best practices, but I don't think we need to create a new function for this. You can put an if statement directly here like:

$: if (execution?.errors) {
selectedResponse = 'errors';
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I've changed it to a ternary operation. The if statement way didn't seem to do the trick correctly (perhaps @TorstenDittmann or @ArmanNik can point out later on what I'm doing wrong there haha).

Comment on lines 194 to 195
if (organization?.billingPlan === BillingPlan.SCALE) {
return BillingPlan.SCALE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still a bit hesitant to hardcode stuff here. For example, enterprise plans will run into a problem with this logic.

Maybe we can rely on the plan order (after it gets fixed for the education plan)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah definitely! However atm we don't have a plan order in code afaik?

Copy link
Member

@ItzNotABug ItzNotABug Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ernstmul We don't have an exact order [there's tier-* format though] but possibly we could check via getNextTier, not 100% sure as it doesn't include anything about enterprise/custom tiers atm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tier-* doesn't hold up anymore, since we now also have auto-1 and cont-1! getNextTier would definitely work, but perhaps its nice get this info from BE?

@@ -25,6 +25,7 @@ export const load: LayoutLoad = async ({ fetch, depends, parent }) => {
let plansInfo = new Map<Tier, Plan>();
if (isCloud) {
const plansArray = await sdk.forConsole.billing.getPlansInfo();
console.log('plansArray', plansArray);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, fixed!

Comment on lines 194 to 195
if (organization?.billingPlan === BillingPlan.SCALE) {
return BillingPlan.SCALE;
Copy link
Member

@ItzNotABug ItzNotABug Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ernstmul We don't have an exact order [there's tier-* format though] but possibly we could check via getNextTier, not 100% sure as it doesn't include anything about enterprise/custom tiers atm.

Copy link
Member

@ItzNotABug ItzNotABug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick

@ernstmul ernstmul merged commit 24e4cfa into main Dec 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants