mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 19:01:28 +00:00
Compare commits
4 Commits
fixed-ts-s
...
cleanup/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b8ed7a555 | ||
|
|
c2923768f8 | ||
|
|
101ddbec17 | ||
|
|
b8ed534c90 |
@@ -223,7 +223,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"_refreshSparkEnabledStateForAccount": [Function],
|
|
||||||
"_resetNotebookWorkspace": [Function],
|
"_resetNotebookWorkspace": [Function],
|
||||||
"addCollectionPane": AddCollectionPane {
|
"addCollectionPane": AddCollectionPane {
|
||||||
"_isSynapseLinkEnabled": [Function],
|
"_isSynapseLinkEnabled": [Function],
|
||||||
@@ -1224,7 +1223,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": undefined,
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
"isTabsContentExpanded": [Function],
|
"isTabsContentExpanded": [Function],
|
||||||
"junoClient": JunoClient {
|
"junoClient": JunoClient {
|
||||||
@@ -1243,6 +1242,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
|
"refreshSparkEnabledStateForAccount": undefined,
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
"resourceTokenCollectionId": [Function],
|
||||||
@@ -1499,7 +1499,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"_refreshSparkEnabledStateForAccount": [Function],
|
|
||||||
"_resetNotebookWorkspace": [Function],
|
"_resetNotebookWorkspace": [Function],
|
||||||
"addCollectionPane": AddCollectionPane {
|
"addCollectionPane": AddCollectionPane {
|
||||||
"_isSynapseLinkEnabled": [Function],
|
"_isSynapseLinkEnabled": [Function],
|
||||||
@@ -2500,7 +2499,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": undefined,
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
"isTabsContentExpanded": [Function],
|
"isTabsContentExpanded": [Function],
|
||||||
"junoClient": JunoClient {
|
"junoClient": JunoClient {
|
||||||
@@ -2519,6 +2518,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
|
"refreshSparkEnabledStateForAccount": undefined,
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
"resourceTokenCollectionId": [Function],
|
||||||
@@ -2788,7 +2788,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"_refreshSparkEnabledStateForAccount": [Function],
|
|
||||||
"_resetNotebookWorkspace": [Function],
|
"_resetNotebookWorkspace": [Function],
|
||||||
"addCollectionPane": AddCollectionPane {
|
"addCollectionPane": AddCollectionPane {
|
||||||
"_isSynapseLinkEnabled": [Function],
|
"_isSynapseLinkEnabled": [Function],
|
||||||
@@ -3789,7 +3788,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": undefined,
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
"isTabsContentExpanded": [Function],
|
"isTabsContentExpanded": [Function],
|
||||||
"junoClient": JunoClient {
|
"junoClient": JunoClient {
|
||||||
@@ -3808,6 +3807,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
|
"refreshSparkEnabledStateForAccount": undefined,
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
"resourceTokenCollectionId": [Function],
|
||||||
@@ -4064,7 +4064,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"_refreshSparkEnabledStateForAccount": [Function],
|
|
||||||
"_resetNotebookWorkspace": [Function],
|
"_resetNotebookWorkspace": [Function],
|
||||||
"addCollectionPane": AddCollectionPane {
|
"addCollectionPane": AddCollectionPane {
|
||||||
"_isSynapseLinkEnabled": [Function],
|
"_isSynapseLinkEnabled": [Function],
|
||||||
@@ -5065,7 +5064,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": undefined,
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
"isTabsContentExpanded": [Function],
|
"isTabsContentExpanded": [Function],
|
||||||
"junoClient": JunoClient {
|
"junoClient": JunoClient {
|
||||||
@@ -5084,6 +5083,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
|
"refreshSparkEnabledStateForAccount": undefined,
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
"resourceTokenCollectionId": [Function],
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as ko from "knockout";
|
|
||||||
import { IChoiceGroupProps } from "@fluentui/react";
|
import { IChoiceGroupProps } from "@fluentui/react";
|
||||||
|
import * as ko from "knockout";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import Q from "q";
|
import Q from "q";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
@@ -97,6 +97,8 @@ export interface ExplorerParams {
|
|||||||
closeDialog: () => void;
|
closeDialog: () => void;
|
||||||
openDialog: (props: DialogProps) => void;
|
openDialog: (props: DialogProps) => void;
|
||||||
tabsManager: TabsManager;
|
tabsManager: TabsManager;
|
||||||
|
refreshSparkEnabledStateForAccount: () => void;
|
||||||
|
isSparkEnabledForAccount: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Explorer {
|
export default class Explorer {
|
||||||
@@ -174,7 +176,6 @@ export default class Explorer {
|
|||||||
public notebookWorkspaceManager: NotebookWorkspaceManager;
|
public notebookWorkspaceManager: NotebookWorkspaceManager;
|
||||||
public sparkClusterConnectionInfo: ko.Observable<DataModels.SparkClusterConnectionInfo>;
|
public sparkClusterConnectionInfo: ko.Observable<DataModels.SparkClusterConnectionInfo>;
|
||||||
public isSparkEnabled: ko.Observable<boolean>;
|
public isSparkEnabled: ko.Observable<boolean>;
|
||||||
public isSparkEnabledForAccount: ko.Observable<boolean>;
|
|
||||||
public arcadiaToken: ko.Observable<string>;
|
public arcadiaToken: ko.Observable<string>;
|
||||||
public arcadiaWorkspaces: ko.ObservableArray<ArcadiaWorkspaceItem>;
|
public arcadiaWorkspaces: ko.ObservableArray<ArcadiaWorkspaceItem>;
|
||||||
public hasStorageAnalyticsAfecFeature: ko.Observable<boolean>;
|
public hasStorageAnalyticsAfecFeature: ko.Observable<boolean>;
|
||||||
@@ -193,6 +194,10 @@ export default class Explorer {
|
|||||||
content: string;
|
content: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Refresh spark
|
||||||
|
public refreshSparkEnabledStateForAccount: () => void;
|
||||||
|
public isSparkEnabledForAccount: boolean;
|
||||||
|
|
||||||
// React adapters
|
// React adapters
|
||||||
private commandBarComponentAdapter: CommandBarComponentAdapter;
|
private commandBarComponentAdapter: CommandBarComponentAdapter;
|
||||||
|
|
||||||
@@ -208,6 +213,8 @@ export default class Explorer {
|
|||||||
this.closeSidePanel = params?.closeSidePanel;
|
this.closeSidePanel = params?.closeSidePanel;
|
||||||
this.closeDialog = params?.closeDialog;
|
this.closeDialog = params?.closeDialog;
|
||||||
this.openDialog = params?.openDialog;
|
this.openDialog = params?.openDialog;
|
||||||
|
this.refreshSparkEnabledStateForAccount = params?.refreshSparkEnabledStateForAccount;
|
||||||
|
this.isSparkEnabledForAccount = params?.isSparkEnabledForAccount;
|
||||||
|
|
||||||
const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, {
|
const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, {
|
||||||
dataExplorerArea: Constants.Areas.ResourceTree,
|
dataExplorerArea: Constants.Areas.ResourceTree,
|
||||||
@@ -233,8 +240,7 @@ export default class Explorer {
|
|||||||
});
|
});
|
||||||
this.isNotebooksEnabledForAccount = ko.observable(false);
|
this.isNotebooksEnabledForAccount = ko.observable(false);
|
||||||
this.isNotebooksEnabledForAccount.subscribe((isEnabledForAccount: boolean) => this.refreshCommandBarButtons());
|
this.isNotebooksEnabledForAccount.subscribe((isEnabledForAccount: boolean) => this.refreshCommandBarButtons());
|
||||||
this.isSparkEnabledForAccount = ko.observable(false);
|
// this.isSparkEnabledForAccount.subscribe((isEnabledForAccount: boolean) => this.refreshCommandBarButtons());
|
||||||
this.isSparkEnabledForAccount.subscribe((isEnabledForAccount: boolean) => this.refreshCommandBarButtons());
|
|
||||||
this.hasStorageAnalyticsAfecFeature = ko.observable(false);
|
this.hasStorageAnalyticsAfecFeature = ko.observable(false);
|
||||||
this.hasStorageAnalyticsAfecFeature.subscribe((enabled: boolean) => this.refreshCommandBarButtons());
|
this.hasStorageAnalyticsAfecFeature.subscribe((enabled: boolean) => this.refreshCommandBarButtons());
|
||||||
this.isSynapseLinkUpdating = ko.observable<boolean>(false);
|
this.isSynapseLinkUpdating = ko.observable<boolean>(false);
|
||||||
@@ -250,7 +256,7 @@ export default class Explorer {
|
|||||||
this._isAfecFeatureRegistered(Constants.AfecFeatures.StorageAnalytics).then((isRegistered) =>
|
this._isAfecFeatureRegistered(Constants.AfecFeatures.StorageAnalytics).then((isRegistered) =>
|
||||||
this.hasStorageAnalyticsAfecFeature(isRegistered)
|
this.hasStorageAnalyticsAfecFeature(isRegistered)
|
||||||
);
|
);
|
||||||
Promise.all([this._refreshNotebooksEnabledStateForAccount(), this._refreshSparkEnabledStateForAccount()]).then(
|
Promise.all([this._refreshNotebooksEnabledStateForAccount(), this.refreshSparkEnabledStateForAccount()]).then(
|
||||||
async () => {
|
async () => {
|
||||||
this.isNotebookEnabled(
|
this.isNotebookEnabled(
|
||||||
userContext.authType !== AuthType.ResourceToken &&
|
userContext.authType !== AuthType.ResourceToken &&
|
||||||
@@ -273,7 +279,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
this.isSparkEnabled(
|
this.isSparkEnabled(
|
||||||
(this.isNotebookEnabled() &&
|
(this.isNotebookEnabled() &&
|
||||||
this.isSparkEnabledForAccount() &&
|
this.isSparkEnabledForAccount &&
|
||||||
this.arcadiaWorkspaces() &&
|
this.arcadiaWorkspaces() &&
|
||||||
this.arcadiaWorkspaces().length > 0) ||
|
this.arcadiaWorkspaces().length > 0) ||
|
||||||
userContext.features.enableSpark
|
userContext.features.enableSpark
|
||||||
@@ -1587,34 +1593,6 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public _refreshSparkEnabledStateForAccount = async (): Promise<void> => {
|
|
||||||
const { subscriptionId, authType } = userContext;
|
|
||||||
const armEndpoint = configContext.ARM_ENDPOINT;
|
|
||||||
if (!subscriptionId || !armEndpoint || authType === AuthType.EncryptedToken) {
|
|
||||||
// explorer is not aware of the database account yet
|
|
||||||
this.isSparkEnabledForAccount(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const featureUri = `subscriptions/${subscriptionId}/providers/Microsoft.Features/providers/Microsoft.DocumentDb/features/${Constants.AfecFeatures.Spark}`;
|
|
||||||
const resourceProviderClient = new ResourceProviderClientFactory().getOrCreate(featureUri);
|
|
||||||
try {
|
|
||||||
const sparkNotebooksFeature: DataModels.AfecFeature = await resourceProviderClient.getAsync(
|
|
||||||
featureUri,
|
|
||||||
Constants.ArmApiVersions.armFeatures
|
|
||||||
);
|
|
||||||
const isEnabled =
|
|
||||||
(sparkNotebooksFeature &&
|
|
||||||
sparkNotebooksFeature.properties &&
|
|
||||||
sparkNotebooksFeature.properties.state === "Registered") ||
|
|
||||||
false;
|
|
||||||
this.isSparkEnabledForAccount(isEnabled);
|
|
||||||
} catch (error) {
|
|
||||||
Logger.logError(getErrorMessage(error), "Explorer/isSparkEnabledForAccount");
|
|
||||||
this.isSparkEnabledForAccount(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public _isAfecFeatureRegistered = async (featureName: string): Promise<boolean> => {
|
public _isAfecFeatureRegistered = async (featureName: string): Promise<boolean> => {
|
||||||
const { subscriptionId, authType } = userContext;
|
const { subscriptionId, authType } = userContext;
|
||||||
const armEndpoint = configContext.ARM_ENDPOINT;
|
const armEndpoint = configContext.ARM_ENDPOINT;
|
||||||
|
|||||||
@@ -212,7 +212,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"_refreshSparkEnabledStateForAccount": [Function],
|
|
||||||
"_resetNotebookWorkspace": [Function],
|
"_resetNotebookWorkspace": [Function],
|
||||||
"addCollectionPane": AddCollectionPane {
|
"addCollectionPane": AddCollectionPane {
|
||||||
"_isSynapseLinkEnabled": [Function],
|
"_isSynapseLinkEnabled": [Function],
|
||||||
@@ -1213,7 +1212,7 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
|||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": undefined,
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
"isTabsContentExpanded": [Function],
|
"isTabsContentExpanded": [Function],
|
||||||
"junoClient": JunoClient {
|
"junoClient": JunoClient {
|
||||||
@@ -1232,6 +1231,7 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
|||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
|
"refreshSparkEnabledStateForAccount": undefined,
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
"resourceTokenCollectionId": [Function],
|
||||||
|
|||||||
@@ -202,7 +202,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"_refreshSparkEnabledStateForAccount": [Function],
|
|
||||||
"_resetNotebookWorkspace": [Function],
|
"_resetNotebookWorkspace": [Function],
|
||||||
"addCollectionPane": AddCollectionPane {
|
"addCollectionPane": AddCollectionPane {
|
||||||
"_isSynapseLinkEnabled": [Function],
|
"_isSynapseLinkEnabled": [Function],
|
||||||
@@ -1203,7 +1202,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
|||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": undefined,
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
"isTabsContentExpanded": [Function],
|
"isTabsContentExpanded": [Function],
|
||||||
"junoClient": JunoClient {
|
"junoClient": JunoClient {
|
||||||
@@ -1222,6 +1221,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
|||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
},
|
},
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
|
"refreshSparkEnabledStateForAccount": undefined,
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
"resourceTokenCollectionId": [Function],
|
||||||
|
|||||||
@@ -200,7 +200,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"_refreshSparkEnabledStateForAccount": [Function],
|
|
||||||
"_resetNotebookWorkspace": [Function],
|
"_resetNotebookWorkspace": [Function],
|
||||||
"addCollectionPane": AddCollectionPane {
|
"addCollectionPane": AddCollectionPane {
|
||||||
"_isSynapseLinkEnabled": [Function],
|
"_isSynapseLinkEnabled": [Function],
|
||||||
@@ -1204,7 +1203,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
|||||||
"isSelectedDatabaseShared": [Function],
|
"isSelectedDatabaseShared": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": undefined,
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
"isTabsContentExpanded": [Function],
|
"isTabsContentExpanded": [Function],
|
||||||
"junoClient": JunoClient {
|
"junoClient": JunoClient {
|
||||||
@@ -1224,6 +1223,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
|||||||
},
|
},
|
||||||
"refreshAllDatabases": [Function],
|
"refreshAllDatabases": [Function],
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
|
"refreshSparkEnabledStateForAccount": undefined,
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
"resourceTokenCollection": [Function],
|
"resourceTokenCollection": [Function],
|
||||||
"resourceTokenCollectionId": [Function],
|
"resourceTokenCollectionId": [Function],
|
||||||
|
|||||||
38
src/Main.tsx
38
src/Main.tsx
@@ -28,6 +28,11 @@ import "../less/TableStyles/fulldatatables.less";
|
|||||||
import "../less/TableStyles/queryBuilder.less";
|
import "../less/TableStyles/queryBuilder.less";
|
||||||
import "../less/tree.less";
|
import "../less/tree.less";
|
||||||
import { AuthType } from "./AuthType";
|
import { AuthType } from "./AuthType";
|
||||||
|
import { AfecFeatures, ArmApiVersions } from "./Common/Constants";
|
||||||
|
import { getErrorMessage } from "./Common/ErrorHandlingUtils";
|
||||||
|
import { logError } from "./Common/Logger";
|
||||||
|
import { configContext } from "./ConfigContext";
|
||||||
|
import { AfecFeature } from "./Contracts/DataModels";
|
||||||
import "./Explorer/Controls/Accordion/AccordionComponent.less";
|
import "./Explorer/Controls/Accordion/AccordionComponent.less";
|
||||||
import "./Explorer/Controls/CollapsiblePanel/CollapsiblePanelComponent.less";
|
import "./Explorer/Controls/CollapsiblePanel/CollapsiblePanelComponent.less";
|
||||||
import { Dialog, DialogProps } from "./Explorer/Controls/Dialog";
|
import { Dialog, DialogProps } from "./Explorer/Controls/Dialog";
|
||||||
@@ -54,6 +59,7 @@ import { useKnockoutExplorer } from "./hooks/useKnockoutExplorer";
|
|||||||
import { useSidePanel } from "./hooks/useSidePanel";
|
import { useSidePanel } from "./hooks/useSidePanel";
|
||||||
import { useTabs } from "./hooks/useTabs";
|
import { useTabs } from "./hooks/useTabs";
|
||||||
import "./Libs/jquery";
|
import "./Libs/jquery";
|
||||||
|
import { ResourceProviderClientFactory } from "./ResourceProvider/ResourceProviderClientFactory";
|
||||||
import "./Shared/appInsights";
|
import "./Shared/appInsights";
|
||||||
import { userContext } from "./UserContext";
|
import { userContext } from "./UserContext";
|
||||||
|
|
||||||
@@ -67,6 +73,36 @@ const App: React.FunctionComponent = () => {
|
|||||||
|
|
||||||
const [dialogProps, setDialogProps] = useState<DialogProps>();
|
const [dialogProps, setDialogProps] = useState<DialogProps>();
|
||||||
const [showDialog, setShowDialog] = useState<boolean>(false);
|
const [showDialog, setShowDialog] = useState<boolean>(false);
|
||||||
|
const [isSparkEnabledForAccount, setIsSparkEnabledForAccount] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const refreshSparkEnabledStateForAccount = async (): Promise<void> => {
|
||||||
|
const subscriptionId = userContext.subscriptionId;
|
||||||
|
const armEndpoint = configContext.ARM_ENDPOINT;
|
||||||
|
const authType = userContext.authType;
|
||||||
|
if (!subscriptionId || !armEndpoint || authType === AuthType.EncryptedToken) {
|
||||||
|
// explorer is not aware of the database account yet
|
||||||
|
setIsSparkEnabledForAccount(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const featureUri = `subscriptions/${subscriptionId}/providers/Microsoft.Features/providers/Microsoft.DocumentDb/features/${AfecFeatures.Spark}`;
|
||||||
|
const resourceProviderClient = new ResourceProviderClientFactory().getOrCreate(featureUri);
|
||||||
|
try {
|
||||||
|
const sparkNotebooksFeature: AfecFeature = await resourceProviderClient.getAsync(
|
||||||
|
featureUri,
|
||||||
|
ArmApiVersions.armFeatures
|
||||||
|
);
|
||||||
|
const isEnabled =
|
||||||
|
(sparkNotebooksFeature &&
|
||||||
|
sparkNotebooksFeature.properties &&
|
||||||
|
sparkNotebooksFeature.properties.state === "Registered") ||
|
||||||
|
false;
|
||||||
|
setIsSparkEnabledForAccount(isEnabled);
|
||||||
|
} catch (error) {
|
||||||
|
logError(getErrorMessage(error), "Explorer/isSparkEnabledForAccount");
|
||||||
|
setIsSparkEnabledForAccount(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const openDialog = (props: DialogProps) => {
|
const openDialog = (props: DialogProps) => {
|
||||||
setDialogProps(props);
|
setDialogProps(props);
|
||||||
@@ -88,6 +124,8 @@ const App: React.FunctionComponent = () => {
|
|||||||
openDialog,
|
openDialog,
|
||||||
closeDialog,
|
closeDialog,
|
||||||
tabsManager,
|
tabsManager,
|
||||||
|
refreshSparkEnabledStateForAccount,
|
||||||
|
isSparkEnabledForAccount,
|
||||||
};
|
};
|
||||||
|
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
|
|||||||
Reference in New Issue
Block a user