Skip to content

Commit 4a7ae0b

Browse files
authored
feat(onboarding-ui): add oauth auth page (#586)
* feat(onboarding-ui): add Oauth Auth Page * chore: update loki screenshots * chore: remove tag cloud from logo * chore: update loki screenshots
1 parent f443a11 commit 4a7ae0b

9 files changed

+147
-0
lines changed

packages/onboarding-ui/.i18n/en.i18n.json

+8
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
"label": "New here? <1>Create account</1>"
7575
}
7676
},
77+
"oauthAuthorizationPage": {
78+
"title": "Authorization",
79+
"allowLogin": "Do you wish to allow <1>{{name}}</1> to login with your Rocket.Chat Cloud Account?",
80+
"buttons": {
81+
"authorize": "Authorize",
82+
"goBack": "Go Back"
83+
}
84+
},
7785
"newAccountForm": {
7886
"title": "Register new account"
7987
}

packages/onboarding-ui/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export { default as RequestTrialPage } from './pages/RequestTrialPage';
1313
export { default as DarkModeProvider } from './common/DarkModeProvider';
1414
export { default as LoginPage } from './pages/LoginPage';
1515
export { default as CreateNewAccountPage } from './pages/CreateNewAccountPage';
16+
export { default as OauthAuthorizationPage } from './pages/OauthAuthorizationPage';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import ReactDOM from 'react-dom';
2+
3+
import OauthAuthorizationPage from './OauthAuthorizationPage';
4+
5+
it('renders without crashing', () => {
6+
const div = document.createElement('div');
7+
ReactDOM.render(
8+
<OauthAuthorizationPage
9+
clientName={undefined}
10+
onClickAuthorizeOAuth={() => undefined}
11+
error={{
12+
message: undefined,
13+
onGoBack: () => undefined,
14+
}}
15+
/>,
16+
div
17+
);
18+
ReactDOM.unmountComponentAtNode(div);
19+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { Story, Meta } from '@storybook/react';
2+
import type { ComponentProps } from 'react';
3+
4+
import OauthAuthorizationPage from './OauthAuthorizationPage';
5+
6+
type Args = ComponentProps<typeof OauthAuthorizationPage>;
7+
8+
export default {
9+
title: 'pages/OauthAuthorizationPage',
10+
component: OauthAuthorizationPage,
11+
parameters: {
12+
actions: { argTypesRegex: '^on.*' },
13+
layout: 'fullscreen',
14+
},
15+
args: {
16+
clientName: 'Rocket.Chat',
17+
error: {
18+
message: '',
19+
onGoBack: () => console.log('Back'),
20+
},
21+
},
22+
} as Meta<Args>;
23+
24+
export const _OauthAuthorizationPage: Story<Args> = (args) => (
25+
<OauthAuthorizationPage {...args} />
26+
);
27+
28+
_OauthAuthorizationPage.storyName = 'OauthAuthorizationPage';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { Box, Button } from '@rocket.chat/fuselage';
2+
import colors from '@rocket.chat/fuselage-tokens/colors.json';
3+
import type { ReactElement } from 'react';
4+
import { Trans, useTranslation } from 'react-i18next';
5+
6+
import BackgroundLayer from '../../common/BackgroundLayer';
7+
import { OnboardingLogo } from '../../common/OnboardingLogo';
8+
9+
type OauthAuthorizationPageProps = {
10+
clientName?: string;
11+
onClickAuthorizeOAuth: () => void;
12+
error: {
13+
message?: string;
14+
onGoBack?: () => void;
15+
};
16+
};
17+
18+
const OauthAuthorizationPage = ({
19+
clientName,
20+
onClickAuthorizeOAuth,
21+
error,
22+
}: OauthAuthorizationPageProps): ReactElement => {
23+
const { t } = useTranslation();
24+
25+
const name = clientName || '...loading...';
26+
27+
return (
28+
<BackgroundLayer>
29+
<Box
30+
display='flex'
31+
flexDirection='column'
32+
alignItems='center'
33+
textAlign='center'
34+
width='100%'
35+
maxWidth={576}
36+
paddingBlock={32}
37+
paddingInline={16}
38+
>
39+
<OnboardingLogo />
40+
<Box
41+
fontWeight={500}
42+
width='100%'
43+
mbs='x24'
44+
mbe='x36'
45+
fontSize='x57'
46+
lineHeight='x62'
47+
fontFamily='sans'
48+
>
49+
{t('page.oauthAuthorizationPage.title')}
50+
</Box>
51+
<Box width='full' backgroundColor='white'>
52+
<Box fontScale='p1' p='x40' textAlign='start' color={colors.n900}>
53+
{error.message ? (
54+
<>
55+
<Box fontScale='h1' mbe='x18'>
56+
Error
57+
</Box>
58+
{error.message}
59+
<Box mbs='x24'>
60+
<Button onClick={error.onGoBack} primary>
61+
{t('page.oauthAuthorizationPage.buttons.goBack')}
62+
</Button>
63+
</Box>
64+
</>
65+
) : (
66+
<>
67+
<Trans
68+
i18nKey='page.oauthAuthorizationPage.allowLogin'
69+
name={name}
70+
>
71+
Do you wish to allow
72+
<strong>{{ name }}</strong>
73+
to login with your Rocket.Chat Cloud Account?
74+
</Trans>
75+
76+
<Box mbs='x24'>
77+
<Button onClick={onClickAuthorizeOAuth} primary>
78+
{t('page.oauthAuthorizationPage.buttons.authorize')}
79+
</Button>
80+
</Box>
81+
</>
82+
)}
83+
</Box>
84+
</Box>
85+
</Box>
86+
</BackgroundLayer>
87+
);
88+
};
89+
90+
export default OauthAuthorizationPage;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './OauthAuthorizationPage';

0 commit comments

Comments
 (0)