overleaf/services/web/frontend/stories/settings/linking.stories.js
Timothée Alby 4b87568e4f Merge pull request #7810 from overleaf/ta-settings-intermediate-pages
[SettingsPage] Github and Dropbox Linking Flow Improvements

GitOrigin-RevId: 4fd69e7e3a8989b2478299751582007635f9e0b0
2022-05-17 08:03:29 +00:00

87 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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'
const MOCK_DELAY = 1000
export const Section = args => {
useFetchMock(defaultSetupMocks)
setDefaultMeta()
return (
<UserProvider>
<SSOProvider>
<LinkingSection {...args} />
</SSOProvider>
</UserProvider>
)
}
export const SectionAllUnlinked = args => {
useFetchMock(defaultSetupMocks)
setDefaultMeta()
window.metaAttributesCache.set('ol-thirdPartyIds', {})
window.metaAttributesCache.set('ol-user', {
features: { github: true, dropbox: true, mendeley: true, zotero: true },
refProviders: {
mendeley: false,
zotero: false,
},
})
window.metaAttributesCache.set('ol-github', { enabled: false })
window.metaAttributesCache.set('ol-dropbox', { registered: false })
return (
<UserProvider>
<SSOProvider>
<LinkingSection {...args} />
</SSOProvider>
</UserProvider>
)
}
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} />
</SSOProvider>
</UserProvider>
)
}
export const SectionProjetSyncSuccess = args => {
useFetchMock(defaultSetupMocks)
setDefaultMeta()
window.metaAttributesCache.set('ol-github', { enabled: true })
window.metaAttributesCache.set(
'ol-projectSyncSuccessMessage',
'Thanks, weve 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} />
</SSOProvider>
</UserProvider>
)
}
export default {
title: 'Account Settings / Linking',
component: LinkingSection,
}