mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 10:51:30 +00:00
Compare commits
4 Commits
add-eslint
...
cleanup/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b8ed7a555 | ||
|
|
c2923768f8 | ||
|
|
101ddbec17 | ||
|
|
b8ed534c90 |
@@ -223,7 +223,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
],
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
@@ -1224,7 +1223,7 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"isSchemaEnabled": [Function],
|
||||
"isServerlessEnabled": [Function],
|
||||
"isSparkEnabled": [Function],
|
||||
"isSparkEnabledForAccount": [Function],
|
||||
"isSparkEnabledForAccount": undefined,
|
||||
"isSynapseLinkUpdating": [Function],
|
||||
"isTabsContentExpanded": [Function],
|
||||
"junoClient": JunoClient {
|
||||
@@ -1243,6 +1242,7 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"container": [Circular],
|
||||
},
|
||||
"refreshNotebookList": [Function],
|
||||
"refreshSparkEnabledStateForAccount": undefined,
|
||||
"refreshTreeTitle": [Function],
|
||||
"resourceTokenCollection": [Function],
|
||||
"resourceTokenCollectionId": [Function],
|
||||
@@ -1499,7 +1499,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
],
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
@@ -2500,7 +2499,7 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"isSchemaEnabled": [Function],
|
||||
"isServerlessEnabled": [Function],
|
||||
"isSparkEnabled": [Function],
|
||||
"isSparkEnabledForAccount": [Function],
|
||||
"isSparkEnabledForAccount": undefined,
|
||||
"isSynapseLinkUpdating": [Function],
|
||||
"isTabsContentExpanded": [Function],
|
||||
"junoClient": JunoClient {
|
||||
@@ -2519,6 +2518,7 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"container": [Circular],
|
||||
},
|
||||
"refreshNotebookList": [Function],
|
||||
"refreshSparkEnabledStateForAccount": undefined,
|
||||
"refreshTreeTitle": [Function],
|
||||
"resourceTokenCollection": [Function],
|
||||
"resourceTokenCollectionId": [Function],
|
||||
@@ -2788,7 +2788,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
],
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
@@ -3789,7 +3788,7 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"isSchemaEnabled": [Function],
|
||||
"isServerlessEnabled": [Function],
|
||||
"isSparkEnabled": [Function],
|
||||
"isSparkEnabledForAccount": [Function],
|
||||
"isSparkEnabledForAccount": undefined,
|
||||
"isSynapseLinkUpdating": [Function],
|
||||
"isTabsContentExpanded": [Function],
|
||||
"junoClient": JunoClient {
|
||||
@@ -3808,6 +3807,7 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"container": [Circular],
|
||||
},
|
||||
"refreshNotebookList": [Function],
|
||||
"refreshSparkEnabledStateForAccount": undefined,
|
||||
"refreshTreeTitle": [Function],
|
||||
"resourceTokenCollection": [Function],
|
||||
"resourceTokenCollectionId": [Function],
|
||||
@@ -4064,7 +4064,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
],
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
@@ -5065,7 +5064,7 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"isSchemaEnabled": [Function],
|
||||
"isServerlessEnabled": [Function],
|
||||
"isSparkEnabled": [Function],
|
||||
"isSparkEnabledForAccount": [Function],
|
||||
"isSparkEnabledForAccount": undefined,
|
||||
"isSynapseLinkUpdating": [Function],
|
||||
"isTabsContentExpanded": [Function],
|
||||
"junoClient": JunoClient {
|
||||
@@ -5084,6 +5083,7 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"container": [Circular],
|
||||
},
|
||||
"refreshNotebookList": [Function],
|
||||
"refreshSparkEnabledStateForAccount": undefined,
|
||||
"refreshTreeTitle": [Function],
|
||||
"resourceTokenCollection": [Function],
|
||||
"resourceTokenCollectionId": [Function],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as ko from "knockout";
|
||||
import { IChoiceGroupProps } from "@fluentui/react";
|
||||
import * as ko from "knockout";
|
||||
import * as path from "path";
|
||||
import Q from "q";
|
||||
import React from "react";
|
||||
@@ -97,6 +97,8 @@ export interface ExplorerParams {
|
||||
closeDialog: () => void;
|
||||
openDialog: (props: DialogProps) => void;
|
||||
tabsManager: TabsManager;
|
||||
refreshSparkEnabledStateForAccount: () => void;
|
||||
isSparkEnabledForAccount: boolean;
|
||||
}
|
||||
|
||||
export default class Explorer {
|
||||
@@ -174,7 +176,6 @@ export default class Explorer {
|
||||
public notebookWorkspaceManager: NotebookWorkspaceManager;
|
||||
public sparkClusterConnectionInfo: ko.Observable<DataModels.SparkClusterConnectionInfo>;
|
||||
public isSparkEnabled: ko.Observable<boolean>;
|
||||
public isSparkEnabledForAccount: ko.Observable<boolean>;
|
||||
public arcadiaToken: ko.Observable<string>;
|
||||
public arcadiaWorkspaces: ko.ObservableArray<ArcadiaWorkspaceItem>;
|
||||
public hasStorageAnalyticsAfecFeature: ko.Observable<boolean>;
|
||||
@@ -193,6 +194,10 @@ export default class Explorer {
|
||||
content: string;
|
||||
};
|
||||
|
||||
// Refresh spark
|
||||
public refreshSparkEnabledStateForAccount: () => void;
|
||||
public isSparkEnabledForAccount: boolean;
|
||||
|
||||
// React adapters
|
||||
private commandBarComponentAdapter: CommandBarComponentAdapter;
|
||||
|
||||
@@ -208,6 +213,8 @@ export default class Explorer {
|
||||
this.closeSidePanel = params?.closeSidePanel;
|
||||
this.closeDialog = params?.closeDialog;
|
||||
this.openDialog = params?.openDialog;
|
||||
this.refreshSparkEnabledStateForAccount = params?.refreshSparkEnabledStateForAccount;
|
||||
this.isSparkEnabledForAccount = params?.isSparkEnabledForAccount;
|
||||
|
||||
const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, {
|
||||
dataExplorerArea: Constants.Areas.ResourceTree,
|
||||
@@ -233,8 +240,7 @@ export default class Explorer {
|
||||
});
|
||||
this.isNotebooksEnabledForAccount = ko.observable(false);
|
||||
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.subscribe((enabled: boolean) => this.refreshCommandBarButtons());
|
||||
this.isSynapseLinkUpdating = ko.observable<boolean>(false);
|
||||
@@ -250,7 +256,7 @@ export default class Explorer {
|
||||
this._isAfecFeatureRegistered(Constants.AfecFeatures.StorageAnalytics).then((isRegistered) =>
|
||||
this.hasStorageAnalyticsAfecFeature(isRegistered)
|
||||
);
|
||||
Promise.all([this._refreshNotebooksEnabledStateForAccount(), this._refreshSparkEnabledStateForAccount()]).then(
|
||||
Promise.all([this._refreshNotebooksEnabledStateForAccount(), this.refreshSparkEnabledStateForAccount()]).then(
|
||||
async () => {
|
||||
this.isNotebookEnabled(
|
||||
userContext.authType !== AuthType.ResourceToken &&
|
||||
@@ -273,7 +279,7 @@ export default class Explorer {
|
||||
|
||||
this.isSparkEnabled(
|
||||
(this.isNotebookEnabled() &&
|
||||
this.isSparkEnabledForAccount() &&
|
||||
this.isSparkEnabledForAccount &&
|
||||
this.arcadiaWorkspaces() &&
|
||||
this.arcadiaWorkspaces().length > 0) ||
|
||||
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> => {
|
||||
const { subscriptionId, authType } = userContext;
|
||||
const armEndpoint = configContext.ARM_ENDPOINT;
|
||||
|
||||
@@ -212,7 +212,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
],
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
@@ -1213,7 +1212,7 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
||||
"isSchemaEnabled": [Function],
|
||||
"isServerlessEnabled": [Function],
|
||||
"isSparkEnabled": [Function],
|
||||
"isSparkEnabledForAccount": [Function],
|
||||
"isSparkEnabledForAccount": undefined,
|
||||
"isSynapseLinkUpdating": [Function],
|
||||
"isTabsContentExpanded": [Function],
|
||||
"junoClient": JunoClient {
|
||||
@@ -1232,6 +1231,7 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
|
||||
"container": [Circular],
|
||||
},
|
||||
"refreshNotebookList": [Function],
|
||||
"refreshSparkEnabledStateForAccount": undefined,
|
||||
"refreshTreeTitle": [Function],
|
||||
"resourceTokenCollection": [Function],
|
||||
"resourceTokenCollectionId": [Function],
|
||||
|
||||
@@ -202,7 +202,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
],
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
@@ -1203,7 +1202,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
||||
"isSchemaEnabled": [Function],
|
||||
"isServerlessEnabled": [Function],
|
||||
"isSparkEnabled": [Function],
|
||||
"isSparkEnabledForAccount": [Function],
|
||||
"isSparkEnabledForAccount": undefined,
|
||||
"isSynapseLinkUpdating": [Function],
|
||||
"isTabsContentExpanded": [Function],
|
||||
"junoClient": JunoClient {
|
||||
@@ -1222,6 +1221,7 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
|
||||
"container": [Circular],
|
||||
},
|
||||
"refreshNotebookList": [Function],
|
||||
"refreshSparkEnabledStateForAccount": undefined,
|
||||
"refreshTreeTitle": [Function],
|
||||
"resourceTokenCollection": [Function],
|
||||
"resourceTokenCollectionId": [Function],
|
||||
|
||||
@@ -200,7 +200,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
||||
"visible": [Function],
|
||||
},
|
||||
],
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
@@ -1204,7 +1203,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
||||
"isSelectedDatabaseShared": [Function],
|
||||
"isServerlessEnabled": [Function],
|
||||
"isSparkEnabled": [Function],
|
||||
"isSparkEnabledForAccount": [Function],
|
||||
"isSparkEnabledForAccount": undefined,
|
||||
"isSynapseLinkUpdating": [Function],
|
||||
"isTabsContentExpanded": [Function],
|
||||
"junoClient": JunoClient {
|
||||
@@ -1224,6 +1223,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
|
||||
},
|
||||
"refreshAllDatabases": [Function],
|
||||
"refreshNotebookList": [Function],
|
||||
"refreshSparkEnabledStateForAccount": undefined,
|
||||
"refreshTreeTitle": [Function],
|
||||
"resourceTokenCollection": [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/tree.less";
|
||||
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/CollapsiblePanel/CollapsiblePanelComponent.less";
|
||||
import { Dialog, DialogProps } from "./Explorer/Controls/Dialog";
|
||||
@@ -54,6 +59,7 @@ import { useKnockoutExplorer } from "./hooks/useKnockoutExplorer";
|
||||
import { useSidePanel } from "./hooks/useSidePanel";
|
||||
import { useTabs } from "./hooks/useTabs";
|
||||
import "./Libs/jquery";
|
||||
import { ResourceProviderClientFactory } from "./ResourceProvider/ResourceProviderClientFactory";
|
||||
import "./Shared/appInsights";
|
||||
import { userContext } from "./UserContext";
|
||||
|
||||
@@ -67,6 +73,36 @@ const App: React.FunctionComponent = () => {
|
||||
|
||||
const [dialogProps, setDialogProps] = useState<DialogProps>();
|
||||
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) => {
|
||||
setDialogProps(props);
|
||||
@@ -88,6 +124,8 @@ const App: React.FunctionComponent = () => {
|
||||
openDialog,
|
||||
closeDialog,
|
||||
tabsManager,
|
||||
refreshSparkEnabledStateForAccount,
|
||||
isSparkEnabledForAccount,
|
||||
};
|
||||
|
||||
const config = useConfig();
|
||||
|
||||
Reference in New Issue
Block a user