Remove route handlers (#909)

* Remove tab handlers

* Fix tests
This commit is contained in:
victor-meng
2021-06-23 21:54:37 -07:00
committed by GitHub
parent 6b35ab03f2
commit 59655eed5f
20 changed files with 5 additions and 630 deletions

View File

@@ -15,7 +15,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
hashLocation: "",
});
expect(documentsTab.buildQuery("")).toContain("select");
@@ -90,7 +89,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
hashLocation: "",
});
expect(documentsTab.showPartitionKey).toBe(false);
@@ -104,7 +102,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
hashLocation: "",
});
expect(documentsTab.showPartitionKey).toBe(false);
@@ -118,7 +115,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
hashLocation: "",
});
expect(documentsTab.showPartitionKey).toBe(true);
@@ -135,7 +131,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
hashLocation: "",
});
expect(documentsTab.showPartitionKey).toBe(false);
@@ -149,7 +144,6 @@ describe("Documents tab", () => {
tabKind: ViewModels.CollectionTabKind.Documents,
title: "",
tabPath: "",
hashLocation: "",
});
expect(documentsTab.showPartitionKey).toBe(true);

View File

@@ -37,7 +37,6 @@ export class NewStoredProcedureTab extends ScriptTabBase {
tabPath: options.tabPath,
collectionBase: options.collection,
node: options.node,
hasLocation: options.hashLocation,
scriptTabBaseInstance: this,
collection: props.collection,
iStorProcTabComponentAccessor: (instance: IStorProcTabComponentAccessor) => {

View File

@@ -4,7 +4,6 @@ import React from "react";
import DiscardIcon from "../../../../images/discard.svg";
import ExecuteQueryIcon from "../../../../images/ExecuteQuery.svg";
import SaveIcon from "../../../../images/save-cosmos.svg";
import * as Constants from "../../../Common/Constants";
import { NormalizedEventKey } from "../../../Common/Constants";
import { createStoredProcedure } from "../../../Common/dataAccess/createStoredProcedure";
import { ExecuteSprocResult } from "../../../Common/dataAccess/executeStoredProcedure";
@@ -55,7 +54,6 @@ export interface IStoredProcTabComponentProps {
collectionBase: ViewModels.CollectionBase;
//eslint-disable-next-line
node?: any;
hasLocation: string;
scriptTabBaseInstance: ScriptTabBase;
collection: ViewModels.Collection;
iStorProcTabComponentAccessor: (instance: IStorProcTabComponentAccessor) => void;
@@ -389,12 +387,6 @@ export default class StoredProcedureTabComponent extends React.Component<
this.props.scriptTabBaseInstance.tabTitle(createdResource.id);
this.props.scriptTabBaseInstance.isNew(false);
this.props.scriptTabBaseInstance.resource(createdResource);
this.props.scriptTabBaseInstance.hashLocation(
`${Constants.HashRoutePrefixes.collectionsWithIds(
this.props.collectionBase.databaseId,
this.props.collectionBase.id()
)}/sprocs/${createdResource.id}`
);
this.props.scriptTabBaseInstance.setBaselines();
const editorModel =

View File

@@ -4,7 +4,6 @@ import * as ThemeUtility from "../../Common/ThemeUtility";
import * as DataModels from "../../Contracts/DataModels";
import * as ViewModels from "../../Contracts/ViewModels";
import { useNotificationConsole } from "../../hooks/useNotificationConsole";
import { RouteHandler } from "../../RouteHandlers/RouteHandler";
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
@@ -25,7 +24,6 @@ export default class TabsBase extends WaitsForTemplateViewModel {
public tabKind: ViewModels.CollectionTabKind;
public tabTitle: ko.Observable<string>;
public tabPath: ko.Observable<string>;
public hashLocation: ko.Observable<string>;
public isExecutionError = ko.observable(false);
public isExecuting = ko.observable(false);
public pendingNotification?: ko.Observable<DataModels.Notification>;
@@ -49,8 +47,6 @@ export default class TabsBase extends WaitsForTemplateViewModel {
ko.observable<string>(`${this.collection.databaseId}>${this.collection.id()}>${this.tabTitle()}`));
this.pendingNotification = ko.observable<DataModels.Notification>(undefined);
this.onLoadStartKey = options.onLoadStartKey;
this.hashLocation = ko.observable<string>(options.hashLocation || "");
this.hashLocation.subscribe((newLocation: string) => this.updateGlobalHash(newLocation));
this.closeTabButton = {
enabled: ko.computed<boolean>(() => {
return true;
@@ -114,7 +110,6 @@ export default class TabsBase extends WaitsForTemplateViewModel {
this.updateSelectedNode();
this.collection?.selectedSubnodeKind(this.tabKind);
this.database?.selectedSubnodeKind(this.tabKind);
this.updateGlobalHash(this.hashLocation());
this.updateNavbarWithTabsButtons();
TelemetryProcessor.trace(Action.Tab, ActionModifiers.Open, {
tabName: this.constructor.name,
@@ -152,10 +147,6 @@ export default class TabsBase extends WaitsForTemplateViewModel {
return JSON.stringify(value, replacer, space);
}
private updateGlobalHash(newHash: string): void {
RouteHandler.getInstance().updateRouteHashLocation(newHash);
}
/**
* @return buttons that are displayed in the navbar
*/

View File

@@ -53,7 +53,6 @@ describe("Tabs manager tests", () => {
database,
title: "",
tabPath: "",
hashLocation: "",
queryText: "",
partitionKey: collection.partitionKey,
onLoadStartKey: 1,
@@ -70,7 +69,6 @@ describe("Tabs manager tests", () => {
collection,
title: "",
tabPath: "",
hashLocation: "",
});
// make sure tabs have different tabId

View File

@@ -100,12 +100,6 @@ export class TriggerTabContent extends Component<TriggerTab, ITriggerTabContentS
this.props.tabTitle(createdResource.id);
this.props.isNew(false);
this.props.resource(createdResource);
this.props.hashLocation(
`${Constants.HashRoutePrefixes.collectionsWithIds(
this.props.collection.databaseId,
this.props.collection.id()
)}/triggers/${createdResource.id}`
);
this.props.editorContent.setBaseline(createdResource.body as string);
this.props.addNodeInCollection(createdResource);
this.saveButton.visible = false;

View File

@@ -145,12 +145,6 @@ export default class UserDefinedFunctionTabContent extends Component<
this.updateButton.visible = true;
this.saveButton.visible = false;
this.props.resource(createdResource);
this.props.hashLocation(
`${Constants.HashRoutePrefixes.collectionsWithIds(
this.props.collection.databaseId,
this.props.collection.id()
)}/udfs/${createdResource.id}`
);
this.props.addNodeInCollection(createdResource);
this.setState({ isUdfIdEditable: false });
this.props.isExecuting(false);