2022-04-25 11:04:44 +00:00
import useFetchMock from '../hooks/use-fetch-mock'
import LinkingSection from '../../js/features/settings/components/linking-section'
import { setDefaultMeta , defaultSetupMocks } from './helpers/linking'
import { UserProvider } from '../../js/shared/context/user-context'
import { SSOProvider } from '../../js/features/settings/context/sso-context'
2022-05-16 09:38:20 +00:00
import { ScopeDecorator } from '../decorators/scope'
import { useEffect } from 'react'
import { useMeta } from '../hooks/use-meta'
2022-04-25 11:04:44 +00:00
2022-05-16 08:02:17 +00:00
const MOCK _DELAY = 1000
2022-04-25 11:04:44 +00:00
export const Section = args => {
useFetchMock ( defaultSetupMocks )
setDefaultMeta ( )
return (
< UserProvider >
< SSOProvider >
< LinkingSection { ... args } / >
< / S S O P r o v i d e r >
< / U s e r P r o v i d e r >
)
}
export const SectionAllUnlinked = args => {
useFetchMock ( defaultSetupMocks )
2022-05-16 09:38:20 +00:00
useMeta ( {
'ol-thirdPartyIds' : { } ,
'ol-user' : {
features : { github : true , dropbox : true , mendeley : true , zotero : true } ,
refProviders : {
mendeley : false ,
zotero : false ,
} ,
2022-04-25 11:04:44 +00:00
} ,
2022-05-16 09:38:20 +00:00
'ol-github' : { enabled : false } ,
'ol-dropbox' : { registered : false } ,
2022-04-25 11:04:44 +00:00
} )
2022-05-16 09:38:20 +00:00
useEffect ( ( ) => {
setDefaultMeta ( )
} , [ ] )
2022-04-25 11:04:44 +00:00
return (
< UserProvider >
< SSOProvider >
< LinkingSection { ... args } / >
< / S S O P r o v i d e r >
< / U s e r P r o v i d e r >
)
}
2022-05-16 08:02:17 +00:00
export const SectionSSOErrors = args => {
useFetchMock ( fetchMock =>
fetchMock . post ( '/user/oauth-unlink' , 500 , { delay : MOCK _DELAY } )
)
setDefaultMeta ( )
window . metaAttributesCache . set ( 'integrationLinkingWidgets' , [ ] )
window . metaAttributesCache . set ( 'referenceLinkingWidgets' , [ ] )
window . metaAttributesCache . set (
'ol-ssoErrorMessage' ,
'Account already linked to another Overleaf user'
)
return (
< UserProvider >
< SSOProvider >
< LinkingSection { ... args } / >
< / S S O P r o v i d e r >
< / U s e r P r o v i d e r >
)
}
2022-05-16 08:02:32 +00:00
export const SectionProjetSyncSuccess = args => {
useFetchMock ( defaultSetupMocks )
setDefaultMeta ( )
window . metaAttributesCache . set ( 'ol-github' , { enabled : true } )
window . metaAttributesCache . set (
'ol-projectSyncSuccessMessage' ,
'Thanks, we’ ve successfully linked your GitHub account to Overleaf. You can now export your Overleaf projects to GitHub, or import projects from your GitHub repositories.'
)
return (
< UserProvider >
< SSOProvider >
< LinkingSection { ... args } / >
< / S S O P r o v i d e r >
< / U s e r P r o v i d e r >
)
}
2022-04-25 11:04:44 +00:00
export default {
title : 'Account Settings / Linking' ,
component : LinkingSection ,
2022-05-16 09:38:20 +00:00
decorators : [ ScopeDecorator ] ,
2022-04-25 11:04:44 +00:00
}