Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Rename dropzone to ImageUpload

dominik-zeglen2514d33b4ea4
diff --git a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx
index e7556b989c..ae93112819 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryBackground/CategoryBackground.tsx
@@ -11,9 +11,9 @@ import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import CardTitle from "../../../components/CardTitle";
-import { Dropzone } from "../../../components/Dropzone";
import Hr from "../../../components/Hr";
import ImageTile from "../../../components/ImageTile";
+import ImageUpload from "../../../components/ImageUpload";
import Skeleton from "../../../components/Skeleton";
import i18n from "../../../i18n";
import { CategoryDetails_category_backgroundImage } from "../../types/CategoryDetails";
@@ -101,7 +101,7 @@ export const CategoryBackground = withStyles(styles)(
</div>
</CardContent>
) : image === null ? (
- <Dropzone onImageUpload={onImageUpload} />
+ <ImageUpload onImageUpload={onImageUpload} />
) : (
<CardContent>
<ImageTile image={image} onImageDelete={onImageDelete} />
diff --git a/saleor/static/dashboard-next/collections/components/CollectionImage/CollectionImage.tsx b/saleor/static/dashboard-next/collections/components/CollectionImage/CollectionImage.tsx
index 853847d71b..b922cb54e4 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionImage/CollectionImage.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionImage/CollectionImage.tsx
@@ -11,9 +11,9 @@ import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import CardTitle from "../../../components/CardTitle";
-import Dropzone from "../../../components/Dropzone";
import Hr from "../../../components/Hr";
import ImageTile from "../../../components/ImageTile";
+import ImageUpload from "../../../components/ImageUpload";
import Skeleton from "../../../components/Skeleton";
import i18n from "../../../i18n";
import { CollectionDetails_collection_backgroundImage } from "../../types/CollectionDetails";
@@ -111,7 +111,7 @@ export const CollectionImage = withStyles(styles)(
</div>
</CardContent>
) : image === null ? (
- <Dropzone onImageUpload={onImageUpload} />
+ <ImageUpload onImageUpload={onImageUpload} />
) : (
<CardContent>
<ImageTile image={image} onImageDelete={onImageDelete} />
diff --git a/saleor/static/dashboard-next/components/Dropzone/index.tsx b/saleor/static/dashboard-next/components/Dropzone/index.tsx
deleted file mode 100644
index 8190212338..0000000000
--- a/saleor/static/dashboard-next/components/Dropzone/index.tsx
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./Dropzone";
-export * from "./Dropzone";
diff --git a/saleor/static/dashboard-next/components/Dropzone/Dropzone.tsx b/saleor/static/dashboard-next/components/ImageUpload/ImageUpload.tsx
similarity index 54%
rename from saleor/static/dashboard-next/components/Dropzone/Dropzone.tsx
rename to saleor/static/dashboard-next/components/ImageUpload/ImageUpload.tsx
index 47ecf364b5..90a7ccfe5e 100644
--- a/saleor/static/dashboard-next/components/Dropzone/Dropzone.tsx
+++ b/saleor/static/dashboard-next/components/ImageUpload/ImageUpload.tsx
@@ -9,10 +9,10 @@ import Typography from "@material-ui/core/Typography";
import AddPhotoIcon from "@material-ui/icons/AddAPhoto";
import classNames from "classnames";
import * as React from "react";
-import DropzoneComponent from "react-dropzone";
+import Dropzone from "react-dropzone";
import i18n from "../../i18n";
-interface DropzoneProps {
+interface ImageUploadProps {
onImageUpload: (file: File) => void;
}
@@ -52,28 +52,35 @@ const styles = (theme: Theme) =>
}
});
-export const Dropzone = withStyles(styles, { name: "Dropzone" })(
- ({ classes, onImageUpload }: DropzoneProps & WithStyles<typeof styles>) => (
- <DropzoneComponent onDrop={files => onImageUpload(files[0])}>
- {({ isDragActive, getInputProps, getRootProps }) => (
- <div
- {...getRootProps()}
- className={classNames({
- [classes.photosIconContainer]: true,
- [classes.containerDragActive]: isDragActive
- })}
- >
- <input {...getInputProps()} className={classes.fileField} />
- <AddPhotoIcon className={classes.photosIcon} />
- <Typography className={classes.uploadText} variant="body2">
- {i18n.t("Drop here to upload", {
- context: "image upload"
+export const ImageUpload = withStyles(styles, { name: "ImageUpload" })(
+ ({
+ classes,
+ onImageUpload
+ }: ImageUploadProps & WithStyles<typeof styles>) => {
+ // console.log(DropzoneComponent);
+ // throw DropzoneComponent;
+ return (
+ <Dropzone onDrop={files => onImageUpload(files[0])}>
+ {({ isDragActive, getInputProps, getRootProps }) => (
+ <div
+ {...getRootProps()}
+ className={classNames({
+ [classes.photosIconContainer]: true,
+ [classes.containerDragActive]: isDragActive
})}
- </Typography>
- </div>
- )}
- </DropzoneComponent>
- )
+ >
+ <input {...getInputProps()} className={classes.fileField} />
+ <AddPhotoIcon className={classes.photosIcon} />
+ <Typography className={classes.uploadText} variant="body2">
+ {i18n.t("Drop here to upload", {
+ context: "image upload"
+ })}
+ </Typography>
+ </div>
+ )}
+ </Dropzone>
+ );
+ }
);
-Dropzone.displayName = "Dropzone";
-export default Dropzone;
+ImageUpload.displayName = "ImageUpload";
+export default ImageUpload;
diff --git a/saleor/static/dashboard-next/components/ImageUpload/index.tsx b/saleor/static/dashboard-next/components/ImageUpload/index.tsx
new file mode 100644
index 0000000000..1ff646a387
--- /dev/null
+++ b/saleor/static/dashboard-next/components/ImageUpload/index.tsx
@@ -0,0 +1,2 @@
+export { default } from "./ImageUpload";
+export * from "./ImageUpload";