Skip to content

Commit

Permalink
fix(corel): fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Jul 5, 2024
1 parent a32b76d commit 1a91266
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 15 deletions.
3 changes: 3 additions & 0 deletions packages/sanity/src/core/bundles/components/BundleBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {type CSSProperties} from 'react'

import {type BundleDocument} from '../../store/bundles/types'

/**
* @internal
*/
export function BundleBadge(
props: Partial<BundleDocument> & {openButton?: boolean; padding?: number; title?: string},
): JSX.Element {
Expand Down
3 changes: 3 additions & 0 deletions packages/sanity/src/core/bundles/components/BundleMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ interface BundleListProps {
actions?: ReactElement
}

/**
* @internal
*/
export function BundleMenu(props: BundleListProps): JSX.Element {
const {bundles, loading, actions, button} = props
const hasBundles = bundles && bundles.filter((b) => !isDraftOrPublished(b.name)).length > 0
Expand Down
3 changes: 3 additions & 0 deletions packages/sanity/src/core/bundles/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './BundleBadge'
export * from './BundleMenu'
export * from './panes/BundleActions'
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ interface BundleActionsProps {
documentType: string
}

/**
* @internal
*/
export function BundleActions(props: BundleActionsProps): JSX.Element {
const {currentGlobalBundle, documentId, documentType} = props
const {name, title} = currentGlobalBundle
Expand Down
1 change: 1 addition & 0 deletions packages/sanity/src/core/bundles/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './usePerspective'
3 changes: 3 additions & 0 deletions packages/sanity/src/core/bundles/hooks/usePerspective.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export interface PerspectiveValue {
setPerspective: (name: string) => void
}

/**
* @internal
*/
export function usePerspective(): PerspectiveValue {
const router = useRouter()
const {data: bundles} = useBundles()
Expand Down
4 changes: 4 additions & 0 deletions packages/sanity/src/core/bundles/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './components'
export * from './hooks'
export * from './util/const'
export * from './util/dummyGetters'
3 changes: 3 additions & 0 deletions packages/sanity/src/core/bundles/util/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import {type BundleDocument} from '../../store/bundles/types'

/**
* @internal
*/
export const LATEST: Partial<BundleDocument> = {
name: 'drafts',
title: 'Latest',
Expand Down
1 change: 1 addition & 0 deletions packages/sanity/src/core/bundles/util/dummyGetters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {type BundleDocument} from '../../store/bundles/types'

/**
* Returns all versions of a document
* @internal
*
* @param documentId - document id
* @param client - sanity client
Expand Down
8 changes: 8 additions & 0 deletions packages/sanity/src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export {
BundleActions,
BundleBadge,
BundleMenu,
getAllVersionsOfDocument,
LATEST,
usePerspective,
} from './bundles'
export * from './changeIndicators'
export {
CommentInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
useMemo,
useState,
} from 'react'
import {useRouter} from 'sanity/router'

import {useRouter} from '../../../router'
import {type PreviewProps} from '../../components'
import {type RenderPreviewCallbackProps} from '../../form'
import {useTranslation} from '../../i18n'
Expand Down
6 changes: 6 additions & 0 deletions packages/sanity/src/core/store/bundles/BundlesProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ interface BundlesProviderProps {

const EMPTY_ARRAY: [] = []

/**
* @internal
*/
export type BundlesContextValue = {
dispatch: Dispatch<bundlesReducerAction>
loading: boolean
Expand Down Expand Up @@ -38,6 +41,9 @@ export function BundlesProvider(props: BundlesProviderProps) {
return <BundlesContext.Provider value={value}>{children}</BundlesContext.Provider>
}

/**
* @internal
*/
export function useBundles(): BundlesContextValue {
const context = useContext(BundlesContext)
if (!context) {
Expand Down
4 changes: 3 additions & 1 deletion packages/sanity/src/core/store/bundles/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './useBundlesStore'
export * from './BundlesProvider'
export * from './types'
export {useBundlesStore} from './useBundlesStore'
6 changes: 6 additions & 0 deletions packages/sanity/src/core/store/bundles/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {type ColorHueKey} from '@sanity/color'
import {type IconSymbol} from '@sanity/icons'
import {type SanityDocument} from '@sanity/types'

/**
* @internal
*/
export interface BundleDocument extends SanityDocument {
_type: 'bundle'
title: string
Expand All @@ -13,6 +16,9 @@ export interface BundleDocument extends SanityDocument {
publishedAt?: string
}

/**
* @internal
*/
export function isBundleDocument(doc: unknown): doc is BundleDocument {
return typeof doc === 'object' && doc !== null && '_type' in doc && doc._type === 'bundle'
}
3 changes: 3 additions & 0 deletions packages/sanity/src/core/store/bundles/useBundlesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const QUERY_SORT_ORDER = `order(${SORT_FIELD} ${SORT_ORDER})`

const QUERY = `*[${QUERY_FILTERS.join(' && ')}] ${QUERY_PROJECTION} | ${QUERY_SORT_ORDER}`

/**
* @internal
*/
export function useBundlesStore(): BundlesStoreReturnType {
const {client} = useAddonDataset()

Expand Down
1 change: 1 addition & 0 deletions packages/sanity/src/core/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './_legacy'
export * from './bundles'
export * from './user'
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import {ChevronDownIcon} from '@sanity/icons'
import {Box, Button} from '@sanity/ui'
import {useCallback, useEffect, useState} from 'react'
import {DEFAULT_STUDIO_CLIENT_OPTIONS, useClient} from 'sanity'

import {BundleBadge} from '../../../../../../core/bundles/components/BundleBadge'
import {BundleMenu} from '../../../../../../core/bundles/components/BundleMenu'
import {usePerspective} from '../../../../../../core/bundles/hooks/usePerspective'
import {LATEST} from '../../../../../../core/bundles/util/const'
import {getAllVersionsOfDocument} from '../../../../../../core/bundles/util/dummyGetters'
import {useBundles} from '../../../../../../core/store/bundles/BundlesProvider'
import {type BundleDocument} from '../../../../../../core/store/bundles/types'
import {
BundleBadge,
type BundleDocument,
BundleMenu,
DEFAULT_STUDIO_CLIENT_OPTIONS,
getAllVersionsOfDocument,
LATEST,
useBundles,
useClient,
usePerspective,
} from 'sanity'

export function DocumentPerspectiveMenu(props: {documentId: string}): JSX.Element {
const {documentId} = props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import {Flex, Hotkeys, LayerProvider, Stack, Text} from '@sanity/ui'
import {memo, useMemo, useState} from 'react'
import {
BundleActions,
type DocumentActionComponent,
type DocumentActionDescription,
isBundleDocument,
LATEST,
shouldArrayDialogOpen,
usePerspective,
useSource,
useTimelineSelector,
} from 'sanity'

import {BundleActions} from '../../../../core/bundles/components/panes/BundleActions'
import {usePerspective} from '../../../../core/bundles/hooks/usePerspective'
import {LATEST} from '../../../../core/bundles/util/const'
import {isBundleDocument} from '../../../../core/store/bundles/types'
import {Button, Tooltip} from '../../../../ui-components'
import {RenderActionCollectionState} from '../../../components'
import {HistoryRestoreAction} from '../../../documentActions'
Expand Down

0 comments on commit 1a91266

Please sign in to comment.