Localize connection-string login validation and connectivity messages

Move the hardcoded SQL/Tables/Gremlin connection-string login strings into en/Resources.json and reference them via the type-safe Keys object (t(Keys.connectExplorer.errors.*)).
This commit is contained in:
Asier Isayas
2026-08-11 11:38:15 -04:00
parent 6a524be12f
commit 2e2763f80f
3 changed files with 25 additions and 12 deletions
@@ -1,5 +1,6 @@
import { useBoolean } from "@fluentui/react-hooks";
import { client } from "Common/CosmosClient";
import { Keys, t } from "Localization";
import { updateUserContext, userContext } from "UserContext";
import * as React from "react";
import ConnectImage from "../../../../images/HdeConnectCosmosDB.svg";
@@ -60,7 +61,7 @@ export const validateDirectConnectionStringConnectivity = async (
): Promise<string | undefined> => {
const masterKey = extractAccountKeyFromConnectionString(connectionString);
if (!metadata?.documentEndpoint || !masterKey) {
return "Unable to connect to the account with the provided connection string.";
return t(Keys.connectExplorer.errors.connectivityInvalid);
}
// Configure the client the same way the Data Explorer will, then issue a lightweight authenticated
@@ -76,7 +77,7 @@ export const validateDirectConnectionStringConnectivity = async (
await client().getDatabaseAccount();
return undefined;
} catch {
return "Unable to connect to the account. Please verify the connection string is correct and that the account is reachable.";
return t(Keys.connectExplorer.errors.connectivityUnreachable);
}
};
@@ -148,9 +149,7 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
setEncryptedToken(encryptedToken);
setAuthType(AuthType.ConnectionString);
} catch (error) {
setErrorMessage(
"Failed to connect using the provided connection string. Please verify it is correct and try again.",
);
setErrorMessage(t(Keys.connectExplorer.errors.connectFailed));
}
}}
>