Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .changeset/fix-ui-lint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ describe('connectionBackingEmail', () => {
const email = (id: string, status: 'verified' | 'unverified'): EmailAddressResource =>
({ id, emailAddress: `${id}@acme.com`, verification: { status } }) as EmailAddressResource;

const makeUser = (overrides: Partial<UserResource>): UserResource => overrides as UserResource;
const makeUser = (overrides: Partial<UserResource>): UserResource => overrides;
Comment thread
coderabbitai[bot] marked this conversation as resolved.

it('returns the primary email when one is present', () => {
const primary = email('primary', 'verified');
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/UserProfile/SecurityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ProfileCard } from '@/ui/elements/ProfileCard';

import { localizationKeys } from '../../customizables';
import { ActiveDevicesSection } from './ActiveDevicesSection';
import { SecurityPassword, SecurityPasskeys, SecurityMfa, SecurityDelete } from './SecuritySections';
import { SecurityDelete, SecurityMfa, SecurityPasskeys, SecurityPassword } from './SecuritySections';

export const SecurityPage = withCardStateProvider(() => {
const card = useCardState();
Expand Down
18 changes: 13 additions & 5 deletions packages/ui/src/components/UserProfile/SecuritySections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import type { ReactNode } from 'react';
import { getSecondFactors } from '@/ui/utils/mfa';

import { useEnvironment, useUserProfileContext } from '../../contexts';
import { DeleteSection } from './DeleteSection';
import { MfaSection } from './MfaSection';
import { PasskeySection } from './PasskeySection';
import { PasswordSection } from './PasswordSection';
import { DeleteSection } from './DeleteSection';

export function SecurityPassword(): ReactNode {
const { instanceIsPasswordBased } = useEnvironment().userSettings;

if (!instanceIsPasswordBased) return null;
if (!instanceIsPasswordBased) {
return null;
}

return <PasswordSection />;
}
Expand All @@ -21,23 +23,29 @@ export function SecurityPasskeys(): ReactNode {
const { attributes } = useEnvironment().userSettings;
const { shouldAllowIdentificationCreation } = useUserProfileContext();

if (!attributes.passkey?.enabled || !shouldAllowIdentificationCreation) return null;
if (!attributes.passkey?.enabled || !shouldAllowIdentificationCreation) {
return null;
}

return <PasskeySection />;
}

export function SecurityMfa(): ReactNode {
const { attributes } = useEnvironment().userSettings;

if (getSecondFactors(attributes).length === 0) return null;
if (getSecondFactors(attributes).length === 0) {
return null;
}

return <MfaSection />;
}

export function SecurityDelete(): ReactNode {
const { user } = useUser();

if (!user?.deleteSelfEnabled) return null;
if (!user?.deleteSelfEnabled) {
return null;
}

return <DeleteSection />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('ConnectedAccountsSection ', () => {
open,
},
});
const reload = vi.spyOn(fixtures.clerk.user!, 'reload').mockResolvedValue(fixtures.clerk.user!);
const reload = vi.spyOn(fixtures.clerk.user, 'reload').mockResolvedValue(fixtures.clerk.user);
fixtures.clerk.user?.createExternalAccount.mockResolvedValue({
verification: { externalVerificationRedirectURL: new URL('https://provider.example/auth') },
} as ExternalAccountResource);
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('ConnectedAccountsSection ', () => {
open,
},
});
const reload = vi.spyOn(fixtures.clerk.user!, 'reload').mockResolvedValue(fixtures.clerk.user!);
const reload = vi.spyOn(fixtures.clerk.user, 'reload').mockResolvedValue(fixtures.clerk.user);
fixtures.clerk.user?.createExternalAccount.mockResolvedValue({
verification: { externalVerificationRedirectURL: new URL('https://provider.example/auth') },
} as ExternalAccountResource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { render, screen } from '@/test/utils';
import { CardStateProvider } from '@/ui/elements/contexts';

import { clearFetchCache } from '../../../hooks';
import { SecurityPassword, SecurityPasskeys, SecurityMfa, SecurityDelete } from '../SecuritySections';
import { SecurityDelete, SecurityMfa, SecurityPasskeys, SecurityPassword } from '../SecuritySections';

const { createFixtures } = bindCreateFixtures('UserProfile');

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/composed/APIKeysSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { Suspense, type ComponentType, type ReactNode } from 'react';
import { type ComponentType, type ReactNode, Suspense } from 'react';

import { CardStateProvider } from '../elements/contexts';

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/composed/BillingSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { Suspense, type ComponentType, type ReactNode } from 'react';
import { type ComponentType, type ReactNode, Suspense } from 'react';

import { RouteContext } from '../router/RouteContext';
import { useBillingRouter } from './useBillingRouter';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { ClerkPaginatedResponse, OrganizationMembershipResource } from '@clerk/shared/types';
import { describe, expect, it } from 'vitest';
import { describe, it } from 'vitest';

import { bindCreateFixtures } from '@/test/create-fixtures';
import { render, screen, waitFor } from '@/test/utils';
import { render, screen } from '@/test/utils';

import { OrganizationGeneralPage } from '../../components/OrganizationProfile/OrganizationGeneralPage';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook, act } from '@testing-library/react';
import { act, renderHook } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';

import { createComposedRouter, stubRouter } from '../stubRouter';
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/composed/createSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { useRequirePage } from './useRequirePage';

export function createSection(name: string, Component: ComponentType): () => ReactNode {
function Section(): ReactNode {
if (!useRequirePage(name)) return null;
if (!useRequirePage(name)) {
return null;
}
return <Component />;
}
Section.displayName = name;
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/composed/useBillingRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export function useBillingRouter(): { router: RouteContextValue; route: BillingR
window.location.href = to;
return;
}
} catch {}
} catch {
// `to` is not an absolute URL; fall through to relative-route handling.
}
const newRoute = resolveNavigation(to);
setRoute(newRoute);
if (options?.searchParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export function useWarnAboutCustomizationWithoutPinning(appearance: Appearance |

return () => {
if (useIdleCallback) {
cancelIdleCallback(handle as number);
cancelIdleCallback(handle);
} else {
clearTimeout(handle as ReturnType<typeof setTimeout>);
clearTimeout(handle);
}
};
}, [clerkCtx?.value, stableAppearance, uiPinned]);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/mosaic/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function expandConditions(input: StyleRule): StyleRule {
fastDeepMergeAndReplace(nest(chain, expanded), out);
} else if (expanded && typeof expanded === 'object' && out[key] && typeof out[key] === 'object') {
// A prior condition already expanded into this raw selector — merge rather than overwrite.
fastDeepMergeAndReplace(expanded, out[key] as StyleRule);
fastDeepMergeAndReplace(expanded, out[key]);
} else {
out[key] = expanded;
}
Expand Down
Loading