Skip to content

Commit

Permalink
chore(repo): Update ui.retheme dir
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosdouvlis committed Nov 10, 2023
1 parent 624626f commit 13d0ae4
Show file tree
Hide file tree
Showing 19 changed files with 18 additions and 77 deletions.
11 changes: 0 additions & 11 deletions packages/clerk-js/src/ui.retheme/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { deprecated } from '@clerk/shared/deprecated';
import type { Attribute, Web3Provider } from '@clerk/types';

import type { LocalizationKey } from '../localization/localizationKeys';
Expand Down Expand Up @@ -97,16 +96,6 @@ export function getWeb3ProviderData(name: Web3Provider): Web3ProviderData | unde
return WEB3_PROVIDERS[name];
}

/**
* Returns the URL for a static SVG image
* using the old images.clerk.com service
* @deprecated In favor of iconImageUrl
*/
export function svgUrl(id: string): string {
deprecated('svgUrl', 'Use `iconImageUrl` instead');
return `https://images.clerk.com/static/${id}.svg`;
}

/**
* Returns the URL for a static SVG image
* using the new img.clerk.com service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type FakeOrganizationParams = {
id: string;
createdAt?: Date;
imageUrl?: string;
logoUrl?: string;
slug: string;
name: string;
membersCount: number;
Expand All @@ -23,7 +22,6 @@ export type FakeOrganizationParams = {

export const createFakeOrganization = (params: FakeOrganizationParams): OrganizationResource => {
return {
logoUrl: null,
pathRoot: '',
id: params.id,
name: params.name,
Expand All @@ -39,7 +37,6 @@ export const createFakeOrganization = (params: FakeOrganizationParams): Organiza
updatedAt: new Date(),
update: jest.fn() as any,
getMemberships: jest.fn() as any,
getPendingInvitations: jest.fn() as any,
addMember: jest.fn() as any,
inviteMember: jest.fn() as any,
inviteMembers: jest.fn() as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ export const ActiveMembersList = () => {
return null;
}

const handleRoleChange = (membership: OrganizationMembershipResource) => (newRole: string) => {
return card
.runAsync(async () => {
return await membership.update({ role: newRole });
})
.catch(err => handleError(err, [], card.setError));
};
const handleRoleChange = (membership: OrganizationMembershipResource) => (newRole: string) =>
card.runAsync(() => membership.update({ role: newRole })).catch(err => handleError(err, [], card.setError));

const handleRemove = (membership: OrganizationMembershipResource) => async () => {
return card
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type FakeMemberParams = {
identifier?: string;
firstName?: string;
lastName?: string;
profileImageUrl?: string;
imageUrl?: string;
createdAt?: Date;
};
Expand All @@ -39,7 +38,6 @@ export const createFakeMember = (params: FakeMemberParams): OrganizationMembersh
identifier: params?.identifier || 'test_user',
firstName: params?.firstName || 'test_firstName',
lastName: params?.lastName || 'test_lastName',
profileImageUrl: params?.profileImageUrl || '',
imageUrl: params?.imageUrl || '',
},
} as any;
Expand Down Expand Up @@ -121,7 +119,6 @@ export const createFakeOrganizationMembershipRequest = (
publicUserData: {
firstName: null,
lastName: null,
profileImageUrl: '',
imageUrl: '',
hasImage: false,
userId: params.publicUserData.userId || '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { deprecatedObjectProperty } from '@clerk/shared/deprecated';
import type { ActiveSessionResource, UserButtonProps, UserResource } from '@clerk/types';

import { windowNavigate } from '../../../utils/windowNavigate';
Expand Down Expand Up @@ -44,28 +43,14 @@ export const useMultisessionActions = (opts: UseMultisessionActionsParams) => {
});
}

// The UserButton can also accept an appearance object for the nested UserProfile modal
if (opts.appearance?.userProfile) {
deprecatedObjectProperty(
opts.appearance,
'userProfile',
'Use `<UserButton userProfileProps={{appearance: {...}}} />` instead.',
);
}
openUserProfile({
appearance: opts.appearance?.userProfile,
// Prioritize the appearance of `userProfileProps`
...opts.userProfileProps,
});
openUserProfile(opts.userProfileProps);
return opts.actionCompleteCallback?.();
};

const handleSignOutAllClicked = () => {
return signOut(opts.navigateAfterSignOut);
};

// TODO: Fix this eslint error

const handleSessionClicked = (session: ActiveSessionResource) => async () => {
card.setLoading();
return setActive({ session, beforeEmit: opts.navigateAfterSwitchSession }).finally(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ContentPage, Form, FormButtons, SuccessPage, useCardState, withCardStat
import { useRouter } from '../../router';
import { handleError, useFormControl } from '../../utils';
import { UserProfileBreadcrumbs } from './UserProfileNavbar';
import { magicLinksEnabledForInstance } from './utils';
import { emailLinksEnabledForInstance } from './utils';
import { VerifyWithCode } from './VerifyWithCode';
import { VerifyWithLink } from './VerifyWithLink';

Expand All @@ -17,7 +17,7 @@ export const EmailPage = withCardStateProvider(() => {
const card = useCardState();
const user = useCoreUser();
const environment = useEnvironment();
const preferEmailLinks = magicLinksEnabledForInstance(environment);
const preferEmailLinks = emailLinksEnabledForInstance(environment);

const { params } = useRouter();
const { id } = params || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ describe('ProfilePage', () => {
const { wrapper } = await createFixtures(f => {
f.withUser({
email_addresses: ['[email protected]'],
profile_image_url: 'https://clerk.com',
image_url: 'https://clerk.com',
first_name: 'F',
last_name: 'L',
Expand Down Expand Up @@ -149,7 +148,6 @@ describe('ProfilePage', () => {
const { wrapper, fixtures } = await createFixtures(f => {
f.withUser({
email_addresses: ['[email protected]'],
profile_image_url: 'https://clerk.com',
image_url:
'https://img.clerkstage.dev/70726f78792f68747470733a2f2f696d616765732e6c636c636c65726b2e636f6d2f75706c6f616465642f696d675f324f4559646f346e575263766579536c6a366b7775757a336e79472e6a706567',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const currentSessionFirst = (id: string) => (a: IDable) => a.id === id ?

export const defaultFirst = (a: PhoneNumberResource) => (a.defaultSecondFactor ? -1 : 1);

export function magicLinksEnabledForInstance(env: EnvironmentResource): boolean {
export function emailLinksEnabledForInstance(env: EnvironmentResource): boolean {
const { userSettings } = env;
const { email_address } = userSettings.attributes;
return email_address.enabled && email_address.verifications.includes('email_link');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deprecated, snakeToCamel } from '@clerk/shared';
import { snakeToCamel } from '@clerk/shared/underscore';
import type { OrganizationResource, UserResource } from '@clerk/types';
import React, { useMemo } from 'react';

Expand Down Expand Up @@ -302,12 +302,6 @@ export const useOrganizationSwitcherContext = () => {
return navigate(parsedUrl);
}

// Continue to support afterSwitchOrganizationUrl
if (ctx.afterSwitchOrganizationUrl) {
deprecated('afterSwitchOrganizationUrl', 'Use `afterSelectOrganizationUrl` or `afterSelectPersonalUrl`');
return navigate(ctx.afterSwitchOrganizationUrl);
}

return Promise.resolve();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ export function CoreClerkContextWrapper(props: CoreClerkContextWrapperProps): JS
const userCtx = React.useMemo(() => ({ value: user }), [user]);
const organizationCtx = React.useMemo(
() => ({
value: {
organization: organization,
lastOrganizationInvitation: undefined,
lastOrganizationMember: undefined,
},
value: { organization: organization },
}),
[organization],
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { OrganizationProvider, useOrganization, useOrganizationList, useOrganizations } from '@clerk/shared/react';
import { OrganizationProvider, useOrganization, useOrganizationList } from '@clerk/shared/react';

export const CoreOrganizationProvider = OrganizationProvider;
export const useCoreOrganization = useOrganization;
export const useCoreOrganizationList = useOrganizationList;
export const useCoreOrganizations = useOrganizations;
1 change: 0 additions & 1 deletion packages/clerk-js/src/ui.retheme/elements/UserAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type UserAvatarProps = Omit<PropsOfComponent<typeof Avatar>, 'imageUrl'> &
};

export const UserAvatar = (props: UserAvatarProps) => {
//TODO: replace profileImageUrl with imageUrl
const { name, firstName, lastName, avatarUrl, imageUrl, ...rest } = props;
const generatedName = getFullName({ name, firstName, lastName });
const initials = getInitials({ name, firstName, lastName });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ describe('useOrganization', () => {
}),
);

expect(result.current.invitationList).not.toBeDefined();
expect(result.current.membershipList).not.toBeDefined();

expect(result.current.memberships).toEqual(expect.objectContaining(undefinedPaginatedResource));
expect(result.current.domains).toEqual(expect.objectContaining(undefinedPaginatedResource));
expect(result.current.membershipRequests).toEqual(expect.objectContaining(undefinedPaginatedResource));
Expand All @@ -78,9 +75,6 @@ describe('useOrganization', () => {
expect(result.current.isLoaded).toBe(true);
expect(result.current.organization).toBeNull();

expect(result.current.invitationList).toBeNull();
expect(result.current.membershipList).toBeNull();

expect(result.current.memberships).toBeNull();
expect(result.current.domains).toBeNull();
expect(result.current.membershipRequests).toBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jest.mock('../../contexts', () => {
return {
useCoreClerk: () => {
return {
frontendApi: 'clerk.clerk.com',
publishableKey: 'pk_live_Y2xlcmsuY2xlcmsuY29tJA',
};
},
useEnvironment: () => mockUseEnvironment(),
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui.retheme/icons/upload.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const outAnimation = keyframes`
translateY(0px);
max-height: 6rem;
visibility: visible;
}
}
100% {
opacity: 0;
transform: translateY(5px);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const unboundCreateFixtures = <N extends UnpackContext<typeof ComponentContext>[
Client.getInstance().fetch = jest.fn(() => Promise.resolve(clientMock));

// Use a FAPI value for local production instances to avoid triggering the devInit flow during testing
const frontendApi = 'clerk.abcef.12345.prod.lclclerk.com';
const tempClerk = new ClerkCtor(frontendApi);
const productionPublishableKey = 'pk_live_Y2xlcmsuYWJjZWYuMTIzNDUucHJvZC5sY2xjbGVyay5jb20k';
const tempClerk = new ClerkCtor(productionPublishableKey);
await tempClerk.load();
const clerkMock = mockClerkMethods(tempClerk as LoadedClerk);
const optionsMock = {} as ClerkOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const createUserFixtureHelpers = (baseClient: ClientJSON) => {
return {
first_name: 'FirstName',
last_name: 'LastName',
profile_image_url: '',
image_url: '',
identifier: '[email protected]',
user_id: '',
Expand Down
9 changes: 4 additions & 5 deletions packages/clerk-js/src/ui.retheme/utils/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const createBaseDisplayConfig = (): DisplayConfigJSON => {
},
},
preferred_sign_in_strategy: 'password',
logo_url: 'https://images.clerk.com/uploaded/img_logo.png',
favicon_url: 'https://images.clerk.com/uploaded/img_favicon.png',
logo_image_url: 'https://images.clerk.com/uploaded/img_logo.png',
favicon_image_url: 'https://images.clerk.com/uploaded/img_favicon.png',
home_url: 'https://dashboard.clerk.com',
sign_in_url: 'https://dashboard.clerk.com/sign-in',
sign_up_url: 'https://dashboard.clerk.com/sign-up',
Expand Down Expand Up @@ -199,12 +199,11 @@ export const createBaseClientJSON = (): ClientJSON => {
return {} as ClientJSON;
};

// TODO:
export const createUserFixture = (): UserJSON => {
return {
first_name: 'Firstname',
last_name: 'Lastname',
profile_image_url: 'https://lh3.googleusercontent.com/a/public-photo-kmmfZIb=s1000-c',
image_url: 'https://lh3.googleusercontent.com/a/public-photo-kmmfZIb=s1000-c',
image_url:
'https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2xoMy5nb29nbGV1c2VyY29udGVudC5jb20vYS9BQ2c4b2NLTmR2TUtFQzN5cUVpMVFjV0UzQjExbF9WUEVOWW5manlLMlVQd0tCSWw9czEwMDAtYyIsInMiOiJkRkowS3dTSkRINndiODE5cXJTUUxxaWF1ZS9QcHdndC84L0lUUlpYNHpnIn0?width=160',
} as UserJSON;
};

0 comments on commit 13d0ae4

Please sign in to comment.