[go: nahoru, domu]

Skip to content

Commit

Permalink
Fixed an issue where row count notification was disappearing automati…
Browse files Browse the repository at this point in the history
  • Loading branch information
pravesh-sharma authored and akshay-joshi committed Jan 4, 2023
1 parent 61d91d6 commit 69ddb30
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions web/pgadmin/browser/static/js/node_view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
11 changes: 10 additions & 1 deletion web/pgadmin/static/js/SchemaView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand All @@ -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)=>{
Expand Down Expand Up @@ -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({
Expand Down
26 changes: 14 additions & 12 deletions web/pgadmin/static/js/helpers/Notifier.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
},

Expand Down

0 comments on commit 69ddb30

Please sign in to comment.