From ad1b8a35cc468233e1a7273fb07a0430316ad460 Mon Sep 17 00:00:00 2001 From: RitaDias Date: Thu, 5 Sep 2024 11:50:35 +0200 Subject: [PATCH] refactor(sanity): rename BundleIconEditorPicker to ReleaseIconEditorPicker --- .../src/core/bundles/components/ReleaseBadge.tsx | 2 +- .../src/core/bundles/components/dialog/ReleaseForm.tsx | 8 ++++---- ...conEditorPicker.tsx => ReleaseIconEditorPicker.tsx} | 8 ++++---- ...icker.test.tsx => ReleaseIconEditorPicker.test.tsx} | 2 +- .../src/core/releases/tool/detail/ReleaseSummary.tsx | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) rename packages/sanity/src/core/bundles/components/dialog/{BundleIconEditorPicker.tsx => ReleaseIconEditorPicker.tsx} (95%) rename packages/sanity/src/core/bundles/components/dialog/__tests__/{BundleIconEditorPicker.test.tsx => ReleaseIconEditorPicker.test.tsx} (98%) diff --git a/packages/sanity/src/core/bundles/components/ReleaseBadge.tsx b/packages/sanity/src/core/bundles/components/ReleaseBadge.tsx index 1f32f4f5c162..d7554a4b0c30 100644 --- a/packages/sanity/src/core/bundles/components/ReleaseBadge.tsx +++ b/packages/sanity/src/core/bundles/components/ReleaseBadge.tsx @@ -52,7 +52,7 @@ export function ReleaseBadge( {icon && ( - + )} diff --git a/packages/sanity/src/core/bundles/components/dialog/ReleaseForm.tsx b/packages/sanity/src/core/bundles/components/dialog/ReleaseForm.tsx index d7b2b1fc998b..150de29d08f9 100644 --- a/packages/sanity/src/core/bundles/components/dialog/ReleaseForm.tsx +++ b/packages/sanity/src/core/bundles/components/dialog/ReleaseForm.tsx @@ -14,7 +14,7 @@ import {type CalendarLabels} from '../../../../ui-components/inputs/DateInputs/c import {DateTimeInput} from '../../../../ui-components/inputs/DateInputs/DateTimeInput' import {getCalendarLabels} from '../../../form/inputs/DateInputs/utils' import {type BundleDocument} from '../../../store/bundles/types' -import {BundleIconEditorPicker, type BundleIconEditorPickerValue} from './BundleIconEditorPicker' +import {ReleaseIconEditorPicker, type ReleaseIconEditorPickerValue} from './ReleaseIconEditorPicker' interface BaseBundleDocument extends Partial { hue: ColorHueKey @@ -50,7 +50,7 @@ export function ReleaseForm(props: { publishedAt ? dateFormatter.format(new Date(publishedAt)) : undefined, ) - const iconValue: BundleIconEditorPickerValue = useMemo( + const iconValue: ReleaseIconEditorPickerValue = useMemo( () => ({ icon: icon ?? DEFAULT_BUNDLE.icon, hue: hue ?? DEFAULT_BUNDLE.hue, @@ -89,7 +89,7 @@ export function ReleaseForm(props: { ) const handleIconValueChange = useCallback( - (pickedIcon: BundleIconEditorPickerValue) => { + (pickedIcon: ReleaseIconEditorPickerValue) => { onChange({...value, icon: pickedIcon.icon, hue: pickedIcon.hue}) }, [onChange, value], @@ -98,7 +98,7 @@ export function ReleaseForm(props: { return ( - + diff --git a/packages/sanity/src/core/bundles/components/dialog/BundleIconEditorPicker.tsx b/packages/sanity/src/core/bundles/components/dialog/ReleaseIconEditorPicker.tsx similarity index 95% rename from packages/sanity/src/core/bundles/components/dialog/BundleIconEditorPicker.tsx rename to packages/sanity/src/core/bundles/components/dialog/ReleaseIconEditorPicker.tsx index aedf30befa0e..f46e910e3984 100644 --- a/packages/sanity/src/core/bundles/components/dialog/BundleIconEditorPicker.tsx +++ b/packages/sanity/src/core/bundles/components/dialog/ReleaseIconEditorPicker.tsx @@ -17,14 +17,14 @@ const IconPickerFlex = styled(Flex)` max-width: 269px; ` -export interface BundleIconEditorPickerValue { +export interface ReleaseIconEditorPickerValue { hue: BundleDocument['hue'] icon: BundleDocument['icon'] } -export function BundleIconEditorPicker(props: { - onChange: (value: BundleIconEditorPickerValue) => void - value: BundleIconEditorPickerValue +export function ReleaseIconEditorPicker(props: { + onChange: (value: ReleaseIconEditorPickerValue) => void + value: ReleaseIconEditorPickerValue }): JSX.Element { const {onChange, value} = props diff --git a/packages/sanity/src/core/bundles/components/dialog/__tests__/BundleIconEditorPicker.test.tsx b/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx similarity index 98% rename from packages/sanity/src/core/bundles/components/dialog/__tests__/BundleIconEditorPicker.test.tsx rename to packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx index 454310fb5daf..2064b3c31ad4 100644 --- a/packages/sanity/src/core/bundles/components/dialog/__tests__/BundleIconEditorPicker.test.tsx +++ b/packages/sanity/src/core/bundles/components/dialog/__tests__/ReleaseIconEditorPicker.test.tsx @@ -2,7 +2,7 @@ import {beforeEach, describe, expect, it, jest} from '@jest/globals' import {fireEvent, render, screen} from '@testing-library/react' import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' -import {BundleIconEditorPicker, type BundleIconEditorPickerValue} from '../BundleIconEditorPicker' +import {BundleIconEditorPicker, type BundleIconEditorPickerValue} from '../ReleaseIconEditorPicker' jest.mock('sanity', () => ({ useTranslation: jest.fn().mockReturnValue({t: jest.fn()}), diff --git a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx index ad36018f4d6e..fc85fb86b81c 100644 --- a/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx +++ b/packages/sanity/src/core/releases/tool/detail/ReleaseSummary.tsx @@ -3,9 +3,9 @@ import {AvatarStack, Box, Flex, Heading, Stack, Text, useToast} from '@sanity/ui import {type RefObject, useCallback, useEffect, useMemo, useState} from 'react' import { - BundleIconEditorPicker, - type BundleIconEditorPickerValue, -} from '../../../bundles/components/dialog/BundleIconEditorPicker' + ReleaseIconEditorPicker, + type ReleaseIconEditorPickerValue, +} from '../../../bundles/components/dialog/ReleaseIconEditorPicker' import {RelativeTime} from '../../../components/RelativeTime' import {UserAvatar} from '../../../components/userAvatar/UserAvatar' import {Translate, useTranslation} from '../../../i18n' @@ -47,7 +47,7 @@ export function ReleaseSummary(props: ReleaseSummaryProps) { const {t} = useTranslation(releasesLocaleNamespace) const {updateBundle} = useBundleOperations() - const [iconValue, setIconValue] = useState(setIconHue({hue, icon})) + const [iconValue, setIconValue] = useState(setIconHue({hue, icon})) const toast = useToast() const handleIconValueChange = useCallback( async (value: {hue: BundleDocument['hue']; icon: BundleDocument['icon']}) => { @@ -105,7 +105,7 @@ export function ReleaseSummary(props: ReleaseSummaryProps) { <> - +