Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/plugins/content-export-import/admin/src/components/UploadFileForm/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import React, { useState, memo } from "react";
import PropTypes from "prop-types";
import DropFileZone from "../DropFileZone";
import DataViewer from "../DataViewer";
import { Button } from "@buffetjs/core";
import { Row } from "../common";
import FORMATS from "../../constants/formats";
import readFileContent from "../../utils/readFileContent";
function UploadFileForm({ onSubmit }) {
const [file, setFile] = useState(null);
const [data, setData] = useState("");
const handleFileUpload = async (file) => {
try {
const content = await readFileContent(file);
setData(content);
setFile(file);
} catch (err) {
strapi.notification.toggle({
type: "warning",
message: "import.file.content.error",
});
}
};
const removeFile = () => {
setData(null);
setFile(null);
};
// Form Controls
const handleSubmit = (ev) => {
ev.preventDefault();
onSubmit({ data, type: file.type });
};
return (
<form className="col-12" onSubmit={handleSubmit}>
<Row>
{file ? (
<DataViewer data={data} type={file.type} />
) : (
<DropFileZone
acceptMimeTypes={FORMATS.map(({ mimeType }) => mimeType)}
acceptFilesTypes={FORMATS.map(({ ext }) => ext)}
onUploadFile={handleFileUpload}
onUploadError={() =>
strapi.notification.toggle({
type: "warning",
message: "import.file.type.error",
})
}
/>
)}
</Row>
<Row>
<Button
type="submit"
label="Analyze"
color={file ? "primary" : "cancel"}
disabled={!file}
/>
<Button
className="ml-3"
label="Remove File"
color="delete"
onClick={removeFile}
disabled={!file}
/>
</Row>
</form>
);
}
UploadFileForm.defaultProps = {
onSubmit: () => {},
};
UploadFileForm.propTypes = {
onSubmit: PropTypes.func.isRequired,
};
export default memo(UploadFileForm);
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0073 ]-- |