import {APIButton} from "../Common";
import {Icon, Popup, Table} from "../Theme";
import React from "react";
import {TableBody, TableCell, TableHeader, TableHeaderCell, TableRow} from "semantic-ui-react";
import {TableRowPlaceholder} from "../Placeholder";
import {useNavigate} from "react-router";
function WarningIcon({ok}) {
// null is empty, true is valid, false is invalid.
const trigger = ;
const content = ok === true ? 'Valid and can be imported.' : ok === false ? 'Invalid, can be overwritten.' : 'Empty config, can be overwritten.';
return
}
function ConfigTableRow({config, importConfig, saveConfig, fetchConfigs}) {
const {file_name, rel_path, valid, successful_import} = config;
const navigate = useNavigate();
const localImportConfig = async () => {
await importConfig(file_name);
await fetchConfigs();
}
const localSaveConfig = async () => {
await saveConfig(file_name);
await fetchConfigs();
}
const importButton = ;
let saveButton;
if (successful_import) {
saveButton = ;
} else {
// Warn the user they may overwrite because import was not successful.
saveButton = ;
}
return
navigate(`?preview=${rel_path}`)}>{file_name}
{importButton}
{saveButton}
}
export function ConfigsTable({configs, loading, importConfig, saveConfig, fetchConfigs}) {
let body =
if (loading) {
// Configs are being fetched again.
} else if (configs === undefined) {
body =
Failed to fetch configs
;
} else if (configs && Object.keys(configs).length === 0) {
body =
No configs exist. Try tagging some files.
;
} else if (configs) {
body = Object.entries(configs).map(([key, value]) =>
);
}
return
File Name
Imported
Valid
Import
Save
{body}
}