editor: disable the "Add champ" button until the champ is saved

Otherwise some champs are created before the previous one has been
saved, and React complains that several champs have the same
`champ-undefined` key.

(Plus it made the tests flaky and unreliable.)
This commit is contained in:
Pierre de La Morinerie 2019-11-26 17:32:58 +01:00
parent 7ed649dfca
commit 52051914aa

View file

@ -12,6 +12,8 @@ function TypeDeChamps({ state: rootState, typeDeChamps }) {
typeDeChamps
});
const hasUnsavedChamps = state.typeDeChamps.some(tdc => tdc.id == undefined);
return (
<div className="champs-editor">
<SortableContainer
@ -43,6 +45,7 @@ function TypeDeChamps({ state: rootState, typeDeChamps }) {
<div className="buttons">
<button
className="button"
disabled={hasUnsavedChamps}
onClick={() =>
dispatch({
type: 'addNewTypeDeChamp',