Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(releases): sorting release overview table #7159

Merged
merged 5 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {createContext, useContext} from 'react'

/**
* @internal
*/
export interface TableContextValue {
searchTerm: string | null
setSearchTerm: (searchTerm: string) => void
sort: {column: string; direction: 'asc' | 'desc'} | null
setSearchColumn: (column: string) => void
}

const DEFAULT_TABLE_CONTEXT: TableContextValue = {
searchTerm: null,
setSearchTerm: () => null,
sort: null,
setSearchColumn: () => null,
}

/**
* @internal
*/
export const TableContext = createContext<TableContextValue | null>(null)

/**
* @internal
*/
export const useTableContext = (): TableContextValue => {
const context = useContext(TableContext)
if (!context) {
throw new Error('useTableContext must be used within a TableProvider')
}
return context || DEFAULT_TABLE_CONTEXT
}
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/form/studio/ValidationContext'
export * from './core/i18n/LocaleContext'
export * from './core/presence/FormFieldPresenceContext'
export * from './core/releases/BundlesMetadataContext'
export * from './core/releases/ReleasesTableContext'
export * from './core/schedulePublishing/DocumentActionPropsContext'
export * from './core/schedulePublishing/tool/ScheduledPublishingEnabledContext'
export * from './core/schedulePublishing/tool/SchedulePublishingUpsellContext'
Expand Down
14 changes: 11 additions & 3 deletions packages/sanity/src/core/bundles/components/BundleBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {hues} from '@sanity/color'
import {ChevronDownIcon, Icon} from '@sanity/icons'
import {type ColorHueKey, hues} from '@sanity/color'
import {ChevronDownIcon, Icon, type IconSymbol} from '@sanity/icons'
// eslint-disable-next-line camelcase
import {Box, Flex, rgba, Text, useTheme_v2} from '@sanity/ui'
import {type CSSProperties} from 'react'
Expand All @@ -10,7 +10,15 @@ import {type BundleDocument} from '../../store/bundles/types'
* @internal
*/
export function BundleBadge(
props: Partial<BundleDocument> & {openButton?: boolean; padding?: number; title?: string},
props: Partial<
BundleDocument & {
icon: IconSymbol
hue: ColorHueKey
openButton: boolean
padding: number
title: string
}
>,
): JSX.Element {
const {hue = 'gray', icon, openButton, padding = 3, title} = props
const {color} = useTheme_v2()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const BundleMenuButton = ({bundle, documentCount}: Props) => {
padding={bundleHasDocuments}
footer={{
confirmButton: {
text: 'Delete',
tone: 'default',
onClick: handleOnDeleteBundle,
loading: discardStatus === 'discarding',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('BundleMenuButton', () => {
screen.getByText('This will also delete 2 document versions', {exact: false})

await act(() => {
fireEvent.click(screen.getByText('Confirm'))
fireEvent.click(screen.getByText('Delete'))
juice49 marked this conversation as resolved.
Show resolved Hide resolved
})

expect(useBundleOperations().deleteBundle).toHaveBeenCalledWith(activeBundle)
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('BundleMenuButton', () => {
expect(screen.queryByTestId('confirm-delete-body')).toBeNull()

await act(() => {
fireEvent.click(screen.getByText('Confirm'))
fireEvent.click(screen.getByText('Delete'))
})

expect(useBundleOperations().deleteBundle).toHaveBeenCalledWith(activeEmptyBundle)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading