aminghadersohi commented on code in PR #45843:
URL: https://github.com/apache/superset/pull/45843#discussion_r4429300217
##########
superset-frontend/src/features/databases/DatabaseModal/index.tsx:
##########
@@ -1522,13 +1540,14 @@ const DatabaseModal:
FunctionComponent<DatabaseModalProps> = ({
if (dbFetched) {
setDB({
type: ActionType.Fetched,
+ isEditMode,
payload: dbFetched,
});
// keep a copy of the name separate for display purposes
// because it shouldn't change when the form is updated
setDbName(dbFetched.database_name);
}
- }, [dbFetched]);
+ }, [dbFetched, isEditMode]);
Review Comment:
Fixed in f875d424a8f02311fd263fe1fcd39425a17c0155. I kept `isEditMode` in
the fetched action (preserving the edit-only URI fallback), but removed it from
the effect dependencies so closing an edit cannot replay the cached record into
create state.
Regression test: 'closing edit then creating a database starts at the picker
and never updates the old connection' in
`superset-frontend/src/features/databases/DatabaseModal/index.test.tsx`. With
the old dependencies restored, it fails with `Expected length: 0 / Received
length: 1` for PUT `/api/v1/database/10`; with the change, it passes, asserts
the picker was shown, and saves via POST without an inherited id. The
PostgreSQL create-flow and unavailable-driver edit tests also pass.
Siblings checked:
- superset-frontend/src/features/databases/DatabaseModal/index.tsx:1539 —
fixed in f875d424a8f02311fd263fe1fcd39425a17c0155
- superset-frontend/src/pages/DatabaseList/index.tsx:1184 — fixed in
f875d424a8f02311fd263fe1fcd39425a17c0155
- superset-frontend/src/features/databases/DatabaseModal/index.tsx:1344 —
not affected: the finish/back handler explicitly fetches a resource; changing
edit mode does not invoke it.
- superset-frontend/src/features/databases/DatabaseModal/index.tsx:1903 —
not affected: the CTA handler explicitly fetches a resource, rather than
replaying it on an edit-mode transition.
- superset-frontend/src/features/home/RightMenu.tsx:734 — not affected: this
DatabaseModal caller supplies no databaseId and only creates connections.
- superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx:205 — not
affected: the resource-copy effect depends only on resource, with a separate
create reset.
- superset-frontend/src/features/rls/RowLevelSecurityModal.tsx:261 — not
affected: the resource-copy effect depends only on resource, with a separate
create reset.
-
superset-frontend/src/features/annotationLayers/AnnotationLayerModal.tsx:210 —
not affected: the resource-copy effect depends only on resource, with a
separate create reset.
- superset-frontend/src/features/themes/ThemeModal.tsx:483 — not affected:
the resource-copy effect depends only on resource; the mode-dependent
initialization resets create state.
- superset-frontend/src/features/annotations/AnnotationModal.tsx:265 — not
affected: the resource-copy effect depends only on resource, with a separate
create reset.
- superset-frontend/src/features/alerts/AlertReportModal.tsx:2262 — not
affected: the resource-copy effect depends only on resource, with separate
create initialization.
- superset-frontend/src/features/datasets/AddDataset/Footer/index.tsx:72 —
not affected: this hook caller only creates datasets and does not copy fetched
edit state into a create form.
- superset-frontend/src/pages/ExecutionLogList/index.tsx:81 — not affected:
this hook caller displays report execution logs, not a shared edit/create modal.
- superset-frontend/src/pages/AlertReportList/index.tsx:165 — not affected:
this hook caller only uses updateResource for toggling reports, not fetched
form state.
-
superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/index.tsx:92
— not affected: its effect derives credential visibility from db fields and
never restores a fetched record.
-
superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx:129
— not affected: its effects update credential fields or validate them, not
database identity.
- superset-frontend/src/features/databases/DatabaseModal/SSHTunnelSwitch.tsx
— not affected: its effects synchronize the SSH toggle, with no dbFetched or
isEditMode dependency.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]