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(onboarding-ui): add oauth auth page #586

Merged
merged 4 commits into from
Dec 14, 2021
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
8 changes: 8 additions & 0 deletions packages/onboarding-ui/.i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
"label": "New here? <1>Create account</1>"
}
},
"oauthAuthorizationPage": {
"title": "Authorization",
"allowLogin": "Do you wish to allow <1>{{name}}</1> to login with your Rocket.Chat Cloud Account?",
PedroRorato marked this conversation as resolved.
Show resolved Hide resolved
"buttons": {
"authorize": "Authorize",
"goBack": "Go Back"
}
},
"newAccountForm": {
"title": "Register new account"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/onboarding-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export { default as RequestTrialPage } from './pages/RequestTrialPage';
export { default as DarkModeProvider } from './common/DarkModeProvider';
export { default as LoginPage } from './pages/LoginPage';
export { default as CreateNewAccountPage } from './pages/CreateNewAccountPage';
export { default as OauthAuthorizationPage } from './pages/OauthAuthorizationPage';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import ReactDOM from 'react-dom';

import OauthAuthorizationPage from './OauthAuthorizationPage';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(
<OauthAuthorizationPage
clientName={undefined}
onClickAuthorizeOAuth={() => undefined}
error={{
message: undefined,
onGoBack: () => undefined,
}}
/>,
div
);
ReactDOM.unmountComponentAtNode(div);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Story, Meta } from '@storybook/react';
import type { ComponentProps } from 'react';

import OauthAuthorizationPage from './OauthAuthorizationPage';

type Args = ComponentProps<typeof OauthAuthorizationPage>;

export default {
title: 'pages/OauthAuthorizationPage',
component: OauthAuthorizationPage,
parameters: {
actions: { argTypesRegex: '^on.*' },
layout: 'fullscreen',
},
args: {
clientName: 'Rocket.Chat',
error: {
message: '',
onGoBack: () => console.log('Back'),
},
},
} as Meta<Args>;

export const _OauthAuthorizationPage: Story<Args> = (args) => (
<OauthAuthorizationPage {...args} />
);

_OauthAuthorizationPage.storyName = 'OauthAuthorizationPage';
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Box, Button } from '@rocket.chat/fuselage';
import colors from '@rocket.chat/fuselage-tokens/colors.json';
import type { ReactElement } from 'react';
import { Trans, useTranslation } from 'react-i18next';

import BackgroundLayer from '../../common/BackgroundLayer';
import { OnboardingLogo } from '../../common/OnboardingLogo';

type OauthAuthorizationPageProps = {
clientName?: string;
onClickAuthorizeOAuth: () => void;
error: {
message?: string;
onGoBack?: () => void;
};
};

const OauthAuthorizationPage = ({
clientName,
onClickAuthorizeOAuth,
error,
}: OauthAuthorizationPageProps): ReactElement => {
const { t } = useTranslation();

const name = clientName || '...loading...';

return (
<BackgroundLayer>
<Box
display='flex'
flexDirection='column'
alignItems='center'
textAlign='center'
width='100%'
maxWidth={576}
paddingBlock={32}
paddingInline={16}
>
<OnboardingLogo />
<Box
fontWeight={500}
width='100%'
mbs='x24'
mbe='x36'
fontSize='x57'
lineHeight='x62'
fontFamily='sans'
>
{t('page.oauthAuthorizationPage.title')}
</Box>
<Box width='full' backgroundColor='white'>
<Box fontScale='p1' p='x40' textAlign='start' color={colors.n900}>
{error.message ? (
<>
<Box fontScale='h1' mbe='x18'>
Error
</Box>
{error.message}
<Box mbs='x24'>
<Button onClick={error.onGoBack} primary>
{t('page.oauthAuthorizationPage.buttons.goBack')}
</Button>
</Box>
</>
) : (
<>
<Trans
i18nKey='page.oauthAuthorizationPage.allowLogin'
name={name}
>
Do you wish to allow
<strong>{{ name }}</strong>
to login with your Rocket.Chat Cloud Account?
</Trans>

<Box mbs='x24'>
<Button onClick={onClickAuthorizeOAuth} primary>
{t('page.oauthAuthorizationPage.buttons.authorize')}
</Button>
</Box>
</>
)}
</Box>
</Box>
</Box>
</BackgroundLayer>
);
};

export default OauthAuthorizationPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './OauthAuthorizationPage';