mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-06-05 15:12:04 +01:00
Deprecate Explorer Properties (#535)
This commit is contained in:
parent
184910ee6c
commit
62550f8d6a
@ -9,10 +9,10 @@ export interface DatabaseAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DatabaseAccountExtendedProperties {
|
export interface DatabaseAccountExtendedProperties {
|
||||||
documentEndpoint: string;
|
documentEndpoint?: string;
|
||||||
tableEndpoint: string;
|
tableEndpoint?: string;
|
||||||
gremlinEndpoint: string;
|
gremlinEndpoint?: string;
|
||||||
cassandraEndpoint: string;
|
cassandraEndpoint?: string;
|
||||||
configurationOverrides?: ConfigurationOverrides;
|
configurationOverrides?: ConfigurationOverrides;
|
||||||
capabilities?: Capability[];
|
capabilities?: Capability[];
|
||||||
enableMultipleWriteLocations?: boolean;
|
enableMultipleWriteLocations?: boolean;
|
||||||
|
@ -1,90 +1,87 @@
|
|||||||
import React from "react";
|
|
||||||
import * as ComponentRegisterer from "./ComponentRegisterer";
|
|
||||||
import * as Constants from "../Common/Constants";
|
|
||||||
import * as DataModels from "../Contracts/DataModels";
|
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
|
import { IChoiceGroupProps } from "office-ui-fabric-react";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as SharedConstants from "../Shared/Constants";
|
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
|
||||||
import _ from "underscore";
|
|
||||||
import AddCollectionPane from "./Panes/AddCollectionPane";
|
|
||||||
import AddDatabasePane from "./Panes/AddDatabasePane";
|
|
||||||
import AddTableEntityPane from "./Panes/Tables/AddTableEntityPane";
|
|
||||||
import AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
|
||||||
import CassandraAddCollectionPane from "./Panes/CassandraAddCollectionPane";
|
|
||||||
import Database from "./Tree/Database";
|
|
||||||
import DeleteCollectionConfirmationPane from "./Panes/DeleteCollectionConfirmationPane";
|
|
||||||
import DeleteDatabaseConfirmationPane from "./Panes/DeleteDatabaseConfirmationPane";
|
|
||||||
import { readCollection } from "../Common/dataAccess/readCollection";
|
|
||||||
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
|
||||||
import EditTableEntityPane from "./Panes/Tables/EditTableEntityPane";
|
|
||||||
import { normalizeArmEndpoint } from "../Common/EnvironmentUtility";
|
|
||||||
import GraphStylingPane from "./Panes/GraphStylingPane";
|
|
||||||
import NewVertexPane from "./Panes/NewVertexPane";
|
|
||||||
import NotebookV2Tab, { NotebookTabOptions } from "./Tabs/NotebookV2Tab";
|
|
||||||
import Q from "q";
|
import Q from "q";
|
||||||
import ResourceTokenCollection from "./Tree/ResourceTokenCollection";
|
import React from "react";
|
||||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
import _ from "underscore";
|
||||||
import TerminalTab from "./Tabs/TerminalTab";
|
|
||||||
import { Action, ActionModifiers } from "../Shared/Telemetry/TelemetryConstants";
|
|
||||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
|
||||||
import { ArcadiaResourceManager } from "../SparkClusterManager/ArcadiaResourceManager";
|
|
||||||
import { ArcadiaWorkspaceItem } from "./Controls/Arcadia/ArcadiaMenuPicker";
|
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
|
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
|
||||||
import { BrowseQueriesPane } from "./Panes/BrowseQueriesPane";
|
import { ReactAdapter } from "../Bindings/ReactBindingHandler";
|
||||||
import { CassandraAPIDataClient, TableDataClient, TablesAPIDataClient } from "./Tables/TableDataClient";
|
import * as Constants from "../Common/Constants";
|
||||||
import { CommandBarComponentAdapter } from "./Menus/CommandBar/CommandBarComponentAdapter";
|
|
||||||
import { configContext, Platform, updateConfigContext } from "../ConfigContext";
|
|
||||||
import { ConsoleData, ConsoleDataType } from "./Menus/NotificationConsole/NotificationConsoleComponent";
|
|
||||||
import { decryptJWTToken, getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
|
||||||
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
|
||||||
import { DialogProps, TextFieldProps } from "./Controls/Dialog";
|
|
||||||
import { ExecuteSprocParamsPane } from "./Panes/ExecuteSprocParamsPane";
|
|
||||||
import { ExplorerMetrics } from "../Common/Constants";
|
import { ExplorerMetrics } from "../Common/Constants";
|
||||||
import { ExplorerSettings } from "../Shared/ExplorerSettings";
|
import { readCollection } from "../Common/dataAccess/readCollection";
|
||||||
import { FileSystemUtil } from "./Notebook/FileSystemUtil";
|
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
||||||
import { IGalleryItem } from "../Juno/JunoClient";
|
import { getErrorMessage, getErrorStack, handleError } from "../Common/ErrorHandlingUtils";
|
||||||
import { LoadQueryPane } from "./Panes/LoadQueryPane";
|
|
||||||
import * as Logger from "../Common/Logger";
|
import * as Logger from "../Common/Logger";
|
||||||
import { sendMessage, sendCachedDataMessage } from "../Common/MessageHandler";
|
import { sendCachedDataMessage, sendMessage } from "../Common/MessageHandler";
|
||||||
|
import { QueriesClient } from "../Common/QueriesClient";
|
||||||
|
import { Splitter, SplitterBounds, SplitterDirection } from "../Common/Splitter";
|
||||||
|
import { configContext, Platform } from "../ConfigContext";
|
||||||
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
|
import { SubscriptionType } from "../Contracts/SubscriptionType";
|
||||||
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
|
import { IGalleryItem } from "../Juno/JunoClient";
|
||||||
|
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
|
||||||
|
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
||||||
|
import { RouteHandler } from "../RouteHandlers/RouteHandler";
|
||||||
|
import { appInsights } from "../Shared/appInsights";
|
||||||
|
import * as SharedConstants from "../Shared/Constants";
|
||||||
|
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
||||||
|
import { ExplorerSettings } from "../Shared/ExplorerSettings";
|
||||||
|
import { Action, ActionModifiers } from "../Shared/Telemetry/TelemetryConstants";
|
||||||
|
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
import { ArcadiaResourceManager } from "../SparkClusterManager/ArcadiaResourceManager";
|
||||||
|
import { updateUserContext, userContext } from "../UserContext";
|
||||||
|
import { decryptJWTToken, getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||||
|
import { stringToBlob } from "../Utils/BlobUtils";
|
||||||
|
import { fromContentUri, toRawContentUri } from "../Utils/GitHubUtils";
|
||||||
|
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||||
|
import * as ComponentRegisterer from "./ComponentRegisterer";
|
||||||
|
import { ArcadiaWorkspaceItem } from "./Controls/Arcadia/ArcadiaMenuPicker";
|
||||||
|
import { CommandButtonComponentProps } from "./Controls/CommandButton/CommandButtonComponent";
|
||||||
|
import { DialogProps, TextFieldProps } from "./Controls/Dialog";
|
||||||
|
import { GalleryTab } from "./Controls/NotebookGallery/GalleryViewerComponent";
|
||||||
|
import { CommandBarComponentAdapter } from "./Menus/CommandBar/CommandBarComponentAdapter";
|
||||||
|
import { ConsoleData, ConsoleDataType } from "./Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
|
import { FileSystemUtil } from "./Notebook/FileSystemUtil";
|
||||||
import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem";
|
import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem";
|
||||||
import { NotebookUtil } from "./Notebook/NotebookUtil";
|
import { NotebookUtil } from "./Notebook/NotebookUtil";
|
||||||
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
|
import AddCollectionPane from "./Panes/AddCollectionPane";
|
||||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
import AddDatabasePane from "./Panes/AddDatabasePane";
|
||||||
import { QueriesClient } from "../Common/QueriesClient";
|
import { BrowseQueriesPane } from "./Panes/BrowseQueriesPane";
|
||||||
import { QuerySelectPane } from "./Panes/Tables/QuerySelectPane";
|
import CassandraAddCollectionPane from "./Panes/CassandraAddCollectionPane";
|
||||||
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
import { ContextualPaneBase } from "./Panes/ContextualPaneBase";
|
||||||
import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
import DeleteCollectionConfirmationPane from "./Panes/DeleteCollectionConfirmationPane";
|
||||||
import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterForResourceToken";
|
import { DeleteCollectionConfirmationPanel } from "./Panes/DeleteCollectionConfirmationPanel";
|
||||||
import { RouteHandler } from "../RouteHandlers/RouteHandler";
|
import DeleteDatabaseConfirmationPane from "./Panes/DeleteDatabaseConfirmationPane";
|
||||||
|
import { ExecuteSprocParamsPane } from "./Panes/ExecuteSprocParamsPane";
|
||||||
|
import GraphStylingPane from "./Panes/GraphStylingPane";
|
||||||
|
import { LoadQueryPane } from "./Panes/LoadQueryPane";
|
||||||
|
import NewVertexPane from "./Panes/NewVertexPane";
|
||||||
import { SaveQueryPane } from "./Panes/SaveQueryPane";
|
import { SaveQueryPane } from "./Panes/SaveQueryPane";
|
||||||
import { SettingsPane } from "./Panes/SettingsPane";
|
import { SettingsPane } from "./Panes/SettingsPane";
|
||||||
import { SetupNotebooksPane } from "./Panes/SetupNotebooksPane";
|
import { SetupNotebooksPane } from "./Panes/SetupNotebooksPane";
|
||||||
import { SplashScreen } from "./SplashScreen/SplashScreen";
|
|
||||||
import { Splitter, SplitterBounds, SplitterDirection } from "../Common/Splitter";
|
|
||||||
import { StringInputPane } from "./Panes/StringInputPane";
|
import { StringInputPane } from "./Panes/StringInputPane";
|
||||||
|
import AddTableEntityPane from "./Panes/Tables/AddTableEntityPane";
|
||||||
|
import EditTableEntityPane from "./Panes/Tables/EditTableEntityPane";
|
||||||
|
import { QuerySelectPane } from "./Panes/Tables/QuerySelectPane";
|
||||||
import { TableColumnOptionsPane } from "./Panes/Tables/TableColumnOptionsPane";
|
import { TableColumnOptionsPane } from "./Panes/Tables/TableColumnOptionsPane";
|
||||||
import { TabsManager } from "./Tabs/TabsManager";
|
|
||||||
import { UploadFilePane } from "./Panes/UploadFilePane";
|
import { UploadFilePane } from "./Panes/UploadFilePane";
|
||||||
import { UploadItemsPane } from "./Panes/UploadItemsPane";
|
import { UploadItemsPane } from "./Panes/UploadItemsPane";
|
||||||
import { UploadItemsPaneAdapter } from "./Panes/UploadItemsPaneAdapter";
|
import { UploadItemsPaneAdapter } from "./Panes/UploadItemsPaneAdapter";
|
||||||
import { ReactAdapter } from "../Bindings/ReactBindingHandler";
|
import { CassandraAPIDataClient, TableDataClient, TablesAPIDataClient } from "./Tables/TableDataClient";
|
||||||
import { toRawContentUri, fromContentUri } from "../Utils/GitHubUtils";
|
import NotebookV2Tab, { NotebookTabOptions } from "./Tabs/NotebookV2Tab";
|
||||||
import UserDefinedFunction from "./Tree/UserDefinedFunction";
|
import TabsBase from "./Tabs/TabsBase";
|
||||||
|
import { TabsManager } from "./Tabs/TabsManager";
|
||||||
|
import TerminalTab from "./Tabs/TerminalTab";
|
||||||
|
import Database from "./Tree/Database";
|
||||||
|
import ResourceTokenCollection from "./Tree/ResourceTokenCollection";
|
||||||
|
import { ResourceTreeAdapter } from "./Tree/ResourceTreeAdapter";
|
||||||
|
import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterForResourceToken";
|
||||||
import StoredProcedure from "./Tree/StoredProcedure";
|
import StoredProcedure from "./Tree/StoredProcedure";
|
||||||
import Trigger from "./Tree/Trigger";
|
import Trigger from "./Tree/Trigger";
|
||||||
import { ContextualPaneBase } from "./Panes/ContextualPaneBase";
|
import UserDefinedFunction from "./Tree/UserDefinedFunction";
|
||||||
import TabsBase from "./Tabs/TabsBase";
|
|
||||||
import { CommandButtonComponentProps } from "./Controls/CommandButton/CommandButtonComponent";
|
|
||||||
import { updateUserContext, userContext } from "../UserContext";
|
|
||||||
import { stringToBlob } from "../Utils/BlobUtils";
|
|
||||||
import { IChoiceGroupProps } from "office-ui-fabric-react";
|
|
||||||
import { getErrorMessage, handleError, getErrorStack } from "../Common/ErrorHandlingUtils";
|
|
||||||
import { SubscriptionType } from "../Contracts/SubscriptionType";
|
|
||||||
import { appInsights } from "../Shared/appInsights";
|
|
||||||
import { GalleryTab } from "./Controls/NotebookGallery/GalleryViewerComponent";
|
|
||||||
import { DeleteCollectionConfirmationPanel } from "./Panes/DeleteCollectionConfirmationPanel";
|
|
||||||
|
|
||||||
BindingHandlersRegisterer.registerBindingHandlers();
|
BindingHandlersRegisterer.registerBindingHandlers();
|
||||||
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
||||||
@ -115,16 +112,52 @@ export default class Explorer {
|
|||||||
public hasWriteAccess: ko.Observable<boolean>;
|
public hasWriteAccess: ko.Observable<boolean>;
|
||||||
public collapsedResourceTreeWidth: number = ExplorerMetrics.CollapsedResourceTreeWidth;
|
public collapsedResourceTreeWidth: number = ExplorerMetrics.CollapsedResourceTreeWidth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Use userContext.databaseAccount instead
|
||||||
|
* */
|
||||||
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
|
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
|
||||||
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
|
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Use userContext.subscriptionType instead
|
||||||
|
* */
|
||||||
public subscriptionType: ko.Observable<SubscriptionType>;
|
public subscriptionType: ko.Observable<SubscriptionType>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Use userContext.apiType instead
|
||||||
|
* */
|
||||||
public defaultExperience: ko.Observable<string>;
|
public defaultExperience: ko.Observable<string>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Compare a string with userContext.apiType instead: userContext.apiType === "SQL"
|
||||||
|
* */
|
||||||
public isPreferredApiDocumentDB: ko.Computed<boolean>;
|
public isPreferredApiDocumentDB: ko.Computed<boolean>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Compare a string with userContext.apiType instead: userContext.apiType === "Cassandra"
|
||||||
|
* */
|
||||||
public isPreferredApiCassandra: ko.Computed<boolean>;
|
public isPreferredApiCassandra: ko.Computed<boolean>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Compare a string with userContext.apiType instead: userContext.apiType === "Mongo"
|
||||||
|
* */
|
||||||
public isPreferredApiMongoDB: ko.Computed<boolean>;
|
public isPreferredApiMongoDB: ko.Computed<boolean>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Compare a string with userContext.apiType instead: userContext.apiType === "Gremlin"
|
||||||
|
* */
|
||||||
public isPreferredApiGraph: ko.Computed<boolean>;
|
public isPreferredApiGraph: ko.Computed<boolean>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Compare a string with userContext.apiType instead: userContext.apiType === "Tables"
|
||||||
|
* */
|
||||||
public isPreferredApiTable: ko.Computed<boolean>;
|
public isPreferredApiTable: ko.Computed<boolean>;
|
||||||
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
|
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Compare a string with userContext.apiType instead: userContext.apiType === "Mongo"
|
||||||
|
* */
|
||||||
public isEnableMongoCapabilityPresent: ko.Computed<boolean>;
|
public isEnableMongoCapabilityPresent: ko.Computed<boolean>;
|
||||||
public isServerlessEnabled: ko.Computed<boolean>;
|
public isServerlessEnabled: ko.Computed<boolean>;
|
||||||
public isAccountReady: ko.Observable<boolean>;
|
public isAccountReady: ko.Observable<boolean>;
|
||||||
@ -153,6 +186,10 @@ export default class Explorer {
|
|||||||
public selectedCollectionId: ko.Computed<string>;
|
public selectedCollectionId: ko.Computed<string>;
|
||||||
public isLeftPaneExpanded: ko.Observable<boolean>;
|
public isLeftPaneExpanded: ko.Observable<boolean>;
|
||||||
public selectedNode: ko.Observable<ViewModels.TreeNode>;
|
public selectedNode: ko.Observable<ViewModels.TreeNode>;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Use a local loading state and spinner instead. Using a global isRefreshing state causes problems.
|
||||||
|
* */
|
||||||
public isRefreshingExplorer: ko.Observable<boolean>;
|
public isRefreshingExplorer: ko.Observable<boolean>;
|
||||||
private resourceTree: ResourceTreeAdapter;
|
private resourceTree: ResourceTreeAdapter;
|
||||||
|
|
||||||
@ -432,6 +469,7 @@ export default class Explorer {
|
|||||||
databaseAccount
|
databaseAccount
|
||||||
);
|
);
|
||||||
this.defaultExperience(defaultExperience);
|
this.defaultExperience(defaultExperience);
|
||||||
|
// TODO. Remove this entirely
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
defaultExperience: DefaultExperienceUtility.mapDefaultExperienceStringToEnum(defaultExperience),
|
defaultExperience: DefaultExperienceUtility.mapDefaultExperienceStringToEnum(defaultExperience),
|
||||||
});
|
});
|
||||||
@ -1406,8 +1444,6 @@ export default class Explorer {
|
|||||||
sessionStorage.setItem("portalDataExplorerInitMessage", JSON.stringify(inputs));
|
sessionStorage.setItem("portalDataExplorerInitMessage", JSON.stringify(inputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
const authorizationToken = inputs.authorizationToken || "";
|
|
||||||
const masterKey = inputs.masterKey || "";
|
|
||||||
const databaseAccount = inputs.databaseAccount || null;
|
const databaseAccount = inputs.databaseAccount || null;
|
||||||
if (inputs.defaultCollectionThroughput) {
|
if (inputs.defaultCollectionThroughput) {
|
||||||
this.collectionCreationDefaults = inputs.defaultCollectionThroughput;
|
this.collectionCreationDefaults = inputs.defaultCollectionThroughput;
|
||||||
@ -1423,21 +1459,6 @@ export default class Explorer {
|
|||||||
this.isTryCosmosDBSubscription(inputs.isTryCosmosDBSubscription ?? false);
|
this.isTryCosmosDBSubscription(inputs.isTryCosmosDBSubscription ?? false);
|
||||||
this.isAuthWithResourceToken(inputs.isAuthWithresourceToken ?? false);
|
this.isAuthWithResourceToken(inputs.isAuthWithresourceToken ?? false);
|
||||||
this.setFeatureFlagsFromFlights(inputs.flights);
|
this.setFeatureFlagsFromFlights(inputs.flights);
|
||||||
|
|
||||||
updateConfigContext({
|
|
||||||
BACKEND_ENDPOINT: inputs.extensionEndpoint || configContext.BACKEND_ENDPOINT,
|
|
||||||
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT),
|
|
||||||
});
|
|
||||||
|
|
||||||
updateUserContext({
|
|
||||||
authorizationToken,
|
|
||||||
masterKey,
|
|
||||||
databaseAccount,
|
|
||||||
resourceGroup: inputs.resourceGroup,
|
|
||||||
subscriptionId: inputs.subscriptionId,
|
|
||||||
subscriptionType: inputs.subscriptionType,
|
|
||||||
quotaId: inputs.quotaId,
|
|
||||||
});
|
|
||||||
TelemetryProcessor.traceSuccess(
|
TelemetryProcessor.traceSuccess(
|
||||||
Action.LoadDatabaseAccount,
|
Action.LoadDatabaseAccount,
|
||||||
{
|
{
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
import * as AutoPilotUtils from "../../Utils/AutoPilotUtils";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as PricingUtils from "../../Utils/PricingUtils";
|
|
||||||
import * as SharedConstants from "../../Shared/Constants";
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
|
||||||
import DiscardIcon from "../../../images/discard.svg";
|
|
||||||
import editable from "../../Common/EditableUtility";
|
|
||||||
import Q from "q";
|
import Q from "q";
|
||||||
|
import DiscardIcon from "../../../images/discard.svg";
|
||||||
import SaveIcon from "../../../images/save-cosmos.svg";
|
import SaveIcon from "../../../images/save-cosmos.svg";
|
||||||
import TabsBase from "./TabsBase";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
|
||||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
|
||||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
|
||||||
import Explorer from "../Explorer";
|
|
||||||
import { updateOffer } from "../../Common/dataAccess/updateOffer";
|
import { updateOffer } from "../../Common/dataAccess/updateOffer";
|
||||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
import editable from "../../Common/EditableUtility";
|
||||||
import { configContext, Platform } from "../../ConfigContext";
|
|
||||||
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
||||||
|
import { configContext, Platform } from "../../ConfigContext";
|
||||||
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
|
import * as SharedConstants from "../../Shared/Constants";
|
||||||
|
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
import { userContext } from "../../UserContext";
|
||||||
|
import * as AutoPilotUtils from "../../Utils/AutoPilotUtils";
|
||||||
|
import * as PricingUtils from "../../Utils/PricingUtils";
|
||||||
|
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||||
|
import Explorer from "../Explorer";
|
||||||
|
import TabsBase from "./TabsBase";
|
||||||
|
|
||||||
const updateThroughputBeyondLimitWarningMessage: string = `
|
const updateThroughputBeyondLimitWarningMessage: string = `
|
||||||
You are about to request an increase in throughput beyond the pre-allocated capacity.
|
You are about to request an increase in throughput beyond the pre-allocated capacity.
|
||||||
@ -131,7 +131,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.requestUnitsUsageCost = ko.pureComputed(() => {
|
this.requestUnitsUsageCost = ko.pureComputed(() => {
|
||||||
const account = this.container.databaseAccount();
|
const account = userContext.databaseAccount;
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
this.isTemplateReady = ko.observable<boolean>(false);
|
this.isTemplateReady = ko.observable<boolean>(false);
|
||||||
|
|
||||||
this.isFreeTierAccount = ko.computed<boolean>(() => {
|
this.isFreeTierAccount = ko.computed<boolean>(() => {
|
||||||
const databaseAccount = this.container?.databaseAccount();
|
const databaseAccount = userContext.databaseAccount;
|
||||||
return databaseAccount?.properties?.enableFreeTier;
|
return databaseAccount?.properties?.enableFreeTier;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -17,12 +17,43 @@ interface UserContext {
|
|||||||
useSDKOperations?: boolean;
|
useSDKOperations?: boolean;
|
||||||
subscriptionType?: SubscriptionType;
|
subscriptionType?: SubscriptionType;
|
||||||
quotaId?: string;
|
quotaId?: string;
|
||||||
|
// API Type is not yet provided by ARM. You need to manually inspect all the capabilities+kind so we abstract that logic in userContext
|
||||||
|
// This is coming in a future Cosmos ARM API version as a prperty on databaseAccount
|
||||||
|
apiType?: ApiType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userContext: Readonly<UserContext> = {} as const;
|
type ApiType = "SQL" | "Mongo" | "Gremlin" | "Tables" | "Cassandra";
|
||||||
|
|
||||||
|
const userContext: UserContext = {};
|
||||||
|
|
||||||
function updateUserContext(newContext: UserContext): void {
|
function updateUserContext(newContext: UserContext): void {
|
||||||
Object.assign(userContext, newContext);
|
Object.assign(userContext, newContext);
|
||||||
|
Object.assign(userContext, { apiType: apiType(userContext.databaseAccount) });
|
||||||
|
}
|
||||||
|
|
||||||
|
function apiType(account: DatabaseAccount | undefined): ApiType {
|
||||||
|
if (!account) {
|
||||||
|
return "SQL";
|
||||||
|
}
|
||||||
|
const capabilities = account.properties?.capabilities;
|
||||||
|
if (capabilities) {
|
||||||
|
if (capabilities.find((c) => c.name === "EnableCassandra")) {
|
||||||
|
return "Cassandra";
|
||||||
|
}
|
||||||
|
if (capabilities.find((c) => c.name === "EnableGremlin")) {
|
||||||
|
return "Gremlin";
|
||||||
|
}
|
||||||
|
if (capabilities.find((c) => c.name === "EnableMongo")) {
|
||||||
|
return "Mongo";
|
||||||
|
}
|
||||||
|
if (capabilities.find((c) => c.name === "EnableTable")) {
|
||||||
|
return "Tables";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (account.kind === "MongoDB" || account.kind === "Parse") {
|
||||||
|
return "Mongo";
|
||||||
|
}
|
||||||
|
return "SQL";
|
||||||
}
|
}
|
||||||
|
|
||||||
export { userContext, updateUserContext };
|
export { userContext, updateUserContext };
|
||||||
|
13
src/global.d.ts
vendored
13
src/global.d.ts
vendored
@ -1,11 +1,22 @@
|
|||||||
import { AuthType } from "./AuthType";
|
|
||||||
import Explorer from "./Explorer/Explorer";
|
import Explorer from "./Explorer/Explorer";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* DO NOT take new usage of window.dataExplorer. If you must use Explorer, find it directly.
|
||||||
|
* */
|
||||||
dataExplorer: Explorer;
|
dataExplorer: Explorer;
|
||||||
__REACT_DEVTOOLS_GLOBAL_HOOK__: any;
|
__REACT_DEVTOOLS_GLOBAL_HOOK__: any;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* No new usage of jQuery ($)
|
||||||
|
* */
|
||||||
$: any;
|
$: any;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* No new usage of jQuery
|
||||||
|
* */
|
||||||
jQuery: any;
|
jQuery: any;
|
||||||
gitSha: string;
|
gitSha: string;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,9 @@ import { useEffect } from "react";
|
|||||||
import { applyExplorerBindings } from "../applyExplorerBindings";
|
import { applyExplorerBindings } from "../applyExplorerBindings";
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import { AccountKind, DefaultAccountExperience } from "../Common/Constants";
|
import { AccountKind, DefaultAccountExperience } from "../Common/Constants";
|
||||||
|
import { normalizeArmEndpoint } from "../Common/EnvironmentUtility";
|
||||||
import { sendMessage } from "../Common/MessageHandler";
|
import { sendMessage } from "../Common/MessageHandler";
|
||||||
import { configContext, Platform } from "../ConfigContext";
|
import { configContext, Platform, updateConfigContext } from "../ConfigContext";
|
||||||
import { ActionType, DataExplorerAction } from "../Contracts/ActionContracts";
|
import { ActionType, DataExplorerAction } from "../Contracts/ActionContracts";
|
||||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
import { DataExplorerInputsFrame } from "../Contracts/ViewModels";
|
import { DataExplorerInputsFrame } from "../Contracts/ViewModels";
|
||||||
@ -89,20 +90,24 @@ async function configureHostedWithAAD(config: AAD) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function configureHostedWithConnectionString(config: ConnectionString) {
|
function configureHostedWithConnectionString(config: ConnectionString) {
|
||||||
|
const apiExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(config.encryptedTokenMetadata.apiKind);
|
||||||
|
const databaseAccount = {
|
||||||
|
id: "",
|
||||||
|
location: "",
|
||||||
|
type: "",
|
||||||
|
name: config.encryptedTokenMetadata.accountName,
|
||||||
|
kind: getDatabaseAccountKindFromExperience(apiExperience),
|
||||||
|
properties: getDatabaseAccountPropertiesFromMetadata(config.encryptedTokenMetadata),
|
||||||
|
tags: {},
|
||||||
|
};
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
// For legacy reasons lots of code expects a connection string login to look and act like an encrypted token login
|
// For legacy reasons lots of code expects a connection string login to look and act like an encrypted token login
|
||||||
authType: AuthType.EncryptedToken,
|
authType: AuthType.EncryptedToken,
|
||||||
accessToken: encodeURIComponent(config.encryptedToken),
|
accessToken: encodeURIComponent(config.encryptedToken),
|
||||||
|
databaseAccount,
|
||||||
});
|
});
|
||||||
const apiExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(config.encryptedTokenMetadata.apiKind);
|
|
||||||
explorer.configure({
|
explorer.configure({
|
||||||
databaseAccount: {
|
databaseAccount,
|
||||||
id: "",
|
|
||||||
name: config.encryptedTokenMetadata.accountName,
|
|
||||||
kind: getDatabaseAccountKindFromExperience(apiExperience),
|
|
||||||
properties: getDatabaseAccountPropertiesFromMetadata(config.encryptedTokenMetadata),
|
|
||||||
tags: {},
|
|
||||||
},
|
|
||||||
masterKey: config.masterKey,
|
masterKey: config.masterKey,
|
||||||
features: extractFeatures(),
|
features: extractFeatures(),
|
||||||
});
|
});
|
||||||
@ -110,7 +115,18 @@ function configureHostedWithConnectionString(config: ConnectionString) {
|
|||||||
|
|
||||||
function configureHostedWithResourceToken(config: ResourceToken) {
|
function configureHostedWithResourceToken(config: ResourceToken) {
|
||||||
const parsedResourceToken = parseResourceTokenConnectionString(config.resourceToken);
|
const parsedResourceToken = parseResourceTokenConnectionString(config.resourceToken);
|
||||||
|
const databaseAccount = {
|
||||||
|
id: "",
|
||||||
|
location: "",
|
||||||
|
type: "",
|
||||||
|
name: parsedResourceToken.accountEndpoint,
|
||||||
|
kind: AccountKind.GlobalDocumentDB,
|
||||||
|
properties: { documentEndpoint: parsedResourceToken.accountEndpoint },
|
||||||
|
// Resource tokens can only be used with SQL API
|
||||||
|
tags: { defaultExperience: DefaultAccountExperience.DocumentDB },
|
||||||
|
};
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
|
databaseAccount,
|
||||||
authType: AuthType.ResourceToken,
|
authType: AuthType.ResourceToken,
|
||||||
resourceToken: parsedResourceToken.resourceToken,
|
resourceToken: parsedResourceToken.resourceToken,
|
||||||
endpoint: parsedResourceToken.accountEndpoint,
|
endpoint: parsedResourceToken.accountEndpoint,
|
||||||
@ -121,14 +137,7 @@ function configureHostedWithResourceToken(config: ResourceToken) {
|
|||||||
explorer.resourceTokenPartitionKey(parsedResourceToken.partitionKey);
|
explorer.resourceTokenPartitionKey(parsedResourceToken.partitionKey);
|
||||||
}
|
}
|
||||||
explorer.configure({
|
explorer.configure({
|
||||||
databaseAccount: {
|
databaseAccount,
|
||||||
id: "",
|
|
||||||
name: parsedResourceToken.accountEndpoint,
|
|
||||||
kind: AccountKind.GlobalDocumentDB,
|
|
||||||
properties: { documentEndpoint: parsedResourceToken.accountEndpoint },
|
|
||||||
// Resource tokens can only be used with SQL API
|
|
||||||
tags: { defaultExperience: DefaultAccountExperience.DocumentDB },
|
|
||||||
},
|
|
||||||
features: extractFeatures(),
|
features: extractFeatures(),
|
||||||
isAuthWithresourceToken: true,
|
isAuthWithresourceToken: true,
|
||||||
});
|
});
|
||||||
@ -157,6 +166,7 @@ function configureHostedWithEncryptedToken(config: EncryptedToken) {
|
|||||||
|
|
||||||
function configureEmulator() {
|
function configureEmulator() {
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
|
databaseAccount: emulatorAccount,
|
||||||
authType: AuthType.MasterKey,
|
authType: AuthType.MasterKey,
|
||||||
});
|
});
|
||||||
explorer.databaseAccount(emulatorAccount);
|
explorer.databaseAccount(emulatorAccount);
|
||||||
@ -207,6 +217,25 @@ function configurePortal() {
|
|||||||
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const authorizationToken = inputs.authorizationToken || "";
|
||||||
|
const masterKey = inputs.masterKey || "";
|
||||||
|
const databaseAccount = inputs.databaseAccount;
|
||||||
|
|
||||||
|
updateConfigContext({
|
||||||
|
BACKEND_ENDPOINT: inputs.extensionEndpoint || configContext.BACKEND_ENDPOINT,
|
||||||
|
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT),
|
||||||
|
});
|
||||||
|
|
||||||
|
updateUserContext({
|
||||||
|
authorizationToken,
|
||||||
|
masterKey,
|
||||||
|
databaseAccount,
|
||||||
|
resourceGroup: inputs.resourceGroup,
|
||||||
|
subscriptionId: inputs.subscriptionId,
|
||||||
|
subscriptionType: inputs.subscriptionType,
|
||||||
|
quotaId: inputs.quotaId,
|
||||||
|
});
|
||||||
|
|
||||||
explorer.configure(inputs);
|
explorer.configure(inputs);
|
||||||
applyExplorerBindings(explorer);
|
applyExplorerBindings(explorer);
|
||||||
if (openAction) {
|
if (openAction) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user