Remove Explorer collection/database text properties (#821)

Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
Sunil Kumar Yadav 2021-05-25 19:02:40 +05:30 committed by GitHub
parent bfdeae56d9
commit 522fdc69ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 16 additions and 120 deletions

View File

@ -11,12 +11,12 @@ import DeleteUDFIcon from "../../images/DeleteUDF.svg";
import HostedTerminalIcon from "../../images/Hosted-Terminal.svg";
import * as ViewModels from "../Contracts/ViewModels";
import { userContext } from "../UserContext";
import { getCollectionName, getDatabaseName } from "../Utils/APITypeUtils";
import { TreeNodeMenuItem } from "./Controls/TreeComponent/TreeComponent";
import Explorer from "./Explorer";
import StoredProcedure from "./Tree/StoredProcedure";
import Trigger from "./Tree/Trigger";
import UserDefinedFunction from "./Tree/UserDefinedFunction";
export interface CollectionContextMenuButtonParams {
databaseId: string;
collectionId: string;
@ -34,7 +34,7 @@ export class ResourceTreeContextMenuButtonFactory {
{
iconSrc: AddCollectionIcon,
onClick: () => container.onNewCollectionClicked(databaseId),
label: container.addCollectionText(),
label: `New ${getCollectionName()}`,
},
];
@ -42,7 +42,7 @@ export class ResourceTreeContextMenuButtonFactory {
items.push({
iconSrc: DeleteDatabaseIcon,
onClick: () => container.openDeleteDatabaseConfirmationPane(),
label: container.deleteDatabaseText(),
label: `Delete ${getDatabaseName()}`,
styleClass: "deleteDatabaseMenuItem",
});
}
@ -115,7 +115,7 @@ export class ResourceTreeContextMenuButtonFactory {
items.push({
iconSrc: DeleteCollectionIcon,
onClick: () => container.openDeleteCollectionConfirmationPane(),
label: container.deleteCollectionText(),
label: `Delete ${getCollectionName()}`,
styleClass: "deleteCollectionMenuItem",
});

View File

@ -32,7 +32,6 @@ exports[`SettingsComponent renders 1`] = `
"_isInitializingNotebooks": false,
"_refreshSparkEnabledStateForAccount": [Function],
"_resetNotebookWorkspace": [Function],
"addCollectionText": [Function],
"arcadiaToken": [Function],
"canExceedMaximumValue": [Function],
"canSaveQueries": [Function],
@ -48,8 +47,6 @@ exports[`SettingsComponent renders 1`] = `
"unlimitedmin": 400,
},
},
"collectionTitle": [Function],
"collectionTreeNodeAltText": [Function],
"commandBarComponentAdapter": CommandBarComponentAdapter {
"container": [Circular],
"isNotebookTabActive": [Function],
@ -57,8 +54,6 @@ exports[`SettingsComponent renders 1`] = `
"tabsButtons": Array [],
},
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
"errorCallback": [Function],
"ocktokit": OctokitWithDefaults {
@ -858,7 +853,6 @@ exports[`SettingsComponent renders 1`] = `
"container": [Circular],
},
"refreshNotebookList": [Function],
"refreshTreeTitle": [Function],
"resourceTokenCollection": [Function],
"resourceTokenCollectionId": [Function],
"resourceTokenDatabaseId": [Function],
@ -923,7 +917,6 @@ exports[`SettingsComponent renders 1`] = `
"_isInitializingNotebooks": false,
"_refreshSparkEnabledStateForAccount": [Function],
"_resetNotebookWorkspace": [Function],
"addCollectionText": [Function],
"arcadiaToken": [Function],
"canExceedMaximumValue": [Function],
"canSaveQueries": [Function],
@ -939,8 +932,6 @@ exports[`SettingsComponent renders 1`] = `
"unlimitedmin": 400,
},
},
"collectionTitle": [Function],
"collectionTreeNodeAltText": [Function],
"commandBarComponentAdapter": CommandBarComponentAdapter {
"container": [Circular],
"isNotebookTabActive": [Function],
@ -948,8 +939,6 @@ exports[`SettingsComponent renders 1`] = `
"tabsButtons": Array [],
},
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
"errorCallback": [Function],
"ocktokit": OctokitWithDefaults {
@ -1749,7 +1738,6 @@ exports[`SettingsComponent renders 1`] = `
"container": [Circular],
},
"refreshNotebookList": [Function],
"refreshTreeTitle": [Function],
"resourceTokenCollection": [Function],
"resourceTokenCollectionId": [Function],
"resourceTokenDatabaseId": [Function],
@ -1827,7 +1815,6 @@ exports[`SettingsComponent renders 1`] = `
"_isInitializingNotebooks": false,
"_refreshSparkEnabledStateForAccount": [Function],
"_resetNotebookWorkspace": [Function],
"addCollectionText": [Function],
"arcadiaToken": [Function],
"canExceedMaximumValue": [Function],
"canSaveQueries": [Function],
@ -1843,8 +1830,6 @@ exports[`SettingsComponent renders 1`] = `
"unlimitedmin": 400,
},
},
"collectionTitle": [Function],
"collectionTreeNodeAltText": [Function],
"commandBarComponentAdapter": CommandBarComponentAdapter {
"container": [Circular],
"isNotebookTabActive": [Function],
@ -1852,8 +1837,6 @@ exports[`SettingsComponent renders 1`] = `
"tabsButtons": Array [],
},
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
"errorCallback": [Function],
"ocktokit": OctokitWithDefaults {
@ -2653,7 +2636,6 @@ exports[`SettingsComponent renders 1`] = `
"container": [Circular],
},
"refreshNotebookList": [Function],
"refreshTreeTitle": [Function],
"resourceTokenCollection": [Function],
"resourceTokenCollectionId": [Function],
"resourceTokenDatabaseId": [Function],
@ -2718,7 +2700,6 @@ exports[`SettingsComponent renders 1`] = `
"_isInitializingNotebooks": false,
"_refreshSparkEnabledStateForAccount": [Function],
"_resetNotebookWorkspace": [Function],
"addCollectionText": [Function],
"arcadiaToken": [Function],
"canExceedMaximumValue": [Function],
"canSaveQueries": [Function],
@ -2734,8 +2715,6 @@ exports[`SettingsComponent renders 1`] = `
"unlimitedmin": 400,
},
},
"collectionTitle": [Function],
"collectionTreeNodeAltText": [Function],
"commandBarComponentAdapter": CommandBarComponentAdapter {
"container": [Circular],
"isNotebookTabActive": [Function],
@ -2743,8 +2722,6 @@ exports[`SettingsComponent renders 1`] = `
"tabsButtons": Array [],
},
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
"errorCallback": [Function],
"ocktokit": OctokitWithDefaults {
@ -3544,7 +3521,6 @@ exports[`SettingsComponent renders 1`] = `
"container": [Circular],
},
"refreshNotebookList": [Function],
"refreshTreeTitle": [Function],
"resourceTokenCollection": [Function],
"resourceTokenCollectionId": [Function],
"resourceTokenDatabaseId": [Function],

View File

@ -97,12 +97,6 @@ export interface ExplorerParams {
}
export default class Explorer {
public addCollectionText: ko.Observable<string>;
public collectionTitle: ko.Observable<string>;
public deleteCollectionText: ko.Observable<string>;
public deleteDatabaseText: ko.Observable<string>;
public collectionTreeNodeAltText: ko.Observable<string>;
public refreshTreeTitle: ko.Observable<string>;
public collapsedResourceTreeWidth: number = ExplorerMetrics.CollapsedResourceTreeWidth;
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
@ -199,13 +193,6 @@ export default class Explorer {
const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, {
dataExplorerArea: Constants.Areas.ResourceTree,
});
this.addCollectionText = ko.observable<string>("New Collection");
this.collectionTitle = ko.observable<string>("Collections");
this.collectionTreeNodeAltText = ko.observable<string>("Collection");
this.deleteCollectionText = ko.observable<string>("Delete Collection");
this.deleteDatabaseText = ko.observable<string>("Delete Database");
this.refreshTreeTitle = ko.observable<string>("Refresh collections");
this.isAccountReady = ko.observable<boolean>(false);
this._isInitializingNotebooks = false;
this.arcadiaToken = ko.observable<string>();
@ -420,46 +407,10 @@ export default class Explorer {
});
switch (userContext.apiType) {
case "SQL":
this.addCollectionText("New Container");
this.collectionTitle("SQL API");
this.collectionTreeNodeAltText("Container");
this.deleteCollectionText("Delete Container");
this.deleteDatabaseText("Delete Database");
this.refreshTreeTitle("Refresh containers");
break;
case "Mongo":
this.addCollectionText("New Collection");
this.collectionTitle("Collections");
this.collectionTreeNodeAltText("Collection");
this.deleteCollectionText("Delete Collection");
this.deleteDatabaseText("Delete Database");
this.refreshTreeTitle("Refresh collections");
break;
case "Gremlin":
this.addCollectionText("New Graph");
this.deleteCollectionText("Delete Graph");
this.deleteDatabaseText("Delete Database");
this.collectionTitle("Gremlin API");
this.collectionTreeNodeAltText("Graph");
this.refreshTreeTitle("Refresh graphs");
break;
case "Tables":
this.addCollectionText("New Table");
this.deleteCollectionText("Delete Table");
this.deleteDatabaseText("Delete Database");
this.collectionTitle("Azure Table API");
this.collectionTreeNodeAltText("Table");
this.refreshTreeTitle("Refresh tables");
this.tableDataClient = new TablesAPIDataClient();
break;
case "Cassandra":
this.addCollectionText("New Table");
this.deleteCollectionText("Delete Table");
this.deleteDatabaseText("Delete Keyspace");
this.collectionTitle("Cassandra API");
this.collectionTreeNodeAltText("Table");
this.refreshTreeTitle("Refresh tables");
this.tableDataClient = new CassandraAPIDataClient();
break;
}

View File

@ -30,9 +30,6 @@ export class CommandBarComponentAdapter implements ReactAdapter {
// These are the parameters watched by the react binding that will trigger a renderComponent() if one of the ko mutates
const toWatch = [
container.deleteCollectionText,
container.deleteDatabaseText,
container.addCollectionText,
container.isDatabaseNodeOrNoneSelected,
container.isDatabaseNodeSelected,
container.isNoneSelected,

View File

@ -15,7 +15,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
beforeAll(() => {
mockExplorer = {} as Explorer;
mockExplorer.addCollectionText = ko.observable("mockText");
updateUserContext({
databaseAccount: {
properties: {
@ -58,7 +57,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
beforeAll(() => {
mockExplorer = {} as Explorer;
mockExplorer.addCollectionText = ko.observable("mockText");
updateUserContext({
databaseAccount: {
properties: {
@ -126,7 +124,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
beforeAll(() => {
mockExplorer = {} as Explorer;
mockExplorer.addCollectionText = ko.observable("mockText");
updateUserContext({
databaseAccount: {
properties: {
@ -226,7 +223,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
beforeAll(() => {
mockExplorer = {} as Explorer;
mockExplorer.addCollectionText = ko.observable("mockText");
updateUserContext({
databaseAccount: {
properties: {
@ -318,7 +314,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
beforeAll(() => {
mockExplorer = {} as Explorer;
mockExplorer.addCollectionText = ko.observable("mockText");
updateUserContext({
databaseAccount: {
properties: {
@ -380,7 +375,6 @@ describe("CommandBarComponentButtonFactory tests", () => {
describe("Resource token", () => {
beforeAll(() => {
mockExplorer = {} as Explorer;
mockExplorer.addCollectionText = ko.observable("mockText");
mockExplorer.isDatabaseNodeOrNoneSelected = () => true;
mockExplorer.isResourceTokenCollectionNodeSelected = ko.computed(() => true);
mockExplorer.isServerlessEnabled = ko.computed<boolean>(() => false);

View File

@ -22,7 +22,7 @@ import * as Constants from "../../../Common/Constants";
import { configContext, Platform } from "../../../ConfigContext";
import * as ViewModels from "../../../Contracts/ViewModels";
import { userContext } from "../../../UserContext";
import { getDatabaseName } from "../../../Utils/APITypeUtils";
import { getCollectionName, getDatabaseName } from "../../../Utils/APITypeUtils";
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
import Explorer from "../../Explorer";
import { OpenFullScreen } from "../../OpenFullScreen";
@ -215,7 +215,7 @@ function areScriptsSupported(): boolean {
}
function createNewCollectionGroup(container: Explorer): CommandButtonComponentProps {
const label = container.addCollectionText();
const label = `New ${getCollectionName()}`;
return {
iconSrc: AddCollectionIcon,
iconAlt: label,

View File

@ -21,7 +21,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
"_isInitializingNotebooks": false,
"_refreshSparkEnabledStateForAccount": [Function],
"_resetNotebookWorkspace": [Function],
"addCollectionText": [Function],
"arcadiaToken": [Function],
"canExceedMaximumValue": [Function],
"canSaveQueries": [Function],
@ -37,8 +36,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
"unlimitedmin": 400,
},
},
"collectionTitle": [Function],
"collectionTreeNodeAltText": [Function],
"commandBarComponentAdapter": CommandBarComponentAdapter {
"container": [Circular],
"isNotebookTabActive": [Function],
@ -46,8 +43,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
"tabsButtons": Array [],
},
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
"errorCallback": [Function],
"ocktokit": OctokitWithDefaults {
@ -847,7 +842,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = `
"container": [Circular],
},
"refreshNotebookList": [Function],
"refreshTreeTitle": [Function],
"resourceTokenCollection": [Function],
"resourceTokenCollectionId": [Function],
"resourceTokenDatabaseId": [Function],

View File

@ -11,7 +11,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
"_isInitializingNotebooks": false,
"_refreshSparkEnabledStateForAccount": [Function],
"_resetNotebookWorkspace": [Function],
"addCollectionText": [Function],
"arcadiaToken": [Function],
"canExceedMaximumValue": [Function],
"canSaveQueries": [Function],
@ -27,8 +26,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
"unlimitedmin": 400,
},
},
"collectionTitle": [Function],
"collectionTreeNodeAltText": [Function],
"commandBarComponentAdapter": CommandBarComponentAdapter {
"container": [Circular],
"isNotebookTabActive": [Function],
@ -36,8 +33,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
"tabsButtons": Array [],
},
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
"errorCallback": [Function],
"ocktokit": OctokitWithDefaults {
@ -837,7 +832,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = `
"container": [Circular],
},
"refreshNotebookList": [Function],
"refreshTreeTitle": [Function],
"resourceTokenCollection": [Function],
"resourceTokenCollectionId": [Function],
"resourceTokenDatabaseId": [Function],

View File

@ -9,7 +9,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
"_isInitializingNotebooks": false,
"_refreshSparkEnabledStateForAccount": [Function],
"_resetNotebookWorkspace": [Function],
"addCollectionText": [Function],
"arcadiaToken": [Function],
"canExceedMaximumValue": [Function],
"canSaveQueries": [Function],
@ -25,8 +24,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
"unlimitedmin": 400,
},
},
"collectionTitle": [Function],
"collectionTreeNodeAltText": [Function],
"commandBarComponentAdapter": CommandBarComponentAdapter {
"container": [Circular],
"isNotebookTabActive": [Function],
@ -34,8 +31,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
"tabsButtons": Array [],
},
"databases": [Function],
"deleteCollectionText": [Function],
"deleteDatabaseText": [Function],
"gitHubClient": GitHubClient {
"errorCallback": [Function],
"ocktokit": OctokitWithDefaults {
@ -839,7 +834,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database
},
"refreshAllDatabases": [Function],
"refreshNotebookList": [Function],
"refreshTreeTitle": [Function],
"resourceTokenCollection": [Function],
"resourceTokenCollectionId": [Function],
"resourceTokenDatabaseId": [Function],

View File

@ -1,15 +1,14 @@
import * as ko from "knockout";
import { DataSamplesUtil } from "../DataSamples/DataSamplesUtil";
import { SplashScreen } from "./SplashScreen";
import { TabsManager } from "../Tabs/TabsManager";
import Explorer from "../Explorer";
import { TabsManager } from "../Tabs/TabsManager";
import { SplashScreen } from "./SplashScreen";
jest.mock("../Explorer");
const createExplorer = () => {
const mock = new Explorer();
mock.selectedNode = ko.observable();
mock.isNotebookEnabled = ko.observable(false);
mock.addCollectionText = ko.observable("add collection");
mock.tabsManager = new TabsManager();
return mock as jest.Mocked<Explorer>;
};

View File

@ -17,7 +17,7 @@ import { AuthType } from "../../AuthType";
import * as Constants from "../../Common/Constants";
import * as ViewModels from "../../Contracts/ViewModels";
import { userContext } from "../../UserContext";
import { getDatabaseName } from "../../Utils/APITypeUtils";
import { getCollectionName, getDatabaseName } from "../../Utils/APITypeUtils";
import { FeaturePanelLauncher } from "../Controls/FeaturePanel/FeaturePanelLauncher";
import { DataSamplesUtil } from "../DataSamples/DataSamplesUtil";
import Explorer from "../Explorer";
@ -192,7 +192,7 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
const heroes: SplashScreenItem[] = [
{
iconSrc: NewContainerIcon,
title: this.container.addCollectionText(),
title: `New ${getCollectionName()}`,
description: "Create a new container for storage and throughput",
onClick: () => this.container.onNewCollectionClicked(),
},

View File

@ -1,4 +1,3 @@
import * as ko from "knockout";
import * as DataModels from "../../Contracts/DataModels";
import Explorer from "../Explorer";
import Collection from "./Collection";
@ -36,8 +35,6 @@ describe("Collection", () => {
return false;
};
mockContainer.deleteCollectionText = ko.observable<string>("delete collection");
return generateCollection(mockContainer, "abc", data, {} as DataModels.Offer);
}

View File

@ -55,6 +55,7 @@ import { useTabs } from "./hooks/useTabs";
import "./Libs/jquery";
import "./Shared/appInsights";
import { userContext } from "./UserContext";
import { getCollectionName } from "./Utils/APITypeUtils";
initializeIcons();
@ -83,6 +84,8 @@ const App: React.FunctionComponent = () => {
return <LoadingExplorer />;
}
const collectionTitle = `${getCollectionName()} API`;
const refreshTreeTitle = `Refresh ${getCollectionName()}`;
return (
<div className="flexContainer">
<div id="divExplorer" className="flexContainer hideOverflows">
@ -105,7 +108,7 @@ const App: React.FunctionComponent = () => {
{/* Collections Window Title/Command Bar - Start */}
<div className="collectiontitle">
<div className="coltitle">
<span className="titlepadcol" data-bind="text: collectionTitle" />
<span className="titlepadcol">{collectionTitle}</span>
<div className="float-right">
<span
className="padimgcolrefresh"
@ -117,7 +120,7 @@ const App: React.FunctionComponent = () => {
aria-label="Refresh tree"
title="Refresh tree"
>
<img className="refreshcol" src={refreshImg} data-bind="attr: { alt: refreshTreeTitle }" />
<img className="refreshcol" src={refreshImg} alt={refreshTreeTitle} />
</span>
<span
className="padimgcolrefresh1"
@ -172,10 +175,7 @@ const App: React.FunctionComponent = () => {
data-bind="
click: toggleLeftPaneExpanded"
>
<span
data-bind="
text: collectionTitle"
/>
<span>{collectionTitle}</span>
</span>
</li>
</ul>