Fixed an issue where row count notification was disappearing automatically. #5647

This commit is contained in:
Pravesh Sharma 2023-01-02 10:54:24 +05:30 committed by GitHub
parent 34e409f313
commit 67bc0c23ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 14 deletions

View File

@ -279,7 +279,7 @@ define('pgadmin.node.table', [
type:'GET',
})
.done(function(res) {
Notify.success(res.info);
Notify.success(res.info, undefined, true);
d.rows_cnt = res.data.total_rows;
t.unload(i);
t.setInode(i);

View File

@ -210,6 +210,7 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo
key={itemNodeData?._id}
formType={formType}
getInitData={initData}
updatedData={{rows_cnt: itemNodeData?.rows_cnt}}
schema={schema}
viewHelperProps={viewHelperProps}
onSave={onSaveClick}

View File

@ -866,7 +866,7 @@ const usePropsStyles = makeStyles((theme)=>({
/* If its the properties tab */
function SchemaPropertiesView({
getInitData, viewHelperProps, schema={}, ...props}) {
getInitData, viewHelperProps, schema={}, updatedData, ...props}) {
const classes = usePropsStyles();
let defaultTab = 'General';
let tabs = {};
@ -890,6 +890,14 @@ function SchemaPropertiesView({
});
}, []);
useEffect(()=>{
if(updatedData) {
setOrigData(prevData => ({
...prevData,
...updatedData
}));
}
},[updatedData]);
/* A simple loop to get all the controls for the fields */
schema.fields.forEach((field)=>{
@ -1008,6 +1016,7 @@ function SchemaPropertiesView({
SchemaPropertiesView.propTypes = {
getInitData: PropTypes.func.isRequired,
updatedData: PropTypes.object,
viewHelperProps: PropTypes.shape({
mode: PropTypes.string.isRequired,
serverInfo: PropTypes.shape({

View File

@ -26,6 +26,7 @@ import pgWindow from 'sources/window';
import ModalProvider, { useModal } from './ModalProvider';
const AUTO_HIDE_DURATION = 3000; // In milliseconds
const PERSIST_SNACK_BAR = false; // Snackbar stays on the screen, unless it is dismissed
let snackbarRef;
let notifierInitialized = false;
@ -119,34 +120,35 @@ AlertContent.propTypes = {
let Notifier = {
success(msg, autoHideDuration = AUTO_HIDE_DURATION) {
this._callNotify(msg, MESSAGE_TYPE.SUCCESS, autoHideDuration);
success(msg, autoHideDuration = AUTO_HIDE_DURATION, persist = PERSIST_SNACK_BAR) {
this._callNotify(msg, MESSAGE_TYPE.SUCCESS, autoHideDuration, persist);
},
warning(msg, autoHideDuration = AUTO_HIDE_DURATION) {
this._callNotify(msg, MESSAGE_TYPE.WARNING, autoHideDuration);
warning(msg, autoHideDuration = AUTO_HIDE_DURATION, persist = PERSIST_SNACK_BAR) {
this._callNotify(msg, MESSAGE_TYPE.WARNING, autoHideDuration, persist);
},
info(msg, autoHideDuration = AUTO_HIDE_DURATION) {
this._callNotify(msg, MESSAGE_TYPE.INFO, autoHideDuration);
info(msg, autoHideDuration = AUTO_HIDE_DURATION, persist = PERSIST_SNACK_BAR) {
this._callNotify(msg, MESSAGE_TYPE.INFO, autoHideDuration, persist);
},
error(msg, autoHideDuration = AUTO_HIDE_DURATION) {
this._callNotify(msg, MESSAGE_TYPE.ERROR, autoHideDuration);
error(msg, autoHideDuration = AUTO_HIDE_DURATION, persist = PERSIST_SNACK_BAR) {
this._callNotify(msg, MESSAGE_TYPE.ERROR, autoHideDuration, persist);
},
notify(content, autoHideDuration) {
notify(content, autoHideDuration, persist) {
if (content) {
if(!notifierInitialized) {
initializeNotifier();
}
let options = {autoHideDuration, content:(key) => (
<FinalNotifyContent>{React.cloneElement(content, {onClose:()=>{snackbarRef.closeSnackbar(key);}})}</FinalNotifyContent>
)};
), persist};
options.content.displayName = 'content';
snackbarRef.enqueueSnackbar(null, options);
}
},
_callNotify(msg, type, autoHideDuration) {
_callNotify(msg, type, autoHideDuration, persist) {
this.notify(
<NotifierMessage style={{maxWidth: '50vw'}} type={type} message={msg} closable={true} />,
autoHideDuration
autoHideDuration,
persist
);
},