mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 06:56:38 +00:00
Merge branch 'master' of https://github.com/Azure/cosmos-explorer
This commit is contained in:
commit
d3a3033b25
@ -2296,6 +2296,17 @@ a:link {
|
|||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.monaco-editor .quick-input-list-label {
|
||||||
|
/* Restore some of Monaco's default styles that are clobbered by our global styles */
|
||||||
|
padding: 0;
|
||||||
|
line-height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.monaco-editor .quick-input-list .highlight {
|
||||||
|
/* Padding in highlighted text within the quick input list breaks the flow of the text */
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
td a {
|
td a {
|
||||||
color: #393939;
|
color: #393939;
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,9 @@ export enum MongoBackendEndpointType {
|
|||||||
remote,
|
remote,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum BackendApi {
|
export class BackendApi {
|
||||||
GenerateToken,
|
public static readonly GenerateToken: string = "GenerateToken";
|
||||||
|
public static readonly PortalSettings: string = "PortalSettings";
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PortalBackendEndpoints {
|
export class PortalBackendEndpoints {
|
||||||
|
@ -67,7 +67,7 @@ export function queryDocuments(
|
|||||||
query: string,
|
query: string,
|
||||||
continuationToken?: string,
|
continuationToken?: string,
|
||||||
): Promise<QueryResponse> {
|
): Promise<QueryResponse> {
|
||||||
if (!useMongoProxyEndpoint("resourcelist")) {
|
if (!useMongoProxyEndpoint("resourcelist") || !useMongoProxyEndpoint("queryDocuments")) {
|
||||||
return queryDocuments_ToBeDeprecated(databaseId, collection, isResourceList, query, continuationToken);
|
return queryDocuments_ToBeDeprecated(databaseId, collection, isResourceList, query, continuationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ export function queryDocuments(
|
|||||||
headers[CosmosSDKConstants.HttpHeaders.Continuation] = continuationToken;
|
headers[CosmosSDKConstants.HttpHeaders.Continuation] = continuationToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = isResourceList ? "/resourcelist" : "";
|
const path = isResourceList ? "/resourcelist" : "/queryDocuments";
|
||||||
|
|
||||||
return window
|
return window
|
||||||
.fetch(`${endpoint}${path}`, {
|
.fetch(`${endpoint}${path}`, {
|
||||||
@ -690,7 +690,7 @@ export function getARMCreateCollectionEndpoint(params: DataModels.MongoParameter
|
|||||||
}
|
}
|
||||||
|
|
||||||
function useMongoProxyEndpoint(api: string): boolean {
|
function useMongoProxyEndpoint(api: string): boolean {
|
||||||
const activeMongoProxyEndpoints: string[] = [MongoProxyEndpoints.Development];
|
const activeMongoProxyEndpoints: string[] = [MongoProxyEndpoints.Development, MongoProxyEndpoints.Mpac];
|
||||||
let canAccessMongoProxy: boolean = userContext.databaseAccount.properties.publicNetworkAccess === "Enabled";
|
let canAccessMongoProxy: boolean = userContext.databaseAccount.properties.publicNetworkAccess === "Enabled";
|
||||||
if (userContext.databaseAccount.properties.ipRules?.length > 0) {
|
if (userContext.databaseAccount.properties.ipRules?.length > 0) {
|
||||||
canAccessMongoProxy = canAccessMongoProxy && configContext.MONGO_PROXY_OUTBOUND_IPS_ALLOWLISTED;
|
canAccessMongoProxy = canAccessMongoProxy && configContext.MONGO_PROXY_OUTBOUND_IPS_ALLOWLISTED;
|
||||||
|
@ -99,24 +99,19 @@ let configContext: Readonly<ConfigContext> = {
|
|||||||
JUNO_ENDPOINT: JunoEndpoints.Prod,
|
JUNO_ENDPOINT: JunoEndpoints.Prod,
|
||||||
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com",
|
BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com",
|
||||||
PORTAL_BACKEND_ENDPOINT: PortalBackendEndpoints.Prod,
|
PORTAL_BACKEND_ENDPOINT: PortalBackendEndpoints.Prod,
|
||||||
NEW_BACKEND_APIS: [BackendApi.GenerateToken],
|
|
||||||
MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Prod,
|
MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Prod,
|
||||||
NEW_MONGO_APIS: [
|
NEW_MONGO_APIS: [
|
||||||
// "resourcelist",
|
"resourcelist",
|
||||||
// "createDocument",
|
"queryDocuments",
|
||||||
// "readDocument",
|
"createDocument",
|
||||||
// "updateDocument",
|
"readDocument",
|
||||||
// "deleteDocument",
|
"updateDocument",
|
||||||
// "createCollectionWithProxy",
|
"deleteDocument",
|
||||||
|
"createCollectionWithProxy",
|
||||||
],
|
],
|
||||||
MONGO_PROXY_OUTBOUND_IPS_ALLOWLISTED: false,
|
MONGO_PROXY_OUTBOUND_IPS_ALLOWLISTED: false,
|
||||||
CASSANDRA_PROXY_ENDPOINT: CassandraProxyEndpoints.Prod,
|
CASSANDRA_PROXY_ENDPOINT: CassandraProxyEndpoints.Prod,
|
||||||
NEW_CASSANDRA_APIS: [
|
NEW_CASSANDRA_APIS: ["postQuery", "createOrDelete", "getKeys", "getSchema"],
|
||||||
// "postQuery",
|
|
||||||
// "createOrDelete",
|
|
||||||
// "getKeys",
|
|
||||||
// "getSchema",
|
|
||||||
],
|
|
||||||
CASSANDRA_PROXY_OUTBOUND_IPS_ALLOWLISTED: false,
|
CASSANDRA_PROXY_OUTBOUND_IPS_ALLOWLISTED: false,
|
||||||
isTerminalEnabled: false,
|
isTerminalEnabled: false,
|
||||||
isPhoenixEnabled: false,
|
isPhoenixEnabled: false,
|
||||||
|
@ -53,6 +53,7 @@ export type FabricMessageV2 =
|
|||||||
id: string;
|
id: string;
|
||||||
message: {
|
message: {
|
||||||
connectionId: string;
|
connectionId: string;
|
||||||
|
isVisible: boolean;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
@ -72,7 +73,7 @@ export type FabricMessageV2 =
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: "setToolbarStatus";
|
type: "explorerVisible";
|
||||||
message: {
|
message: {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
};
|
};
|
||||||
|
@ -47,6 +47,7 @@ export enum MessageTypes {
|
|||||||
GetAllResourceTokens, // Data Explorer -> Fabric
|
GetAllResourceTokens, // Data Explorer -> Fabric
|
||||||
Ready, // Data Explorer -> Fabric
|
Ready, // Data Explorer -> Fabric
|
||||||
OpenCESCVAFeedbackBlade,
|
OpenCESCVAFeedbackBlade,
|
||||||
|
ActivateTab,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthorizationToken {
|
export interface AuthorizationToken {
|
||||||
|
@ -387,6 +387,7 @@ export interface DataExplorerInputsFrame {
|
|||||||
dnsSuffix?: string;
|
dnsSuffix?: string;
|
||||||
serverId?: string;
|
serverId?: string;
|
||||||
extensionEndpoint?: string;
|
extensionEndpoint?: string;
|
||||||
|
portalBackendEndpoint?: string;
|
||||||
mongoProxyEndpoint?: string;
|
mongoProxyEndpoint?: string;
|
||||||
cassandraProxyEndpoint?: string;
|
cassandraProxyEndpoint?: string;
|
||||||
subscriptionType?: SubscriptionType;
|
subscriptionType?: SubscriptionType;
|
||||||
|
@ -46,9 +46,21 @@ export class EditorReact extends React.Component<EditorReactProps, EditorReactSt
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidUpdate(previous: EditorReactProps) {
|
public componentDidUpdate() {
|
||||||
if (this.props.content !== previous.content) {
|
if (!this.editor) {
|
||||||
this.editor?.setValue(this.props.content);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const existingContent = this.editor.getModel().getValue();
|
||||||
|
|
||||||
|
if (this.props.content !== existingContent) {
|
||||||
|
this.editor.pushUndoStop();
|
||||||
|
this.editor.executeEdits("", [
|
||||||
|
{
|
||||||
|
range: this.editor.getModel().getFullModelRange(),
|
||||||
|
text: this.props.content,
|
||||||
|
},
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,9 +83,14 @@ export class EditorReact extends React.Component<EditorReactProps, EditorReactSt
|
|||||||
|
|
||||||
protected configureEditor(editor: monaco.editor.IStandaloneCodeEditor) {
|
protected configureEditor(editor: monaco.editor.IStandaloneCodeEditor) {
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
const queryEditorModel = this.editor.getModel();
|
|
||||||
if (!this.props.isReadOnly && this.props.onContentChanged) {
|
if (!this.props.isReadOnly && this.props.onContentChanged) {
|
||||||
queryEditorModel.onDidChangeContent(() => {
|
// Hooking the model's onDidChangeContent event because of some event ordering issues.
|
||||||
|
// If a single user input causes BOTH the editor content to change AND the cursor selection to change (which is likely),
|
||||||
|
// then there are some inconsistencies as to which event fires first.
|
||||||
|
// But the editor.onDidChangeModelContent event seems to always fire before the cursor selection event.
|
||||||
|
// (This is NOT true for the model's onDidChangeContent event, which sometimes fires after the cursor selection event.)
|
||||||
|
// If the cursor selection event fires first, then the calling component may re-render the component with old content, so we want to ensure the model content changed event always fires first.
|
||||||
|
this.editor.onDidChangeModelContent(() => {
|
||||||
const queryEditorModel = this.editor.getModel();
|
const queryEditorModel = this.editor.getModel();
|
||||||
this.props.onContentChanged(queryEditorModel.getValue());
|
this.props.onContentChanged(queryEditorModel.getValue());
|
||||||
});
|
});
|
||||||
|
@ -2,10 +2,8 @@ import * as ko from "knockout";
|
|||||||
import { AuthType } from "../../../AuthType";
|
import { AuthType } from "../../../AuthType";
|
||||||
import { DatabaseAccount } from "../../../Contracts/DataModels";
|
import { DatabaseAccount } from "../../../Contracts/DataModels";
|
||||||
import { CollectionBase } from "../../../Contracts/ViewModels";
|
import { CollectionBase } from "../../../Contracts/ViewModels";
|
||||||
import { GitHubOAuthService } from "../../../GitHub/GitHubOAuthService";
|
|
||||||
import { updateUserContext } from "../../../UserContext";
|
import { updateUserContext } from "../../../UserContext";
|
||||||
import Explorer from "../../Explorer";
|
import Explorer from "../../Explorer";
|
||||||
import NotebookManager from "../../Notebook/NotebookManager";
|
|
||||||
import { useNotebook } from "../../Notebook/useNotebook";
|
import { useNotebook } from "../../Notebook/useNotebook";
|
||||||
import { useDatabases } from "../../useDatabases";
|
import { useDatabases } from "../../useDatabases";
|
||||||
import { useSelectedNode } from "../../useSelectedNode";
|
import { useSelectedNode } from "../../useSelectedNode";
|
||||||
@ -72,181 +70,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Enable notebook button", () => {
|
|
||||||
const enableNotebookBtnLabel = "Enable Notebooks (Preview)";
|
|
||||||
const selectedNodeState = useSelectedNode.getState();
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
mockExplorer = {} as Explorer;
|
|
||||||
updateUserContext({
|
|
||||||
portalEnv: "prod",
|
|
||||||
databaseAccount: {
|
|
||||||
properties: {
|
|
||||||
capabilities: [{ name: "EnableTable" }],
|
|
||||||
},
|
|
||||||
} as DatabaseAccount,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
updateUserContext({
|
|
||||||
portalEnv: "prod",
|
|
||||||
});
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(false);
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is already enabled - button should be hidden", () => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(true);
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const enableNotebookBtn = buttons.find((button) => button.commandButtonLabel === enableNotebookBtnLabel);
|
|
||||||
expect(enableNotebookBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Account is running on one of the national clouds - button should be hidden", () => {
|
|
||||||
updateUserContext({
|
|
||||||
portalEnv: "mooncake",
|
|
||||||
});
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const enableNotebookBtn = buttons.find((button) => button.commandButtonLabel === enableNotebookBtnLabel);
|
|
||||||
expect(enableNotebookBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is not enabled but is available - button should be shown and enabled", () => {
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const enableNotebookBtn = buttons.find((button) => button.commandButtonLabel === enableNotebookBtnLabel);
|
|
||||||
|
|
||||||
//TODO: modify once notebooks are available
|
|
||||||
expect(enableNotebookBtn).toBeUndefined();
|
|
||||||
//expect(enableNotebookBtn).toBeDefined();
|
|
||||||
//expect(enableNotebookBtn.disabled).toBe(false);
|
|
||||||
//expect(enableNotebookBtn.tooltipText).toBe("");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is not enabled and is unavailable - button should be shown and disabled", () => {
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const enableNotebookBtn = buttons.find((button) => button.commandButtonLabel === enableNotebookBtnLabel);
|
|
||||||
|
|
||||||
//TODO: modify once notebooks are available
|
|
||||||
expect(enableNotebookBtn).toBeUndefined();
|
|
||||||
//expect(enableNotebookBtn).toBeDefined();
|
|
||||||
//expect(enableNotebookBtn.disabled).toBe(true);
|
|
||||||
//expect(enableNotebookBtn.tooltipText).toBe(
|
|
||||||
// "Notebooks are not yet available in your account's region. View supported regions here: https://aka.ms/cosmos-enable-notebooks."
|
|
||||||
//);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Open Mongo shell button", () => {
|
|
||||||
const openMongoShellBtnLabel = "Open Mongo shell";
|
|
||||||
const selectedNodeState = useSelectedNode.getState();
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
mockExplorer = {} as Explorer;
|
|
||||||
updateUserContext({
|
|
||||||
databaseAccount: {
|
|
||||||
properties: {
|
|
||||||
capabilities: [{ name: "EnableTable" }],
|
|
||||||
},
|
|
||||||
} as DatabaseAccount,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
updateUserContext({
|
|
||||||
apiType: "SQL",
|
|
||||||
});
|
|
||||||
useNotebook.getState().setIsShellEnabled(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
updateUserContext({
|
|
||||||
apiType: "Mongo",
|
|
||||||
});
|
|
||||||
useNotebook.getState().setIsShellEnabled(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(false);
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Mongo Api not available - button should be hidden", () => {
|
|
||||||
updateUserContext({
|
|
||||||
apiType: "SQL",
|
|
||||||
});
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
|
||||||
expect(openMongoShellBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Running on a national cloud - button should be hidden", () => {
|
|
||||||
updateUserContext({
|
|
||||||
portalEnv: "mooncake",
|
|
||||||
});
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
|
||||||
expect(openMongoShellBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is not enabled and is unavailable - button should be hidden", () => {
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
|
||||||
expect(openMongoShellBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is not enabled and is available - button should be hidden", () => {
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
|
||||||
expect(openMongoShellBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is enabled and is unavailable - button should be shown and enabled", () => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
|
||||||
expect(openMongoShellBtn).toBeDefined();
|
|
||||||
|
|
||||||
//TODO: modify once notebooks are available
|
|
||||||
expect(openMongoShellBtn.disabled).toBe(true);
|
|
||||||
//expect(openMongoShellBtn.disabled).toBe(false);
|
|
||||||
//expect(openMongoShellBtn.tooltipText).toBe("");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is enabled and is available - button should be shown and enabled", () => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(true);
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
|
||||||
expect(openMongoShellBtn).toBeDefined();
|
|
||||||
|
|
||||||
//TODO: modify once notebooks are available
|
|
||||||
expect(openMongoShellBtn.disabled).toBe(true);
|
|
||||||
//expect(openMongoShellBtn.disabled).toBe(false);
|
|
||||||
//expect(openMongoShellBtn.tooltipText).toBe("");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is enabled and is available, terminal is unavailable due to ipRules - button should be hidden", () => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(true);
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
|
||||||
useNotebook.getState().setIsShellEnabled(false);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openMongoShellBtn = buttons.find((button) => button.commandButtonLabel === openMongoShellBtnLabel);
|
|
||||||
expect(openMongoShellBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Open Cassandra shell button", () => {
|
describe("Open Cassandra shell button", () => {
|
||||||
const openCassandraShellBtnLabel = "Open Cassandra shell";
|
const openCassandraShellBtnLabel = "Open Cassandra shell";
|
||||||
const selectedNodeState = useSelectedNode.getState();
|
const selectedNodeState = useSelectedNode.getState();
|
||||||
@ -305,42 +128,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||||||
const openCassandraShellBtn = buttons.find((button) => button.commandButtonLabel === openCassandraShellBtnLabel);
|
const openCassandraShellBtn = buttons.find((button) => button.commandButtonLabel === openCassandraShellBtnLabel);
|
||||||
expect(openCassandraShellBtn).toBeUndefined();
|
expect(openCassandraShellBtn).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Notebooks is not enabled and is available - button should be shown and enabled", () => {
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openCassandraShellBtn = buttons.find((button) => button.commandButtonLabel === openCassandraShellBtnLabel);
|
|
||||||
expect(openCassandraShellBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is enabled and is unavailable - button should be shown and enabled", () => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openCassandraShellBtn = buttons.find((button) => button.commandButtonLabel === openCassandraShellBtnLabel);
|
|
||||||
|
|
||||||
expect(openCassandraShellBtn).toBeDefined();
|
|
||||||
|
|
||||||
//TODO: modify once notebooks are available
|
|
||||||
expect(openCassandraShellBtn.disabled).toBe(true);
|
|
||||||
//expect(openCassandraShellBtn.disabled).toBe(false);
|
|
||||||
//expect(openCassandraShellBtn.tooltipText).toBe("");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is enabled and is available - button should be shown and enabled", () => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(true);
|
|
||||||
useNotebook.getState().setIsNotebooksEnabledForAccount(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const openCassandraShellBtn = buttons.find((button) => button.commandButtonLabel === openCassandraShellBtnLabel);
|
|
||||||
expect(openCassandraShellBtn).toBeDefined();
|
|
||||||
|
|
||||||
//TODO: modify once notebooks are available
|
|
||||||
expect(openCassandraShellBtn.disabled).toBe(true);
|
|
||||||
//expect(openCassandraShellBtn.disabled).toBe(false);
|
|
||||||
//expect(openCassandraShellBtn.tooltipText).toBe("");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Open Postgres and vCore Mongo buttons", () => {
|
describe("Open Postgres and vCore Mongo buttons", () => {
|
||||||
@ -368,62 +155,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("GitHub buttons", () => {
|
|
||||||
const connectToGitHubBtnLabel = "Connect to GitHub";
|
|
||||||
const manageGitHubSettingsBtnLabel = "Manage GitHub settings";
|
|
||||||
const selectedNodeState = useSelectedNode.getState();
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
mockExplorer = {} as Explorer;
|
|
||||||
updateUserContext({
|
|
||||||
databaseAccount: {
|
|
||||||
properties: {
|
|
||||||
capabilities: [{ name: "EnableTable" }],
|
|
||||||
},
|
|
||||||
} as DatabaseAccount,
|
|
||||||
});
|
|
||||||
|
|
||||||
mockExplorer.notebookManager = new NotebookManager();
|
|
||||||
mockExplorer.notebookManager.gitHubOAuthService = new GitHubOAuthService(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.resetAllMocks();
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is enabled and GitHubOAuthService is not logged in - connect to github button should be visible", () => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const connectToGitHubBtn = buttons.find((button) => button.commandButtonLabel === connectToGitHubBtnLabel);
|
|
||||||
expect(connectToGitHubBtn).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is enabled and GitHubOAuthService is logged in - manage github settings button should be visible", () => {
|
|
||||||
useNotebook.getState().setIsNotebookEnabled(true);
|
|
||||||
mockExplorer.notebookManager.gitHubOAuthService.isLoggedIn = jest.fn().mockReturnValue(true);
|
|
||||||
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
const manageGitHubSettingsBtn = buttons.find(
|
|
||||||
(button) => button.commandButtonLabel === manageGitHubSettingsBtnLabel,
|
|
||||||
);
|
|
||||||
expect(manageGitHubSettingsBtn).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Notebooks is not enabled - connect to github and manage github settings buttons should be hidden", () => {
|
|
||||||
const buttons = CommandBarComponentButtonFactory.createStaticCommandBarButtons(mockExplorer, selectedNodeState);
|
|
||||||
|
|
||||||
const connectToGitHubBtn = buttons.find((button) => button.commandButtonLabel === connectToGitHubBtnLabel);
|
|
||||||
expect(connectToGitHubBtn).toBeUndefined();
|
|
||||||
|
|
||||||
const manageGitHubSettingsBtn = buttons.find(
|
|
||||||
(button) => button.commandButtonLabel === manageGitHubSettingsBtnLabel,
|
|
||||||
);
|
|
||||||
expect(manageGitHubSettingsBtn).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Resource token", () => {
|
describe("Resource token", () => {
|
||||||
const mockCollection = { id: ko.observable("test") } as CollectionBase;
|
const mockCollection = { id: ko.observable("test") } as CollectionBase;
|
||||||
useSelectedNode.getState().setSelectedNode(mockCollection);
|
useSelectedNode.getState().setSelectedNode(mockCollection);
|
||||||
|
@ -7,14 +7,10 @@ import AddStoredProcedureIcon from "../../../../images/AddStoredProcedure.svg";
|
|||||||
import AddTriggerIcon from "../../../../images/AddTrigger.svg";
|
import AddTriggerIcon from "../../../../images/AddTrigger.svg";
|
||||||
import AddUdfIcon from "../../../../images/AddUdf.svg";
|
import AddUdfIcon from "../../../../images/AddUdf.svg";
|
||||||
import BrowseQueriesIcon from "../../../../images/BrowseQuery.svg";
|
import BrowseQueriesIcon from "../../../../images/BrowseQuery.svg";
|
||||||
import CosmosTerminalIcon from "../../../../images/Cosmos-Terminal.svg";
|
|
||||||
import FeedbackIcon from "../../../../images/Feedback-Command.svg";
|
import FeedbackIcon from "../../../../images/Feedback-Command.svg";
|
||||||
import HomeIcon from "../../../../images/Home_16.svg";
|
import HomeIcon from "../../../../images/Home_16.svg";
|
||||||
import HostedTerminalIcon from "../../../../images/Hosted-Terminal.svg";
|
import HostedTerminalIcon from "../../../../images/Hosted-Terminal.svg";
|
||||||
import OpenQueryFromDiskIcon from "../../../../images/OpenQueryFromDisk.svg";
|
import OpenQueryFromDiskIcon from "../../../../images/OpenQueryFromDisk.svg";
|
||||||
import GitHubIcon from "../../../../images/github.svg";
|
|
||||||
import NewNotebookIcon from "../../../../images/notebook/Notebook-new.svg";
|
|
||||||
import ResetWorkspaceIcon from "../../../../images/notebook/Notebook-reset-workspace.svg";
|
|
||||||
import OpenInTabIcon from "../../../../images/open-in-tab.svg";
|
import OpenInTabIcon from "../../../../images/open-in-tab.svg";
|
||||||
import SettingsIcon from "../../../../images/settings_15x15.svg";
|
import SettingsIcon from "../../../../images/settings_15x15.svg";
|
||||||
import SynapseIcon from "../../../../images/synapse-link.svg";
|
import SynapseIcon from "../../../../images/synapse-link.svg";
|
||||||
@ -22,7 +18,6 @@ import { AuthType } from "../../../AuthType";
|
|||||||
import * as Constants from "../../../Common/Constants";
|
import * as Constants from "../../../Common/Constants";
|
||||||
import { Platform, configContext } from "../../../ConfigContext";
|
import { Platform, configContext } from "../../../ConfigContext";
|
||||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import { JunoClient } from "../../../Juno/JunoClient";
|
|
||||||
import { userContext } from "../../../UserContext";
|
import { userContext } from "../../../UserContext";
|
||||||
import { getCollectionName, getDatabaseName } from "../../../Utils/APITypeUtils";
|
import { getCollectionName, getDatabaseName } from "../../../Utils/APITypeUtils";
|
||||||
import { isRunningOnNationalCloud } from "../../../Utils/CloudUtils";
|
import { isRunningOnNationalCloud } from "../../../Utils/CloudUtils";
|
||||||
@ -33,7 +28,6 @@ import { useNotebook } from "../../Notebook/useNotebook";
|
|||||||
import { OpenFullScreen } from "../../OpenFullScreen";
|
import { OpenFullScreen } from "../../OpenFullScreen";
|
||||||
import { AddDatabasePanel } from "../../Panes/AddDatabasePanel/AddDatabasePanel";
|
import { AddDatabasePanel } from "../../Panes/AddDatabasePanel/AddDatabasePanel";
|
||||||
import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane";
|
import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPane";
|
||||||
import { GitHubReposPanel } from "../../Panes/GitHubReposPanel/GitHubReposPanel";
|
|
||||||
import { LoadQueryPane } from "../../Panes/LoadQueryPane/LoadQueryPane";
|
import { LoadQueryPane } from "../../Panes/LoadQueryPane/LoadQueryPane";
|
||||||
import { SettingsPane } from "../../Panes/SettingsPane/SettingsPane";
|
import { SettingsPane } from "../../Panes/SettingsPane/SettingsPane";
|
||||||
import { useDatabases } from "../../useDatabases";
|
import { useDatabases } from "../../useDatabases";
|
||||||
@ -80,57 +74,6 @@ export function createStaticCommandBarButtons(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useNotebook.getState().isNotebookEnabled) {
|
|
||||||
addDivider();
|
|
||||||
const notebookButtons: CommandButtonComponentProps[] = [];
|
|
||||||
|
|
||||||
const newNotebookButton = createNewNotebookButton(container);
|
|
||||||
newNotebookButton.children = [createNewNotebookButton(container), createuploadNotebookButton(container)];
|
|
||||||
notebookButtons.push(newNotebookButton);
|
|
||||||
|
|
||||||
if (container.notebookManager?.gitHubOAuthService) {
|
|
||||||
notebookButtons.push(createManageGitHubAccountButton(container));
|
|
||||||
}
|
|
||||||
if (useNotebook.getState().isPhoenixFeatures && configContext.isTerminalEnabled) {
|
|
||||||
notebookButtons.push(createOpenTerminalButton(container));
|
|
||||||
}
|
|
||||||
if (useNotebook.getState().isPhoenixNotebooks && selectedNodeState.isConnectedToContainer()) {
|
|
||||||
notebookButtons.push(createNotebookWorkspaceResetButton(container));
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
(userContext.apiType === "Mongo" &&
|
|
||||||
useNotebook.getState().isShellEnabled &&
|
|
||||||
selectedNodeState.isDatabaseNodeOrNoneSelected()) ||
|
|
||||||
userContext.apiType === "Cassandra"
|
|
||||||
) {
|
|
||||||
notebookButtons.push(createDivider());
|
|
||||||
if (userContext.apiType === "Cassandra") {
|
|
||||||
notebookButtons.push(createOpenTerminalButtonByKind(container, ViewModels.TerminalKind.Cassandra));
|
|
||||||
} else {
|
|
||||||
notebookButtons.push(createOpenTerminalButtonByKind(container, ViewModels.TerminalKind.Mongo));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notebookButtons.forEach((btn) => {
|
|
||||||
if (btn.commandButtonLabel.indexOf("Cassandra") !== -1) {
|
|
||||||
if (!useNotebook.getState().isPhoenixFeatures) {
|
|
||||||
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.cassandraShellTemporarilyDownMsg);
|
|
||||||
}
|
|
||||||
} else if (btn.commandButtonLabel.indexOf("Mongo") !== -1) {
|
|
||||||
if (!useNotebook.getState().isPhoenixFeatures) {
|
|
||||||
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.mongoShellTemporarilyDownMsg);
|
|
||||||
}
|
|
||||||
} else if (btn.commandButtonLabel.indexOf("Open Terminal") !== -1) {
|
|
||||||
if (!useNotebook.getState().isPhoenixFeatures) {
|
|
||||||
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.temporarilyDownMsg);
|
|
||||||
}
|
|
||||||
} else if (!useNotebook.getState().isPhoenixNotebooks) {
|
|
||||||
applyNotebooksTemporarilyDownStyle(btn, Constants.Notebook.temporarilyDownMsg);
|
|
||||||
}
|
|
||||||
buttons.push(btn);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedNodeState.isDatabaseNodeOrNoneSelected()) {
|
if (!selectedNodeState.isDatabaseNodeOrNoneSelected()) {
|
||||||
const isQuerySupported = userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
const isQuerySupported = userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
||||||
|
|
||||||
@ -240,7 +183,7 @@ export function createControlCommandBarButtons(container: Explorer): CommandButt
|
|||||||
buttons.push(fullScreenButton);
|
buttons.push(fullScreenButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configContext.platform !== Platform.Emulator) {
|
if (configContext.platform === Platform.Portal) {
|
||||||
const label = "Feedback";
|
const label = "Feedback";
|
||||||
const feedbackButtonOptions: CommandButtonComponentProps = {
|
const feedbackButtonOptions: CommandButtonComponentProps = {
|
||||||
iconSrc: FeedbackIcon,
|
iconSrc: FeedbackIcon,
|
||||||
@ -449,40 +392,6 @@ export function createScriptCommandButtons(selectedNodeState: SelectedNodeState)
|
|||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyNotebooksTemporarilyDownStyle(buttonProps: CommandButtonComponentProps, tooltip: string): void {
|
|
||||||
if (!buttonProps.isDivider) {
|
|
||||||
buttonProps.disabled = true;
|
|
||||||
buttonProps.tooltipText = tooltip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function createNewNotebookButton(container: Explorer): CommandButtonComponentProps {
|
|
||||||
const label = "New Notebook";
|
|
||||||
return {
|
|
||||||
id: "newNotebookBtn",
|
|
||||||
iconSrc: NewNotebookIcon,
|
|
||||||
iconAlt: label,
|
|
||||||
onCommandClick: () => container.onNewNotebookClicked(),
|
|
||||||
commandButtonLabel: label,
|
|
||||||
hasPopup: false,
|
|
||||||
disabled: useSelectedNode.getState().isQueryCopilotCollectionSelected(),
|
|
||||||
ariaLabel: label,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function createuploadNotebookButton(container: Explorer): CommandButtonComponentProps {
|
|
||||||
const label = "Upload to Notebook Server";
|
|
||||||
return {
|
|
||||||
iconSrc: NewNotebookIcon,
|
|
||||||
iconAlt: label,
|
|
||||||
onCommandClick: () => container.openUploadFilePanel(),
|
|
||||||
commandButtonLabel: label,
|
|
||||||
hasPopup: false,
|
|
||||||
disabled: useSelectedNode.getState().isQueryCopilotCollectionSelected(),
|
|
||||||
ariaLabel: label,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function createOpenQueryButton(container: Explorer): CommandButtonComponentProps {
|
function createOpenQueryButton(container: Explorer): CommandButtonComponentProps {
|
||||||
const label = "Open Query";
|
const label = "Open Query";
|
||||||
return {
|
return {
|
||||||
@ -510,19 +419,6 @@ function createOpenQueryFromDiskButton(): CommandButtonComponentProps {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOpenTerminalButton(container: Explorer): CommandButtonComponentProps {
|
|
||||||
const label = "Open Terminal";
|
|
||||||
return {
|
|
||||||
iconSrc: CosmosTerminalIcon,
|
|
||||||
iconAlt: label,
|
|
||||||
onCommandClick: () => container.openNotebookTerminal(ViewModels.TerminalKind.Default),
|
|
||||||
commandButtonLabel: label,
|
|
||||||
hasPopup: false,
|
|
||||||
disabled: useSelectedNode.getState().isQueryCopilotCollectionSelected(),
|
|
||||||
ariaLabel: label,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function createOpenTerminalButtonByKind(
|
function createOpenTerminalButtonByKind(
|
||||||
container: Explorer,
|
container: Explorer,
|
||||||
terminalKind: ViewModels.TerminalKind,
|
terminalKind: ViewModels.TerminalKind,
|
||||||
@ -562,45 +458,6 @@ function createOpenTerminalButtonByKind(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNotebookWorkspaceResetButton(container: Explorer): CommandButtonComponentProps {
|
|
||||||
const label = "Reset Workspace";
|
|
||||||
return {
|
|
||||||
iconSrc: ResetWorkspaceIcon,
|
|
||||||
iconAlt: label,
|
|
||||||
onCommandClick: () => container.resetNotebookWorkspace(),
|
|
||||||
commandButtonLabel: label,
|
|
||||||
hasPopup: false,
|
|
||||||
disabled: useSelectedNode.getState().isQueryCopilotCollectionSelected(),
|
|
||||||
ariaLabel: label,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function createManageGitHubAccountButton(container: Explorer): CommandButtonComponentProps {
|
|
||||||
const connectedToGitHub: boolean = container.notebookManager?.gitHubOAuthService.isLoggedIn();
|
|
||||||
const label = connectedToGitHub ? "Manage GitHub settings" : "Connect to GitHub";
|
|
||||||
const junoClient = new JunoClient();
|
|
||||||
return {
|
|
||||||
iconSrc: GitHubIcon,
|
|
||||||
iconAlt: label,
|
|
||||||
onCommandClick: () => {
|
|
||||||
useSidePanel
|
|
||||||
.getState()
|
|
||||||
.openSidePanel(
|
|
||||||
label,
|
|
||||||
<GitHubReposPanel
|
|
||||||
explorer={container}
|
|
||||||
gitHubClientProp={container.notebookManager.gitHubClient}
|
|
||||||
junoClientProp={junoClient}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
commandButtonLabel: label,
|
|
||||||
hasPopup: false,
|
|
||||||
disabled: useSelectedNode.getState().isQueryCopilotCollectionSelected(),
|
|
||||||
ariaLabel: label,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function createStaticCommandBarButtonsForResourceToken(
|
function createStaticCommandBarButtonsForResourceToken(
|
||||||
container: Explorer,
|
container: Explorer,
|
||||||
selectedNodeState: SelectedNodeState,
|
selectedNodeState: SelectedNodeState,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// TODO convert this file to an action registry in order to have actions and their handlers be more tightly coupled.
|
// TODO convert this file to an action registry in order to have actions and their handlers be more tightly coupled.
|
||||||
|
import { useDatabases } from "Explorer/useDatabases";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { ActionContracts } from "../../Contracts/ExplorerContracts";
|
import { ActionContracts } from "../../Contracts/ExplorerContracts";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
@ -40,12 +41,26 @@ function openCollectionTab(
|
|||||||
databases: ViewModels.Database[],
|
databases: ViewModels.Database[],
|
||||||
initialDatabaseIndex = 0,
|
initialDatabaseIndex = 0,
|
||||||
) {
|
) {
|
||||||
|
//if databases are not yet loaded, wait until loaded
|
||||||
|
if (!databases || databases.length === 0) {
|
||||||
|
const databaseActionHandler = (databases: ViewModels.Database[]) => {
|
||||||
|
databasesUnsubscription();
|
||||||
|
openCollectionTab(action, databases, 0);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
const databasesUnsubscription = useDatabases.subscribe(databaseActionHandler, (state) => state.databases);
|
||||||
|
} else {
|
||||||
for (let i = initialDatabaseIndex; i < databases.length; i++) {
|
for (let i = initialDatabaseIndex; i < databases.length; i++) {
|
||||||
const database: ViewModels.Database = databases[i];
|
const database: ViewModels.Database = databases[i];
|
||||||
if (!!action.databaseResourceId && database.id() !== action.databaseResourceId) {
|
if (!!action.databaseResourceId && database.id() !== action.databaseResourceId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//expand database first if not expanded to load the collections
|
||||||
|
if (!database.isDatabaseExpanded?.()) {
|
||||||
|
database.expandDatabase?.();
|
||||||
|
}
|
||||||
|
|
||||||
const collectionActionHandler = (collections: ViewModels.Collection[]) => {
|
const collectionActionHandler = (collections: ViewModels.Collection[]) => {
|
||||||
if (!action.collectionResourceId && collections.length === 0) {
|
if (!action.collectionResourceId && collections.length === 0) {
|
||||||
subscription.dispose();
|
subscription.dispose();
|
||||||
@ -133,6 +148,7 @@ function openCollectionTab(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function openPane(action: ActionContracts.OpenPane, explorer: Explorer) {
|
function openPane(action: ActionContracts.OpenPane, explorer: Explorer) {
|
||||||
if (
|
if (
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { FeedOptions } from "@azure/cosmos";
|
import { FeedOptions } from "@azure/cosmos";
|
||||||
import {
|
import {
|
||||||
Areas,
|
Areas,
|
||||||
|
BackendApi,
|
||||||
ConnectionStatusType,
|
ConnectionStatusType,
|
||||||
ContainerStatusType,
|
ContainerStatusType,
|
||||||
HttpStatusCodes,
|
HttpStatusCodes,
|
||||||
@ -30,6 +31,7 @@ import { Action } from "Shared/Telemetry/TelemetryConstants";
|
|||||||
import { traceFailure, traceStart, traceSuccess } from "Shared/Telemetry/TelemetryProcessor";
|
import { traceFailure, traceStart, traceSuccess } from "Shared/Telemetry/TelemetryProcessor";
|
||||||
import { userContext } from "UserContext";
|
import { userContext } from "UserContext";
|
||||||
import { getAuthorizationHeader } from "Utils/AuthorizationUtils";
|
import { getAuthorizationHeader } from "Utils/AuthorizationUtils";
|
||||||
|
import { useNewPortalBackendEndpoint } from "Utils/EndpointUtils";
|
||||||
import { queryPagesUntilContentPresent } from "Utils/QueryUtils";
|
import { queryPagesUntilContentPresent } from "Utils/QueryUtils";
|
||||||
import { QueryCopilotState, useQueryCopilot } from "hooks/useQueryCopilot";
|
import { QueryCopilotState, useQueryCopilot } from "hooks/useQueryCopilot";
|
||||||
import { useTabs } from "hooks/useTabs";
|
import { useTabs } from "hooks/useTabs";
|
||||||
@ -80,7 +82,11 @@ export const isCopilotFeatureRegistered = async (subscriptionId: string): Promis
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getCopilotEnabled = async (): Promise<boolean> => {
|
export const getCopilotEnabled = async (): Promise<boolean> => {
|
||||||
const url = `${configContext.BACKEND_ENDPOINT}/api/portalsettings/querycopilot`;
|
const backendEndpoint: string = useNewPortalBackendEndpoint(BackendApi.PortalSettings)
|
||||||
|
? configContext.PORTAL_BACKEND_ENDPOINT
|
||||||
|
: configContext.BACKEND_ENDPOINT;
|
||||||
|
|
||||||
|
const url = `${backendEndpoint}/api/portalsettings/querycopilot`;
|
||||||
const authorizationHeader: AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
const authorizationHeader: AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
||||||
const headers = { [authorizationHeader.header]: authorizationHeader.token };
|
const headers = { [authorizationHeader.header]: authorizationHeader.token };
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import Explorer from "../Explorer";
|
|||||||
import * as TableConstants from "./Constants";
|
import * as TableConstants from "./Constants";
|
||||||
import * as Entities from "./Entities";
|
import * as Entities from "./Entities";
|
||||||
import * as TableEntityProcessor from "./TableEntityProcessor";
|
import * as TableEntityProcessor from "./TableEntityProcessor";
|
||||||
import { CassandraProxyAPIs } from "../../Common/Constants";
|
import { CassandraProxyAPIs, CassandraProxyEndpoints } from "../../Common/Constants";
|
||||||
|
|
||||||
export interface CassandraTableKeys {
|
export interface CassandraTableKeys {
|
||||||
partitionKeys: CassandraTableKey[];
|
partitionKeys: CassandraTableKey[];
|
||||||
@ -458,7 +458,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getTableKeys(collection: ViewModels.Collection): Q.Promise<CassandraTableKeys> {
|
public getTableKeys(collection: ViewModels.Collection): Q.Promise<CassandraTableKeys> {
|
||||||
if (!this.useCassandraProxyEndpoint("getTableKeys")) {
|
if (!this.useCassandraProxyEndpoint("getKeys")) {
|
||||||
return this.getTableKeys_ToBeDeprecated(collection);
|
return this.getTableKeys_ToBeDeprecated(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -732,6 +732,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private useCassandraProxyEndpoint(api: string): boolean {
|
private useCassandraProxyEndpoint(api: string): boolean {
|
||||||
|
const activeCassandraProxyEndpoints: string[] = [CassandraProxyEndpoints.Development, CassandraProxyEndpoints.Mpac];
|
||||||
let canAccessCassandraProxy: boolean = userContext.databaseAccount.properties.publicNetworkAccess === "Enabled";
|
let canAccessCassandraProxy: boolean = userContext.databaseAccount.properties.publicNetworkAccess === "Enabled";
|
||||||
if (userContext.databaseAccount.properties.ipRules?.length > 0) {
|
if (userContext.databaseAccount.properties.ipRules?.length > 0) {
|
||||||
canAccessCassandraProxy = canAccessCassandraProxy && configContext.CASSANDRA_PROXY_OUTBOUND_IPS_ALLOWLISTED;
|
canAccessCassandraProxy = canAccessCassandraProxy && configContext.CASSANDRA_PROXY_OUTBOUND_IPS_ALLOWLISTED;
|
||||||
@ -740,9 +741,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
return (
|
return (
|
||||||
canAccessCassandraProxy &&
|
canAccessCassandraProxy &&
|
||||||
configContext.NEW_CASSANDRA_APIS?.includes(api) &&
|
configContext.NEW_CASSANDRA_APIS?.includes(api) &&
|
||||||
[Constants.CassandraProxyEndpoints.Development, Constants.CassandraProxyEndpoints.Mpac].includes(
|
activeCassandraProxyEndpoints.includes(configContext.CASSANDRA_PROXY_ENDPOINT)
|
||||||
configContext.CASSANDRA_PROXY_ENDPOINT,
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { sendMessage } from "Common/MessageHandler";
|
||||||
|
import { MessageTypes } from "Contracts/MessageTypes";
|
||||||
import { CopilotProvider } from "Explorer/QueryCopilot/QueryCopilotContext";
|
import { CopilotProvider } from "Explorer/QueryCopilot/QueryCopilotContext";
|
||||||
import { userContext } from "UserContext";
|
import { userContext } from "UserContext";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
@ -54,6 +56,11 @@ export class NewQueryTab extends TabsBase {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onActivate(): void {
|
||||||
|
this.propagateTabInformation(MessageTypes.ActivateTab);
|
||||||
|
super.onActivate();
|
||||||
|
}
|
||||||
|
|
||||||
public onTabClick(): void {
|
public onTabClick(): void {
|
||||||
useTabs.getState().activateTab(this);
|
useTabs.getState().activateTab(this);
|
||||||
this.iTabAccessor.onTabClickEvent();
|
this.iTabAccessor.onTabClickEvent();
|
||||||
@ -61,6 +68,7 @@ export class NewQueryTab extends TabsBase {
|
|||||||
|
|
||||||
public onCloseTabButtonClick(): void {
|
public onCloseTabButtonClick(): void {
|
||||||
useTabs.getState().closeTab(this);
|
useTabs.getState().closeTab(this);
|
||||||
|
this.propagateTabInformation(MessageTypes.CloseTab);
|
||||||
if (this.iTabAccessor) {
|
if (this.iTabAccessor) {
|
||||||
this.iTabAccessor.onCloseClickEvent(true);
|
this.iTabAccessor.onCloseClickEvent(true);
|
||||||
}
|
}
|
||||||
@ -69,4 +77,15 @@ export class NewQueryTab extends TabsBase {
|
|||||||
public getContainer(): Explorer {
|
public getContainer(): Explorer {
|
||||||
return this.props.container;
|
return this.props.container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private propagateTabInformation(type: MessageTypes): void {
|
||||||
|
sendMessage({
|
||||||
|
type,
|
||||||
|
data: {
|
||||||
|
kind: this.tabKind,
|
||||||
|
databaseId: this.collection?.databaseId,
|
||||||
|
collectionId: this.collection?.id?.(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
toggleState: ToggleState.Result,
|
toggleState: ToggleState.Result,
|
||||||
sqlQueryEditorContent: props.queryText || "SELECT * FROM c",
|
sqlQueryEditorContent: props.isPreferredApiMongoDB ? "{}" : props.queryText || "SELECT * FROM c",
|
||||||
selectedContent: "",
|
selectedContent: "",
|
||||||
queryResults: undefined,
|
queryResults: undefined,
|
||||||
error: "",
|
error: "",
|
||||||
@ -496,13 +496,16 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
|||||||
};
|
};
|
||||||
|
|
||||||
public onChangeContent(newContent: string): void {
|
public onChangeContent(newContent: string): void {
|
||||||
|
// The copilot store's active query takes precedence over the local state,
|
||||||
|
// and we can't update both states in a single operation.
|
||||||
|
// So, we update the copilot store's state first, then update the local state.
|
||||||
|
if (this.state.copilotActive) {
|
||||||
|
this.props.copilotStore?.setQuery(newContent);
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
sqlQueryEditorContent: newContent,
|
sqlQueryEditorContent: newContent,
|
||||||
queryCopilotGeneratedQuery: "",
|
queryCopilotGeneratedQuery: "",
|
||||||
});
|
});
|
||||||
if (this.state.copilotActive) {
|
|
||||||
this.props.copilotStore?.setQuery(newContent);
|
|
||||||
}
|
|
||||||
if (this.isPreferredApiMongoDB) {
|
if (this.isPreferredApiMongoDB) {
|
||||||
if (newContent.length > 0) {
|
if (newContent.length > 0) {
|
||||||
this.executeQueryButton = {
|
this.executeQueryButton = {
|
||||||
@ -544,7 +547,7 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
|||||||
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
||||||
}
|
}
|
||||||
|
|
||||||
public setEditorContent(): string {
|
public getEditorContent(): string {
|
||||||
if (this.isCopilotTabActive && this.state.queryCopilotGeneratedQuery) {
|
if (this.isCopilotTabActive && this.state.queryCopilotGeneratedQuery) {
|
||||||
return this.state.queryCopilotGeneratedQuery;
|
return this.state.queryCopilotGeneratedQuery;
|
||||||
}
|
}
|
||||||
@ -601,7 +604,7 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
|||||||
<div className="queryEditor" style={{ height: "100%" }}>
|
<div className="queryEditor" style={{ height: "100%" }}>
|
||||||
<EditorReact
|
<EditorReact
|
||||||
language={"sql"}
|
language={"sql"}
|
||||||
content={this.setEditorContent()}
|
content={this.getEditorContent()}
|
||||||
isReadOnly={false}
|
isReadOnly={false}
|
||||||
wordWrap={"on"}
|
wordWrap={"on"}
|
||||||
ariaLabel={"Editing Query"}
|
ariaLabel={"Editing Query"}
|
||||||
|
@ -327,10 +327,9 @@ const showMongoAndCassandraProxiesNetworkSettingsWarning = (): boolean => {
|
|||||||
if ((userContext.apiType === "Mongo" || userContext.apiType === "Cassandra") && ipRules?.length) {
|
if ((userContext.apiType === "Mongo" || userContext.apiType === "Cassandra") && ipRules?.length) {
|
||||||
const legacyPortalBackendIPs: string[] = PortalBackendIPs[configContext.BACKEND_ENDPOINT];
|
const legacyPortalBackendIPs: string[] = PortalBackendIPs[configContext.BACKEND_ENDPOINT];
|
||||||
const ipAddressesFromIPRules: string[] = ipRules.map((ipRule) => ipRule.ipAddressOrRange);
|
const ipAddressesFromIPRules: string[] = ipRules.map((ipRule) => ipRule.ipAddressOrRange);
|
||||||
const ipRulesIncludeLegacyPortalBackend: boolean =
|
const ipRulesIncludeLegacyPortalBackend: boolean = legacyPortalBackendIPs.every((legacyPortalBackendIP: string) =>
|
||||||
ipAddressesFromIPRules.filter((ipAddressFromIPRule) => legacyPortalBackendIPs.includes(ipAddressFromIPRule))
|
ipAddressesFromIPRules.includes(legacyPortalBackendIP),
|
||||||
?.length === legacyPortalBackendIPs.length;
|
);
|
||||||
|
|
||||||
if (!ipRulesIncludeLegacyPortalBackend) {
|
if (!ipRulesIncludeLegacyPortalBackend) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -344,9 +343,9 @@ const showMongoAndCassandraProxiesNetworkSettingsWarning = (): boolean => {
|
|||||||
? [...MongoProxyOutboundIPs[MongoProxyEndpoints.Mpac], ...MongoProxyOutboundIPs[MongoProxyEndpoints.Prod]]
|
? [...MongoProxyOutboundIPs[MongoProxyEndpoints.Mpac], ...MongoProxyOutboundIPs[MongoProxyEndpoints.Prod]]
|
||||||
: MongoProxyOutboundIPs[configContext.MONGO_PROXY_ENDPOINT];
|
: MongoProxyOutboundIPs[configContext.MONGO_PROXY_ENDPOINT];
|
||||||
|
|
||||||
const ipRulesIncludeMongoProxy: boolean =
|
const ipRulesIncludeMongoProxy: boolean = mongoProxyOutboundIPs.every((mongoProxyOutboundIP: string) =>
|
||||||
ipAddressesFromIPRules.filter((ipAddressFromIPRule) => mongoProxyOutboundIPs.includes(ipAddressFromIPRule))
|
ipAddressesFromIPRules.includes(mongoProxyOutboundIP),
|
||||||
?.length === mongoProxyOutboundIPs.length;
|
);
|
||||||
|
|
||||||
if (ipRulesIncludeMongoProxy) {
|
if (ipRulesIncludeMongoProxy) {
|
||||||
updateConfigContext({
|
updateConfigContext({
|
||||||
@ -368,9 +367,15 @@ const showMongoAndCassandraProxiesNetworkSettingsWarning = (): boolean => {
|
|||||||
]
|
]
|
||||||
: CassandraProxyOutboundIPs[configContext.CASSANDRA_PROXY_ENDPOINT];
|
: CassandraProxyOutboundIPs[configContext.CASSANDRA_PROXY_ENDPOINT];
|
||||||
|
|
||||||
const ipRulesIncludeCassandraProxy: boolean =
|
const ipRulesIncludeCassandraProxy: boolean = cassandraProxyOutboundIPs.every(
|
||||||
ipAddressesFromIPRules.filter((ipAddressFromIPRule) => cassandraProxyOutboundIPs.includes(ipAddressFromIPRule))
|
(cassandraProxyOutboundIP: string) => ipAddressesFromIPRules.includes(cassandraProxyOutboundIP),
|
||||||
?.length === cassandraProxyOutboundIPs.length;
|
);
|
||||||
|
|
||||||
|
if (ipRulesIncludeCassandraProxy) {
|
||||||
|
updateConfigContext({
|
||||||
|
CASSANDRA_PROXY_OUTBOUND_IPS_ALLOWLISTED: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return !ipRulesIncludeCassandraProxy;
|
return !ipRulesIncludeCassandraProxy;
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,10 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
|||||||
this.database = options.database;
|
this.database = options.database;
|
||||||
this.rid = options.rid || (this.collection && this.collection.rid) || "";
|
this.rid = options.rid || (this.collection && this.collection.rid) || "";
|
||||||
this.tabKind = options.tabKind;
|
this.tabKind = options.tabKind;
|
||||||
this.tabTitle = ko.observable<string>(options.title);
|
this.tabTitle = ko.observable<string>(this.getTitle(options));
|
||||||
this.tabPath =
|
this.tabPath =
|
||||||
ko.observable(options.tabPath ?? "") ||
|
this.collection &&
|
||||||
(this.collection &&
|
ko.observable<string>(`${this.collection.databaseId}>${this.collection.id()}>${options.title}`);
|
||||||
ko.observable<string>(`${this.collection.databaseId}>${this.collection.id()}>${this.tabTitle()}`));
|
|
||||||
this.pendingNotification = ko.observable<DataModels.Notification>(undefined);
|
this.pendingNotification = ko.observable<DataModels.Notification>(undefined);
|
||||||
this.onLoadStartKey = options.onLoadStartKey;
|
this.onLoadStartKey = options.onLoadStartKey;
|
||||||
this.closeTabButton = {
|
this.closeTabButton = {
|
||||||
@ -143,6 +142,26 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
|||||||
return (this.collection && this.collection.container) || (this.database && this.database.container);
|
return (this.collection && this.collection.container) || (this.database && this.database.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getTitle(options: ViewModels.TabOptions): string {
|
||||||
|
const coll = this.collection?.id();
|
||||||
|
const db = this.database?.id();
|
||||||
|
if (coll) {
|
||||||
|
if (coll.length > 8) {
|
||||||
|
return coll.slice(0, 5) + "…" + options.title;
|
||||||
|
} else {
|
||||||
|
return coll + "." + options.title;
|
||||||
|
}
|
||||||
|
} else if (db) {
|
||||||
|
if (db.length > 8) {
|
||||||
|
return db.slice(0, 5) + "…" + options.title;
|
||||||
|
} else {
|
||||||
|
return db + "." + options.title;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return options.title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Renders a Javascript object to be displayed inside Monaco Editor */
|
/** Renders a Javascript object to be displayed inside Monaco Editor */
|
||||||
public renderObjectForEditor(value: any, replacer: any, space: string | number): string {
|
public renderObjectForEditor(value: any, replacer: any, space: string | number): string {
|
||||||
return JSON.stringify(value, replacer, space);
|
return JSON.stringify(value, replacer, space);
|
||||||
|
@ -308,7 +308,7 @@ export default class Collection implements ViewModels.Collection {
|
|||||||
collectionName: this.id(),
|
collectionName: this.id(),
|
||||||
|
|
||||||
dataExplorerArea: Constants.Areas.Tab,
|
dataExplorerArea: Constants.Areas.Tab,
|
||||||
tabTitle: this.rawDataModel.id + " - Items",
|
tabTitle: "Items",
|
||||||
});
|
});
|
||||||
this.documentIds([]);
|
this.documentIds([]);
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ export default class Collection implements ViewModels.Collection {
|
|||||||
partitionKey: this.partitionKey,
|
partitionKey: this.partitionKey,
|
||||||
documentIds: ko.observableArray<DocumentId>([]),
|
documentIds: ko.observableArray<DocumentId>([]),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: this.rawDataModel.id + " - Items",
|
title: "Items",
|
||||||
collection: this,
|
collection: this,
|
||||||
node: this,
|
node: this,
|
||||||
tabPath: `${this.databaseId}>${this.id()}>Documents`,
|
tabPath: `${this.databaseId}>${this.id()}>Documents`,
|
||||||
|
@ -373,11 +373,6 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
|
|||||||
iconSrc: NewNotebookIcon,
|
iconSrc: NewNotebookIcon,
|
||||||
onClick: () => container.onCreateDirectory(item, isGithubTree),
|
onClick: () => container.onCreateDirectory(item, isGithubTree),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: "New Notebook",
|
|
||||||
iconSrc: NewNotebookIcon,
|
|
||||||
onClick: () => container.onNewNotebookClicked(item, isGithubTree),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: "Upload File",
|
label: "Upload File",
|
||||||
iconSrc: NewNotebookIcon,
|
iconSrc: NewNotebookIcon,
|
||||||
@ -786,9 +781,6 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
|
|||||||
<AccordionItemComponent title={"DATA"} isExpanded={!gitHubNotebooksContentRoot}>
|
<AccordionItemComponent title={"DATA"} isExpanded={!gitHubNotebooksContentRoot}>
|
||||||
<TreeComponent className="dataResourceTree" rootNode={dataRootNode} />
|
<TreeComponent className="dataResourceTree" rootNode={dataRootNode} />
|
||||||
</AccordionItemComponent>
|
</AccordionItemComponent>
|
||||||
<AccordionItemComponent title={"NOTEBOOKS"}>
|
|
||||||
<TreeComponent className="notebookResourceTree" rootNode={buildNotebooksTree()} />
|
|
||||||
</AccordionItemComponent>
|
|
||||||
</AccordionComponent>
|
</AccordionComponent>
|
||||||
|
|
||||||
{/* {buildGalleryCallout()} */}
|
{/* {buildGalleryCallout()} */}
|
||||||
|
@ -800,11 +800,6 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||||||
iconSrc: NewNotebookIcon,
|
iconSrc: NewNotebookIcon,
|
||||||
onClick: () => this.container.onCreateDirectory(item),
|
onClick: () => this.container.onCreateDirectory(item),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: "New Notebook",
|
|
||||||
iconSrc: NewNotebookIcon,
|
|
||||||
onClick: () => this.container.onNewNotebookClicked(item),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: "Upload File",
|
label: "Upload File",
|
||||||
iconSrc: NewNotebookIcon,
|
iconSrc: NewNotebookIcon,
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Import this first, to ensure that the dev tools hook is copied before React is loaded.
|
||||||
|
import "./ReactDevTools";
|
||||||
|
|
||||||
// CSS Dependencies
|
// CSS Dependencies
|
||||||
import { initializeIcons, loadTheme } from "@fluentui/react";
|
import { initializeIcons, loadTheme } from "@fluentui/react";
|
||||||
import { QuickstartCarousel } from "Explorer/Quickstart/QuickstartCarousel";
|
import { QuickstartCarousel } from "Explorer/Quickstart/QuickstartCarousel";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useBoolean } from "@fluentui/react-hooks";
|
import { useBoolean } from "@fluentui/react-hooks";
|
||||||
import { userContext } from "UserContext";
|
import { userContext } from "UserContext";
|
||||||
import { usePortalBackendEndpoint } from "Utils/EndpointUtils";
|
import { useNewPortalBackendEndpoint } from "Utils/EndpointUtils";
|
||||||
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";
|
||||||
@ -19,7 +19,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const fetchEncryptedToken = async (connectionString: string): Promise<string> => {
|
export const fetchEncryptedToken = async (connectionString: string): Promise<string> => {
|
||||||
if (!usePortalBackendEndpoint(BackendApi.GenerateToken)) {
|
if (!useNewPortalBackendEndpoint(BackendApi.GenerateToken)) {
|
||||||
return await fetchEncryptedToken_ToBeDeprecated(connectionString);
|
return await fetchEncryptedToken_ToBeDeprecated(connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
if (window.parent !== window) {
|
if (window.parent !== window) {
|
||||||
|
try {
|
||||||
(window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__ = (window.parent as any).__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
(window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__ = (window.parent as any).__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||||
|
} catch {
|
||||||
|
// No-op. We can throw here if the parent is not the same origin (such as in the Azure portal).
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ interface FabricContext {
|
|||||||
connectionId: string;
|
connectionId: string;
|
||||||
databaseConnectionInfo: FabricDatabaseConnectionInfo | undefined;
|
databaseConnectionInfo: FabricDatabaseConnectionInfo | undefined;
|
||||||
isReadOnly: boolean;
|
isReadOnly: boolean;
|
||||||
|
isVisible: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AdminFeedbackControlPolicy =
|
export type AdminFeedbackControlPolicy =
|
||||||
|
@ -145,8 +145,22 @@ export const allowedJunoOrigins: ReadonlyArray<string> = [
|
|||||||
|
|
||||||
export const allowedNotebookServerUrls: ReadonlyArray<string> = [];
|
export const allowedNotebookServerUrls: ReadonlyArray<string> = [];
|
||||||
|
|
||||||
export function usePortalBackendEndpoint(backendApi: BackendApi): boolean {
|
//
|
||||||
const activePortalBackendEndpoints: string[] = [PortalBackendEndpoints.Development];
|
// Temporary function to determine if a portal backend API is supported by the
|
||||||
const activeBackendApi: boolean = configContext.NEW_BACKEND_APIS?.includes(backendApi) || false;
|
// new backend in this environment.
|
||||||
return activeBackendApi && activePortalBackendEndpoints.includes(configContext.PORTAL_BACKEND_ENDPOINT as string);
|
//
|
||||||
|
// TODO: Remove this function once new backend migration is completed for all environments.
|
||||||
|
//
|
||||||
|
export function useNewPortalBackendEndpoint(backendApi: string): boolean {
|
||||||
|
// This maps backend APIs to the environments supported by the new backend.
|
||||||
|
const newBackendApiEnvironmentMap: { [key: string]: string[] } = {
|
||||||
|
[BackendApi.GenerateToken]: [PortalBackendEndpoints.Development],
|
||||||
|
[BackendApi.PortalSettings]: [PortalBackendEndpoints.Development, PortalBackendEndpoints.Mpac],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!newBackendApiEnvironmentMap[backendApi] || !configContext.PORTAL_BACKEND_ENDPOINT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newBackendApiEnvironmentMap[backendApi].includes(configContext.PORTAL_BACKEND_ENDPOINT);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ import { createUri } from "Common/UrlUtility";
|
|||||||
import { DATA_EXPLORER_RPC_VERSION } from "Contracts/DataExplorerMessagesContract";
|
import { DATA_EXPLORER_RPC_VERSION } from "Contracts/DataExplorerMessagesContract";
|
||||||
import { FABRIC_RPC_VERSION, FabricMessageV2 } from "Contracts/FabricMessagesContract";
|
import { FABRIC_RPC_VERSION, FabricMessageV2 } from "Contracts/FabricMessagesContract";
|
||||||
import Explorer from "Explorer/Explorer";
|
import Explorer from "Explorer/Explorer";
|
||||||
import { useCommandBar } from "Explorer/Menus/CommandBar/CommandBarComponentAdapter";
|
|
||||||
import { useSelectedNode } from "Explorer/useSelectedNode";
|
import { useSelectedNode } from "Explorer/useSelectedNode";
|
||||||
import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil";
|
import { scheduleRefreshDatabaseResourceToken } from "Platform/Fabric/FabricUtil";
|
||||||
import { getNetworkSettingsWarningMessage } from "Utils/NetworkUtility";
|
import { getNetworkSettingsWarningMessage } from "Utils/NetworkUtility";
|
||||||
@ -90,6 +89,7 @@ async function configureFabric(): Promise<Explorer> {
|
|||||||
// These are the versions of Fabric that Data Explorer supports.
|
// These are the versions of Fabric that Data Explorer supports.
|
||||||
const SUPPORTED_FABRIC_VERSIONS = [FABRIC_RPC_VERSION];
|
const SUPPORTED_FABRIC_VERSIONS = [FABRIC_RPC_VERSION];
|
||||||
|
|
||||||
|
let firstContainerOpened = false;
|
||||||
let explorer: Explorer;
|
let explorer: Explorer;
|
||||||
return new Promise<Explorer>((resolve) => {
|
return new Promise<Explorer>((resolve) => {
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
@ -121,7 +121,10 @@ async function configureFabric(): Promise<Explorer> {
|
|||||||
await scheduleRefreshDatabaseResourceToken(true);
|
await scheduleRefreshDatabaseResourceToken(true);
|
||||||
resolve(explorer);
|
resolve(explorer);
|
||||||
await explorer.refreshAllDatabases();
|
await explorer.refreshAllDatabases();
|
||||||
|
if (userContext.fabricContext.isVisible && !firstContainerOpened) {
|
||||||
|
firstContainerOpened = true;
|
||||||
openFirstContainer(explorer, userContext.fabricContext.databaseConnectionInfo.databaseId);
|
openFirstContainer(explorer, userContext.fabricContext.databaseConnectionInfo.databaseId);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "newContainer":
|
case "newContainer":
|
||||||
@ -132,8 +135,16 @@ async function configureFabric(): Promise<Explorer> {
|
|||||||
handleCachedDataMessage(data);
|
handleCachedDataMessage(data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "setToolbarStatus": {
|
case "explorerVisible": {
|
||||||
useCommandBar.getState().setIsHidden(data.message.visible === false);
|
userContext.fabricContext.isVisible = data.message.visible;
|
||||||
|
if (
|
||||||
|
userContext.fabricContext.isVisible &&
|
||||||
|
!firstContainerOpened &&
|
||||||
|
userContext?.fabricContext?.databaseConnectionInfo?.databaseId !== undefined
|
||||||
|
) {
|
||||||
|
firstContainerOpened = true;
|
||||||
|
openFirstContainer(explorer, userContext.fabricContext.databaseConnectionInfo.databaseId);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -327,12 +338,13 @@ function configureHostedWithResourceToken(config: ResourceToken): Explorer {
|
|||||||
return explorer;
|
return explorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createExplorerFabric(params: { connectionId: string }): Explorer {
|
function createExplorerFabric(params: { connectionId: string; isVisible: boolean }): Explorer {
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
fabricContext: {
|
fabricContext: {
|
||||||
connectionId: params.connectionId,
|
connectionId: params.connectionId,
|
||||||
databaseConnectionInfo: undefined,
|
databaseConnectionInfo: undefined,
|
||||||
isReadOnly: true,
|
isReadOnly: true,
|
||||||
|
isVisible: params.isVisible ?? true,
|
||||||
},
|
},
|
||||||
authType: AuthType.ConnectionString,
|
authType: AuthType.ConnectionString,
|
||||||
databaseAccount: {
|
databaseAccount: {
|
||||||
@ -485,6 +497,7 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
|
|||||||
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT),
|
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT),
|
||||||
MONGO_PROXY_ENDPOINT: inputs.mongoProxyEndpoint,
|
MONGO_PROXY_ENDPOINT: inputs.mongoProxyEndpoint,
|
||||||
CASSANDRA_PROXY_ENDPOINT: inputs.cassandraProxyEndpoint,
|
CASSANDRA_PROXY_ENDPOINT: inputs.cassandraProxyEndpoint,
|
||||||
|
PORTAL_BACKEND_ENDPOINT: inputs.portalBackendEndpoint,
|
||||||
});
|
});
|
||||||
|
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
|
Loading…
Reference in New Issue
Block a user