From c29d570b780601dc4037ea44bb9cfa6c15082852 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 26 Mar 2024 11:54:55 +0800 Subject: [PATCH 1/5] remove Auto Sync switch from notion integration page --- packages/web/pages/settings/integrations/notion.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/web/pages/settings/integrations/notion.tsx b/packages/web/pages/settings/integrations/notion.tsx index ba7dbe746..ccfc4c56b 100644 --- a/packages/web/pages/settings/integrations/notion.tsx +++ b/packages/web/pages/settings/integrations/notion.tsx @@ -34,7 +34,6 @@ import { showSuccessToast } from '../../../lib/toastHelpers' type FieldType = { parentPageId?: string parentDatabaseId?: string - enabled: boolean properties?: string[] } @@ -52,7 +51,6 @@ export default function Notion(): JSX.Element { form.setFieldsValue({ parentPageId: notion.settings?.parentPageId, parentDatabaseId: notion.settings?.parentDatabaseId, - enabled: notion.enabled, properties: notion.settings?.properties, }) }, [form, notion]) @@ -71,7 +69,7 @@ export default function Notion(): JSX.Element { name: notion.name, type: notion.type, token: notion.token, - enabled: values.enabled, + enabled: true, settings: values, }) } @@ -194,15 +192,6 @@ export default function Notion(): JSX.Element { - - label="Automatic Sync" - name="enabled" - valuePropName="checked" - help="Once connected all new items will be exported to Notion" - > - - - label="Properties to Export" name="properties" From d051333bcdd0736e70085dfb5830b3c882ba2b59 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 26 Mar 2024 11:58:17 +0800 Subject: [PATCH 2/5] remove beta logo --- packages/web/pages/settings/integrations/notion.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/web/pages/settings/integrations/notion.tsx b/packages/web/pages/settings/integrations/notion.tsx index ccfc4c56b..656714818 100644 --- a/packages/web/pages/settings/integrations/notion.tsx +++ b/packages/web/pages/settings/integrations/notion.tsx @@ -157,7 +157,6 @@ export default function Notion(): JSX.Element { height={75} />
Notion integration settings
-
From 1c85955d7a500a8643a412593a1d0f02accd1225 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 26 Mar 2024 12:27:02 +0800 Subject: [PATCH 3/5] feature flag notion --- packages/web/lib/featureFlag.ts | 6 --- packages/web/pages/settings/integrations.tsx | 46 +++++++++++-------- .../pages/settings/integrations/notion.tsx | 2 - 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/packages/web/lib/featureFlag.ts b/packages/web/lib/featureFlag.ts index 5eb198e11..f79369b78 100644 --- a/packages/web/lib/featureFlag.ts +++ b/packages/web/lib/featureFlag.ts @@ -1,11 +1,5 @@ import { UserBasicData } from './networking/queries/useGetViewerQuery' -const VIP_USERS = ['jacksonh', 'satindar', 'hongbo', 'nat'] - -export const isVipUser = (user: UserBasicData): boolean => { - return VIP_USERS.includes(user.profile.username) -} - export const userHasFeature = ( user: UserBasicData | undefined, feature: string diff --git a/packages/web/pages/settings/integrations.tsx b/packages/web/pages/settings/integrations.tsx index 39af9ec23..409f02ad3 100644 --- a/packages/web/pages/settings/integrations.tsx +++ b/packages/web/pages/settings/integrations.tsx @@ -17,6 +17,7 @@ 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 { @@ -27,8 +28,8 @@ import { Integration, useGetIntegrationsQuery, } from '../../lib/networking/queries/useGetIntegrationsQuery' +import { useGetViewerQuery } from '../../lib/networking/queries/useGetViewerQuery' import { useGetWebhooksQuery } from '../../lib/networking/queries/useGetWebhooksQuery' -import { applyStoredTheme } from '../../lib/themeUpdater' import { showErrorToast, showSuccessToast } from '../../lib/toastHelpers' // Styles const Header = styled(Box, { @@ -74,7 +75,8 @@ type integrationsCard = { } } export default function Integrations(): JSX.Element { - applyStoredTheme() + const { viewerData } = useGetViewerQuery() + const { integrations, revalidate } = useGetIntegrationsQuery() const { webhooks } = useGetWebhooksQuery() @@ -202,7 +204,7 @@ export default function Integrations(): JSX.Element { }, [router]) useEffect(() => { - setIntegrationsArray([ + const integrationsArray = [ { icon: '/static/icons/logseq.svg', title: 'Logseq', @@ -267,22 +269,6 @@ export default function Integrations(): JSX.Element { ], }, }, - { - icon: '/static/icons/notion.png', - title: 'Notion', - subText: - 'Notion is an all-in-one workspace. Use our Notion integration to sync your Omnivore items to Notion.', - button: { - text: isConnected('NOTION') ? 'Settings' : 'Connect', - icon: , - style: isConnected('NOTION') ? 'ctaWhite' : 'ctaDarkYellow', - action: () => { - isConnected('NOTION') - ? router.push('/settings/integrations/notion') - : redirectToIntegration('NOTION') - }, - }, - }, { icon: '/static/icons/webhooks.svg', title: 'Webhooks', @@ -310,7 +296,27 @@ export default function Integrations(): JSX.Element { }, }, }, - ]) + ] + + userHasFeature(viewerData?.me, 'notion') && + integrationsArray.push({ + icon: '/static/icons/notion.png', + title: 'Notion', + subText: + 'Notion is an all-in-one workspace. Use our Notion integration to sync your Omnivore items to Notion.', + button: { + text: isConnected('NOTION') ? 'Settings' : 'Connect', + icon: , + style: isConnected('NOTION') ? 'ctaWhite' : 'ctaDarkYellow', + action: () => { + isConnected('NOTION') + ? router.push('/settings/integrations/notion') + : redirectToIntegration('NOTION') + }, + }, + }) + + setIntegrationsArray(integrationsArray) }, [pocketConnected, readwiseConnected, webhooks, integrations]) return ( diff --git a/packages/web/pages/settings/integrations/notion.tsx b/packages/web/pages/settings/integrations/notion.tsx index 656714818..f45693f74 100644 --- a/packages/web/pages/settings/integrations/notion.tsx +++ b/packages/web/pages/settings/integrations/notion.tsx @@ -7,7 +7,6 @@ import { message, Space, Spin, - Switch, } from 'antd' import 'antd/dist/antd.compact.css' import { CheckboxValueType } from 'antd/lib/checkbox/Group' @@ -16,7 +15,6 @@ import { useRouter } from 'next/router' import { useCallback, useEffect, useState } from 'react' import { HStack, VStack } from '../../../components/elements/LayoutPrimitives' import { PageMetaData } from '../../../components/patterns/PageMetaData' -import { Beta } from '../../../components/templates/Beta' import { Header } from '../../../components/templates/settings/SettingsTable' import { SettingsLayout } from '../../../components/templates/SettingsLayout' import { deleteIntegrationMutation } from '../../../lib/networking/mutations/deleteIntegrationMutation' From 209b08e2ffee9718c6701feec8bf4de036c7f83c Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 26 Mar 2024 12:32:01 +0800 Subject: [PATCH 4/5] add notion to the features list --- packages/api/src/services/features.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/api/src/services/features.ts b/packages/api/src/services/features.ts index 16024bb3b..f6de25593 100644 --- a/packages/api/src/services/features.ts +++ b/packages/api/src/services/features.ts @@ -13,6 +13,7 @@ export enum FeatureName { AISummaries = 'ai-summaries', YouTubeTranscripts = 'youtube-transcripts', UltraRealisticVoice = 'ultra-realistic-voice', + Notion = 'notion', } export const getFeatureName = (name: string): FeatureName | undefined => { @@ -36,8 +37,11 @@ export const optInFeature = async ( uid, MAX_YOUTUBE_TRANSCRIPT_USERS ) + case FeatureName.Notion: + return optInLimitedFeature(FeatureName.Notion, uid, 1) + default: + return undefined } - return undefined } const optInLimitedFeature = async ( From c7990ed0947ef22dbb0bad8507b3970d38ad769b Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 26 Mar 2024 12:38:44 +0800 Subject: [PATCH 5/5] add notion to the features list --- packages/web/pages/settings/features/beta.tsx | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/packages/web/pages/settings/features/beta.tsx b/packages/web/pages/settings/features/beta.tsx index c48d274de..21ab7f17a 100644 --- a/packages/web/pages/settings/features/beta.tsx +++ b/packages/web/pages/settings/features/beta.tsx @@ -1,29 +1,15 @@ -import { useCallback, useEffect, useMemo, useState } from 'react' +import { Spinner } from 'phosphor-react' +import { useCallback, useMemo, useState } from 'react' import { Toaster } from 'react-hot-toast' import { Button } from '../../../components/elements/Button' -import { - Box, - HStack, - SpanBox, - VStack, -} from '../../../components/elements/LayoutPrimitives' +import { HStack, VStack } from '../../../components/elements/LayoutPrimitives' import { StyledText } from '../../../components/elements/StyledText' import { SettingsLayout } from '../../../components/templates/SettingsLayout' -import { styled, theme } from '../../../components/tokens/stitches.config' -import { updateEmailMutation } from '../../../lib/networking/mutations/updateEmailMutation' -import { updateUserMutation } from '../../../lib/networking/mutations/updateUserMutation' -import { updateUserProfileMutation } from '../../../lib/networking/mutations/updateUserProfileMutation' -import { useGetLibraryItemsQuery } from '../../../lib/networking/queries/useGetLibraryItemsQuery' +import { styled } from '../../../components/tokens/stitches.config' +import { optInFeature } from '../../../lib/networking/mutations/optIntoFeatureMutation' import { useGetViewerQuery } from '../../../lib/networking/queries/useGetViewerQuery' -import { useValidateUsernameQuery } from '../../../lib/networking/queries/useValidateUsernameQuery' import { applyStoredTheme } from '../../../lib/themeUpdater' import { showErrorToast, showSuccessToast } from '../../../lib/toastHelpers' -import { ConfirmationModal } from '../../../components/patterns/ConfirmationModal' -import { ProgressBar } from '../../../components/elements/ProgressBar' -import { emptyTrashMutation } from '../../../lib/networking/mutations/emptyTrashMutation' -import { ProgressIndicator } from '@radix-ui/react-progress' -import { Spinner } from 'phosphor-react' -import { optInFeature } from '../../../lib/networking/mutations/optIntoFeatureMutation' const ACCOUNT_LIMIT = 50_000 @@ -62,6 +48,10 @@ export default function Account(): JSX.Element { ) }, [viewerData]) + const hasNotion = useMemo(() => { + return (viewerData?.me?.features.indexOf('notion') ?? -1) !== -1 + }, [viewerData]) + applyStoredTheme() return ( @@ -121,7 +111,8 @@ export default function Account(): JSX.Element { ) })} - {!hasYouTube /* || !hasAISummaries || !hasDigest */ && ( + {(!hasYouTube || + !hasNotion) /* || !hasAISummaries || !hasDigest */ && ( Available beta features @@ -154,6 +145,31 @@ export default function Account(): JSX.Element { )} + {!hasNotion && ( + + + - Notion integration: Export your items and highlights + to Notion. + + + + )} + {/*