@@ -635,10 +686,9 @@ export default class Dialog extends Component {
className={
this.state.isUploading ? 'ix-input-readonly' : ''
}
- value={this.state.uploadForm.destination || '/'}
+ value="/assets/contentful"
onChange={this.updateDestinationFilePath}
- placeholder="/"
- isReadOnly={this.state.isUploading}
+ isReadOnly={true}
>
diff --git a/src/components/Field/Field.tsx b/src/components/Field/Field.tsx
index 3b6740de..832d08c0 100644
--- a/src/components/Field/Field.tsx
+++ b/src/components/Field/Field.tsx
@@ -98,7 +98,33 @@ export default class Field extends Component
{
render() {
// Uncomment to test
- // console.log({ ...this.state.selectedAsset });
+ //console.log({ ...this.state.selectedAsset });
+
+ // INKBOX NOTE: Undo all our shenanigans to get the selectedAsset back to the correct shape for the FieldImagePreview component
+
+ // undo the array wrapping
+ //@ts-ignore
+ this.state.selectedAsset = this.state.selectedAsset?.[0];
+
+ // ensure we have the correct src
+ if (this.state.selectedAsset && !this.state.selectedAsset.src) {
+ //@ts-ignore
+ this.state.selectedAsset.src = this.state.selectedAsset.original_url;
+
+ // get the correct content type by checking the file extension, check if image, video, or other
+ // we are assuming that the content type is image if it doesn't end with .mp4 - not the best way to do this, but it works for now
+ let contentType = 'image';
+ if (this.state.selectedAsset.src.endsWith('.mp4')) {
+ contentType = 'video';
+ }
+
+ // add the content type to the attributes back
+ this.state.selectedAsset.attributes = {
+ content_type: contentType,
+ };
+ }
+
+ // INKBOX NOTE: End of undoing shenanigans
const updateHeightHandler = this.props.sdk.window.updateHeight;
if (this.state.selectedAsset && this.state.selectedAsset.src) {
diff --git a/src/components/Gallery/ImageGallery.tsx b/src/components/Gallery/ImageGallery.tsx
index 64ef06d0..a761f76d 100644
--- a/src/components/Gallery/ImageGallery.tsx
+++ b/src/components/Gallery/ImageGallery.tsx
@@ -69,10 +69,10 @@ export class Gallery extends Component {
]),
};
- this.props.sdk.close({
- ...stringifiedAsset,
- selectedSource: this.props.selectedSource,
- });
+ // INKBOX NOTE: ignore the asset because we need it in our format
+ // [ { original_url: url } ]
+
+ this.props.sdk.close([{ original_url: selectedAsset.src }]);
};
handleClose = () => {
diff --git a/src/components/UploadButton/UploadButton.tsx b/src/components/UploadButton/UploadButton.tsx
index b4d62df7..0071260a 100644
--- a/src/components/UploadButton/UploadButton.tsx
+++ b/src/components/UploadButton/UploadButton.tsx
@@ -53,7 +53,7 @@ export function UploadButton(props: {
style={{ display: 'none' }}
ref={inputRef}
type="file"
- accept="image/*"
+ accept="image/*, video/*"
onChange={handleFileChange}
/>
diff --git a/src/helpers/errors.ts b/src/helpers/errors.ts
index 99d01560..1dec4be7 100644
--- a/src/helpers/errors.ts
+++ b/src/helpers/errors.ts
@@ -4,7 +4,8 @@ export type ErrorType =
| `NoSourcesError`
| `NoOriginAssetsError`
| `NoOriginAssetsWebFolderError`
- | `noSearchAssetsError`;
+ | `noSearchAssetsError`
+ | `fileTooLargeError`;
const DASHBOARD_URL = 'https://dashboard.imgix.com';
const WEBFOLDER_DOCUMENTATION_URL = `https://docs.imgix.com/setup/serving-assets#web-folder`;
@@ -54,6 +55,12 @@ const ERROR_MESSAGES = {
name: 'No results found',
type: 'warning',
dismissable: true,
+ },
+ fileTooLargeError: {
+ message: `The file you are trying to upload is too large. Please try uploading a smaller file.`,
+ name: 'File too large',
+ type: 'negative',
+ dismissable: true,
}
} as const;
@@ -106,3 +113,6 @@ export const noOriginAssetsWebFolderError = (message?: string) =>
export const noSearchAssetsError = (message?: string) =>
new IxError('noSearchAssetsError', message);
+
+export const fileTooLargeError = (message?: string) =>
+ new IxError('fileTooLargeError', message);
\ No newline at end of file