Skip to content

Commit 33f7d34

Browse files
fix(ui): guard against empty plugin prop on connection creation page (#8918)
1 parent cec4286 commit 33f7d34

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

config-ui/src/plugins/components/connection-form/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,18 @@ export const ConnectionForm = ({ plugin, connectionId, onSuccess }: Props) => {
110110
const {
111111
name,
112112
connection: { docLink, fields, initialValues },
113-
} = getPluginConfig(plugin);
113+
} = getPluginConfig(plugin) ?? {};
114114

115115
const disabled = useMemo(() => {
116116
return Object.values(errors).some(Boolean);
117117
}, [errors]);
118118

119119
const sanitizedCustomHeaders = useMemo(() => sanitizeCustomHeaders(values.customHeaders), [values.customHeaders]);
120120

121+
if (!plugin || !name) {
122+
return null;
123+
}
124+
121125
const handleTest = async () => {
122126
const isUpdate = type === 'update' && !!connectionId;
123127
await operator(

config-ui/src/routes/connection/connections.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ export const Connections = () => {
6161
setPlugin(plugin);
6262
};
6363

64-
const handleShowFormDialog = () => {
64+
const handleShowFormDialog = (pluginName?: string) => {
6565
setType('form');
66+
if (pluginName) setPlugin(pluginName);
6667
};
6768

6869
const handleHideDialog = () => {
@@ -168,7 +169,7 @@ export const Connections = () => {
168169
<ConnectionList plugin={plugin} onCreate={handleShowFormDialog} />
169170
</Modal>
170171
)}
171-
{type === 'form' && pluginConfig && (
172+
{type === 'form' && plugin && pluginConfig && (
172173
<Modal
173174
open
174175
width={820}

0 commit comments

Comments
 (0)