1. Make Unlogged switch in table as read only.
2. Fix a console warning when saving node data. Fixes #6778pull/61/head
parent
787a441343
commit
08706ba6b2
|
@ -708,7 +708,7 @@ export default class TableSchema extends BaseUISchema {
|
||||||
},{
|
},{
|
||||||
id: 'relpersistence', label: gettext('Unlogged?'), cell: 'switch',
|
id: 'relpersistence', label: gettext('Unlogged?'), cell: 'switch',
|
||||||
type: 'switch', mode: ['properties', 'create', 'edit'],
|
type: 'switch', mode: ['properties', 'create', 'edit'],
|
||||||
disabled: obj.inSchemaWithModelCheck,
|
readonly: obj.inSchemaWithModelCheck,
|
||||||
group: 'advanced',
|
group: 'advanced',
|
||||||
},{
|
},{
|
||||||
id: 'conname', label: gettext('Primary key'), cell: 'text',
|
id: 'conname', label: gettext('Primary key'), cell: 'text',
|
||||||
|
|
|
@ -36,6 +36,7 @@ import { parseApiError } from '../api_instance';
|
||||||
import DepListener, {DepListenerContext} from './DepListener';
|
import DepListener, {DepListenerContext} from './DepListener';
|
||||||
import FieldSetView from './FieldSetView';
|
import FieldSetView from './FieldSetView';
|
||||||
import DataGridView from './DataGridView';
|
import DataGridView from './DataGridView';
|
||||||
|
import { useIsMounted } from '../custom_hooks';
|
||||||
|
|
||||||
const useDialogStyles = makeStyles((theme)=>({
|
const useDialogStyles = makeStyles((theme)=>({
|
||||||
root: {
|
root: {
|
||||||
|
@ -451,6 +452,7 @@ function SchemaDialogView({
|
||||||
const [formResetKey, setFormResetKey] = useState(0);
|
const [formResetKey, setFormResetKey] = useState(0);
|
||||||
const firstEleRef = useRef();
|
const firstEleRef = useRef();
|
||||||
const isNew = schema.isNew(schema.origData);
|
const isNew = schema.isNew(schema.origData);
|
||||||
|
const checkIsMounted = useIsMounted();
|
||||||
|
|
||||||
const depListenerObj = useRef(new DepListener());
|
const depListenerObj = useRef(new DepListener());
|
||||||
/* The session data */
|
/* The session data */
|
||||||
|
@ -538,7 +540,7 @@ function SchemaDialogView({
|
||||||
setLoaderText('');
|
setLoaderText('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the focus timeout it unmounted */
|
/* Clear the focus timeout if unmounted */
|
||||||
return ()=>clearTimeout(focusTimeout);
|
return ()=>clearTimeout(focusTimeout);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -625,8 +627,10 @@ function SchemaDialogView({
|
||||||
message: parseApiError(err),
|
message: parseApiError(err),
|
||||||
});
|
});
|
||||||
}).finally(()=>{
|
}).finally(()=>{
|
||||||
setSaving(false);
|
if(checkIsMounted()) {
|
||||||
setLoaderText('');
|
setSaving(false);
|
||||||
|
setLoaderText('');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -787,20 +791,18 @@ function SchemaPropertiesView({
|
||||||
let groupLabels = {};
|
let groupLabels = {};
|
||||||
const [origData, setOrigData] = useState({});
|
const [origData, setOrigData] = useState({});
|
||||||
const [loaderText, setLoaderText] = useState('');
|
const [loaderText, setLoaderText] = useState('');
|
||||||
|
const checkIsMounted = useIsMounted();
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
let unmounted = false;
|
|
||||||
setLoaderText('Loading...');
|
setLoaderText('Loading...');
|
||||||
getInitData().then((data)=>{
|
getInitData().then((data)=>{
|
||||||
data = data || {};
|
data = data || {};
|
||||||
schema.initialise(data);
|
schema.initialise(data);
|
||||||
if(!unmounted) {
|
if(checkIsMounted()) {
|
||||||
setOrigData(data || {});
|
setOrigData(data || {});
|
||||||
setLoaderText('');
|
setLoaderText('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return ()=>unmounted=true;
|
|
||||||
}, [getInitData]);
|
}, [getInitData]);
|
||||||
|
|
||||||
let fullTabs = [];
|
let fullTabs = [];
|
||||||
|
|
|
@ -305,6 +305,9 @@ function getFinalTheme(baseTheme) {
|
||||||
colorPrimary: {
|
colorPrimary: {
|
||||||
'&$disabled': {
|
'&$disabled': {
|
||||||
color: 'abc',
|
color: 'abc',
|
||||||
|
'& + .MuiSwitch-track': {
|
||||||
|
backgroundColor: 'abc',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
switchBase: {
|
switchBase: {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {useRef, useEffect, useState} from 'react';
|
import {useRef, useEffect, useState, useCallback} from 'react';
|
||||||
|
|
||||||
/* React hook for setInterval */
|
/* React hook for setInterval */
|
||||||
export function useInterval(callback, delay) {
|
export function useInterval(callback, delay) {
|
||||||
|
@ -57,3 +57,12 @@ export function useOnScreen(ref) {
|
||||||
return isIntersecting;
|
return isIntersecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useIsMounted() {
|
||||||
|
const ref = useRef(true);
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
ref.current = false;
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
return useCallback(() => ref.current, []);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue