mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
Remove share-link feature (#1345)
* Remove share-link feature Cosmos DB supports sharing access to an account data using AAD/RBAC now so this feature is unnecessary. * Fix format issues * Fix unit tests * undo package changes
This commit is contained in:
parent
1ce3adff0f
commit
1213788f9c
@ -1,17 +1,9 @@
|
|||||||
jest.mock("../hooks/useFullScreenURLs");
|
|
||||||
import "@testing-library/jest-dom";
|
import "@testing-library/jest-dom";
|
||||||
import { render, screen } from "@testing-library/react";
|
import { render, screen } from "@testing-library/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useFullScreenURLs } from "../hooks/useFullScreenURLs";
|
|
||||||
import { OpenFullScreen } from "./OpenFullScreen";
|
import { OpenFullScreen } from "./OpenFullScreen";
|
||||||
|
|
||||||
it("renders the correct URLs", () => {
|
it("renders the correct URLs", () => {
|
||||||
(useFullScreenURLs as jest.Mock).mockReturnValue({
|
|
||||||
readWrite: "read and write url",
|
|
||||||
read: "read only url",
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<OpenFullScreen />);
|
render(<OpenFullScreen />);
|
||||||
expect(screen.getByLabelText("Read and Write")).toHaveValue("https://cosmos.azure.com/?key=read and write url");
|
expect(screen.getByText("Open")).toBeDefined();
|
||||||
expect(screen.getByLabelText("Read Only")).toHaveValue("https://cosmos.azure.com/?key=read only url");
|
|
||||||
});
|
});
|
||||||
|
@ -1,66 +1,26 @@
|
|||||||
import { DefaultButton, PrimaryButton, Spinner, Stack, Text, TextField } from "@fluentui/react";
|
import { PrimaryButton, Stack, Text } from "@fluentui/react";
|
||||||
import copyToClipboard from "clipboard-copy";
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { useFullScreenURLs } from "../hooks/useFullScreenURLs";
|
|
||||||
|
|
||||||
export const OpenFullScreen: React.FunctionComponent = () => {
|
export const OpenFullScreen: React.FunctionComponent = () => {
|
||||||
const [isReadUrlCopy, setIsReadUrlCopy] = React.useState<boolean>(false);
|
|
||||||
const [isReadWriteUrlCopy, setIsReadWriteUrlCopy] = React.useState<boolean>(false);
|
|
||||||
const result = useFullScreenURLs();
|
|
||||||
if (!result) {
|
|
||||||
return <Spinner label="Generating URLs..." ariaLive="assertive" labelPosition="right" />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const readWriteUrl = `https://cosmos.azure.com/?key=${result.readWrite}`;
|
|
||||||
const readUrl = `https://cosmos.azure.com/?key=${result.read}`;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack tokens={{ childrenGap: 10 }}>
|
<div style={{ padding: "34px" }}>
|
||||||
<Text>
|
<Stack tokens={{ childrenGap: 10 }}>
|
||||||
Open this database account in a new browser tab with Cosmos DB Explorer. Or copy the read-write or read only
|
<Text>
|
||||||
access urls below to share with others. For security purposes, the URLs grant time-bound access to the
|
Open this database account in a new browser tab with Cosmos DB Explorer. You can connect using your
|
||||||
account. When access expires, you can reconnect, using a valid connection string for the account.
|
Microsoft account or a connection string.
|
||||||
</Text>
|
</Text>
|
||||||
<TextField label="Read and Write" readOnly defaultValue={readWriteUrl} />
|
<Stack horizontal tokens={{ childrenGap: 10 }}>
|
||||||
<Stack horizontal tokens={{ childrenGap: 10 }}>
|
<PrimaryButton
|
||||||
<DefaultButton
|
onClick={() => {
|
||||||
ariaLabel={isReadWriteUrlCopy ? "Copied url" : "Copy"}
|
window.open("https://cosmos.azure.com/", "_blank");
|
||||||
onClick={() => {
|
}}
|
||||||
copyToClipboard(readWriteUrl);
|
text="Open"
|
||||||
setIsReadWriteUrlCopy(true);
|
iconProps={{ iconName: "OpenInNewWindow" }}
|
||||||
}}
|
/>
|
||||||
text={isReadWriteUrlCopy ? "Copied" : "Copy"}
|
</Stack>
|
||||||
iconProps={{ iconName: "Copy" }}
|
|
||||||
/>
|
|
||||||
<PrimaryButton
|
|
||||||
onClick={() => {
|
|
||||||
window.open(readWriteUrl, "_blank");
|
|
||||||
}}
|
|
||||||
text="Open"
|
|
||||||
iconProps={{ iconName: "OpenInNewWindow" }}
|
|
||||||
/>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
<TextField label="Read Only" readOnly defaultValue={readUrl} />
|
</div>
|
||||||
<Stack horizontal tokens={{ childrenGap: 10 }}>
|
|
||||||
<DefaultButton
|
|
||||||
ariaLabel={isReadUrlCopy ? "Copied url" : "Copy"}
|
|
||||||
onClick={() => {
|
|
||||||
setIsReadUrlCopy(true);
|
|
||||||
copyToClipboard(readUrl);
|
|
||||||
}}
|
|
||||||
text={isReadUrlCopy ? "Copied" : "Copy"}
|
|
||||||
iconProps={{ iconName: "Copy" }}
|
|
||||||
/>
|
|
||||||
<PrimaryButton
|
|
||||||
onClick={() => {
|
|
||||||
window.open(readUrl, "_blank");
|
|
||||||
}}
|
|
||||||
text="Open"
|
|
||||||
iconProps={{ iconName: "OpenInNewWindow" }}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
import * as Constants from "../../Common/Constants";
|
|
||||||
import { configContext } from "../../ConfigContext";
|
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
|
||||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
|
||||||
import { userContext } from "../../UserContext";
|
|
||||||
|
|
||||||
export default class AuthHeadersUtil {
|
|
||||||
public static async generateEncryptedToken(readOnly: boolean = false): Promise<DataModels.GenerateTokenResponse> {
|
|
||||||
const url = configContext.BACKEND_ENDPOINT + "/api/tokens/generateToken" + AuthHeadersUtil._generateResourceUrl();
|
|
||||||
const headers: any = { authorization: userContext.authorizationToken };
|
|
||||||
headers[Constants.HttpHeaders.getReadOnlyKey] = readOnly;
|
|
||||||
|
|
||||||
const response = await fetch(url, { method: "POST", headers });
|
|
||||||
const result = await response.json();
|
|
||||||
// This API has a quirk where the response must be parsed to JSON twice
|
|
||||||
return JSON.parse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static _generateResourceUrl(): string {
|
|
||||||
const { databaseAccount, resourceGroup, subscriptionId } = userContext;
|
|
||||||
const apiKind: DataModels.ApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(userContext.apiType);
|
|
||||||
const accountEndpoint = databaseAccount?.properties?.documentEndpoint || "";
|
|
||||||
const sid = subscriptionId || "";
|
|
||||||
const rg = resourceGroup || "";
|
|
||||||
const dba = databaseAccount?.name || "";
|
|
||||||
const resourceUrl = encodeURIComponent(accountEndpoint);
|
|
||||||
const rid = "";
|
|
||||||
const rtype = "";
|
|
||||||
return `?resourceUrl=${resourceUrl}&rid=${rid}&rtype=${rtype}&sid=${sid}&rg=${rg}&dba=${dba}&api=${apiKind}`;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
import { useEffect, useState } from "react";
|
|
||||||
import { GenerateTokenResponse } from "../Contracts/DataModels";
|
|
||||||
import AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
|
||||||
|
|
||||||
export function useFullScreenURLs(): GenerateTokenResponse | undefined {
|
|
||||||
const [state, setState] = useState<GenerateTokenResponse>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
Promise.all([AuthHeadersUtil.generateEncryptedToken(), AuthHeadersUtil.generateEncryptedToken(true)]).then(
|
|
||||||
([readWriteResponse, readOnlyResponse]) =>
|
|
||||||
setState({
|
|
||||||
readWrite: readWriteResponse.readWrite,
|
|
||||||
read: readOnlyResponse.read,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}, []);
|
|
||||||
return state;
|
|
||||||
}
|
|
@ -82,7 +82,6 @@
|
|||||||
"./src/Explorer/Tree/AccessibleVerticalList.ts",
|
"./src/Explorer/Tree/AccessibleVerticalList.ts",
|
||||||
"./src/GitHub/GitHubConnector.ts",
|
"./src/GitHub/GitHubConnector.ts",
|
||||||
"./src/HostedExplorerChildFrame.ts",
|
"./src/HostedExplorerChildFrame.ts",
|
||||||
"./src/Platform/Hosted/Authorization.ts",
|
|
||||||
"./src/Platform/Hosted/Components/MeControl.test.tsx",
|
"./src/Platform/Hosted/Components/MeControl.test.tsx",
|
||||||
"./src/Platform/Hosted/Components/MeControl.tsx",
|
"./src/Platform/Hosted/Components/MeControl.tsx",
|
||||||
"./src/Platform/Hosted/Components/SignInButton.tsx",
|
"./src/Platform/Hosted/Components/SignInButton.tsx",
|
||||||
@ -126,7 +125,6 @@
|
|||||||
"./src/Utils/WindowUtils.ts",
|
"./src/Utils/WindowUtils.ts",
|
||||||
"./src/hooks/useConfig.ts",
|
"./src/hooks/useConfig.ts",
|
||||||
"./src/hooks/useDirectories.tsx",
|
"./src/hooks/useDirectories.tsx",
|
||||||
"./src/hooks/useFullScreenURLs.tsx",
|
|
||||||
"./src/hooks/useGraphPhoto.tsx",
|
"./src/hooks/useGraphPhoto.tsx",
|
||||||
"./src/hooks/useNotebookSnapshotStore.ts",
|
"./src/hooks/useNotebookSnapshotStore.ts",
|
||||||
"./src/hooks/usePortalAccessToken.tsx",
|
"./src/hooks/usePortalAccessToken.tsx",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user