Skip to content

Commit 849966e

Browse files
feat(security-questionnaire): add tooltip and disable CTA for unpublished policies (#1761)
Co-authored-by: Tofik Hasanov <annexcies@gmail.com>
1 parent 4079b73 commit 849966e

File tree

2 files changed

+53
-17
lines changed

2 files changed

+53
-17
lines changed

apps/app/src/app/(app)/[orgId]/security-questionnaire/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export default async function SecurityQuestionnairePage() {
4747
imageSrcDark="/questionaire/tmp-questionaire-empty-state.png"
4848
imageAlt="Security Questionnaire"
4949
sheetName="create-policy-sheet"
50+
ctaDisabled={true}
51+
ctaTooltip="To use this feature you need to publish policy"
5052
faqs={[
5153
{
5254
questionKey: 'What is a security questionnaire?',

apps/app/src/components/app-onboarding.tsx

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@c
44
import { Badge } from '@comp/ui/badge';
55
import { Button } from '@comp/ui/button';
66
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@comp/ui/card';
7+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@comp/ui/tooltip';
78
import { BookOpen, HelpCircle, PlusIcon } from 'lucide-react';
89
import { useTheme } from 'next-themes';
910
import Image from 'next/image';
@@ -25,6 +26,8 @@ type Props = {
2526
faqs?: FAQ[];
2627
sheetName?: string;
2728
href?: string;
29+
ctaDisabled?: boolean;
30+
ctaTooltip?: string;
2831
};
2932

3033
export function AppOnboarding({
@@ -37,6 +40,8 @@ export function AppOnboarding({
3740
faqs,
3841
sheetName,
3942
href,
43+
ctaDisabled = false,
44+
ctaTooltip,
4045
}: Props) {
4146
const [open, setOpen] = useQueryState(sheetName ?? 'sheet');
4247
const isOpen = Boolean(open);
@@ -102,23 +107,52 @@ export function AppOnboarding({
102107

103108
{cta && (
104109
<div className="mt-4 flex w-full">
105-
{href ? (
106-
<Link href={href}>
107-
<Button variant="default" className="flex w-full items-center gap-2">
108-
<PlusIcon className="h-4 w-4" />
109-
{cta}
110-
</Button>
111-
</Link>
112-
) : (
113-
<Button
114-
variant="default"
115-
className="flex w-full items-center gap-2"
116-
onClick={() => setOpen('true')}
117-
>
118-
<PlusIcon className="h-4 w-4" />
119-
{cta}
120-
</Button>
121-
)}
110+
<TooltipProvider delayDuration={100}>
111+
{href ? (
112+
<Tooltip>
113+
<TooltipTrigger asChild>
114+
<span className={`w-full ${ctaDisabled ? 'cursor-not-allowed' : ''}`}>
115+
<Link href={href}>
116+
<Button
117+
variant="default"
118+
className={`flex w-full items-center gap-2 ${ctaDisabled ? 'cursor-not-allowed' : ''}`}
119+
disabled={ctaDisabled}
120+
>
121+
<PlusIcon className="h-4 w-4" />
122+
{cta}
123+
</Button>
124+
</Link>
125+
</span>
126+
</TooltipTrigger>
127+
{ctaDisabled && ctaTooltip && (
128+
<TooltipContent>
129+
<p>{ctaTooltip}</p>
130+
</TooltipContent>
131+
)}
132+
</Tooltip>
133+
) : (
134+
<Tooltip>
135+
<TooltipTrigger asChild>
136+
<span className={`w-full ${ctaDisabled ? 'cursor-not-allowed' : ''}`}>
137+
<Button
138+
variant="default"
139+
className={`flex w-full items-center gap-2 ${ctaDisabled ? 'cursor-not-allowed' : ''}`}
140+
onClick={() => setOpen('true')}
141+
disabled={ctaDisabled}
142+
>
143+
<PlusIcon className="h-4 w-4" />
144+
{cta}
145+
</Button>
146+
</span>
147+
</TooltipTrigger>
148+
{ctaDisabled && ctaTooltip && (
149+
<TooltipContent>
150+
<p>{ctaTooltip}</p>
151+
</TooltipContent>
152+
)}
153+
</Tooltip>
154+
)}
155+
</TooltipProvider>
122156
</div>
123157
)}
124158
</div>

0 commit comments

Comments
 (0)