Skip to content
Snippets Groups Projects
Commit 84a09354 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

feat: update Connection buttons

parent 4695ccbf
No related branches found
No related tags found
1 merge request!319accessibility buttons
...@@ -8,7 +8,7 @@ import AccountService from 'services/account.service' ...@@ -8,7 +8,7 @@ import AccountService from 'services/account.service'
import ConnectionService from 'services/connection.service' import ConnectionService from 'services/connection.service'
import StyledIconButton from 'components/CommonKit/IconButton/StyledIconButton' import StyledIconButton from 'components/CommonKit/IconButton/StyledIconButton'
import MuiButton from '@material-ui/core/Button' import Button from '@material-ui/core/Button'
import TrailingIcon from 'assets/icons/ico/trailing-icon.svg' import TrailingIcon from 'assets/icons/ico/trailing-icon.svg'
import iconGRDFLogo from 'assets/icons/visu/grdf-logo.svg' import iconGRDFLogo from 'assets/icons/visu/grdf-logo.svg'
...@@ -206,7 +206,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({ ...@@ -206,7 +206,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({
<div className="form-message">{error === '' ? null : error}</div> <div className="form-message">{error === '' ? null : error}</div>
<div className="kloginauthform"> <div className="kloginauthform">
<div className="kloginauthform-button"> <div className="kloginauthform-button">
<MuiButton <Button
type="submit" type="submit"
aria-label={t('auth.accessibility.button_connect')} aria-label={t('auth.accessibility.button_connect')}
disabled={loading} disabled={loading}
...@@ -224,7 +224,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({ ...@@ -224,7 +224,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({
<div>{t('auth.' + konnectorSlug + '.connect.label2')}</div> <div>{t('auth.' + konnectorSlug + '.connect.label2')}</div>
</div> </div>
</div> </div>
</MuiButton> </Button>
</div> </div>
<div className="kloginauthform-text text-16-bold"> <div className="kloginauthform-text text-16-bold">
<div className="text-16-bold"> <div className="text-16-bold">
...@@ -235,7 +235,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({ ...@@ -235,7 +235,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({
</div> </div>
</div> </div>
<MuiButton <Button
disabled={loading} disabled={loading}
aria-label={t('auth.accessibility.button_create_account')} aria-label={t('auth.accessibility.button_create_account')}
onClick={() => window.open(siteLink, '_blank')} onClick={() => window.open(siteLink, '_blank')}
...@@ -245,7 +245,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({ ...@@ -245,7 +245,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({
}} }}
> >
{t('auth.' + konnectorSlug + '.create_account')} {t('auth.' + konnectorSlug + '.create_account')}
</MuiButton> </Button>
</div> </div>
</form> </form>
) )
......
...@@ -6,7 +6,7 @@ import './connectionFormOAuth.scss' ...@@ -6,7 +6,7 @@ import './connectionFormOAuth.scss'
import { Konnector, Trigger, FluidStatus, FluidConnection } from 'models' import { Konnector, Trigger, FluidStatus, FluidConnection } from 'models'
import OAuthForm from 'components/Connection/OAuthForm' import OAuthForm from 'components/Connection/OAuthForm'
import MuiButton from '@material-ui/core/Button' import Button from '@material-ui/core/Button'
import AccountService from 'services/account.service' import AccountService from 'services/account.service'
import TriggerService from 'services/triggers.service' import TriggerService from 'services/triggers.service'
import { updatedFluidConnection } from 'store/global/global.actions' import { updatedFluidConnection } from 'store/global/global.actions'
...@@ -87,7 +87,7 @@ const ConnectionFormOAuth: React.FC<ConnectionFormOAuthProps> = ({ ...@@ -87,7 +87,7 @@ const ConnectionFormOAuth: React.FC<ConnectionFormOAuthProps> = ({
</div> </div>
</div> </div>
<div className="koauthform-button"> <div className="koauthform-button">
<MuiButton <Button
aria-label={t('auth.accessibility.button_create_account')} aria-label={t('auth.accessibility.button_create_account')}
onClick={() => window.open(siteLink, '_blank')} onClick={() => window.open(siteLink, '_blank')}
classes={{ classes={{
...@@ -96,7 +96,7 @@ const ConnectionFormOAuth: React.FC<ConnectionFormOAuthProps> = ({ ...@@ -96,7 +96,7 @@ const ConnectionFormOAuth: React.FC<ConnectionFormOAuthProps> = ({
}} }}
> >
{t('auth.' + konnectorSlug + '.create_account')} {t('auth.' + konnectorSlug + '.create_account')}
</MuiButton> </Button>
</div> </div>
</div> </div>
) )
......
import React from 'react' import React from 'react'
import { shallow, mount } from 'enzyme' import { shallow, mount } from 'enzyme'
import ConnectionNotFound from './ConnectionNotFound' import ConnectionNotFound from './ConnectionNotFound'
import MuiButton from '@material-ui/core/Button' import Button from '@material-ui/core/Button'
jest.mock('cozy-ui/transpiled/react/I18n', () => { jest.mock('cozy-ui/transpiled/react/I18n', () => {
return { return {
useI18n: jest.fn(() => { useI18n: jest.fn(() => {
return { return {
t: (str: string) => str, t: (str: string) => str,
} }
}), }),
} }
}) })
describe('ConnectionNotFound component test', () => { describe('ConnectionNotFound component test', () => {
const konnectorSlug = 'enedisgrandlyon' const konnectorSlug = 'enedisgrandlyon'
it('should correctly render connection not found', () => { it('should correctly render connection not found', () => {
const result = shallow( const result = shallow(
<ConnectionNotFound konnectorSlug={konnectorSlug} /> <ConnectionNotFound konnectorSlug={konnectorSlug} />
).getElement() ).getElement()
expect(result).toMatchSnapshot() expect(result).toMatchSnapshot()
}) })
it('should open konnector url when button is clicked', () => { it('should open konnector url when button is clicked', () => {
global.open = jest.fn() global.open = jest.fn()
const wrapper = mount(<ConnectionNotFound konnectorSlug={konnectorSlug} />) const wrapper = mount(<ConnectionNotFound konnectorSlug={konnectorSlug} />)
const submitStyledButton = wrapper.find(MuiButton) const submitStyledButton = wrapper.find(Button)
submitStyledButton.simulate('click') submitStyledButton.simulate('click')
expect(global.open).toHaveBeenCalledWith( expect(global.open).toHaveBeenCalledWith(
'http://localhost/#/discover/enedisgrandlyon', 'http://localhost/#/discover/enedisgrandlyon',
'_blank' '_blank'
) )
}) })
}) })
...@@ -10,7 +10,7 @@ import { OAuthWindow } from 'cozy-harvest-lib/dist/components/OAuthWindow' ...@@ -10,7 +10,7 @@ import { OAuthWindow } from 'cozy-harvest-lib/dist/components/OAuthWindow'
import iconEnedisLogo from 'assets/icons/visu/enedis-logo.svg' import iconEnedisLogo from 'assets/icons/visu/enedis-logo.svg'
import iconGrdfLogo from 'assets/icons/visu/grdf-logo.svg' import iconGrdfLogo from 'assets/icons/visu/grdf-logo.svg'
import iconEglLogo from 'assets/icons/visu/egl-logo.svg' import iconEglLogo from 'assets/icons/visu/egl-logo.svg'
import MuiButton from '@material-ui/core/Button' import Button from '@material-ui/core/Button'
import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import StyledIcon from 'components/CommonKit/Icon/StyledIcon'
import StyledBlackSpinner from 'components/CommonKit/Spinner/StyledBlackSpinner' import StyledBlackSpinner from 'components/CommonKit/Spinner/StyledBlackSpinner'
import ModalGRDF from './ModalGRDF' import ModalGRDF from './ModalGRDF'
...@@ -70,7 +70,7 @@ const OAuthForm: React.FC<OAuthFormProps> = ({ ...@@ -70,7 +70,7 @@ const OAuthForm: React.FC<OAuthFormProps> = ({
const isWaiting = status === WAITING const isWaiting = status === WAITING
return !konnector ? null : ( return !konnector ? null : (
<> <>
<MuiButton <Button
aria-label={t('auth.accessibility.button_connect')} aria-label={t('auth.accessibility.button_connect')}
onClick={ onClick={
konnector.slug === fluidconfig[FluidType.GAS].konnectorConfig.slug konnector.slug === fluidconfig[FluidType.GAS].konnectorConfig.slug
...@@ -96,7 +96,7 @@ const OAuthForm: React.FC<OAuthFormProps> = ({ ...@@ -96,7 +96,7 @@ const OAuthForm: React.FC<OAuthFormProps> = ({
<div>{t('auth.' + konnector.slug + '.connect.label2')}</div> <div>{t('auth.' + konnector.slug + '.connect.label2')}</div>
</div> </div>
</div> </div>
</MuiButton> </Button>
{isWaiting && ( {isWaiting && (
<OAuthWindow <OAuthWindow
client={client} client={client}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment