Add feature for disabling connection string login and enable this for aad redirect. (#1660)
* Add redirect for /aad to /?feature.enableAadDataPlane=true * Add feature to hide the connection string login link. Enable this new feature for the aad redirect.
This commit is contained in:
parent
d376a7463c
commit
14d7677056
|
@ -1,6 +1,8 @@
|
||||||
jest.mock("../../../hooks/useDirectories");
|
jest.mock("../../../hooks/useDirectories");
|
||||||
import "@testing-library/jest-dom";
|
import "@testing-library/jest-dom";
|
||||||
import { fireEvent, render, screen } from "@testing-library/react";
|
import { fireEvent, render, screen } from "@testing-library/react";
|
||||||
|
import { extractFeatures } from "Platform/Hosted/extractFeatures";
|
||||||
|
import { updateUserContext, userContext } from "UserContext";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { ConnectExplorer } from "./ConnectExplorer";
|
import { ConnectExplorer } from "./ConnectExplorer";
|
||||||
|
|
||||||
|
@ -16,3 +18,24 @@ it("shows the connect form", () => {
|
||||||
fireEvent.click(screen.getByText("Connect to your account with connection string"));
|
fireEvent.click(screen.getByText("Connect to your account with connection string"));
|
||||||
expect(screen.queryByPlaceholderText("Please enter a connection string")).toBeDefined();
|
expect(screen.queryByPlaceholderText("Please enter a connection string")).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("hides the connection string link when feature.disableConnectionStringLogin is true", () => {
|
||||||
|
const connectionString = "fakeConnectionString";
|
||||||
|
const login = jest.fn();
|
||||||
|
const setConnectionString = jest.fn();
|
||||||
|
const setEncryptedToken = jest.fn();
|
||||||
|
const setAuthType = jest.fn();
|
||||||
|
const oldFeatures = userContext.features;
|
||||||
|
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
"feature.disableConnectionStringLogin": "true",
|
||||||
|
});
|
||||||
|
|
||||||
|
const testFeatures = extractFeatures(params);
|
||||||
|
updateUserContext({ features: testFeatures });
|
||||||
|
|
||||||
|
render(<ConnectExplorer {...{ login, setEncryptedToken, setAuthType, connectionString, setConnectionString }} />);
|
||||||
|
expect(screen.queryByPlaceholderText("Connect to your account with connection string")).toBeNull();
|
||||||
|
|
||||||
|
updateUserContext({ features: oldFeatures });
|
||||||
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { useBoolean } from "@fluentui/react-hooks";
|
import { useBoolean } from "@fluentui/react-hooks";
|
||||||
|
import { userContext } from "UserContext";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import ConnectImage from "../../../../images/HdeConnectCosmosDB.svg";
|
import ConnectImage from "../../../../images/HdeConnectCosmosDB.svg";
|
||||||
import ErrorImage from "../../../../images/error.svg";
|
import ErrorImage from "../../../../images/error.svg";
|
||||||
|
@ -37,6 +38,7 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
|
||||||
setConnectionString,
|
setConnectionString,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const [isFormVisible, { setTrue: showForm }] = useBoolean(false);
|
const [isFormVisible, { setTrue: showForm }] = useBoolean(false);
|
||||||
|
const enableConnectionStringLogin = !userContext.features.disableConnectionStringLogin;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="connectExplorer" className="connectExplorerContainer" style={{ display: "flex" }}>
|
<div id="connectExplorer" className="connectExplorerContainer" style={{ display: "flex" }}>
|
||||||
|
@ -46,7 +48,7 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
|
||||||
<img src={ConnectImage} alt="Azure Cosmos DB" />
|
<img src={ConnectImage} alt="Azure Cosmos DB" />
|
||||||
</p>
|
</p>
|
||||||
<p className="welcomeText">Welcome to Azure Cosmos DB</p>
|
<p className="welcomeText">Welcome to Azure Cosmos DB</p>
|
||||||
{isFormVisible ? (
|
{isFormVisible && enableConnectionStringLogin ? (
|
||||||
<form
|
<form
|
||||||
id="connectWithConnectionString"
|
id="connectWithConnectionString"
|
||||||
onSubmit={async (event) => {
|
onSubmit={async (event) => {
|
||||||
|
@ -89,9 +91,11 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
|
||||||
) : (
|
) : (
|
||||||
<div id="connectWithAad">
|
<div id="connectWithAad">
|
||||||
<input className="filterbtnstyle" type="button" value="Sign In" onClick={login} />
|
<input className="filterbtnstyle" type="button" value="Sign In" onClick={login} />
|
||||||
|
{enableConnectionStringLogin && (
|
||||||
<p className="switchConnectTypeText" onClick={showForm}>
|
<p className="switchConnectTypeText" onClick={showForm}>
|
||||||
Connect to your account with connection string
|
Connect to your account with connection string
|
||||||
</p>
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -41,6 +41,7 @@ export type Features = {
|
||||||
readonly enableCopilotFullSchema: boolean;
|
readonly enableCopilotFullSchema: boolean;
|
||||||
readonly copilotChatFixedMonacoEditorHeight: boolean;
|
readonly copilotChatFixedMonacoEditorHeight: boolean;
|
||||||
readonly enablePriorityBasedExecution: boolean;
|
readonly enablePriorityBasedExecution: boolean;
|
||||||
|
readonly disableConnectionStringLogin: boolean;
|
||||||
|
|
||||||
// can be set via both flight and feature flag
|
// can be set via both flight and feature flag
|
||||||
autoscaleDefault: boolean;
|
autoscaleDefault: boolean;
|
||||||
|
@ -114,6 +115,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
|
||||||
enableCopilotFullSchema: "true" === get("enablecopilotfullschema", "true"),
|
enableCopilotFullSchema: "true" === get("enablecopilotfullschema", "true"),
|
||||||
copilotChatFixedMonacoEditorHeight: "true" === get("copilotchatfixedmonacoeditorheight"),
|
copilotChatFixedMonacoEditorHeight: "true" === get("copilotchatfixedmonacoeditorheight"),
|
||||||
enablePriorityBasedExecution: "true" === get("enableprioritybasedexecution"),
|
enablePriorityBasedExecution: "true" === get("enableprioritybasedexecution"),
|
||||||
|
disableConnectionStringLogin: "true" === get("disableconnectionstringlogin"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<conditions>
|
<conditions>
|
||||||
<add input="{HTTP_HOST}" pattern="^cosmos.azure.com" />
|
<add input="{HTTP_HOST}" pattern="^cosmos.azure.com" />
|
||||||
</conditions>
|
</conditions>
|
||||||
<action type="Redirect" url="/?feature.enableAadDataPlane=true" redirectType="Permanent" />
|
<action type="Redirect" url="/?feature.enableAadDataPlane=true&feature.disableConnectionStringLogin=true" redirectType="Permanent" />
|
||||||
</rule>
|
</rule>
|
||||||
</rules>
|
</rules>
|
||||||
<outboundRules>
|
<outboundRules>
|
||||||
|
|
Loading…
Reference in New Issue