Skip to content

Commit d754741

Browse files
committed
avoid losing redshift credentials when switching auth method
1 parent 2e383f6 commit d754741

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/webviews/webview-side/integrations/RedshiftForm.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export const RedshiftForm: React.FC<IRedshiftFormProps> = ({
4444
? structuredClone(existingConfig)
4545
: createEmptyRedshiftConfig({ id: integrationId, name: defaultName })
4646
);
47+
// Store credentials temporarily when switching to individual-credentials
48+
const [savedCredentials, setSavedCredentials] = React.useState<{ user: string; password: string }>({
49+
user: '',
50+
password: ''
51+
});
4752

4853
React.useEffect(() => {
4954
setPendingConfig(
@@ -67,11 +72,18 @@ export const RedshiftForm: React.FC<IRedshiftFormProps> = ({
6772
host: prev.metadata.host,
6873
port: prev.metadata.port,
6974
database: prev.metadata.database,
70-
user: '',
71-
password: ''
75+
user: savedCredentials.user,
76+
password: savedCredentials.password
7277
}
7378
}));
7479
} else {
80+
// Save current credentials before switching
81+
if (pendingConfig.metadata.authMethod === 'username-and-password') {
82+
setSavedCredentials({
83+
user: pendingConfig.metadata.user,
84+
password: pendingConfig.metadata.password
85+
});
86+
}
7587
setPendingConfig((prev) => ({
7688
...prev,
7789
metadata: {

0 commit comments

Comments
 (0)