From 33aea87deaaeeb4142d465c61b9eeff09b9f1218 Mon Sep 17 00:00:00 2001 From: Pravesh Sharma Date: Mon, 2 Jan 2023 13:30:49 +0530 Subject: [PATCH] Incorporated review comments. #5647 --- .../databases/schemas/tables/__init__.py | 3 +-- .../schemas/tables/static/js/table.js | 2 +- web/pgadmin/browser/static/js/node_view.jsx | 3 ++- web/pgadmin/static/js/SchemaView/index.jsx | 5 +++- web/pgadmin/static/js/helpers/Notifier.jsx | 26 +++++++++---------- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py index 675082ba6..5960db108 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py @@ -438,8 +438,7 @@ class TableView(BaseTableView, DataTypeReader, SchemaDiffTableCompare): icon=icon, tigger_count=row['triggercount'], has_enable_triggers=row['has_enable_triggers'], - is_partitioned=self.is_table_partitioned(row), - rows_cnt=0 + is_partitioned=self.is_table_partitioned(row) )) return make_json_response( diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js index bf6ab7f40..8fc99e6bc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js @@ -279,7 +279,7 @@ define('pgadmin.node.table', [ type:'GET', }) .done(function(res) { - Notify.success(res.info, undefined, true); + Notify.success(res.info, null); d.rows_cnt = res.data.total_rows; t.unload(i); t.setInode(i); diff --git a/web/pgadmin/browser/static/js/node_view.jsx b/web/pgadmin/browser/static/js/node_view.jsx index 624749817..e530484ec 100644 --- a/web/pgadmin/browser/static/js/node_view.jsx +++ b/web/pgadmin/browser/static/js/node_view.jsx @@ -34,6 +34,7 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo let isDirty = false; // usefull for warnings let warnOnCloseFlag = true; const confirmOnCloseReset = pgAdmin.Browser.get_preferences_for_module('browser').confirm_on_properties_close; + let updatedData = ['table', 'partition'].includes(nodeType) && !_.isEmpty(itemNodeData.rows_cnt) ? {rows_cnt: itemNodeData.rows_cnt} : undefined; let onError = (err)=> { if(err.response){ @@ -210,7 +211,7 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo key={itemNodeData?._id} formType={formType} getInitData={initData} - updatedData={{rows_cnt: itemNodeData?.rows_cnt}} + updatedData={updatedData} schema={schema} viewHelperProps={viewHelperProps} onSave={onSaveClick} diff --git a/web/pgadmin/static/js/SchemaView/index.jsx b/web/pgadmin/static/js/SchemaView/index.jsx index 7d2384c38..558042025 100644 --- a/web/pgadmin/static/js/SchemaView/index.jsx +++ b/web/pgadmin/static/js/SchemaView/index.jsx @@ -882,7 +882,10 @@ function SchemaPropertiesView({ data = data || {}; schema.initialise(data); if(checkIsMounted()) { - setOrigData(data || {}); + setOrigData({ + ...data, + ...updatedData + }); setLoaderText(''); } }).catch(()=>{ diff --git a/web/pgadmin/static/js/helpers/Notifier.jsx b/web/pgadmin/static/js/helpers/Notifier.jsx index 47fd77cc2..444aee1fe 100644 --- a/web/pgadmin/static/js/helpers/Notifier.jsx +++ b/web/pgadmin/static/js/helpers/Notifier.jsx @@ -26,7 +26,6 @@ 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; @@ -120,35 +119,34 @@ AlertContent.propTypes = { let Notifier = { - success(msg, autoHideDuration = AUTO_HIDE_DURATION, persist = PERSIST_SNACK_BAR) { - this._callNotify(msg, MESSAGE_TYPE.SUCCESS, autoHideDuration, persist); + success(msg, autoHideDuration = AUTO_HIDE_DURATION) { + this._callNotify(msg, MESSAGE_TYPE.SUCCESS, autoHideDuration); }, - warning(msg, autoHideDuration = AUTO_HIDE_DURATION, persist = PERSIST_SNACK_BAR) { - this._callNotify(msg, MESSAGE_TYPE.WARNING, autoHideDuration, persist); + warning(msg, autoHideDuration = AUTO_HIDE_DURATION) { + this._callNotify(msg, MESSAGE_TYPE.WARNING, autoHideDuration); }, - info(msg, autoHideDuration = AUTO_HIDE_DURATION, persist = PERSIST_SNACK_BAR) { - this._callNotify(msg, MESSAGE_TYPE.INFO, autoHideDuration, persist); + info(msg, autoHideDuration = AUTO_HIDE_DURATION) { + this._callNotify(msg, MESSAGE_TYPE.INFO, autoHideDuration); }, - error(msg, autoHideDuration = AUTO_HIDE_DURATION, persist = PERSIST_SNACK_BAR) { - this._callNotify(msg, MESSAGE_TYPE.ERROR, autoHideDuration, persist); + error(msg, autoHideDuration = AUTO_HIDE_DURATION) { + this._callNotify(msg, MESSAGE_TYPE.ERROR, autoHideDuration); }, - notify(content, autoHideDuration, persist) { + notify(content, autoHideDuration) { if (content) { if(!notifierInitialized) { initializeNotifier(); } let options = {autoHideDuration, content:(key) => ( {React.cloneElement(content, {onClose:()=>{snackbarRef.closeSnackbar(key);}})} - ), persist}; + )}; options.content.displayName = 'content'; snackbarRef.enqueueSnackbar(null, options); } }, - _callNotify(msg, type, autoHideDuration, persist) { + _callNotify(msg, type, autoHideDuration) { this.notify( , - autoHideDuration, - persist + autoHideDuration ); },