Skip to content

Commit 6de2e4a

Browse files
Merge pull request #427 from frontegg/upgrade-admin-portal
Update Frontegg AdminPortal to 7.80.0
2 parents ac17600 + e8009dc commit 6de2e4a

5 files changed

Lines changed: 147 additions & 115 deletions

File tree

packages/example-ssg/src/pages/ssg-page-1.tsx

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
1-
import { AdminPortal, ChangePasswordForm, EditEmailForm, InviteUserDialog, ProfilePage, useAuth, useInviteUserDialog, UsersTable, useUsersTable } from '@frontegg/nextjs';
1+
import {
2+
AdminPortal,
3+
ChangePasswordForm,
4+
EditEmailForm,
5+
InviteUserDialog,
6+
ProfilePage,
7+
useAuth,
8+
useInviteUserDialog,
9+
UsersTable,
10+
useUsersTable,
11+
} from '@frontegg/nextjs';
212
import Link from 'next/link';
313
import { AppHolder } from '@frontegg/js/AppHolder';
414
import { useEffect, useState } from 'react';
515
import Loader from '../components/loader';
616
import Testing from '../components/Testing';
717

8-
918
export default function SsgPage1() {
1019
const { user, isAuthenticated, isLoading } = useAuth();
1120

1221
// get the frontegg app instance // import { AppHolder } from '@frontegg/js/AppHolder';
13-
const app = AppHolder.getInstance('default')
22+
const app = AppHolder.getInstance('default');
1423
const [appLoading, setLoading] = useState(app.loading);
1524

16-
const { openDialog: openInviteUserDialog, } = useInviteUserDialog();
17-
const { onSearch, } = useUsersTable();
25+
const { openDialog: openInviteUserDialog } = useInviteUserDialog();
26+
const { onSearch } = useUsersTable();
1827
// console.log({ appLoading, isLoading, isAuthenticated, app })
1928
useEffect(() => {
2029
// single time load listener that trigger when the login-box cdn js files is loaded
2130
app.addOnLoadedListener(() => {
2231
console.log('App loaded');
23-
setLoading(false)
24-
})
25-
}, [app])
26-
32+
setLoading(false);
33+
});
34+
}, [app]);
2735

2836
// detect SSG build time and render content as should be with optional user object
2937
// this is important to avoid the loader to be pre-rendered in all in SSG pages
30-
const isBuildTime = process.env.NEXT_PHASE == 'phase-production-build'
38+
const isBuildTime = process.env.NEXT_PHASE == 'phase-production-build';
3139

3240
// check if the app is loading
3341
if (!isBuildTime && (isLoading || appLoading)) {
34-
return <>
35-
<Loader />
36-
</>
42+
return (
43+
<>
44+
<Loader />
45+
</>
46+
);
3747
} else {
3848
console.log('Loaded', { user, isAuthenticated });
3949
}
4050

41-
4251
/**
4352
* refreshingToken is true when the token is being refreshed.
4453
* this will be added to the useAuth hook in the next release.
@@ -52,49 +61,62 @@ export default function SsgPage1() {
5261
<div style={{ background: '#c2f2f8', padding: '16px', minHeight: '100vh' }}>
5362
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
5463
components examples
55-
56-
<button onClick={() => {
57-
openInviteUserDialog()
58-
}}>Open invite user dialog</button>
59-
60-
<input type="text" onChange={(e) => {
61-
onSearch(e.target.value)
62-
}} />
64+
<button
65+
onClick={() => {
66+
openInviteUserDialog();
67+
}}
68+
>
69+
Open invite user dialog
70+
</button>
71+
<input
72+
type='text'
73+
onChange={(e) => {
74+
onSearch(e.target.value);
75+
}}
76+
/>
6377
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
64-
<UsersTable props={{}} themeOptions={{
65-
adminPortal: {
66-
components: {
67-
MuiTableCell: {
68-
styleOverrides: {
69-
head: {
70-
background: 'lightgreen',
71-
border: '1px solid red',
72-
},
73-
body: {
74-
background: 'pink',
75-
border: '1px solid red',
78+
<UsersTable
79+
props={{}}
80+
themeOptions={{
81+
adminPortal: {
82+
components: {
83+
MuiTableCell: {
84+
styleOverrides: {
85+
head: {
86+
background: 'lightgreen',
87+
border: '1px solid red',
88+
},
89+
body: {
90+
background: 'pink',
91+
border: '1px solid red',
92+
},
7693
},
7794
},
7895
},
7996
},
80-
}
81-
}} hostStyle={{ width: '100%', height: '450px', marginBottom: '50px' }} />
82-
<ProfilePage props={{}} hostStyle={{ width: '100%', height: '350px', marginBottom: '50px' }} />
97+
}}
98+
hostStyle={{ width: '100%', height: '450px', marginBottom: '50px' }}
99+
/>
100+
<ProfilePage
101+
props={{}}
102+
containerStyle={{ border: '1px solid red' }}
103+
hostStyle={{ width: '100%', height: '350px', marginBottom: '50px' }}
104+
/>
83105
<ChangePasswordForm props={{}} hostStyle={{ width: '100%', height: '150px', marginBottom: '50px' }} />
84106
<InviteUserDialog props={{}} hostStyle={{ width: '100%', height: '0px', marginBottom: '50px' }} />
85-
<EditEmailForm props={{}} hostStyle={{ width: '100%', height: '350px', margin: '50px 0' }} />
107+
<EditEmailForm props={{}} containerStyle={{ border: '1px solid blue' }} />
86108
</div>
87109
</div>
88110
<Testing />
89111
<h1 style={{ marginBottom: '32px' }}>SSG Page 1</h1>
90112
{user ? <div>Logged in as: {user.email}</div> : <div>SSG not authorized</div>}
91113
<br />
92114
<br />
93-
<Link href="/ssg-page-2">
115+
<Link href='/ssg-page-2'>
94116
<button>Go to SSG page 2</button>
95117
</Link>
96118
<br />
97-
<Link href="/">
119+
<Link href='/'>
98120
<button>Go home page (SSR)</button>
99121
</Link>
100122
<br />

packages/nextjs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"lint-json": "eslint -c .eslintrc.json -o ./lint-report.json --format json --no-color ./src/**/*.{ts,tsx}"
2828
},
2929
"dependencies": {
30-
"@frontegg/js": "7.78.0",
31-
"@frontegg/react-hooks": "7.78.0",
30+
"@frontegg/js": "7.80.0",
31+
"@frontegg/react-hooks": "7.80.0",
3232
"http-proxy": "^1.18.1",
3333
"iron-session": "^6.3.1",
3434
"jose": "^4.12.2"

packages/nextjs/src/common/cmc/base.tsx

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,45 @@ import { CMCComponentProps } from '@frontegg/types';
55
import { FC } from 'react';
66
import { AppContext } from '../..';
77

8-
9-
export type RenderableFronteggComponent = keyof Pick<FronteggApp, 'renderChangePasswordForm' | 'renderInviteUserDialog' | 'renderProfilePage' | 'renderUsersTable' | 'renderEditEmailForm'>;
10-
export type FronteggCMCComponentProps<K extends CMCComponentProps> = Pick<K, 'themeOptions' | 'props' | 'localizations' | 'hostStyle'>
11-
12-
export const CMCComponent: FC<FronteggCMCComponentProps<CMCComponentProps> & { renderComponent: RenderableFronteggComponent }> = memo(
13-
({ themeOptions, props, localizations, hostStyle, renderComponent }) => {
14-
const ref = React.useRef<HTMLDivElement>(null);
15-
const app = useContext(AppContext)!;
16-
React.useLayoutEffect(() => {
17-
if (!ref.current) {
18-
return;
19-
}
20-
let rootRendered: { unmount: () => void } = {
21-
unmount: () => { },
22-
};
23-
24-
console.log({ app });
25-
if (!app[renderComponent]) {
26-
throw new Error(`Component ${renderComponent} is not supported`);
27-
}
28-
29-
app[renderComponent](ref.current, props, {
30-
themeOptions,
31-
localizations,
32-
})
33-
.then((root) => (rootRendered = root));
34-
35-
}, []);
36-
37-
return <div style={{ ...hostStyle }} ref={ref} />;
38-
},
39-
() => true
8+
export type RenderableFronteggComponent = keyof Pick<
9+
FronteggApp,
10+
| 'renderChangePasswordForm'
11+
| 'renderInviteUserDialog'
12+
| 'renderProfilePage'
13+
| 'renderUsersTable'
14+
| 'renderEditEmailForm'
15+
>;
16+
export type FronteggCMCComponentProps<K extends CMCComponentProps> = Pick<
17+
K,
18+
'themeOptions' | 'props' | 'localizations' | 'hostStyle' | 'containerStyle'
19+
>;
20+
21+
export const CMCComponent: FC<
22+
FronteggCMCComponentProps<CMCComponentProps> & { renderComponent: RenderableFronteggComponent }
23+
> = memo(
24+
({ themeOptions, props, localizations, hostStyle, containerStyle, renderComponent }) => {
25+
const ref = React.useRef<HTMLDivElement>(null);
26+
const app = useContext(AppContext)!;
27+
React.useLayoutEffect(() => {
28+
if (!ref.current) {
29+
return;
30+
}
31+
let rootRendered: { unmount: () => void } = {
32+
unmount: () => {},
33+
};
34+
35+
if (!app[renderComponent]) {
36+
throw new Error(`Component ${renderComponent} is not supported`);
37+
}
38+
39+
app[renderComponent](ref.current, props, {
40+
themeOptions,
41+
localizations,
42+
containerStyle,
43+
}).then((root) => (rootRendered = root));
44+
}, []);
45+
46+
return <div style={{ ...hostStyle }} ref={ref} />;
47+
},
48+
() => true
4049
);
41-
42-
43-
44-
45-
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
'use client';
22

3-
import { ChangePasswordFormProps, EditEmailFormProps, InviteUserDialogProps, ProfilePageProps, UsersTableProps } from '@frontegg/types';
3+
import {
4+
ChangePasswordFormProps,
5+
EditEmailFormProps,
6+
InviteUserDialogProps,
7+
ProfilePageProps,
8+
UsersTableProps,
9+
} from '@frontegg/types';
410
import React, { FC } from 'react';
511
import { CMCComponent, FronteggCMCComponentProps } from './base';
612

713
export const UsersTable: FC<FronteggCMCComponentProps<UsersTableProps>> = (props) => {
8-
return <CMCComponent renderComponent="renderUsersTable" {...props} />
9-
}
14+
return <CMCComponent renderComponent='renderUsersTable' {...props} />;
15+
};
1016

1117
export const InviteUserDialog: FC<FronteggCMCComponentProps<InviteUserDialogProps>> = (props) => {
12-
return <CMCComponent renderComponent="renderInviteUserDialog" {...props} />
13-
}
18+
return <CMCComponent renderComponent='renderInviteUserDialog' {...props} />;
19+
};
1420

1521
export const ChangePasswordForm: FC<FronteggCMCComponentProps<ChangePasswordFormProps>> = (props) => {
16-
return <CMCComponent renderComponent="renderChangePasswordForm" {...props} />
17-
}
22+
return <CMCComponent renderComponent='renderChangePasswordForm' {...props} />;
23+
};
1824

1925
export const ProfilePage: FC<FronteggCMCComponentProps<ProfilePageProps>> = (props) => {
20-
return <CMCComponent renderComponent="renderProfilePage" {...props} />
21-
}
26+
return <CMCComponent renderComponent='renderProfilePage' {...props} />;
27+
};
2228

2329
export const EditEmailForm: FC<FronteggCMCComponentProps<EditEmailFormProps>> = (props) => {
24-
return <CMCComponent renderComponent="renderEditEmailForm" {...props} />
25-
}
30+
return <CMCComponent renderComponent='renderEditEmailForm' {...props} />;
31+
};

yarn.lock

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,57 +1406,57 @@
14061406
resolved "https://registry.yarnpkg.com/@frontegg/entitlements-javascript-commons/-/entitlements-javascript-commons-1.1.2.tgz#8c771cac0796fde5bbc05abe750cb6b8677ec2c6"
14071407
integrity sha512-vwCFxj9KSIKHXinOH0HbBf4DhKRbUWhjCnL14+JfQnwuEl/zKtSGZoZecrXcPajWUypdi0uT+8q3GGcqnCW13Q==
14081408

1409-
"@frontegg/js@7.78.0":
1410-
version "7.78.0"
1411-
resolved "https://registry.yarnpkg.com/@frontegg/js/-/js-7.78.0.tgz#eeb2ad0b0253a092a8d95e970066b0a327dd693c"
1412-
integrity sha512-lhmnTS6P4Jz29/aZ71Yq+0mPmesaWnVpC9an8uEPavAzNgqefp+ksF6K3lQMQ20Nfxo0jDE2BIDZmF/OioJRIg==
1409+
"@frontegg/js@7.80.0":
1410+
version "7.80.0"
1411+
resolved "https://registry.yarnpkg.com/@frontegg/js/-/js-7.80.0.tgz#8c96440b57d4485759e9a222d2a5b302c647f515"
1412+
integrity sha512-p54pU7YAyYNjrPGnl2BT1SeDHIWqXFVjbl52N0geAVuqS9sze/Lta1KDCrNhzVeET+jCa2IiiUry/koGNmZYwg==
14131413
dependencies:
14141414
"@babel/runtime" "^7.18.6"
1415-
"@frontegg/types" "7.78.0"
1415+
"@frontegg/types" "7.80.0"
14161416

1417-
"@frontegg/react-hooks@7.78.0":
1418-
version "7.78.0"
1419-
resolved "https://registry.yarnpkg.com/@frontegg/react-hooks/-/react-hooks-7.78.0.tgz#e900724812a80ac53e602c7316ac9a8ac4c5d8ca"
1420-
integrity sha512-XuDwC+kwwta1p+2HNX0D899SjTNB4fgLLWxZ092nODMB1LzJVZM7FHJ0ECdpOPS1qa5Cd8/K38sTRbQKInWq6A==
1417+
"@frontegg/react-hooks@7.80.0":
1418+
version "7.80.0"
1419+
resolved "https://registry.yarnpkg.com/@frontegg/react-hooks/-/react-hooks-7.80.0.tgz#e814055a45d77288a4f5013a643d1fe1bf106411"
1420+
integrity sha512-FxVMWdlIQBosxv1HBtJsXOjqdHUqz0Wzs4nH3/kg93CFSnxhTfLg78l3jfmNNPHY/XDER0SgBISVcLEroSV5dw==
14211421
dependencies:
14221422
"@babel/runtime" "^7.18.6"
1423-
"@frontegg/redux-store" "7.78.0"
1424-
"@frontegg/types" "7.78.0"
1423+
"@frontegg/redux-store" "7.80.0"
1424+
"@frontegg/types" "7.80.0"
14251425
"@types/react" "*"
14261426
"@types/react-is" "^17.0.7"
14271427
get-value "^3.0.1"
14281428
react-is "^17.0.2"
14291429
use-sync-external-store "^1.2.2"
14301430

1431-
"@frontegg/redux-store@7.78.0":
1432-
version "7.78.0"
1433-
resolved "https://registry.yarnpkg.com/@frontegg/redux-store/-/redux-store-7.78.0.tgz#9c5bc3668b294612911375e047c3a016b8a34562"
1434-
integrity sha512-K/z5+nLiLIHKnaxLG8D4B+yybWMBo5IRu35RQMkXNFw5CnpeyE1tEsmj1yZun1g9wWPu5N/anlVYiXB4IzUyeQ==
1431+
"@frontegg/redux-store@7.80.0":
1432+
version "7.80.0"
1433+
resolved "https://registry.yarnpkg.com/@frontegg/redux-store/-/redux-store-7.80.0.tgz#fe8293e40c536f8d73e73aa00a731be839c21cfc"
1434+
integrity sha512-BMNgAeL0+19SvnvXBRkZ8+1pyPWeu9zufex1xyfdfA3hyPxl7OzNxzAKcbF5LFc0mIVPylJ3pUXXTaJpVmbUCQ==
14351435
dependencies:
14361436
"@babel/runtime" "^7.18.6"
14371437
"@frontegg/entitlements-javascript-commons" "1.1.2"
1438-
"@frontegg/rest-api" "7.78.0"
1438+
"@frontegg/rest-api" "7.80.0"
14391439
fast-deep-equal "3.1.3"
14401440
get-value "^3.0.1"
14411441
proxy-compare "^3.0.0"
14421442
set-value "^4.1.0"
14431443
uuid "^10.0.0"
14441444

1445-
"@frontegg/rest-api@7.78.0":
1446-
version "7.78.0"
1447-
resolved "https://registry.yarnpkg.com/@frontegg/rest-api/-/rest-api-7.78.0.tgz#6ed80f1ac2340ff0797560de64f87f6cdb50cff4"
1448-
integrity sha512-a1JNoK7xqVh7YMnRVQCcHuMlrUZ2mzp9Ulqea+d3DHr2Nl14BEfpOdrolP1UNNF3+sXLZqFI6edTUOkr3r8inQ==
1445+
"@frontegg/rest-api@7.80.0":
1446+
version "7.80.0"
1447+
resolved "https://registry.yarnpkg.com/@frontegg/rest-api/-/rest-api-7.80.0.tgz#6ac3226a91f8892e8a79c6b61b21a913d3cb9bac"
1448+
integrity sha512-z2clNee6S/729XHnLCwDGDMnH2mB3y/CoSYI8k4MrgIM5TNJh79SkuIF4Xg0dRSdmCEKWi+UzYOIUD1BBEKYDw==
14491449
dependencies:
14501450
"@babel/runtime" "^7.18.6"
14511451
"@frontegg/entitlements-javascript-commons" "1.1.2"
14521452

1453-
"@frontegg/types@7.78.0":
1454-
version "7.78.0"
1455-
resolved "https://registry.yarnpkg.com/@frontegg/types/-/types-7.78.0.tgz#5a33c42e220e5eecf5349c31284e0dde783a51d2"
1456-
integrity sha512-h5aN2pQfwbQlY8VjFueg6QYRy85qrpOPBblOg061EL4Zmqsc/khw0mxCeOkWYgQ2F/wX9y6d4W9BtFPaltZXXQ==
1453+
"@frontegg/types@7.80.0":
1454+
version "7.80.0"
1455+
resolved "https://registry.yarnpkg.com/@frontegg/types/-/types-7.80.0.tgz#75532e571b68a89f32dd1e33528811ad4fcce2dd"
1456+
integrity sha512-dwQtfnpdUKIjkyQ3VIdb4Xz1bqi6XagGEpbEPkVigZEwaa2Al95RTVxV1nUYzv9X4Jeu4s77YjHwG1lwSaEnFw==
14571457
dependencies:
14581458
"@babel/runtime" "^7.18.6"
1459-
"@frontegg/redux-store" "7.78.0"
1459+
"@frontegg/redux-store" "7.80.0"
14601460
csstype "^3.0.9"
14611461
deepmerge "^4.2.2"
14621462

0 commit comments

Comments
 (0)