-
Notifications
You must be signed in to change notification settings - Fork 732
Ensure worspaces/pgadmin state is saved on abrupt shutdown of pgadmin.#GH_3319 #8671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
ae9bd5f
to
7441c9e
Compare
72d6539
to
c2980a1
Compare
c2980a1
to
2b23a35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GUI Review Comments:
-
When opening pgAdmin again in the browser Default Workspace should be in focus. Open Schema Diff tool and refresh the browser.
-
PSQL tools database name not showing in the single line on reopening pgAdmin.
-
Delete all the states from the table if the user changes the preferences and sets them to False.
-
Getting error AttributeError: 'NoneType' object has no attribute 'connection' in line 604, in _get_database_role psql/init.py
-
params['db'] = underscore_escape(data['db_name']) TypeError: 'NoneType' object is not subscriptable in line 104 in psql/init.py
-
Open Query Tool/PSQL in the respective workspace and then refresh the browser. It opens in the Default workspace, which seems to be correct, but we need to document this behaviour.
-
Query Tool/PSQL for adHoc servers are still opening with error. We should not store state of the adHoc server.
-
The show_query_tool.js, show_erd_tool.js, showSchemaDiffTool.js and show_psql_tool.js files have duplicate code to open the respective tools. We can easily make some part of the logic generic.
-
Why file name 'showSchemaDiffTool.js' different in respect to others like show_query_tool.js
-
Documentation/Screenshot updates are missing for Preferences.
-
Create a new .rst file to explain this new feature.
-
Add comments in the new function added in this PR and wherever needed in the code, so that others can understand the logic.
web/regression/feature_tests/xss_checks_panels_and_query_tool_test.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we handled the case where a server is removed?
if(res.data.success && res.data.data.result.length > 0){ | ||
//let oldIds = [] | ||
_.each(res.data.data.result, function(tool_data){ | ||
if (tool_data.tool_name == 'sqleditor'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather use events to trigger open. This loop will be synchronous, events will be async which will improve performance.
data = json.loads(request.data) | ||
id = data['trans_id'] | ||
fernet = Fernet(current_app.config['SECRET_KEY'].encode()) | ||
tool_data = fernet.encrypt(json.dumps(data['tool_data']).encode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure API Content-Type is gzip on POST and GET both for low network footprint.
'tool_data': fernet.decrypt(row.tool_data).decode(), | ||
'id': row.id | ||
}) | ||
return make_json_response( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure API response Type is gzip on POST and GET both for low network footprint.
const eventBus = React.useRef(new EventBus()); | ||
|
||
React.useEffect(()=>{ | ||
eventBus.current.registerListener('SAVE_TOOL_DATA', (data) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not the right place for putting any API call. PgAdmin provider should be purely used for pgAdmin instance only. It can be used at places where there is no need to save tool data.
@@ -156,6 +156,21 @@ export default class ERDTool extends React.Component { | |||
this.forceClose = this.closePanel; | |||
} | |||
|
|||
saveERDToolData = () => { | |||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need a timeout?
|
||
|
||
// Callback to draw ERD Tool for objects | ||
export function relaunchErdTool(state_info) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets not duplicate launch. Follow flux architecture.
setTheme(); | ||
|
||
termRef.current.focus(); | ||
const observer = new ResizeObserver((entries) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should create a react hook for ResizeObserver now. It is present at many places.
@@ -121,7 +120,7 @@ def index(): | |||
|
|||
@blueprint.route( | |||
'/panel/<int:trans_id>/<path:editor_title>', | |||
methods=["GET"], | |||
methods=["POST"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are your making it as POST? This will create problem when refreshing the schema diff in a new tab.
@@ -641,7 +657,16 @@ export function SchemaDiffCompare({ params }) { | |||
} else { | |||
setTargetDatabaseList(res.data.data); | |||
} | |||
|
|||
if(params.params.tool_data){ | |||
let data = JSON.parse(params.params.tool_data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code looks repeated.
const change = useCallback(()=>{ | ||
eventBus.fireEvent(QUERY_TOOL_EVENTS.QUERY_CHANGED, editor.current.isDirty()); | ||
|
||
const debouncedSave = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use lodash debounce? We also have a hook useDelayDebounce
No description provided.