Skip to content

Commit

Permalink
Merge branch 'corel' into corel-175-2
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias authored Oct 31, 2024
2 parents 837847d + e69826a commit 293b1ee
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 22 deletions.
27 changes: 16 additions & 11 deletions packages/sanity/src/core/releases/hooks/usePerspective.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useCallback, useMemo} from 'react'
import {isPublishedPerspective} from 'sanity'
import {useRouter} from 'sanity/router'

import {useReleases} from '../../store/release'
Expand Down Expand Up @@ -54,7 +55,10 @@ export function usePerspective(): PerspectiveValue {
| `bundle.${string}`
| undefined

const excludedPerspectives = router.stickyParams.excludedPerspectives?.split(',') || EMPTY_ARRAY
const excludedPerspectives = useMemo(
() => router.stickyParams.excludedPerspectives?.split(',') || EMPTY_ARRAY,
[router.stickyParams.excludedPerspectives],
)

// TODO: Should it be possible to set the perspective within a pane, rather than globally?
const setPerspective = useCallback(
Expand Down Expand Up @@ -107,15 +111,15 @@ export function usePerspective(): PerspectiveValue {
const toggleExcludedPerspective = useCallback(
(excluded: string) => {
if (excluded === LATEST._id) return
const nextExcludedPerspectives: string[] = excludedPerspectives || []
const existingPerspectives = excludedPerspectives || []

const excludedPerspectiveId = excluded === 'published' ? 'published' : `bundle.${excluded}`
const excludedPerspectiveId = isPublishedPerspective(excluded)
? 'published'
: `bundle.${excluded}`

if (excludedPerspectives?.includes(excludedPerspectiveId)) {
nextExcludedPerspectives.splice(nextExcludedPerspectives.indexOf(excludedPerspectiveId), 1)
} else {
nextExcludedPerspectives.push(excludedPerspectiveId)
}
const nextExcludedPerspectives = existingPerspectives.includes(excludedPerspectiveId)
? existingPerspectives.filter((id) => id !== excludedPerspectiveId)
: [...existingPerspectives, excludedPerspectiveId]

router.navigateStickyParams({excludedPerspectives: nextExcludedPerspectives.toString()})
},
Expand All @@ -126,7 +130,7 @@ export function usePerspective(): PerspectiveValue {
(perspectiveId: string) =>
Boolean(
excludedPerspectives?.includes(
perspectiveId === 'published' ? 'published' : `bundle.${perspectiveId}`,
isPublishedPerspective(perspectiveId) ? 'published' : `bundle.${perspectiveId}`,
),
),
[excludedPerspectives],
Expand All @@ -140,8 +144,9 @@ export function usePerspective(): PerspectiveValue {
setPerspectiveFromRelease,
toggleExcludedPerspective,
currentGlobalBundle,
currentGlobalBundleId:
currentGlobalBundle === 'published' ? 'published' : currentGlobalBundle._id,
currentGlobalBundleId: isPublishedPerspective(currentGlobalBundle)

Check failure on line 147 in packages/sanity/src/core/releases/hooks/usePerspective.tsx

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest / node 18)

src/core/studio/components/navbar/search/components/common/__tests__/FilterLabel.test.tsx > FilterLabel > renders the filter label with field, operator, and value

TypeError: isPublishedPerspective is not a function ❯ src/core/releases/hooks/usePerspective.tsx:147:30 ❯ mountMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16406:19 ❯ Object.useMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16851:16 ❯ Proxy.useMemo ../../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:1650:21 ❯ Module.usePerspective src/core/releases/hooks/usePerspective.tsx:139:10 ❯ SearchProvider src/core/studio/components/navbar/search/contexts/search/SearchProvider.tsx:35:32 ❯ renderWithHooks ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:27465:14

Check failure on line 147 in packages/sanity/src/core/releases/hooks/usePerspective.tsx

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest / node 18)

src/core/studio/components/navbar/search/components/common/__tests__/FilterLabel.test.tsx > FilterLabel > renders only the field when showContent is false

TypeError: isPublishedPerspective is not a function ❯ src/core/releases/hooks/usePerspective.tsx:147:30 ❯ mountMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16406:19 ❯ Object.useMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16851:16 ❯ Proxy.useMemo ../../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:1650:21 ❯ Module.usePerspective src/core/releases/hooks/usePerspective.tsx:139:10 ❯ SearchProvider src/core/studio/components/navbar/search/contexts/search/SearchProvider.tsx:35:32 ❯ renderWithHooks ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:27465:14

Check failure on line 147 in packages/sanity/src/core/releases/hooks/usePerspective.tsx

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest / node 18)

src/core/studio/components/navbar/search/components/common/__tests__/FilterLabel.test.tsx > FilterLabel > handles missing operator descriptionKey

TypeError: isPublishedPerspective is not a function ❯ src/core/releases/hooks/usePerspective.tsx:147:30 ❯ mountMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16406:19 ❯ Object.useMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16851:16 ❯ Proxy.useMemo ../../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:1650:21 ❯ Module.usePerspective src/core/releases/hooks/usePerspective.tsx:139:10 ❯ SearchProvider src/core/studio/components/navbar/search/contexts/search/SearchProvider.tsx:35:32 ❯ renderWithHooks ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:27465:14

Check failure on line 147 in packages/sanity/src/core/releases/hooks/usePerspective.tsx

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest / node 20)

src/core/studio/components/navbar/search/components/common/__tests__/FilterLabel.test.tsx > FilterLabel > renders the filter label with field, operator, and value

TypeError: isPublishedPerspective is not a function ❯ src/core/releases/hooks/usePerspective.tsx:147:30 ❯ mountMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16406:19 ❯ Object.useMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16851:16 ❯ Proxy.useMemo ../../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:1650:21 ❯ Module.usePerspective src/core/releases/hooks/usePerspective.tsx:139:10 ❯ SearchProvider src/core/studio/components/navbar/search/contexts/search/SearchProvider.tsx:35:32 ❯ renderWithHooks ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:27465:14

Check failure on line 147 in packages/sanity/src/core/releases/hooks/usePerspective.tsx

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest / node 20)

src/core/studio/components/navbar/search/components/common/__tests__/FilterLabel.test.tsx > FilterLabel > renders only the field when showContent is false

TypeError: isPublishedPerspective is not a function ❯ src/core/releases/hooks/usePerspective.tsx:147:30 ❯ mountMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16406:19 ❯ Object.useMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16851:16 ❯ Proxy.useMemo ../../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:1650:21 ❯ Module.usePerspective src/core/releases/hooks/usePerspective.tsx:139:10 ❯ SearchProvider src/core/studio/components/navbar/search/contexts/search/SearchProvider.tsx:35:32 ❯ renderWithHooks ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:27465:14

Check failure on line 147 in packages/sanity/src/core/releases/hooks/usePerspective.tsx

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest / node 20)

src/core/studio/components/navbar/search/components/common/__tests__/FilterLabel.test.tsx > FilterLabel > handles missing operator descriptionKey

TypeError: isPublishedPerspective is not a function ❯ src/core/releases/hooks/usePerspective.tsx:147:30 ❯ mountMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16406:19 ❯ Object.useMemo ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:16851:16 ❯ Proxy.useMemo ../../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:1650:21 ❯ Module.usePerspective src/core/releases/hooks/usePerspective.tsx:139:10 ❯ SearchProvider src/core/studio/components/navbar/search/contexts/search/SearchProvider.tsx:35:32 ❯ renderWithHooks ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 ../../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:27465:14
? 'published'
: currentGlobalBundle._id,
bundlesPerspective,
isPerspectiveExcluded,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const GlobalPerspectiveMenuItem = forwardRef<
}}
>
<Text size={1} weight="medium">
{displayTitle}
{isReleasePublishedPerspective ? t('release.chip.published') : release.metadata.title}
</Text>
{!isPublishedPerspective(release) &&
release.metadata.releaseType !== 'undecided' &&
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/core/releases/navbar/ReleasesNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function ReleasesNav(): JSX.Element {
<Stack flex={1} paddingY={2} paddingRight={2} space={2}>
<Text size={1} textOverflow="ellipsis" weight="medium">
{isPublishedPerspective(currentGlobalBundle)
? 'Published'
? t('release.chip.published')
: (currentGlobalBundle.metadata?.title ??
t('release.placeholder-untitled-release'))}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@sanity/ui'
import {useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'
import {NavbarContext} from 'sanity/_singletons'
import {type RouterState, useRouter, useRouterState} from 'sanity/router'
import {type RouterState, useRouterState} from 'sanity/router'
import {styled} from 'styled-components'

import {Button, TooltipDelayGroupProvider} from '../../../../ui-components'
Expand Down Expand Up @@ -70,7 +70,6 @@ export function StudioNavbar(props: Omit<NavbarProps, 'renderDefault'>) {
} = props

const {name, tools} = useWorkspace()
const router = useRouter()
const routerState = useRouterState()
const mediaIndex = useMediaIndex()
const activeToolName = typeof routerState.tool === 'string' ? routerState.tool : undefined
Expand Down Expand Up @@ -163,8 +162,6 @@ export function StudioNavbar(props: Omit<NavbarProps, 'renderDefault'>) {
setDrawerOpen(true)
}, [])

const perspective = useMemo(() => router.stickyParams.perspective, [router.stickyParams])

const actionNodes = useMemo(() => {
if (!shouldRender.tools) return null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export function FreeTrial({type}: FreeTrialProps) {
size={0}
scheme={scheme}
radius={3}
tone="default"
portal
placement={type === 'sidebar' ? 'top' : 'bottom-end'}
content={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export function NewDocumentButton(props: NewDocumentButtonProps) {
constrainSize
onKeyDown={handlePopoverKeyDown}
open={open}
tone="default"
portal
radius={3}
ref={popoverRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function PresenceMenu() {
placement: 'bottom',
portal: true,
scheme: scheme,
tone: 'default',
}),
[scheme],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function ResourcesButton() {
<ResourcesMenuItems error={error} isLoading={isLoading} value={value} />
</StyledMenu>
}
popover={{constrainSize: true}}
popover={{constrainSize: true, tone: 'default'}}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Flex} from '@sanity/ui'
import {startCase} from 'lodash'
import {forwardRef, type Ref, useMemo, useState} from 'react'

import {Button} from '../../../../../ui-components'
import {Button, type MenuButtonProps} from '../../../../../ui-components'
import {useRovingFocus} from '../../../../components'
import {CollapseTabList} from '../../../../components/collapseTabList/CollapseTabList'
import {type Tool} from '../../../../config'
Expand All @@ -24,12 +24,13 @@ export function ToolCollapseMenu(props: ToolCollapseMenuProps) {
navigation: ['arrows'],
})

const menuButtonProps = useMemo(
const menuButtonProps: Partial<MenuButtonProps> = useMemo(
() => ({
popover: {
constrainSize: true,
portal: true,
scheme: scheme,
tone: 'default',
},
}),
[scheme],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function UserMenu() {
preventOverflow: true,
scheme: scheme,
constrainSize: true,
tone: 'default',
}),
[scheme],
)
Expand Down
4 changes: 2 additions & 2 deletions packages/sanity/src/router/RouterProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ export function RouterProvider(props: RouterProviderProps): ReactElement {
const allNextSearchParams = [...(state._searchParams || []), ...Object.entries(params)]

const searchParams = Object.entries(
allNextSearchParams.reduce(
allNextSearchParams.reduce<SearchParam>(
(deduppedSearchParams, [key, value]) => ({
...deduppedSearchParams,
[key]: value,
}),
[],
[] as unknown as SearchParam,
),
)

Expand Down

0 comments on commit 293b1ee

Please sign in to comment.