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

refactor(core): rename dialogs #7774

Merged
merged 1 commit into from
Nov 7, 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
Expand Up @@ -13,13 +13,13 @@ import {createReleaseId} from '../../util/createReleaseId'
import {getBundleIdFromReleaseDocumentId} from '../../util/getBundleIdFromReleaseDocumentId'
import {ReleaseForm} from './ReleaseForm'

interface ReleaseDetailsDialogProps {
interface CreateReleaseDialogProps {
onCancel: () => void
onSubmit: (createdReleaseId: string) => void
origin?: OriginInfo['origin']
}

export function ReleaseDetailsDialog(props: ReleaseDetailsDialogProps): JSX.Element {
export function CreateReleaseDialog(props: CreateReleaseDialogProps): JSX.Element {
const {onCancel, onSubmit, origin} = props
const toast = useToast()
const {createRelease} = useReleaseOperations()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {DateTimeInput} from '../../../../ui-components/inputs/DateInputs/DateTim
import {getCalendarLabels} from '../../../form/inputs/DateInputs/utils'
import {useTranslation} from '../../../i18n'
import {type EditableReleaseDocument, type ReleaseType} from '../../store/types'
import {ReleaseInputsForm} from './ReleaseInputsForm'
import {TitleDescriptionForm} from './TitleDescriptionForm'

const RELEASE_TYPES: ReleaseType[] = ['asap', 'scheduled', 'undecided']

Expand Down Expand Up @@ -144,7 +144,7 @@ export function ReleaseForm(props: {
)}
</Flex>
</Stack>
<ReleaseInputsForm release={value} onChange={handleTitleDescriptionChange} />
<TitleDescriptionForm release={value} onChange={handleTitleDescriptionChange} />
</Stack>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const DescriptionTextArea = styled.textarea((props) => {
`
})

export function ReleaseInputsForm({
export function TitleDescriptionForm({
release,
onChange,
}: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {createTestProvider} from '../../../../../../test/testUtils/TestProvider'
import {type ReleaseDocument} from '../../../index'
import {useReleaseOperations} from '../../../store/useReleaseOperations'
import {useReleases} from '../../../store/useReleases'
import {ReleaseDetailsDialog} from '../ReleaseDetailsDialog'
import {CreateReleaseDialog} from '../CreateReleaseDialog'

vi.mock('../../../store/useReleases', () => ({
useReleases: vi.fn(),
Expand All @@ -27,7 +27,7 @@ vi.mock('../../../i18n/hooks/useTranslation', () => ({
const mockUseBundleStore = useReleases as Mock<typeof useReleases>
//const mockUseDateTimeFormat = useDateTimeFormat as Mock

describe('ReleaseDetailsDialog', () => {
describe('CreateReleaseDialog', () => {
beforeEach(() => {
vi.clearAllMocks()
})
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('ReleaseDetailsDialog', () => {
//mockUseDateTimeFormat.mockReturnValue({format: vi.fn().mockReturnValue('Mocked date')})

const wrapper = await createTestProvider()
render(<ReleaseDetailsDialog onCancel={onCancelMock} onSubmit={onSubmitMock} />, {wrapper})
render(<CreateReleaseDialog onCancel={onCancelMock} onSubmit={onSubmitMock} />, {wrapper})
})
afterEach(() => {
vitest.resetAllMocks()
Expand All @@ -74,7 +74,7 @@ describe('ReleaseDetailsDialog', () => {
// TODO: Fix this test
it.skip('should call createRelease and onCreate when form is submitted', async () => {
// const wrapper = await createTestProvider()
// render(<ReleaseDetailsDialog onCancel={onCancelMock} onSubmit={onSubmitMock} />, {wrapper})
// render(<CreateReleaseDialog onCancel={onCancelMock} onSubmit={onSubmitMock} />, {wrapper})

const value: Partial<ReleaseDocument> = {
metadata: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {getBundleIdFromReleaseDocumentId} from '../../util/getBundleIdFromReleas
import {DiscardVersionDialog} from '../dialog/DiscardVersionDialog'
import {ReleaseAvatar} from '../ReleaseAvatar'
import {VersionContextMenu} from './contextMenu/VersionContextMenu'
import {CreateReleaseDialog} from './dialog/CreateReleaseDialog'
import {CopyToNewReleaseDialog} from './dialog/CopyToNewReleaseDialog'

const Chip = styled(Button)`
border-radius: 9999px !important;
Expand Down Expand Up @@ -214,7 +214,7 @@ export const VersionChip = memo(function VersionChip(props: {
)}

{isCreateReleaseDialogOpen && (
<CreateReleaseDialog
<CopyToNewReleaseDialog
onClose={() => setIsCreateReleaseDialogOpen(false)}
onCreateVersion={handleAddVersion}
documentId={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {createReleaseId} from '../../../util/createReleaseId'
import {ReleaseForm} from '../../dialog/ReleaseForm'
import {ReleaseAvatar} from '../../ReleaseAvatar'

export function CreateReleaseDialog(props: {
export function CopyToNewReleaseDialog(props: {
onClose: () => void
documentId: string
documentType: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {css, styled} from 'styled-components'

import {MenuButton} from '../../../ui-components'
import {useTranslation} from '../../i18n'
import {ReleaseDetailsDialog} from '../components/dialog/ReleaseDetailsDialog'
import {CreateReleaseDialog} from '../components/dialog/CreateReleaseDialog'
import {usePerspective} from '../hooks'
import {type ReleaseDocument, type ReleaseType} from '../store/types'
import {useReleases} from '../store/useReleases'
Expand Down Expand Up @@ -205,7 +205,7 @@ export function GlobalPerspectiveMenu(): JSX.Element {
}}
/>
{createBundleDialogOpen && (
<ReleaseDetailsDialog onCancel={handleClose} onSubmit={handleClose} origin="structure" />
<CreateReleaseDialog onCancel={handleClose} onSubmit={handleClose} origin="structure" />
)}
</>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useCallback, useState} from 'react'

import {ReleaseInputsForm} from '../../components/dialog/ReleaseInputsForm'
import {TitleDescriptionForm} from '../../components/dialog/TitleDescriptionForm'
import {type EditableReleaseDocument, type ReleaseDocument, useReleaseOperations} from '../../index'

export function ReleaseDetailsEditor({release}: {release: ReleaseDocument}): JSX.Element {
Expand All @@ -21,5 +21,5 @@ export function ReleaseDetailsEditor({release}: {release: ReleaseDocument}): JSX
[timer, updateRelease],
)

return <ReleaseInputsForm release={release} onChange={handleOnChange} />
return <TitleDescriptionForm release={release} onChange={handleOnChange} />
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '../../../../ui-components/inputs/DateFilters/calendar/CalendarFilter'
import {useTranslation} from '../../../i18n'
import useTimeZone from '../../../scheduledPublishing/hooks/useTimeZone'
import {ReleaseDetailsDialog} from '../../components/dialog/ReleaseDetailsDialog'
import {CreateReleaseDialog} from '../../components/dialog/CreateReleaseDialog'
import {usePerspective} from '../../hooks/usePerspective'
import {releasesLocaleNamespace} from '../../i18n'
import {type ReleaseDocument, useReleases} from '../../index'
Expand Down Expand Up @@ -280,7 +280,7 @@ export function ReleasesOverview() {
if (!isCreateReleaseDialogOpen) return null

return (
<ReleaseDetailsDialog
<CreateReleaseDialog
onCancel={() => setIsCreateReleaseDialogOpen(false)}
onSubmit={handleOnCreateRelease}
origin="release-plugin"
Expand Down
Loading