fix: clear assistant credentials on destination changes
This commit is contained in:
1 parent
d3205d886a
commit
00e4cc8100
1 file changed
+18
-2
+18
-2
@@ -172,14 +172,30 @@ export const AssistantConfiguration = () => {
|
|||||||
|
|
||||||
const pending = isLoading || updateConnection.isPending || saveConfiguration.isPending || clearCredentials.isPending;
|
const pending = isLoading || updateConnection.isPending || saveConfiguration.isPending || clearCredentials.isPending;
|
||||||
|
|
||||||
|
const clearDraftConnectionState = () => {
|
||||||
|
setApiKey("");
|
||||||
|
setClearApiKey(false);
|
||||||
|
setHeaders([]);
|
||||||
|
setClearHeaders(false);
|
||||||
|
setModelId("");
|
||||||
|
setEnabled(false);
|
||||||
|
};
|
||||||
|
|
||||||
const changeProvider = (value: string | null) => {
|
const changeProvider = (value: string | null) => {
|
||||||
if (!value || !(value in assistantProviderPresets)) return;
|
if (!value || !(value in assistantProviderPresets)) return;
|
||||||
const nextProvider = value as AssistantProvider;
|
const nextProvider = value as AssistantProvider;
|
||||||
const nextPreset = assistantProviderPresets[nextProvider];
|
const nextPreset = assistantProviderPresets[nextProvider];
|
||||||
|
clearDraftConnectionState();
|
||||||
setProvider(nextProvider);
|
setProvider(nextProvider);
|
||||||
setBaseUrl(nextPreset.baseUrl);
|
setBaseUrl(nextPreset.baseUrl);
|
||||||
setModelDiscoveryPath(nextPreset.modelDiscoveryPath ?? "");
|
setModelDiscoveryPath(nextPreset.modelDiscoveryPath ?? "");
|
||||||
setEnabled(false);
|
};
|
||||||
|
|
||||||
|
const changeBaseUrl = (value: string) => {
|
||||||
|
if (value !== baseUrl) {
|
||||||
|
clearDraftConnectionState();
|
||||||
|
}
|
||||||
|
setBaseUrl(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const addHeader = () => {
|
const addHeader = () => {
|
||||||
@@ -249,7 +265,7 @@ export const AssistantConfiguration = () => {
|
|||||||
description={t("baseUrl.description")}
|
description={t("baseUrl.description")}
|
||||||
leftSection={<IconWorld size={16} />}
|
leftSection={<IconWorld size={16} />}
|
||||||
value={baseUrl}
|
value={baseUrl}
|
||||||
onChange={(event) => setBaseUrl(event.currentTarget.value)}
|
onChange={(event) => changeBaseUrl(event.currentTarget.value)}
|
||||||
placeholder="https://provider.example/v1"
|
placeholder="https://provider.example/v1"
|
||||||
/>
|
/>
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
|
|||||||
Reference in new issue
Block a user