Remove Explorer.databaseAccount (#717)

Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
Hardikkumar Nai
2021-05-06 03:24:50 +05:30
committed by GitHub
parent fdd12b41c4
commit 8c05ac740c
67 changed files with 1077 additions and 1046 deletions

View File

@@ -350,11 +350,11 @@ exports[`test render renders with filters 1`] = `
}
>
<div
className="ms-ScrollablePane root-40"
className="ms-ScrollablePane root-72"
data-is-scrollable="true"
>
<div
className="stickyAbove-42"
className="stickyAbove-74"
style={
Object {
"height": 0,
@@ -365,7 +365,7 @@ exports[`test render renders with filters 1`] = `
}
/>
<div
className="ms-ScrollablePane--contentContainer contentContainer-41"
className="ms-ScrollablePane--contentContainer contentContainer-73"
data-is-scrollable={true}
>
<Sticky
@@ -691,18 +691,18 @@ exports[`test render renders with filters 1`] = `
validateOnLoad={true}
>
<div
className="ms-TextField directoryListFilterTextBox root-46"
className="ms-TextField directoryListFilterTextBox root-78"
>
<div
className="ms-TextField-wrapper"
>
<div
className="ms-TextField-fieldGroup fieldGroup-47"
className="ms-TextField-fieldGroup fieldGroup-79"
>
<input
aria-invalid={false}
aria-label="Directory filter text box"
className="ms-TextField-field field-48"
className="ms-TextField-field field-80"
id="TextField0"
onBlur={[Function]}
onChange={[Function]}
@@ -1900,7 +1900,7 @@ exports[`test render renders with filters 1`] = `
>
<button
aria-disabled={true}
className="ms-Button ms-Button--default is-disabled directoryListButton root-57"
className="ms-Button ms-Button--default is-disabled directoryListButton root-89"
data-is-focusable={false}
disabled={true}
onClick={[Function]}
@@ -1912,7 +1912,7 @@ exports[`test render renders with filters 1`] = `
type="button"
>
<span
className="ms-Button-flexContainer flexContainer-58"
className="ms-Button-flexContainer flexContainer-90"
data-automationid="splitbuttonprimary"
>
<div
@@ -1943,7 +1943,7 @@ exports[`test render renders with filters 1`] = `
</List>
</div>
<div
className="stickyBelow-43"
className="stickyBelow-75"
style={
Object {
"bottom": "0px",
@@ -1954,7 +1954,7 @@ exports[`test render renders with filters 1`] = `
}
>
<div
className="stickyBelowItems-44"
className="stickyBelowItems-76"
/>
</div>
</div>

View File

@@ -9,7 +9,7 @@ describe("CodeOfConductComponent", () => {
let codeOfConductProps: CodeOfConductComponentProps;
beforeEach(() => {
const junoClient = new JunoClient(undefined);
const junoClient = new JunoClient();
junoClient.acceptCodeOfConduct = jest.fn().mockReturnValue({
status: HttpStatusCodes.OK,
data: true,

View File

@@ -154,19 +154,20 @@ describe("SettingsComponent", () => {
expect(settingsComponentInstance.hasConflictResolution()).toEqual(undefined);
const newContainer = new Explorer();
newContainer.databaseAccount = ko.observable({
id: undefined,
name: undefined,
location: undefined,
type: undefined,
kind: undefined,
tags: undefined,
properties: {
documentEndpoint: undefined,
tableEndpoint: undefined,
gremlinEndpoint: undefined,
cassandraEndpoint: undefined,
enableMultipleWriteLocations: true,
updateUserContext({
databaseAccount: {
id: undefined,
name: undefined,
location: undefined,
type: undefined,
kind: undefined,
properties: {
documentEndpoint: undefined,
tableEndpoint: undefined,
gremlinEndpoint: undefined,
cassandraEndpoint: undefined,
enableMultipleWriteLocations: true,
},
},
});
const newCollection = { ...collection };

View File

@@ -233,11 +233,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
}
public loadMongoIndexes = async (): Promise<void> => {
if (
userContext.apiType === "Mongo" &&
this.container.isEnableMongoCapabilityPresent() &&
this.container.databaseAccount()
) {
if (userContext.apiType === "Mongo" && userContext?.databaseAccount) {
this.mongoDBCollectionResource = await readMongoDBCollectionThroughRP(
this.collection.databaseId,
this.collection.id()
@@ -300,8 +296,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
this.container && userContext.apiType === "Cassandra" && hasDatabaseSharedThroughput(this.collection);
public hasConflictResolution = (): boolean =>
this.container?.databaseAccount &&
this.container.databaseAccount()?.properties?.enableMultipleWriteLocations &&
userContext?.databaseAccount?.properties?.enableMultipleWriteLocations &&
this.collection.conflictResolutionPolicy &&
!!this.collection.conflictResolutionPolicy();
@@ -876,7 +871,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
mongoIndexingPolicyComponentProps: MongoIndexingPolicyComponentProps
): JSX.Element => {
if (userContext.authType === AuthType.AAD) {
if (this.container.isEnableMongoCapabilityPresent()) {
if (userContext.apiType === "Mongo") {
return <MongoIndexingPolicyComponent {...mongoIndexingPolicyComponentProps} />;
}
return undefined;

View File

@@ -4,6 +4,7 @@ import React from "react";
import * as Constants from "../../../../Common/Constants";
import * as DataModels from "../../../../Contracts/DataModels";
import * as SharedConstants from "../../../../Shared/Constants";
import { updateUserContext } from "../../../../UserContext";
import Explorer from "../../../Explorer";
import { throughputUnit } from "../SettingsRenderUtils";
import { collection, container } from "../TestUtils";
@@ -80,24 +81,25 @@ describe("ScaleComponent", () => {
it("autoScale enabled", () => {
const newContainer = new Explorer();
newContainer.databaseAccount({
id: undefined,
name: undefined,
location: undefined,
type: undefined,
kind: "documentdb",
properties: {
documentEndpoint: undefined,
tableEndpoint: undefined,
gremlinEndpoint: undefined,
cassandraEndpoint: undefined,
capabilities: [
{
name: Constants.CapabilityNames.EnableAutoScale.toLowerCase(),
description: undefined,
},
],
updateUserContext({
databaseAccount: {
id: undefined,
name: undefined,
location: undefined,
type: undefined,
kind: "documentdb",
properties: {
documentEndpoint: undefined,
tableEndpoint: undefined,
gremlinEndpoint: undefined,
cassandraEndpoint: undefined,
capabilities: [
{
name: Constants.CapabilityNames.EnableAutoScale.toLowerCase(),
description: undefined,
},
],
},
},
});
const props = { ...baseProps, container: newContainer };

View File

@@ -54,8 +54,7 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
}
public isAutoScaleEnabled = (): boolean => {
const accountCapabilities: DataModels.Capability[] = this.props.container?.databaseAccount()?.properties
?.capabilities;
const accountCapabilities: DataModels.Capability[] = userContext?.databaseAccount?.properties?.capabilities;
const enableAutoScaleCapability =
accountCapabilities &&
accountCapabilities.find((capability: DataModels.Capability) => {
@@ -170,7 +169,7 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
private getThroughputInputComponent = (): JSX.Element => (
<ThroughputInputAutoPilotV3Component
databaseAccount={this.props.container.databaseAccount()}
databaseAccount={userContext?.databaseAccount}
databaseName={this.databaseId}
collectionName={this.collectionId}
throughput={this.props.throughput}
@@ -199,8 +198,7 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
);
private isFreeTierAccount(): boolean {
const databaseAccount = this.props.container?.databaseAccount();
return databaseAccount?.properties?.enableFreeTier;
return userContext?.databaseAccount?.properties?.enableFreeTier;
}
private getFreeTierInfoMessage(): JSX.Element {

View File

@@ -422,7 +422,6 @@ exports[`SettingsComponent renders 1`] = `
"parameters": [Function],
"tabsButtons": Array [],
},
"databaseAccount": [Function],
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
@@ -1216,7 +1215,6 @@ exports[`SettingsComponent renders 1`] = `
"hasStorageAnalyticsAfecFeature": [Function],
"isAccountReady": [Function],
"isAutoscaleDefaultEnabled": [Function],
"isEnableMongoCapabilityPresent": [Function],
"isFixedCollectionWithSharedThroughputSupported": [Function],
"isHostedDataExplorerEnabled": [Function],
"isLeftPaneExpanded": [Function],
@@ -1234,7 +1232,6 @@ exports[`SettingsComponent renders 1`] = `
"isTabsContentExpanded": [Function],
"junoClient": JunoClient {
"cachedPinnedRepos": [Function],
"databaseAccount": undefined,
},
"memoryUsageInfo": [Function],
"notebookBasePath": [Function],
@@ -1707,7 +1704,6 @@ exports[`SettingsComponent renders 1`] = `
"parameters": [Function],
"tabsButtons": Array [],
},
"databaseAccount": [Function],
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
@@ -2501,7 +2497,6 @@ exports[`SettingsComponent renders 1`] = `
"hasStorageAnalyticsAfecFeature": [Function],
"isAccountReady": [Function],
"isAutoscaleDefaultEnabled": [Function],
"isEnableMongoCapabilityPresent": [Function],
"isFixedCollectionWithSharedThroughputSupported": [Function],
"isHostedDataExplorerEnabled": [Function],
"isLeftPaneExpanded": [Function],
@@ -2519,7 +2514,6 @@ exports[`SettingsComponent renders 1`] = `
"isTabsContentExpanded": [Function],
"junoClient": JunoClient {
"cachedPinnedRepos": [Function],
"databaseAccount": undefined,
},
"memoryUsageInfo": [Function],
"notebookBasePath": [Function],
@@ -3005,7 +2999,6 @@ exports[`SettingsComponent renders 1`] = `
"parameters": [Function],
"tabsButtons": Array [],
},
"databaseAccount": [Function],
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
@@ -3799,7 +3792,6 @@ exports[`SettingsComponent renders 1`] = `
"hasStorageAnalyticsAfecFeature": [Function],
"isAccountReady": [Function],
"isAutoscaleDefaultEnabled": [Function],
"isEnableMongoCapabilityPresent": [Function],
"isFixedCollectionWithSharedThroughputSupported": [Function],
"isHostedDataExplorerEnabled": [Function],
"isLeftPaneExpanded": [Function],
@@ -3817,7 +3809,6 @@ exports[`SettingsComponent renders 1`] = `
"isTabsContentExpanded": [Function],
"junoClient": JunoClient {
"cachedPinnedRepos": [Function],
"databaseAccount": undefined,
},
"memoryUsageInfo": [Function],
"notebookBasePath": [Function],
@@ -4290,7 +4281,6 @@ exports[`SettingsComponent renders 1`] = `
"parameters": [Function],
"tabsButtons": Array [],
},
"databaseAccount": [Function],
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
@@ -5084,7 +5074,6 @@ exports[`SettingsComponent renders 1`] = `
"hasStorageAnalyticsAfecFeature": [Function],
"isAccountReady": [Function],
"isAutoscaleDefaultEnabled": [Function],
"isEnableMongoCapabilityPresent": [Function],
"isFixedCollectionWithSharedThroughputSupported": [Function],
"isHostedDataExplorerEnabled": [Function],
"isLeftPaneExpanded": [Function],
@@ -5102,7 +5091,6 @@ exports[`SettingsComponent renders 1`] = `
"isTabsContentExpanded": [Function],
"junoClient": JunoClient {
"cachedPinnedRepos": [Function],
"databaseAccount": undefined,
},
"memoryUsageInfo": [Function],
"notebookBasePath": [Function],

View File

@@ -216,7 +216,7 @@ export class ThroughputInput extends React.Component<ThroughputInputProps, Throu
}
private getCostAcknowledgeText(): string {
const databaseAccount = userContext.databaseAccount;
const { databaseAccount } = userContext;
if (!databaseAccount || !databaseAccount.properties) {
return "";
}
@@ -259,8 +259,8 @@ interface CostEstimateTextProps {
const CostEstimateText: React.FunctionComponent<CostEstimateTextProps> = (props: CostEstimateTextProps) => {
const { requestUnits, isAutoscale } = props;
const databaseAccount = userContext.databaseAccount;
if (!databaseAccount || !databaseAccount.properties) {
const { databaseAccount } = userContext;
if (!databaseAccount?.properties) {
return <></>;
}