[FIX] Don't display non text files in previewer
This commit is contained in:
parent
9b7539664e
commit
39369fe41a
1 changed files with 13 additions and 2 deletions
|
@ -10,7 +10,17 @@ import Toolbar from "@mui/material/Toolbar";
|
||||||
import TextEditor from "./TextEditor.jsx";
|
import TextEditor from "./TextEditor.jsx";
|
||||||
import { cairoAuthHeader } from "@mcl/util/auth.js";
|
import { cairoAuthHeader } from "@mcl/util/auth.js";
|
||||||
|
|
||||||
const textFileTypes = ["properties", "txt", "yaml", "yml", "json", "env", "toml", "tml", "text"];
|
const textFileTypes = [
|
||||||
|
"properties",
|
||||||
|
"txt",
|
||||||
|
"yaml",
|
||||||
|
"yml",
|
||||||
|
"json",
|
||||||
|
"env",
|
||||||
|
"toml",
|
||||||
|
"tml",
|
||||||
|
"text",
|
||||||
|
];
|
||||||
const imageFileTypes = ["png", "jpeg", "jpg"];
|
const imageFileTypes = ["png", "jpeg", "jpg"];
|
||||||
|
|
||||||
export const supportedFileTypes = [...textFileTypes, ...imageFileTypes];
|
export const supportedFileTypes = [...textFileTypes, ...imageFileTypes];
|
||||||
|
@ -44,6 +54,7 @@ export default function FilePreview(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSave() {
|
async function onSave() {
|
||||||
|
if (!isTextFile) return;
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
const blob = new Blob([modifiedText], { type: "plain/text" });
|
const blob = new Blob([modifiedText], { type: "plain/text" });
|
||||||
formData.append("file", blob, name);
|
formData.append("file", blob, name);
|
||||||
|
@ -77,7 +88,7 @@ export default function FilePreview(props) {
|
||||||
<Toolbar sx={{ display: { sm: "none" } }} />
|
<Toolbar sx={{ display: { sm: "none" } }} />
|
||||||
<DialogTitle>{name}</DialogTitle>
|
<DialogTitle>{name}</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<TextEditor text={fileText} onChange={editorChange} />
|
{isTextFile && <TextEditor text={fileText} onChange={editorChange} />}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button autoFocus onClick={dialogToggle}>
|
<Button autoFocus onClick={dialogToggle}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue