Remove Explorer.openAddCollectionPane (#905)
Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
parent
447db01647
commit
a1d5648bbc
|
@ -154,7 +154,6 @@ src/Explorer/Tree/AccessibleVerticalList.ts
|
||||||
src/Explorer/Tree/Collection.test.ts
|
src/Explorer/Tree/Collection.test.ts
|
||||||
src/Explorer/Tree/Collection.ts
|
src/Explorer/Tree/Collection.ts
|
||||||
src/Explorer/Tree/ConflictId.ts
|
src/Explorer/Tree/ConflictId.ts
|
||||||
src/Explorer/Tree/Database.ts
|
|
||||||
src/Explorer/Tree/DocumentId.ts
|
src/Explorer/Tree/DocumentId.ts
|
||||||
src/Explorer/Tree/ObjectId.ts
|
src/Explorer/Tree/ObjectId.ts
|
||||||
src/Explorer/Tree/ResourceTokenCollection.ts
|
src/Explorer/Tree/ResourceTokenCollection.ts
|
||||||
|
|
|
@ -1200,7 +1200,7 @@ export default class Explorer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onNewCollectionClicked(databaseId?: string): void {
|
public async onNewCollectionClicked(databaseId?: string): Promise<void> {
|
||||||
if (userContext.apiType === "Cassandra") {
|
if (userContext.apiType === "Cassandra") {
|
||||||
useSidePanel
|
useSidePanel
|
||||||
.getState()
|
.getState()
|
||||||
|
@ -1209,7 +1209,10 @@ export default class Explorer {
|
||||||
<CassandraAddCollectionPane explorer={this} cassandraApiClient={new CassandraAPIDataClient()} />
|
<CassandraAddCollectionPane explorer={this} cassandraApiClient={new CassandraAPIDataClient()} />
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.openAddCollectionPanel(databaseId);
|
await useDatabases.getState().loadDatabaseOffers();
|
||||||
|
useSidePanel
|
||||||
|
.getState()
|
||||||
|
.openSidePanel("New " + getCollectionName(), <AddCollectionPanel explorer={this} databaseId={databaseId} />);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,12 +1265,6 @@ export default class Explorer {
|
||||||
.openSidePanel("Input parameters", <ExecuteSprocParamsPane storedProcedure={storedProcedure} />);
|
.openSidePanel("Input parameters", <ExecuteSprocParamsPane storedProcedure={storedProcedure} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async openAddCollectionPanel(databaseId?: string): Promise<void> {
|
|
||||||
await useDatabases.getState().loadDatabaseOffers();
|
|
||||||
useSidePanel
|
|
||||||
.getState()
|
|
||||||
.openSidePanel("New " + getCollectionName(), <AddCollectionPanel explorer={this} databaseId={databaseId} />);
|
|
||||||
}
|
|
||||||
public openAddDatabasePane(): void {
|
public openAddDatabasePane(): void {
|
||||||
useSidePanel.getState().openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={this} />);
|
useSidePanel.getState().openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={this} />);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ updateUserContext({
|
||||||
|
|
||||||
describe("Add Schema", () => {
|
describe("Add Schema", () => {
|
||||||
it("should not call requestSchema or getSchema if analyticalStorageTtl is undefined", () => {
|
it("should not call requestSchema or getSchema if analyticalStorageTtl is undefined", () => {
|
||||||
const collection: DataModels.Collection = {} as DataModels.Collection;
|
const collection: DataModels.Collection = { id: "fakeId" } as DataModels.Collection;
|
||||||
collection.analyticalStorageTtl = undefined;
|
collection.analyticalStorageTtl = undefined;
|
||||||
const database = new Database(createMockContainer(), { id: "fakeId" });
|
const database = new Database(createMockContainer(), collection);
|
||||||
database.container = createMockContainer();
|
database.container = createMockContainer();
|
||||||
database.container.isSchemaEnabled = ko.computed<boolean>(() => false);
|
database.container.isSchemaEnabled = ko.computed<boolean>(() => false);
|
||||||
|
|
||||||
|
@ -47,10 +47,10 @@ describe("Add Schema", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call requestSchema or getSchema if analyticalStorageTtl is not undefined", () => {
|
it("should call requestSchema or getSchema if analyticalStorageTtl is not undefined", () => {
|
||||||
const collection: DataModels.Collection = { id: "fakeId" } as DataModels.Collection;
|
const collection: DataModels.Collection = {} as DataModels.Collection;
|
||||||
collection.analyticalStorageTtl = 0;
|
collection.analyticalStorageTtl = 0;
|
||||||
|
|
||||||
const database = new Database(createMockContainer(), {});
|
const database = new Database(createMockContainer(), collection);
|
||||||
database.container = createMockContainer();
|
database.container = createMockContainer();
|
||||||
database.container.isSchemaEnabled = ko.computed<boolean>(() => true);
|
database.container.isSchemaEnabled = ko.computed<boolean>(() => true);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
|
import React from "react";
|
||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
|
@ -9,18 +10,20 @@ import * as Logger from "../../Common/Logger";
|
||||||
import { fetchPortalNotifications } from "../../Common/PortalNotifications";
|
import { fetchPortalNotifications } from "../../Common/PortalNotifications";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
|
import { useSidePanel } from "../../hooks/useSidePanel";
|
||||||
import { IJunoResponse, JunoClient } from "../../Juno/JunoClient";
|
import { IJunoResponse, JunoClient } from "../../Juno/JunoClient";
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
import { getCollectionName } from "../../Utils/APITypeUtils";
|
||||||
import { isServerlessAccount } from "../../Utils/CapabilityUtils";
|
import { isServerlessAccount } from "../../Utils/CapabilityUtils";
|
||||||
import { logConsoleError } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleError } from "../../Utils/NotificationConsoleUtils";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
|
import { AddCollectionPanel } from "../Panes/AddCollectionPanel";
|
||||||
import { DatabaseSettingsTabV2 } from "../Tabs/SettingsTabV2";
|
import { DatabaseSettingsTabV2 } from "../Tabs/SettingsTabV2";
|
||||||
import { useDatabases } from "../useDatabases";
|
import { useDatabases } from "../useDatabases";
|
||||||
import { useSelectedNode } from "../useSelectedNode";
|
import { useSelectedNode } from "../useSelectedNode";
|
||||||
import Collection from "./Collection";
|
import Collection from "./Collection";
|
||||||
|
|
||||||
export default class Database implements ViewModels.Database {
|
export default class Database implements ViewModels.Database {
|
||||||
public nodeKind: string;
|
public nodeKind: string;
|
||||||
public container: Explorer;
|
public container: Explorer;
|
||||||
|
@ -35,7 +38,7 @@ export default class Database implements ViewModels.Database {
|
||||||
public junoClient: JunoClient;
|
public junoClient: JunoClient;
|
||||||
private isOfferRead: boolean;
|
private isOfferRead: boolean;
|
||||||
|
|
||||||
constructor(container: Explorer, data: any) {
|
constructor(container: Explorer, data: DataModels.Database) {
|
||||||
this.nodeKind = "Database";
|
this.nodeKind = "Database";
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.self = data._self;
|
this.self = data._self;
|
||||||
|
@ -74,6 +77,7 @@ export default class Database implements ViewModels.Database {
|
||||||
tabTitle: "Scale",
|
tabTitle: "Scale",
|
||||||
});
|
});
|
||||||
pendingNotificationsPromise.then(
|
pendingNotificationsPromise.then(
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(data: any) => {
|
(data: any) => {
|
||||||
const pendingNotification: DataModels.Notification = data?.[0];
|
const pendingNotification: DataModels.Notification = data?.[0];
|
||||||
const tabOptions: ViewModels.TabOptions = {
|
const tabOptions: ViewModels.TabOptions = {
|
||||||
|
@ -89,7 +93,7 @@ export default class Database implements ViewModels.Database {
|
||||||
settingsTab.pendingNotification(pendingNotification);
|
settingsTab.pendingNotification(pendingNotification);
|
||||||
this.container.tabsManager.activateNewTab(settingsTab);
|
this.container.tabsManager.activateNewTab(settingsTab);
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error) => {
|
||||||
const errorMessage = getErrorMessage(error);
|
const errorMessage = getErrorMessage(error);
|
||||||
TelemetryProcessor.traceFailure(
|
TelemetryProcessor.traceFailure(
|
||||||
Action.Tab,
|
Action.Tab,
|
||||||
|
@ -114,7 +118,7 @@ export default class Database implements ViewModels.Database {
|
||||||
settingsTab.pendingNotification(pendingNotification);
|
settingsTab.pendingNotification(pendingNotification);
|
||||||
this.container.tabsManager.activateTab(settingsTab);
|
this.container.tabsManager.activateTab(settingsTab);
|
||||||
},
|
},
|
||||||
(error: any) => {
|
() => {
|
||||||
settingsTab.pendingNotification(undefined);
|
settingsTab.pendingNotification(undefined);
|
||||||
this.container.tabsManager.activateTab(settingsTab);
|
this.container.tabsManager.activateTab(settingsTab);
|
||||||
}
|
}
|
||||||
|
@ -190,8 +194,14 @@ export default class Database implements ViewModels.Database {
|
||||||
this.deleteCollectionsFromList(deltaCollections.toDelete);
|
this.deleteCollectionsFromList(deltaCollections.toDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
public openAddCollection(database: Database) {
|
public async openAddCollection(database: Database): Promise<void> {
|
||||||
database.container.openAddCollectionPanel(database.id());
|
await useDatabases.getState().loadDatabaseOffers();
|
||||||
|
useSidePanel
|
||||||
|
.getState()
|
||||||
|
.openSidePanel(
|
||||||
|
"New " + getCollectionName(),
|
||||||
|
<AddCollectionPanel explorer={database.container} databaseId={database.id()} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public findCollectionWithId(collectionId: string): ViewModels.Collection {
|
public findCollectionWithId(collectionId: string): ViewModels.Collection {
|
||||||
|
@ -221,7 +231,7 @@ export default class Database implements ViewModels.Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
return _.find(notifications, (notification: DataModels.Notification) => {
|
return _.find(notifications, (notification: DataModels.Notification) => {
|
||||||
const throughputUpdateRegExp: RegExp = new RegExp("Throughput update (.*) in progress");
|
const throughputUpdateRegExp = new RegExp("Throughput update (.*) in progress");
|
||||||
return (
|
return (
|
||||||
notification.kind === "message" &&
|
notification.kind === "message" &&
|
||||||
!notification.collectionName &&
|
!notification.collectionName &&
|
||||||
|
@ -259,7 +269,7 @@ export default class Database implements ViewModels.Database {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let collectionsToDelete: Collection[] = [];
|
const collectionsToDelete: Collection[] = [];
|
||||||
ko.utils.arrayForEach(this.collections(), (collection: Collection) => {
|
ko.utils.arrayForEach(this.collections(), (collection: Collection) => {
|
||||||
const collectionPresentInUpdatedList = _.some(
|
const collectionPresentInUpdatedList = _.some(
|
||||||
updatedCollectionsList,
|
updatedCollectionsList,
|
||||||
|
@ -299,7 +309,7 @@ export default class Database implements ViewModels.Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
public addSchema(collection: DataModels.Collection, interval?: number): NodeJS.Timeout {
|
public addSchema(collection: DataModels.Collection, interval?: number): NodeJS.Timeout {
|
||||||
let checkForSchema: NodeJS.Timeout = null;
|
let checkForSchema: NodeJS.Timeout;
|
||||||
interval = interval || 5000;
|
interval = interval || 5000;
|
||||||
|
|
||||||
if (collection.analyticalStorageTtl !== undefined && this.container.isSchemaEnabled()) {
|
if (collection.analyticalStorageTtl !== undefined && this.container.isSchemaEnabled()) {
|
||||||
|
@ -325,7 +335,7 @@ export default class Database implements ViewModels.Database {
|
||||||
clearInterval(checkForSchema);
|
clearInterval(checkForSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.data !== null) {
|
if (response.data !== undefined) {
|
||||||
clearInterval(checkForSchema);
|
clearInterval(checkForSchema);
|
||||||
collection.schema = response.data;
|
collection.schema = response.data;
|
||||||
}
|
}
|
Loading…
Reference in New Issue