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