Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): Clerk based settings page #7202

Open
wants to merge 10 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions apps/dashboard/src/components/primitives/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
import { cn } from '@/utils/ui';
import { cva, VariantProps } from 'class-variance-authority';

const tabsListVariants = cva('inline-flex items-center', {
const tabsListVariants = cva('inline-flex', {
variants: {
variant: {
default: 'h-9 justify-center rounded-[10px] bg-neutral-alpha-100 p-1 text-muted-foreground',
default: 'h-9 rounded-[10px] bg-neutral-alpha-100 p-1 text-muted-foreground',
regular: 'border-neutral-alpha-200 w-full justify-start gap-6 border-b border-t px-3.5',
},
align: {
center: 'justify-center',
start: 'justify-start',
end: 'justify-end',
},
Comment on lines +13 to +17
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added control on tabs alignment

},
defaultVariants: {
variant: 'default',
align: 'center',
},
});

type TabsListProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> & VariantProps<typeof tabsListVariants>;

const TabsList = React.forwardRef<React.ElementRef<typeof TabsPrimitive.List>, TabsListProps>(
({ className, variant, ...props }, ref) => (
<TabsPrimitive.List ref={ref} className={tabsListVariants({ variant, className })} {...props} />
({ className, variant, align, ...props }, ref) => (
<TabsPrimitive.List ref={ref} className={tabsListVariants({ variant, align, className })} {...props} />
)
);
TabsList.displayName = TabsPrimitive.List.displayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const SideNavigation = () => {
</NavigationLink>
</NavigationGroup>
<NavigationGroup label="Application">
<NavigationLink to={LEGACY_ROUTES.SETTINGS} isExternal>
<NavigationLink to={ROUTES.SETTINGS}>
<RiSettings4Line className="size-4" />
<span>Settings</span>
</NavigationLink>
Expand Down
17 changes: 17 additions & 0 deletions apps/dashboard/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
OrganizationListPage,
QuestionnairePage,
UsecaseSelectPage,
SettingsPage,
} from '@/pages';
import './index.css';
import { ROUTES } from './utils/routes';
Expand Down Expand Up @@ -94,6 +95,22 @@ const router = createBrowserRouter([
},
],
},
{
path: ROUTES.SETTINGS,
element: <SettingsPage />,
},
{
path: ROUTES.SETTINGS_ACCOUNT,
element: <SettingsPage />,
},
{
path: ROUTES.SETTINGS_ORGANIZATION,
element: <SettingsPage />,
},
{
path: ROUTES.SETTINGS_TEAM,
element: <SettingsPage />,
},
{
path: '*',
element: <CatchAllRoute />,
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './sign-up';
export * from './organization-list';
export * from './questionnaire-page';
export * from './usecase-select-page';
export * from './settings';
125 changes: 125 additions & 0 deletions apps/dashboard/src/pages/settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { Card } from '@/components/primitives/card';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/primitives/tabs';
import { OrganizationProfile, UserProfile } from '@clerk/clerk-react';
import { useOrganization } from '@clerk/clerk-react';
import { DashboardLayout } from '../components/dashboard-layout';
import { useNavigate, useLocation } from 'react-router-dom';
import { ROUTES } from '@/utils/routes';

export const clerkComponentAppearance = {
elements: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the primary font color (black) to match the Dashboard primary font color rgba(82, 88, 102, 0.95)

navbar: { display: 'none' },
navbarMobileMenuRow: { display: 'none !important' },
rootBox: {
width: '100%',
height: '100%',
},
cardBox: {
display: 'block',
width: '100%',
height: '100%',
boxShadow: 'none',
},

pageScrollBox: {
padding: '0 !important',
},
header: {
display: 'none',
},
profileSection: {
borderTop: 'none',
borderBottom: '1px solid #e0e0e0',
},
page: {
padding: '0 5px',
},
},
};

export function SettingsPage() {
const navigate = useNavigate();
const location = useLocation();

const currentTab =
location.pathname === ROUTES.SETTINGS ? 'account' : location.pathname.split('/settings/')[1] || 'account';

const handleTabChange = (value: string) => {
switch (value) {
case 'account':
navigate(ROUTES.SETTINGS_ACCOUNT);
break;
case 'organization':
navigate(ROUTES.SETTINGS_ORGANIZATION);
break;
case 'team':
navigate(ROUTES.SETTINGS_TEAM);
break;
}
};

return (
<DashboardLayout headerStartItems={<h1 className="text-foreground-950">Settings</h1>}>
<Tabs value={currentTab} onValueChange={handleTabChange} className="w-full">
<TabsList
align="center"
className="border-border/20 relative mt-4 flex w-full items-end justify-start space-x-2 rounded-none border-b bg-transparent px-1.5 pb-0"
SokratisVidros marked this conversation as resolved.
Show resolved Hide resolved
>
<TabsTrigger
value="account"
className="text-muted-foreground hover:text-foreground data-[state=active]:border-primary data-[state=active]:text-foreground flex items-center rounded-none border-b-2 border-transparent px-4 py-2.5 font-medium transition-all"
>
Account
</TabsTrigger>
<TabsTrigger
value="organization"
className="text-muted-foreground hover:text-foreground data-[state=active]:border-primary data-[state=active]:text-foreground flex items-center rounded-none border-b-2 border-transparent px-4 py-2.5 font-medium transition-all"
>
Organization
</TabsTrigger>
<TabsTrigger
value="team"
className="text-muted-foreground hover:text-foreground data-[state=active]:border-primary data-[state=active]:text-foreground flex items-center rounded-none border-b-2 border-transparent px-4 py-2.5 font-medium transition-all"
>
Team
</TabsTrigger>
</TabsList>

<div className="mx-auto mt-1 max-w-[700px] px-1.5">
<TabsContent value="account" className="rounded-lg">
<Card className="mx-auto mt-10 border-none shadow-none">
<UserProfile appearance={clerkComponentAppearance}>
<UserProfile.Page label="account" />
<UserProfile.Page label="security" />
Copy link
Contributor

Choose a reason for hiding this comment

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

For posterity: This issue has been reported to Clerk.

</UserProfile>

<h1 className="text-foreground mb-6 mt-10 text-xl font-semibold">Security</h1>
<UserProfile appearance={clerkComponentAppearance}>
<UserProfile.Page label="security" />
<UserProfile.Page label="account" />
</UserProfile>
</Card>
</TabsContent>

<TabsContent value="organization" className="rounded-lg">
<Card className="border-none shadow-none">
<OrganizationProfile appearance={clerkComponentAppearance}>
<OrganizationProfile.Page label="general" />
<OrganizationProfile.Page label="members" />
</OrganizationProfile>
</Card>
</TabsContent>

<TabsContent value="team" className="rounded-lg">
<Card className="border-none shadow-none">
<OrganizationProfile appearance={clerkComponentAppearance}>
<OrganizationProfile.Page label="members" />
<OrganizationProfile.Page label="general" />
</OrganizationProfile>
</Card>
</TabsContent>
</div>
</Tabs>
</DashboardLayout>
);
}
4 changes: 4 additions & 0 deletions apps/dashboard/src/utils/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export const ROUTES = {
USECASE_SELECT: '/auth/usecase',
ROOT: '/',
ENV: '/env',
SETTINGS: '/settings',
SETTINGS_ACCOUNT: '/settings/account',
SETTINGS_ORGANIZATION: '/settings/organization',
SETTINGS_TEAM: '/settings/team',
WORKFLOWS: '/env/:environmentSlug/workflows',
EDIT_WORKFLOW: '/env/:environmentSlug/workflows/:workflowSlug',
TEST_WORKFLOW: '/env/:environmentSlug/workflows/:workflowSlug/test',
Expand Down
Loading