[chore/frogend] Restructure form data default values / update from Query data (#1422)

* eslint: set console use to error to catch debug littering in CI

* remove debug logging

* some form field restructuring, fixes submitted updates not being reflected

* more form field restructuring

* remove debug logger

* simplify field updates

* fix react state set during render when submitting import file

* className instead of class

* show Select hints again
This commit is contained in:
f0x52
2023-02-06 09:19:56 +01:00
committed by GitHub
parent 0a9874329d
commit 47daddc10c
19 changed files with 153 additions and 86 deletions

View File

@@ -36,13 +36,11 @@ const ExportFormatTable = require("./export-format-table");
module.exports = function ImportExportForm({ form, submitParse, parseResult }) {
const [submitExport, exportResult] = useFormSubmit(form, query.useExportDomainListMutation());
const [updateFromFile, setUpdateFromFile] = React.useState(false);
function fileChanged(e) {
const reader = new FileReader();
reader.onload = function (read) {
form.domains.setter(read.target.result);
setUpdateFromFile(true);
form.domains.value = read.target.result;
submitParse();
};
reader.readAsText(e.target.files[0]);
}
@@ -54,10 +52,6 @@ module.exports = function ImportExportForm({ form, submitParse, parseResult }) {
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, [exportResult]);
if (updateFromFile) {
setUpdateFromFile(false);
submitParse();
}
return (
<>
<h1>Import / Export suspended domains</h1>

View File

@@ -40,7 +40,7 @@ module.exports = function ImportExport() {
exportType: useTextInput("exportType", { defaultValue: "plain", dontReset: true })
};
const [submitParse, parseResult] = useFormSubmit(form, query.useProcessDomainListMutation());
const [submitParse, parseResult] = useFormSubmit(form, query.useProcessDomainListMutation(), { changedOnly: false });
const [_location, setLocation] = useLocation();

View File

@@ -234,7 +234,7 @@ const UpdateableEntry = React.memo(
return (
<>
<span className="text-cutoff">{entry.domain}</span>
<i class="fa fa-long-arrow-right" aria-hidden="true"></i>
<i className="fa fa-long-arrow-right" aria-hidden="true"></i>
<span>{entry.suggest}</span>
<a role="button" onClick={() =>
updateEntry(entry.key, { domain: entry.suggest, suggest: null })