Skip to content

Commit

Permalink
refactor(scheduled-publishing): move SchedulePublishUpsellContext to …
Browse files Browse the repository at this point in the history
…singletons
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent 00fc838 commit 2164666
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {createContext} from 'react'

import type {SchedulePublishUpsellContextValue} from '../../../../core/scheduledPublishing/tool/contexts/SchedulePublishingUpsellProvider'

/**
* @internal
*/
export const SchedulePublishUpsellContext = createContext<SchedulePublishUpsellContextValue>({
upsellData: null,
handleOpenDialog: () => null,
upsellDialogOpen: false,
telemetryLogs: {
dialogSecondaryClicked: () => null,
dialogPrimaryClicked: () => null,
panelViewed: () => null,
panelDismissed: () => null,
panelPrimaryClicked: () => null,
panelSecondaryClicked: () => null,
},
})
1 change: 1 addition & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export * from './core/i18n/LocaleContext'
export * from './core/presence/FormFieldPresenceContext'
export * from './core/schedulePublishing/DocumentActionPropsContext'
export * from './core/schedulePublishing/tool/ScheduledPublishingEnabledContext'
export * from './core/schedulePublishing/tool/SchedulePublishingUpsellContext'
export * from './core/store/_legacy/ResourceCacheContext'
export * from './core/studio/activeWorkspaceMatcher/ActiveWorkspaceMatcherContext'
export * from './core/studio/addonDataset/AddonDatasetContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useTelemetry} from '@sanity/telemetry/react'
import {template} from 'lodash'
import {createContext, useCallback, useContext, useEffect, useMemo, useState} from 'react'
import {useCallback, useContext, useEffect, useMemo, useState} from 'react'
import {SchedulePublishUpsellContext} from 'sanity/_singletons'

import {useClient} from '../../../hooks/useClient'
import {useProjectId} from '../../../hooks/useProjectId'
Expand Down Expand Up @@ -29,24 +30,6 @@ export interface SchedulePublishUpsellContextValue {
}
}

/**
* @beta
* @hidden
*/
export const SchedulePublishUpsellContext = createContext<SchedulePublishUpsellContextValue>({
upsellData: null,
handleOpenDialog: () => null,
upsellDialogOpen: false,
telemetryLogs: {
dialogSecondaryClicked: () => null,
dialogPrimaryClicked: () => null,
panelViewed: () => null,
panelDismissed: () => null,
panelPrimaryClicked: () => null,
panelSecondaryClicked: () => null,
},
})

const FEATURE = 'scheduled_publishing' as const
const TEMPLATE_OPTIONS = {interpolate: /{{([\s\S]+?)}}/g}
const BASE_URL = 'www.sanity.io'
Expand Down

0 comments on commit 2164666

Please sign in to comment.