Skip to content

Commit

Permalink
chore(sanity): remove beta and unstable from comments and tasks (#6478)
Browse files Browse the repository at this point in the history
* chore(sanity): remove beta and unstable from comments and tasks

* chore(test-studio): remove unneeded config

* chore(sanity): fix comment
  • Loading branch information
RitaDias committed Apr 30, 2024
1 parent e618da3 commit f92ba3e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 17 deletions.
5 changes: 2 additions & 3 deletions dev/test-studio/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ const sharedSettings = definePlugin({
return prev
},
newDocumentOptions,

unstable_comments: {
comments: {
enabled: true,
},
badges: (prev, context) => (context.schemaType === 'author' ? [CustomBadge, ...prev] : prev),
Expand Down Expand Up @@ -157,7 +156,7 @@ export default defineConfig([
enabled: true,
inputDateTimeFormat: 'MM/dd/yy h:mm a',
},
unstable_tasks: {
tasks: {
enabled: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function useResolveCommentsEnabled(
// Check if the projects plan has the feature enabled
const {enabled: featureEnabled, isLoading, error} = useFeatureEnabled('studioComments')

const {enabled} = useSource().document.unstable_comments
const {enabled} = useSource().document.comments
// Check if the feature is enabled for the current document in the config
const enabledFromConfig = useMemo(
() => enabled({documentType, documentId: getPublishedId(documentId)}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {forwardRef, useCallback} from 'react'
import {styled} from 'styled-components'

import {Button, MenuButton, MenuItem} from '../../../../ui-components'
import {BetaBadge} from '../../../components'
import {useTranslation} from '../../../i18n'
import {commentsLocaleNamespace} from '../../i18n'
import {type CommentStatus, type CommentsUIMode} from '../../types'
Expand Down Expand Up @@ -39,8 +38,6 @@ export const CommentsInspectorHeader = forwardRef(function CommentsInspectorHead
<Text as="h1" size={1} weight="medium">
{t('feature-name')}
</Text>

<BetaBadge />
</Flex>

<Flex flex="none" padding={1} gap={2}>
Expand Down
5 changes: 3 additions & 2 deletions packages/sanity/src/core/config/configPropertyReducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,15 @@ export const documentCommentsEnabledReducer = (opts: {
// That is, if a plugin returns true, but the next plugin returns false, the result will be false.
// The last plugin 'wins'.
const result = flattenedConfig.reduce((acc, {config: innerConfig}) => {
const resolver = innerConfig.document?.unstable_comments?.enabled
const resolver =
innerConfig.document?.comments?.enabled ?? innerConfig.document?.unstable_comments?.enabled

if (!resolver && typeof resolver !== 'boolean') return acc
if (typeof resolver === 'function') return resolver(context)
if (typeof resolver === 'boolean') return resolver

throw new Error(
`Expected \`document.unstable_comments.enabled\` to be a boolean or a function, but received ${getPrintableType(
`Expected \`document.comments.enabled\` to be a boolean or a function, but received ${getPrintableType(
resolver,
)}`,
)
Expand Down
11 changes: 10 additions & 1 deletion packages/sanity/src/core/config/prepareConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ function resolveSource({
propertyName: 'document.unstable_languageFilter',
reducer: documentLanguageFilterReducer,
}),

/** @todo this is deprecated so it will eventually be removed */
unstable_comments: {
enabled: (partialContext) => {
return documentCommentsEnabledReducer({
Expand All @@ -543,6 +543,15 @@ function resolveSource({
})
},
},
comments: {
enabled: (partialContext) => {
return documentCommentsEnabledReducer({
context: partialContext,
config,
initialValue: true,
})
},
},
},

form: {
Expand Down
1 change: 1 addition & 0 deletions packages/sanity/src/core/config/resolveDefaultPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function getDefaultPluginsOptions(
tasks: {
enabled: true,
...workspace.unstable_tasks,
...workspace.tasks,
},
scheduledPublishing: {
...DEFAULT_SCHEDULED_PUBLISH_PLUGIN_OPTIONS,
Expand Down
23 changes: 18 additions & 5 deletions packages/sanity/src/core/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,15 @@ export interface DocumentPluginOptions {
*/
newDocumentOptions?: NewDocumentOptionsResolver

/** @internal */
/** @deprecated Use `comments` instead */
unstable_comments?: {
enabled: boolean | ((context: DocumentCommentsEnabledContext) => boolean)
}

/** @internal */
comments?: {
enabled: boolean | ((context: DocumentCommentsEnabledContext) => boolean)
}
}

/**
Expand Down Expand Up @@ -433,10 +438,13 @@ export interface WorkspaceOptions extends SourceOptions {
*/
unstable_sources?: SourceOptions[]
/**
* @hidden
* @beta
* @deprecated Use `tasks` instead
*/
unstable_tasks?: DefaultPluginsWorkspaceOptions['tasks']
/**
* @internal
*/
tasks?: DefaultPluginsWorkspaceOptions['tasks']

/**
* @hidden
Expand Down Expand Up @@ -654,10 +662,15 @@ export interface Source {
*/
inspectors: (props: PartialContext<DocumentInspectorContext>) => DocumentInspector[]

/** @internal */
/** @deprecated Use `comments` instead */
unstable_comments: {
enabled: (props: DocumentCommentsEnabledContext) => boolean
}

/** @internal */
comments: {
enabled: (props: DocumentCommentsEnabledContext) => boolean
}
}

/** @internal */
Expand Down Expand Up @@ -756,7 +769,7 @@ export interface Source {
i18next: i18n
}
/** @beta */
tasks?: WorkspaceOptions['unstable_tasks']
tasks?: WorkspaceOptions['tasks']
/** @beta */
serverActions?: WorkspaceOptions['unstable_serverActions']
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import {useCallback} from 'react'

import {Button} from '../../../../ui-components'
import {BetaBadge} from '../../../components'
import {useTranslation} from '../../../i18n'
import {useTasksEnabled, useTasksNavigation} from '../../context'
import {tasksLocaleNamespace} from '../../i18n'
Expand Down Expand Up @@ -65,7 +64,6 @@ export function TasksSidebarHeader(props: TasksSidebarHeaderProps) {
</Box>
</>
)}
<BetaBadge marginLeft={2} />
</Flex>
{(viewMode === 'create' || viewMode === 'draft') && <TasksHeaderDraftsMenu />}
{viewMode === 'edit' && <TasksActiveTabNavigation items={allItems} />}
Expand Down

0 comments on commit f92ba3e

Please sign in to comment.