Fixed some granted value bugs within the PermissionEditor.tsx
parent
e84a4dcaf0
commit
4365e03dbe
|
@ -274,6 +274,7 @@ const PermissionEntryRow = (props: {
|
||||||
const [ flagSkip, setFlagSkip ] = useState(props.value.flagSkip);
|
const [ flagSkip, setFlagSkip ] = useState(props.value.flagSkip);
|
||||||
|
|
||||||
const [ granted, setGranted ] = useState(props.value.granted);
|
const [ granted, setGranted ] = useState(props.value.granted);
|
||||||
|
const [ forceGrantedUpdate, setForceGrantedUpdate ] = useState(false);
|
||||||
const [ grantedEditing, setGrantedEditing ] = useState(false);
|
const [ grantedEditing, setGrantedEditing ] = useState(false);
|
||||||
const [ grantedApplying, setGrantedApplying ] = useState(false);
|
const [ grantedApplying, setGrantedApplying ] = useState(false);
|
||||||
|
|
||||||
|
@ -346,15 +347,17 @@ const PermissionEntryRow = (props: {
|
||||||
if(typeof granted === "undefined")
|
if(typeof granted === "undefined")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
setForceGrantedUpdate(true);
|
||||||
props.events.fire("action_remove_permissions", { permissions: [{ name: props.permission, mode: "grant" }] });
|
props.events.fire("action_remove_permissions", { permissions: [{ name: props.permission, mode: "grant" }] });
|
||||||
} else {
|
} else {
|
||||||
const numberValue = parseInt(newValue);
|
const numberValue = parseInt(newValue);
|
||||||
if(isNaN(numberValue)) return;
|
if(isNaN(numberValue)) return;
|
||||||
if(numberValue === granted) {
|
if(numberValue === granted && !forceGrantedUpdate) {
|
||||||
/* no change */
|
/* no change */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setForceGrantedUpdate(true);
|
||||||
props.events.fire("action_set_permissions", { permissions: [{ name: props.permission, mode: "grant", value: numberValue }]});
|
props.events.fire("action_set_permissions", { permissions: [{ name: props.permission, mode: "grant", value: numberValue }]});
|
||||||
}
|
}
|
||||||
}} onChange={() => {}} onKeyPress={e => e.key === "Enter" && e.currentTarget.blur()} />;
|
}} onChange={() => {}} onKeyPress={e => e.key === "Enter" && e.currentTarget.blur()} />;
|
||||||
|
@ -368,6 +371,7 @@ const PermissionEntryRow = (props: {
|
||||||
if(event.target === "grant") {
|
if(event.target === "grant") {
|
||||||
setGranted(event.defaultValue);
|
setGranted(event.defaultValue);
|
||||||
setGrantedEditing(true);
|
setGrantedEditing(true);
|
||||||
|
setForceGrantedUpdate(true);
|
||||||
} else {
|
} else {
|
||||||
if(isBoolPermission && typeof value === "undefined") {
|
if(isBoolPermission && typeof value === "undefined") {
|
||||||
setValue(event.defaultValue >= 1 ? 1 : 0);
|
setValue(event.defaultValue >= 1 ? 1 : 0);
|
||||||
|
|
Loading…
Reference in New Issue