fix: add badge for disabled workflow actions and templates in trial mode (#19675)

* add badge for trial mode

* fix tooltip issue

* fix typo

* add inactive team plan badge

* change to one salesforce request

* clean up

* fix type error

---------

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Bailey Pumfleet <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-03-10 15:34:29 +01:00
1 parent bb36807689
commit f2ca2bdc83
10 files changed
+61 -33

No files matched your search

@@ -1,21 +1,36 @@
import Link from "next/link";
import { useHasPaidPlan } from "@calcom/lib/hooks/useHasPaidPlan";
import { useHasPaidPlan, useHasActiveTeamPlan } from "@calcom/lib/hooks/useHasPaidPlan";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Tooltip } from "../tooltip";
import { Badge } from "./Badge";
export const UpgradeTeamsBadge = function UpgradeTeamsBadge() {
export const UpgradeTeamsBadge = function UpgradeTeamsBadge({
checkForActiveStatus,
}: {
checkForActiveStatus?: boolean;
}) {
const { t } = useLocale();
const { hasPaidPlan } = useHasPaidPlan();
const { hasActiveTeamPlan, isTrial } = useHasActiveTeamPlan();
if (hasPaidPlan) return null;
if (hasPaidPlan) {
if (!checkForActiveStatus || hasActiveTeamPlan) return null;
}
const badgeString = isTrial ? t("trial_mode") : hasPaidPlan ? t("inactive_team_plan") : t("upgrade");
const tooltipString = isTrial
? t("limited_access_trial_mode")
: hasPaidPlan
? t("inactive_team_plan_description")
: t("upgrade_to_enable_feature");
return (
<Tooltip content={t("upgrade_to_enable_feature")}>
<Link href="/teams">
<Badge variant="gray">{t("upgrade")}</Badge>
<Tooltip content={tooltipString}>
<Link href={!hasPaidPlan ? "/teams" : ""}>
<Badge variant="gray">{badgeString}</Badge>
</Link>
</Tooltip>
);
@@ -47,7 +47,11 @@ export const OptionComponent = <
<span className="mr-auto" data-testid={`select-option-${(props as unknown as ExtendedOption).value}`}>
{props.label || <>&nbsp;</>}
</span>
{(props.data as unknown as ExtendedOption).needsTeamsUpgrade ? <UpgradeTeamsBadge /> : <></>}
{(props.data as unknown as ExtendedOption).needsTeamsUpgrade ? (
<UpgradeTeamsBadge checkForActiveStatus={true} />
) : (
<></>
)}
{props.isSelected && <Icon name="check" className="ml-2 h-4 w-4" />}
</div>
</reactSelectComponents.Option>