feat: open notion to public

This commit is contained in:
Hongbo Wu
2024-05-06 13:29:48 +08:00
parent ac63dd5f52
commit 023df68f7b
2 changed files with 24 additions and 60 deletions

View File

@ -12,8 +12,6 @@ import { useGetViewerQuery } from '../../../lib/networking/queries/useGetViewerQ
import { applyStoredTheme } from '../../../lib/themeUpdater'
import { showErrorToast, showSuccessToast } from '../../../lib/toastHelpers'
const ACCOUNT_LIMIT = 50_000
const StyledLabel = styled('label', {
fontWeight: 600,
fontSize: '16px',
@ -49,10 +47,6 @@ export default function Account(): JSX.Element {
)
}, [viewerData])
const hasNotion = useMemo(() => {
return viewerData?.me?.featureList?.some((f) => f.name === 'notion')
}, [viewerData])
applyStoredTheme()
return (
@ -116,8 +110,7 @@ export default function Account(): JSX.Element {
)
})}
{(!hasYouTube ||
!hasNotion) /* || !hasAISummaries || !hasDigest */ && (
{!hasYouTube /* || !hasAISummaries || !hasDigest */ && (
<StyledLabel css={{ mt: '25px' }}>
Available beta features
</StyledLabel>
@ -150,31 +143,6 @@ export default function Account(): JSX.Element {
</VStack>
)}
{!hasNotion && (
<VStack
alignment="start"
distribution="start"
css={{ width: '100%' }}
>
<StyledText
style="footnote"
css={{ display: 'flex', gap: '5px' }}
>
- Notion integration: Export your items and highlights
to Notion.
</StyledText>
<Button
style="ctaDarkYellow"
onClick={(event) => {
requestFeatureAccess('notion')
event.preventDefault()
}}
>
Request feature
</Button>
</VStack>
)}
{/* <VStack
alignment="start"
distribution="start"

View File

@ -17,16 +17,15 @@ import {
} from '../../components/elements/LayoutPrimitives'
import { SettingsLayout } from '../../components/templates/SettingsLayout'
import { fetchEndpoint } from '../../lib/appConfig'
import { userHasFeature } from '../../lib/featureFlag'
import { deleteIntegrationMutation } from '../../lib/networking/mutations/deleteIntegrationMutation'
import { importFromIntegrationMutation } from '../../lib/networking/mutations/importFromIntegrationMutation'
import {
ImportItemState,
setIntegrationMutation
setIntegrationMutation,
} from '../../lib/networking/mutations/setIntegrationMutation'
import {
Integration,
useGetIntegrationsQuery
useGetIntegrationsQuery,
} from '../../lib/networking/queries/useGetIntegrationsQuery'
import { useGetViewerQuery } from '../../lib/networking/queries/useGetViewerQuery'
import { showErrorToast, showSuccessToast } from '../../lib/toastHelpers'
@ -76,7 +75,6 @@ type integrationsCard = {
export default function Integrations(): JSX.Element {
const { viewerData } = useGetViewerQuery()
const { integrations, revalidate } = useGetIntegrationsQuery()
// const { webhooks } = useGetWebhooksQuery()
@ -112,25 +110,25 @@ export default function Integrations(): JSX.Element {
}
}
const redirectToIntegration = useCallback((
name: string,
importItemState?: ImportItemState
) => {
// create a form and submit it to the backend
const form = document.createElement('form')
form.method = 'POST'
form.action = `${fetchEndpoint}/integration/${name.toLowerCase()}/auth`
if (importItemState) {
const input = document.createElement('input')
input.type = 'hidden'
input.name = 'state'
input.value = importItemState
form.appendChild(input)
}
document.body.appendChild(form)
const redirectToIntegration = useCallback(
(name: string, importItemState?: ImportItemState) => {
// create a form and submit it to the backend
const form = document.createElement('form')
form.method = 'POST'
form.action = `${fetchEndpoint}/integration/${name.toLowerCase()}/auth`
if (importItemState) {
const input = document.createElement('input')
input.type = 'hidden'
input.name = 'state'
input.value = importItemState
form.appendChild(input)
}
document.body.appendChild(form)
form.submit()
}, [])
form.submit()
},
[]
)
const isImporting = (integration: Integration | undefined) => {
return !!integration && !!integration.taskName
@ -307,10 +305,7 @@ export default function Integrations(): JSX.Element {
},
},
},
]
userHasFeature(viewerData?.me, 'notion') &&
integrationsArray.push({
{
icon: '/static/icons/notion.png',
title: 'Notion',
subText:
@ -325,7 +320,8 @@ export default function Integrations(): JSX.Element {
: redirectToIntegration('NOTION')
},
},
})
},
]
setIntegrationsArray(integrationsArray)
}, [getIntegration, router])