Skip to content

fix(organisation): disable delete button when active subscription exists#7809

Open
afsuyadi wants to merge 2 commits into
Flagsmith:mainfrom
afsuyadi:fix/prevent-deletion-chargebee-subscription
Open

fix(organisation): disable delete button when active subscription exists#7809
afsuyadi wants to merge 2 commits into
Flagsmith:mainfrom
afsuyadi:fix/prevent-deletion-chargebee-subscription

Conversation

@afsuyadi

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • [✔] I have read the Contributing Guide.
  • [ ] I have added information to docs/ if required so people know about the feature.
  • [✔] I have filled in the "Changes" section below.
  • [✔] I have filled in the "How did you test this code" section below.

Changes

Contributes to #7700

  1. In DeleteOrganisation.tsx, the button Delete Organisation is disabled only when isLoading is true.
  2. However to prevent it being active, we need to add more condition which is related to billing subscription.
  3. The component DeleteOrganisation receives Organisation data, which has Subscription property.
  4. The interface Subscription itself accepts 2 properties; plan and cancellation_date, for which we can use them as the guarding condition.
  5. The Delete Organisation button will remain disabled if plan !== null and cancellation_date === null.

How did you test this code?

  1. In local, it's quite difficult for me to find the Billing tab under Organisation Settings and make sure both of the condition has disabled Delete Organisation button, though I can see it in the deployed flagsmith app (https://app.flagsmith.com/).
  2. To navigate through this, I use Python Shell to manipulate the database's data, and console.log to see the manipulated value of plan and cancellation_date.

Before changes:
Screencast from 18-06-26 08:44:50.webm

Input for python shell:

from organisations.models import Subscription
sub = Subscription.objects.first()
sub.plan = 'startup'
sub.cancellation_date = None
sub.save()
print(sub.id, sub.plan, sub.cancellation_date)

Input for console.log:

{console.log(
          organisation.subscription.plan,
          organisation.subscription.cancellation_date,
        )}

Output of python shell:
image

Output of console.log:
Screencast from 18-06-26 09:11:24.webm

@afsuyadi afsuyadi requested a review from a team as a code owner June 18, 2026 02:41
@afsuyadi afsuyadi requested review from kyle-ssg and removed request for a team June 18, 2026 02:41
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

@afsuyadi is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the front-end Issue related to the React Front End Dashboard label Jun 18, 2026
@manos-saratsis

This comment was marked as spam.

@Zaimwa9 Zaimwa9 assigned Zaimwa9 and unassigned kyle-ssg Jun 23, 2026
@Zaimwa9 Zaimwa9 requested review from Zaimwa9 and removed request for kyle-ssg June 23, 2026 10:50

@Zaimwa9 Zaimwa9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the contribution. We'll need to be more precise to not block free customers to delete their organization

Comment on lines +56 to +60
disabled={
isLoading ||
(organisation.subscription.plan !== null &&
organisation.subscription.cancellation_date === null)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would disable the button for all free accounts. We might want to use the planName directly, something like:
Utils.getPlanName(organisation.subscription?.plan ?? '') !== planNames.free && !organisation.subscription?.cancellation_date

@afsuyadi afsuyadi Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see. I just knew that planNames variable exists. Thanks for the additional info.

@afsuyadi afsuyadi force-pushed the fix/prevent-deletion-chargebee-subscription branch from 6ae43cd to 2093bbf Compare June 23, 2026 11:51
@afsuyadi afsuyadi requested a review from Zaimwa9 June 23, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants