diff --git a/src/components/site-form.tsx b/src/modules/add-site/components/create-site-form.tsx similarity index 74% rename from src/components/site-form.tsx rename to src/modules/add-site/components/create-site-form.tsx index c3ae99c2a7..51d9b08248 100644 --- a/src/components/site-form.tsx +++ b/src/modules/add-site/components/create-site-form.tsx @@ -1,22 +1,14 @@ import { Icon, SelectControl, Notice } from '@wordpress/components'; import { createInterpolateElement } from '@wordpress/element'; import { __, sprintf, _n } from '@wordpress/i18n'; -import { - tip, - cautionFilled, - trash, - chevronRight, - chevronDown, - chevronLeft, -} from '@wordpress/icons'; +import { tip, cautionFilled, chevronRight, chevronDown, chevronLeft } from '@wordpress/icons'; import { useI18n } from '@wordpress/react-i18n'; -import { FormEvent, useRef, useState, useEffect } from 'react'; +import { FormEvent, useState, useEffect } from 'react'; import { generateCustomDomainFromSiteName } from 'common/lib/domains'; import Button from 'src/components/button'; import FolderIcon from 'src/components/folder-icon'; import TextControlComponent from 'src/components/text-control'; import { WPVersionSelector } from 'src/components/wp-version-selector'; -import { ACCEPTED_IMPORT_FILE_TYPES } from 'src/constants'; import { cx } from 'src/lib/cx'; import { getIpcApi } from 'src/lib/get-ipc-api'; import { getLocalizedLink } from 'src/lib/get-localized-link'; @@ -33,19 +25,9 @@ interface FormPathInputComponentProps { onClick: () => void; error?: string; doesPathContainWordPress: boolean; - isDisabled: boolean; id?: string; } -interface FormImportComponentProps { - value?: File | null; - onFileSelected?: ( file: File ) => void; - onClear?: () => void; - onChange: ( file: File | null ) => void; - error?: string; - placeholder?: string; -} - interface SiteFormErrorProps { error?: string; tipMessage?: string; @@ -53,20 +35,13 @@ interface SiteFormErrorProps { } interface SiteFormProps { - className?: string; - children?: React.ReactNode; siteName: string; setSiteName: ( name: string ) => void; sitePath?: string; onSelectPath?: () => void; error: string; doesPathContainWordPress?: boolean; - isPathInputDisabled?: boolean; onSubmit: ( event: FormEvent ) => void; - fileForImport?: File | null; - setFileForImport?: ( file: File | null ) => void; - onFileSelected?: ( file: File ) => void; - fileError?: string; useCustomDomain?: boolean; setUseCustomDomain?: ( use: boolean ) => void; customDomain?: string | null; @@ -112,7 +87,6 @@ function FormPathInputComponent( { onClick, error, doesPathContainWordPress, - isDisabled = false, id, }: FormPathInputComponentProps ) { const { __ } = useI18n(); @@ -136,7 +110,6 @@ function FormPathInputComponent( { error && 'border-red-500 [&_.local-path-icon]:border-l-red-500' ) } data-testid="select-path-button" - disabled={ isDisabled } onClick={ onClick } id={ id } > @@ -165,91 +138,7 @@ function FormPathInputComponent( { ); } -function FormImportComponent( { - value, - onFileSelected, - onClear, - error, - placeholder, -}: FormImportComponentProps ) { - const fileName = value ? value.name : ''; - - const inputFileRef = useRef< HTMLInputElement >( null ); - - const handleIconClick = ( event: FormEvent ) => { - event.stopPropagation(); - if ( onClear ) { - onClear(); - if ( inputFileRef.current ) { - inputFileRef.current.value = ''; - } - } - }; - - const handleFileChange = ( event: React.ChangeEvent< HTMLInputElement > ) => { - if ( ! onFileSelected ) { - return; - } - if ( event.target.files && event.target.files[ 0 ] ) { - onFileSelected( event.target.files[ 0 ] ); - } - }; - - return ( - <> -