Skip to content

Commit

Permalink
refactor(sanity): rename FileInput to BaseFileInput
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard committed Oct 4, 2022
1 parent e0e3899 commit f5aed74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ import {FileDetails} from './FileDetails'
import {FileSkeleton} from './FileSkeleton'
import {InvalidFileWarning} from './InvalidFileWarning'

// We alias DOM File type here to distinguish it from the type of the File value
type DOMFile = globalThis.File

export interface BaseFileInputValue extends Partial<BaseFile> {
_upload?: UploadState
}
Expand Down Expand Up @@ -155,7 +152,7 @@ export class BaseFileInput extends React.PureComponent<BaseFileInputProps, BaseF
this.props.onChange(unset(['asset']))
}

handleSelectFiles = (files: DOMFile[]) => {
handleSelectFiles = (files: globalThis.File[]) => {
const {directUploads, readOnly} = this.props
const {hoveringFiles} = this.state
if (directUploads && !readOnly) {
Expand All @@ -173,7 +170,7 @@ export class BaseFileInput extends React.PureComponent<BaseFileInputProps, BaseF
this.setState({selectedAssetSource: null})
}

uploadFirstAccepted(files: DOMFile[]) {
uploadFirstAccepted(files: globalThis.File[]) {
const {schemaType} = this.props

const match = files
Expand All @@ -187,7 +184,11 @@ export class BaseFileInput extends React.PureComponent<BaseFileInputProps, BaseF
this.setState({isMenuOpen: false})
}

uploadWith = (uploader: Uploader, file: DOMFile, assetDocumentProps: UploadOptions = {}) => {
uploadWith = (
uploader: Uploader,
file: globalThis.File,
assetDocumentProps: UploadOptions = {}
) => {
const {schemaType, onChange, client} = this.props
const {source} = assetDocumentProps
const options = {
Expand Down Expand Up @@ -574,7 +575,7 @@ export class BaseFileInput extends React.PureComponent<BaseFileInputProps, BaseF
this._focusRef = ref
}

handleUpload = ({file, uploader}: {file: DOMFile; uploader: Uploader}) => {
handleUpload = ({file, uploader}: {file: globalThis.File; uploader: Uploader}) => {
this.uploadWith(uploader, file)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe('FileInput with asset', () => {
/* assetSources - adds a list of sources that a user can pick from when browsing */

it('renders the browse button in the file menu when it has at least one element in assetSources', async () => {
// const {queryByTestId} = render(<FileInput value={value} />)
// const {queryByTestId} = render(<BaseFileInput value={value} />)
// const {result} = render({
// value,
// })
Expand Down

0 comments on commit f5aed74

Please sign in to comment.