Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

exclude get, default to ent plan on upgrade modal

Steven Tey202fa208c45c
diff --git a/app/ui/button.tsx b/app/ui/button.tsx
index e647e58948..73eae4409d 100644
--- a/app/ui/button.tsx
+++ b/app/ui/button.tsx
@@ -25,7 +25,7 @@ export default function Button({
if (disabledTooltip) {
return (
<Tooltip content={disabledTooltip} fullWidth>
- <div className="flex h-10 w-full cursor-not-allowed items-center justify-center rounded-md border border-gray-200 bg-gray-100 text-sm text-gray-400 transition-all focus:outline-none">
+ <div className="flex h-10 w-full cursor-not-allowed items-center justify-center rounded-md border border-gray-200 bg-gray-100 px-4 text-sm text-gray-400 transition-all focus:outline-none">
<p>{text}</p>
</div>
</Tooltip>
diff --git a/components/app/modals/upgrade-plan-modal.tsx b/components/app/modals/upgrade-plan-modal.tsx
index 67d5399a1b..609ae8d799 100644
--- a/components/app/modals/upgrade-plan-modal.tsx
+++ b/components/app/modals/upgrade-plan-modal.tsx
@@ -22,13 +22,15 @@ import { Logo } from "#/ui/icons";
function UpgradePlanModal({
showUpgradePlanModal,
setShowUpgradePlanModal,
+ defaultPlan,
}: {
showUpgradePlanModal: boolean;
setShowUpgradePlanModal: Dispatch<SetStateAction<boolean>>;
+ defaultPlan: "Pro" | "Enterprise";
}) {
const router = useRouter();
const { slug } = router.query;
- const [plan, setPlan] = useState<"Pro" | "Enterprise">("Pro");
+ const [plan, setPlan] = useState<"Pro" | "Enterprise">(defaultPlan);
const [period, setPeriod] = useState<"monthly" | "yearly">("yearly");
const features = useMemo(() => {
return [
@@ -210,7 +212,11 @@ function UpgradePlanModal({
);
}
-export function useUpgradePlanModal() {
+export function useUpgradePlanModal(
+ { defaultPlan } = { defaultPlan: "Pro" } as {
+ defaultPlan: "Pro" | "Enterprise";
+ },
+) {
const [showUpgradePlanModal, setShowUpgradePlanModal] = useState(false);
const UpgradePlanModalCallback = useCallback(() => {
@@ -218,9 +224,10 @@ export function useUpgradePlanModal() {
<UpgradePlanModal
showUpgradePlanModal={showUpgradePlanModal}
setShowUpgradePlanModal={setShowUpgradePlanModal}
+ defaultPlan={defaultPlan}
/>
);
- }, [showUpgradePlanModal, setShowUpgradePlanModal]);
+ }, [showUpgradePlanModal, setShowUpgradePlanModal, defaultPlan]);
return useMemo(
() => ({
diff --git a/pages/api/projects/[slug]/saml.ts b/pages/api/projects/[slug]/saml.ts
index 9d4d557219..21532b76f0 100644
--- a/pages/api/projects/[slug]/saml.ts
+++ b/pages/api/projects/[slug]/saml.ts
@@ -60,5 +60,6 @@ export default withProjectAuth(
},
{
requiredPlan: ["enterprise"],
+ excludeGet: true,
},
);
diff --git a/pages/api/projects/[slug]/scim.ts b/pages/api/projects/[slug]/scim.ts
index 6accc3cbd5..b97765cdbc 100644
--- a/pages/api/projects/[slug]/scim.ts
+++ b/pages/api/projects/[slug]/scim.ts
@@ -66,5 +66,6 @@ export default withProjectAuth(
},
{
requiredPlan: ["enterprise"],
+ excludeGet: true,
},
);
diff --git a/pages/app/[slug]/settings/security.tsx b/pages/app/[slug]/settings/security.tsx
index 16499936cd..5018936612 100644
--- a/pages/app/[slug]/settings/security.tsx
+++ b/pages/app/[slug]/settings/security.tsx
@@ -4,7 +4,7 @@ import { useSAMLModal } from "@/components/app/modals/saml-modal";
import { useRemoveSAMLModal } from "@/components/app/modals/remove-saml-modal";
import SettingsLayout from "@/components/layout/app/settings-layout";
import { FolderSync, Lock, ShieldOff } from "lucide-react";
-import { useMemo, useState } from "react";
+import { Dispatch, SetStateAction, useContext, useMemo, useState } from "react";
import { ThreeDots } from "@/components/shared/icons";
import Popover from "#/ui/popover";
import IconMenu from "@/components/shared/icon-menu";
@@ -12,18 +12,31 @@ import useSAML from "#/lib/swr/use-saml";
import useSCIM from "#/lib/swr/use-scim";
import { useRemoveSCIMModal } from "@/components/app/modals/remove-scim-modal";
import { useSCIMModal } from "@/components/app/modals/scim-modal";
-import { SAML_PROVIDERS } from "#/lib/constants";
+import { HOME_DOMAIN, SAML_PROVIDERS } from "#/lib/constants";
+import useProject from "#/lib/swr/use-project";
+import { TooltipContent } from "#/ui/tooltip";
+import { ModalContext } from "#/ui/modal-provider";
+import { useUpgradePlanModal } from "@/components/app/modals/upgrade-plan-modal";
export default function ProjectSecurity() {
+ const { setShowUpgradePlanModal, UpgradePlanModal } = useUpgradePlanModal({
+ defaultPlan: "Enterprise",
+ });
return (
<SettingsLayout>
- <SAMLSection />
- <SCIMSection />
+ <UpgradePlanModal />
+ <SAMLSection setShowUpgradePlanModal={setShowUpgradePlanModal} />
+ <SCIMSection setShowUpgradePlanModal={setShowUpgradePlanModal} />
</SettingsLayout>
);
}
-const SAMLSection = () => {
+const SAMLSection = ({
+ setShowUpgradePlanModal,
+}: {
+ setShowUpgradePlanModal: Dispatch<SetStateAction<boolean>>;
+}) => {
+ const { plan } = useProject();
const { SAMLModal, setShowSAMLModal } = useSAMLModal();
const { RemoveSAMLModal, setShowRemoveSAMLModal } = useRemoveSAMLModal();
const { provider, configured, loading } = useSAML();
@@ -133,6 +146,17 @@ const SAMLSection = () => {
) : (
<Button
text="Configure"
+ disabled={plan !== "enterprise"}
+ {...(plan !== "enterprise" && {
+ disabledTooltip: (
+ // "SAML SSO is only available on Enterprise plans.",
+ <TooltipContent
+ title="SAML SSO is only available on Enterprise plans. Upgrade to get started."
+ cta="Upgrade to Enterprise"
+ onClick={() => setShowUpgradePlanModal(true)}
+ />
+ ),
+ })}
onClick={() => setShowSAMLModal(true)}
/>
)}
@@ -141,14 +165,25 @@ const SAMLSection = () => {
</div>
<div className="flex items-center justify-between rounded-b-lg border-t border-gray-200 bg-gray-50 px-3 py-5 sm:px-10">
- <p className="text-sm text-gray-500">Learn more about SAML SSO</p>
+ <a
+ href={`${HOME_DOMAIN}/help/article/saml-sso`}
+ target="_blank"
+ className="text-sm text-gray-400 underline underline-offset-4 transition-colors hover:text-gray-700"
+ >
+ Learn more about SAML SSO.
+ </a>
</div>
</div>
</>
);
};
-const SCIMSection = () => {
+const SCIMSection = ({
+ setShowUpgradePlanModal,
+}: {
+ setShowUpgradePlanModal: Dispatch<SetStateAction<boolean>>;
+}) => {
+ const { plan } = useProject();
const { SCIMModal, setShowSCIMModal } = useSCIMModal();
const { RemoveSCIMModal, setShowRemoveSCIMModal } = useRemoveSCIMModal();
@@ -271,6 +306,16 @@ const SCIMSection = () => {
) : (
<Button
text="Configure"
+ disabled={plan !== "enterprise"}
+ {...(plan !== "enterprise" && {
+ disabledTooltip: (
+ <TooltipContent
+ title="SCIM Directory Sync is only available on Enterprise plans. Upgrade to get started."
+ cta="Upgrade to Enterprise"
+ onClick={() => setShowUpgradePlanModal(true)}
+ />
+ ),
+ })}
onClick={() => setShowSCIMModal(true)}
/>
)}
@@ -279,7 +324,13 @@ const SCIMSection = () => {
</div>
<div className="flex items-center justify-between rounded-b-lg border-t border-gray-200 bg-gray-50 px-3 py-5 sm:px-10">
- <p className="text-sm text-gray-500">Learn more about SAML SSO</p>
+ <a
+ href={`${HOME_DOMAIN}/help/article/directory-sync`}
+ target="_blank"
+ className="text-sm text-gray-400 underline underline-offset-4 transition-colors hover:text-gray-700"
+ >
+ Learn more about SCIM Directory Sync.
+ </a>
</div>
</div>
</>