From 2ed9e7fa6d9c86115298dc2723e67a17e17321c0 Mon Sep 17 00:00:00 2001 From: "blinkagent[bot]" <237617714+blinkagent[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 07:34:51 +0000 Subject: [PATCH] fix: show accurate removal dialog for expired licenses (#22018) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary The license removal confirmation dialog always showed: > Removing this license will disable all Premium features. You add a new license at any time. This is misleading when the license being removed is already expired — an expired license isn't providing any features, so removing it won't disable anything. ## Changes - Extracted `isExpired` variable in `LicenseCard` (reusing the existing expiry check) - Made the dialog description conditional: - **Expired license**: "This license has already expired and is not providing any features. Removing it will not affect your current entitlements." - **Active license**: "Removing this license will disable all Premium features. You can add a new license at any time." - Also fixed a minor typo in the active license message ("You add" → "You can add") - Added two new tests covering both dialog variants ## Testing All 5 `LicenseCard` tests pass, including the 2 new ones: - `shows expired removal message for expired licenses` - `shows disabling features warning for active licenses` --------- Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> --- .../LicensesSettingsPage/LicenseCard.test.tsx | 39 +++++++++++++++++++ .../LicensesSettingsPage/LicenseCard.tsx | 12 +++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.test.tsx b/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.test.tsx index 59f1182ac7..09737c1e98 100644 --- a/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.test.tsx +++ b/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.test.tsx @@ -1,6 +1,7 @@ import { MockLicenseResponse } from "testHelpers/entities"; import { render } from "testHelpers/renderHelpers"; import { screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; import { LicenseCard } from "./LicenseCard"; describe("LicenseCard", () => { @@ -40,6 +41,44 @@ describe("LicenseCard", () => { await screen.findByText("Enterprise"); }); + it("shows expired removal message for expired licenses", async () => { + const user = userEvent.setup(); + render( + null} + isRemoving={false} + />, + ); + + const removeButton = await screen.findByRole("button", { name: /remove/i }); + await user.click(removeButton); + + await screen.findByText(/This license has already expired/); + }); + + it("shows disabling features warning for active licenses", async () => { + const user = userEvent.setup(); + render( + null} + isRemoving={false} + />, + ); + + const removeButton = await screen.findByRole("button", { name: /remove/i }); + await user.click(removeButton); + + await screen.findByText( + /Removing this license will disable all Premium features/, + ); + }); + it("renders license's user_limit when it is available instead of using the default", async () => { const licenseUserLimit = 3; const license = { diff --git a/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.tsx b/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.tsx index 0a22317d75..15edcf5da4 100644 --- a/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.tsx +++ b/site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicenseCard.tsx @@ -29,6 +29,10 @@ export const LicenseCard: FC = ({ const currentUserLimit = license.claims.features.user_limit || userLimitLimit; + const isExpired = dayjs + .unix(license.claims.license_expires) + .isBefore(dayjs()); + const licenseType = license.claims.trial ? "Trial" : license.claims.feature_set?.toLowerCase() === "premium" @@ -57,7 +61,11 @@ export const LicenseCard: FC = ({ title="Confirm License Removal" confirmLoading={isRemoving} confirmText="Remove" - description="Removing this license will disable all Premium features. You add a new license at any time." + description={ + isExpired + ? "This license has already expired and is not providing any features. Removing it will not affect your current entitlements." + : "Removing this license will disable all Premium features. You can add a new license at any time." + } /> = ({ )} - {dayjs(license.claims.license_expires * 1000).isBefore(dayjs()) ? ( + {isExpired ? ( Expired