mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 10:51:30 +00:00
Compare commits
6 Commits
tsStrict/f
...
users/lang
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
572d573fdd | ||
|
|
37c64c4a4d | ||
|
|
fc5ffeb7ca | ||
|
|
f39b6accb1 | ||
|
|
64601693b7 | ||
|
|
0c80c45e22 |
@@ -26,7 +26,7 @@ ko.components.register("throughput-input-autopilot-v3", ThroughputInputComponent
|
||||
ko.components.register("tabs-manager", TabsManagerKOComponent());
|
||||
|
||||
// Collection Tabs
|
||||
ko.components.register("documents-tab", new TabComponents.DocumentsTab());
|
||||
ko.components.register("documents-tab", new TabComponents.MongoDocumentsTabV2());
|
||||
ko.components.register("mongo-documents-tab", new TabComponents.MongoDocumentsTab());
|
||||
ko.components.register("stored-procedure-tab", new TabComponents.StoredProcedureTab());
|
||||
ko.components.register("trigger-tab", new TabComponents.TriggerTab());
|
||||
|
||||
@@ -2379,13 +2379,11 @@ export default class Explorer {
|
||||
this.tabsManager.activateTab(notebookTab);
|
||||
} else {
|
||||
const options: NotebookTabOptions = {
|
||||
account: userContext.databaseAccount,
|
||||
tabKind: ViewModels.CollectionTabKind.NotebookV2,
|
||||
node: null,
|
||||
title: notebookContentItem.name,
|
||||
tabPath: notebookContentItem.path,
|
||||
collection: null,
|
||||
masterKey: userContext.masterKey || "",
|
||||
hashLocation: "notebooks",
|
||||
isActive: ko.observable(false),
|
||||
isTabsContentExpanded: ko.observable(true),
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
.mongoQueryComponent {
|
||||
margin-left: 10px;
|
||||
|
||||
input {
|
||||
margin-top: 0;
|
||||
}
|
||||
label {
|
||||
padding: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
label:before {
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.queryInput {
|
||||
border: 1px solid black;
|
||||
margin: 5px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
import * as React from "react";
|
||||
import { Dispatch } from "redux";
|
||||
import MonacoEditor from "@nteract/monaco-editor";
|
||||
import { PrimaryButton } from "office-ui-fabric-react";
|
||||
import { ChoiceGroup, IChoiceGroupOption } from "office-ui-fabric-react/lib/ChoiceGroup";
|
||||
import Outputs from "@nteract/stateful-components/lib/outputs";
|
||||
import { KernelOutputError, StreamText } from "@nteract/outputs";
|
||||
import TransformMedia from "@nteract/stateful-components/lib/outputs/transform-media";
|
||||
import { actions, selectors, AppState, ContentRef, KernelRef } from "@nteract/core";
|
||||
import loadTransform from "../NotebookComponent/loadTransform";
|
||||
import { connect } from "react-redux";
|
||||
import Immutable from "immutable";
|
||||
|
||||
import "./MongoQueryComponent.less";
|
||||
interface MongoQueryComponentPureProps {
|
||||
contentRef: ContentRef;
|
||||
kernelRef: KernelRef;
|
||||
databaseId: string;
|
||||
collectionId: string;
|
||||
}
|
||||
|
||||
interface MongoQueryComponentDispatchProps {
|
||||
runCell: (contentRef: ContentRef, cellId: string) => void;
|
||||
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => void;
|
||||
onChange: (text: string, id: string, contentRef: ContentRef) => void;
|
||||
save: (contentRef: ContentRef) => void;
|
||||
}
|
||||
|
||||
type OutputType = "rich" | "json";
|
||||
|
||||
interface MongoQueryComponentState {
|
||||
outputType: OutputType;
|
||||
selectedId: string;
|
||||
}
|
||||
|
||||
const options: IChoiceGroupOption[] = [
|
||||
{ key: "rich", text: "Rich Output" },
|
||||
{ key: "json", text: "Json Output" }
|
||||
];
|
||||
|
||||
interface MongoKernelJsonOutput {
|
||||
results: any;
|
||||
}
|
||||
|
||||
interface MongoDocument {
|
||||
id: string;
|
||||
}
|
||||
|
||||
type MongoQueryComponentProps = MongoQueryComponentPureProps & StateProps & MongoQueryComponentDispatchProps;
|
||||
export class MongoQueryComponent extends React.Component<MongoQueryComponentProps, MongoQueryComponentState> {
|
||||
constructor(props: MongoQueryComponentProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
outputType: "json",
|
||||
selectedId: undefined
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount(): void {
|
||||
loadTransform(this.props);
|
||||
}
|
||||
|
||||
private onExecute = () => {
|
||||
this.props.runCell(this.props.contentRef, this.props.firstCellId);
|
||||
this.props.save(this.props.contentRef);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param databaseId
|
||||
* @param collectionId
|
||||
* @param query e.g. { "lastName": { $in: ["Andersen"] } }
|
||||
*/
|
||||
private createFilterQuery(databaseId: string, collectionId: string, query: string): string {
|
||||
const newCommand = `{ "command": "filter", "database": "${databaseId}", "collection": "${collectionId}", "filter": ${JSON.stringify(query)}, "outputType": "${this.state.outputType}" }`;
|
||||
return newCommand;
|
||||
}
|
||||
|
||||
private onOutputTypeChange = (e: React.FormEvent<HTMLElement | HTMLInputElement>, option: IChoiceGroupOption): void => {
|
||||
const outputType = option.key as OutputType;
|
||||
this.setState({ outputType }, () => this.onInputChange(this.props.inputValue));
|
||||
};
|
||||
|
||||
private onInputChange = (text: string) => {
|
||||
this.props.onChange(this.createFilterQuery(this.props.databaseId, this.props.collectionId, text),
|
||||
this.props.firstCellId, this.props.contentRef);
|
||||
};
|
||||
|
||||
render(): JSX.Element {
|
||||
const { firstCellId: id, contentRef, outputDocuments } = this.props;
|
||||
|
||||
if (!id) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mongoQueryComponent">
|
||||
<div className="queryInput">
|
||||
<MonacoEditor id={this.props.firstCellId} contentRef={this.props.contentRef} theme={""}
|
||||
language="json" onChange={this.onInputChange}
|
||||
value={this.props.inputValue} />
|
||||
</div>
|
||||
<PrimaryButton text="Apply" onClick={this.onExecute} disabled={!this.props.firstCellId} />
|
||||
<ChoiceGroup
|
||||
selectedKey={this.state.outputType}
|
||||
options={options}
|
||||
onChange={this.onOutputTypeChange}
|
||||
label="Output Type"
|
||||
styles={{ input: { marginTop: 0 }, root: { marginTop: 0 } }}
|
||||
/>
|
||||
<hr />
|
||||
<div style={ { display: "flex" } }>
|
||||
<ul>
|
||||
{outputDocuments && outputDocuments.map(d => (
|
||||
<li key={d.id}>
|
||||
<a onClick={() => this.setState({ selectedId: id })}>{d.id}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div style={{ width: "100%" }} >
|
||||
<MonacoEditor id={""} contentRef={""} theme={""} language="json" onChange={() => {}}
|
||||
value={JSON.stringify(outputDocuments.find(doc => doc.id ===this.state.selectedId)) ?? ""} />
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<Outputs id={id} contentRef={contentRef}>
|
||||
<TransformMedia output_type={"display_data"} id={id} contentRef={contentRef} />
|
||||
<TransformMedia output_type={"execute_result"} id={id} contentRef={contentRef} />
|
||||
<KernelOutputError />
|
||||
<StreamText />
|
||||
</Outputs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface StateProps {
|
||||
firstCellId: string;
|
||||
inputValue: string;
|
||||
outputDocuments: MongoDocument[];
|
||||
}
|
||||
interface InitialProps {
|
||||
contentRef: string;
|
||||
}
|
||||
|
||||
// Redux
|
||||
const makeMapStateToProps = (state: AppState, initialProps: InitialProps) => {
|
||||
const { contentRef } = initialProps;
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
let firstCellId;
|
||||
let inputValue = "";
|
||||
let outputDocuments = [];
|
||||
const content = selectors.content(state, { contentRef });
|
||||
if (content?.type === "notebook") {
|
||||
const cellOrder = selectors.notebook.cellOrder(content.model);
|
||||
if (cellOrder.size > 0) {
|
||||
firstCellId = cellOrder.first() as string;
|
||||
const cell = selectors.notebook.cellById(content.model, { id: firstCellId });
|
||||
|
||||
// Parse to extract filter and output type
|
||||
const cellValue = cell.get("source", "");
|
||||
if (cellValue) {
|
||||
try {
|
||||
const filterValue = JSON.parse(cellValue).filter;
|
||||
if (filterValue) {
|
||||
inputValue = filterValue;
|
||||
}
|
||||
} catch(e) {
|
||||
console.error("Could not parse", e);
|
||||
}
|
||||
}
|
||||
const outputs = cell.get("outputs", Immutable.List());
|
||||
// Extract "application/json" mime-type
|
||||
let jsonOutput: MongoKernelJsonOutput;
|
||||
for (const output of outputs) {
|
||||
if (Object.prototype.hasOwnProperty.call(output.data, "application/json")) {
|
||||
jsonOutput = output.data["application/json"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
outputDocuments = jsonOutput?.results ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
firstCellId,
|
||||
inputValue,
|
||||
outputDocuments
|
||||
};
|
||||
};
|
||||
return mapStateToProps;
|
||||
};
|
||||
|
||||
const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: MongoQueryComponentProps) => {
|
||||
const mapDispatchToProps = (dispatch: Dispatch) => {
|
||||
return {
|
||||
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => {
|
||||
return dispatch(
|
||||
actions.addTransform({
|
||||
mediaType: transform.MIMETYPE,
|
||||
component: transform
|
||||
})
|
||||
);
|
||||
},
|
||||
runCell: (contentRef: ContentRef, cellId: string) => {
|
||||
return dispatch(
|
||||
actions.executeCell({
|
||||
contentRef,
|
||||
id: cellId
|
||||
})
|
||||
);
|
||||
},
|
||||
onChange: (text: string, id: string, contentRef: ContentRef) => {
|
||||
dispatch(actions.updateCellSource({ id, contentRef, value: text }));
|
||||
},
|
||||
save: (contentRef: ContentRef) => {
|
||||
dispatch(actions.save({ contentRef }));
|
||||
}
|
||||
};
|
||||
};
|
||||
return mapDispatchToProps;
|
||||
};
|
||||
|
||||
export default connect(makeMapStateToProps, makeMapDispatchToProps)(MongoQueryComponent);
|
||||
@@ -0,0 +1,49 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { ReactAdapter } from "../../../Bindings/ReactBindingHandler";
|
||||
import {
|
||||
NotebookComponentBootstrapper,
|
||||
NotebookComponentBootstrapperOptions
|
||||
} from "../NotebookComponent/NotebookComponentBootstrapper";
|
||||
import MongoQueryComponent from "../MongoQueryComponent/MongoQueryComponent";
|
||||
import { actions, createContentRef, createKernelRef, KernelRef } from "@nteract/core";
|
||||
import { Provider } from "react-redux";
|
||||
|
||||
export class MongoQueryComponentAdapter extends NotebookComponentBootstrapper implements ReactAdapter {
|
||||
public parameters: unknown;
|
||||
private kernelRef: KernelRef;
|
||||
|
||||
constructor(options: NotebookComponentBootstrapperOptions, private databaseId: string, private collectionId: string) {
|
||||
super(options);
|
||||
|
||||
if (!this.contentRef) {
|
||||
this.contentRef = createContentRef();
|
||||
this.kernelRef = createKernelRef();
|
||||
|
||||
// Request fetching notebook content
|
||||
this.getStore().dispatch(
|
||||
actions.fetchContent({
|
||||
filepath: "mongo.ipynb",
|
||||
params: {},
|
||||
kernelRef: this.kernelRef,
|
||||
contentRef: this.contentRef
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public renderComponent(): JSX.Element {
|
||||
const props = {
|
||||
contentRef: this.contentRef,
|
||||
kernelRef: this.kernelRef,
|
||||
databaseId: this.databaseId,
|
||||
collectionId: this.collectionId
|
||||
};
|
||||
|
||||
return (
|
||||
<Provider store={this.getStore()}>
|
||||
<MongoQueryComponent {...props} />;
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
1
src/Explorer/Tabs/MongoDocumentsTabV2.html
Normal file
1
src/Explorer/Tabs/MongoDocumentsTabV2.html
Normal file
@@ -0,0 +1 @@
|
||||
<div data-bind="react:mongoQueryComponentAdapter" style="height: 100%"></div>
|
||||
45
src/Explorer/Tabs/MongoDocumentsTabV2.ts
Normal file
45
src/Explorer/Tabs/MongoDocumentsTabV2.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import * as Q from "q";
|
||||
import NotebookTabBase, { NotebookTabBaseOptions } from "./NotebookTabBase";
|
||||
import { MongoQueryComponentAdapter } from "../Notebook/MongoQueryComponent/MongoQueryComponentAdapter";
|
||||
|
||||
export default class MongoDocumentsTabV2 extends NotebookTabBase {
|
||||
private mongoQueryComponentAdapter: MongoQueryComponentAdapter;
|
||||
|
||||
constructor(options: NotebookTabBaseOptions) {
|
||||
super(options);
|
||||
this.mongoQueryComponentAdapter = new MongoQueryComponentAdapter({
|
||||
contentRef: undefined,
|
||||
notebookClient: NotebookTabBase.clientManager
|
||||
}, options.collection?.databaseId, options.collection?.id());
|
||||
}
|
||||
|
||||
public onCloseTabButtonClick(): Q.Promise<void> {
|
||||
super.onCloseTabButtonClick();
|
||||
|
||||
// const cleanup = () => {
|
||||
// this.notebookComponentAdapter.notebookShutdown();
|
||||
// this.isActive(false);
|
||||
// super.onCloseTabButtonClick();
|
||||
// };
|
||||
|
||||
// if (this.notebookComponentAdapter.isContentDirty()) {
|
||||
// this.container.showOkCancelModalDialog(
|
||||
// "Close without saving?",
|
||||
// `File has unsaved changes, close without saving?`,
|
||||
// "Close",
|
||||
// cleanup,
|
||||
// "Cancel",
|
||||
// undefined
|
||||
// );
|
||||
// return Q.resolve(null);
|
||||
// } else {
|
||||
// cleanup();
|
||||
// return Q.resolve(null);
|
||||
// }
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected buildCommandBarOptions(): void {
|
||||
this.updateNavbarWithTabsButtons();
|
||||
}
|
||||
}
|
||||
50
src/Explorer/Tabs/NotebookTabBase.ts
Normal file
50
src/Explorer/Tabs/NotebookTabBase.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import TabsBase from "./TabsBase";
|
||||
|
||||
import { NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import Explorer from "../Explorer";
|
||||
import { ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { Areas } from "../../Common/Constants";
|
||||
|
||||
export interface NotebookTabBaseOptions extends ViewModels.TabOptions {
|
||||
container: Explorer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every notebook-based tab inherits from this class. It holds the static reference to a notebook client (singleton)
|
||||
*/
|
||||
export default class NotebookTabBase extends TabsBase {
|
||||
protected static clientManager: NotebookClientV2;
|
||||
protected container: Explorer;
|
||||
|
||||
constructor(options: NotebookTabBaseOptions) {
|
||||
super(options);
|
||||
|
||||
this.container = options.container;
|
||||
|
||||
if (!NotebookTabBase.clientManager) {
|
||||
NotebookTabBase.clientManager = new NotebookClientV2({
|
||||
connectionInfo: this.container.notebookServerInfo(),
|
||||
databaseAccountName: this.container.databaseAccount().name,
|
||||
defaultExperience: this.container.defaultExperience(),
|
||||
contentProvider: this.container.notebookManager?.notebookContentProvider
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override base behavior
|
||||
*/
|
||||
protected getContainer(): Explorer {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
protected traceTelemetry(actionType: number): void {
|
||||
TelemetryProcessor.trace(actionType, ActionModifiers.Mark, {
|
||||
databaseAccountName: this.container.databaseAccount() && this.container.databaseAccount().name,
|
||||
defaultExperience: this.container.defaultExperience && this.container.defaultExperience(),
|
||||
dataExplorerArea: Areas.Notebook
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ import * as _ from "underscore";
|
||||
import * as Q from "q";
|
||||
import * as ko from "knockout";
|
||||
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import TabsBase from "./TabsBase";
|
||||
|
||||
import NewCellIcon from "../../../images/notebook/Notebook-insert-cell.svg";
|
||||
import CutIcon from "../../../images/notebook/Notebook-cut.svg";
|
||||
@@ -17,31 +15,25 @@ import SaveIcon from "../../../images/save-cosmos.svg";
|
||||
import ClearAllOutputsIcon from "../../../images/notebook/Notebook-clear-all-outputs.svg";
|
||||
import InterruptKernelIcon from "../../../images/notebook/Notebook-stop.svg";
|
||||
import KillKernelIcon from "../../../images/notebook/Notebook-stop.svg";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { Areas, ArmApiVersions } from "../../Common/Constants";
|
||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { ArmApiVersions } from "../../Common/Constants";
|
||||
import { CommandBarComponentButtonFactory } from "../Menus/CommandBar/CommandBarComponentButtonFactory";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter";
|
||||
import { NotebookConfigurationUtils } from "../../Utils/NotebookConfigurationUtils";
|
||||
import { KernelSpecsDisplay, NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
||||
import { KernelSpecsDisplay } from "../Notebook/NotebookClientV2";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import Explorer from "../Explorer";
|
||||
import { NotebookContentItem } from "../Notebook/NotebookContentItem";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
import { toJS, stringifyNotebook } from "@nteract/commutable";
|
||||
import NotebookTabBase, { NotebookTabBaseOptions } from "./NotebookTabBase";
|
||||
|
||||
export interface NotebookTabOptions extends ViewModels.TabOptions {
|
||||
account: DataModels.DatabaseAccount;
|
||||
masterKey: string;
|
||||
container: Explorer;
|
||||
export interface NotebookTabOptions extends NotebookTabBaseOptions {
|
||||
notebookContentItem: NotebookContentItem;
|
||||
}
|
||||
|
||||
export default class NotebookTabV2 extends TabsBase {
|
||||
private static clientManager: NotebookClientV2;
|
||||
private container: Explorer;
|
||||
export default class NotebookTabV2 extends NotebookTabBase {
|
||||
public notebookPath: ko.Observable<string>;
|
||||
private selectedSparkPool: ko.Observable<string>;
|
||||
private notebookComponentAdapter: NotebookComponentAdapter;
|
||||
@@ -50,16 +42,6 @@ export default class NotebookTabV2 extends TabsBase {
|
||||
super(options);
|
||||
|
||||
this.container = options.container;
|
||||
|
||||
if (!NotebookTabV2.clientManager) {
|
||||
NotebookTabV2.clientManager = new NotebookClientV2({
|
||||
connectionInfo: this.container.notebookServerInfo(),
|
||||
databaseAccountName: this.container.databaseAccount().name,
|
||||
defaultExperience: this.container.defaultExperience(),
|
||||
contentProvider: this.container.notebookManager?.notebookContentProvider
|
||||
});
|
||||
}
|
||||
|
||||
this.notebookPath = ko.observable(options.notebookContentItem.path);
|
||||
|
||||
this.container.notebookServerInfo.subscribe((newValue: DataModels.NotebookWorkspaceConnectionInfo) => {
|
||||
@@ -69,7 +51,7 @@ export default class NotebookTabV2 extends TabsBase {
|
||||
this.notebookComponentAdapter = new NotebookComponentAdapter({
|
||||
contentItem: options.notebookContentItem,
|
||||
notebooksBasePath: this.container.getNotebookBasePath(),
|
||||
notebookClient: NotebookTabV2.clientManager,
|
||||
notebookClient: NotebookTabBase.clientManager,
|
||||
onUpdateKernelInfo: this.onKernelUpdate
|
||||
});
|
||||
|
||||
@@ -115,10 +97,6 @@ export default class NotebookTabV2 extends TabsBase {
|
||||
return await this.configureServiceEndpoints(this.notebookComponentAdapter.getCurrentKernelName());
|
||||
}
|
||||
|
||||
protected getContainer(): Explorer {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
protected getTabsButtons(): CommandButtonComponentProps[] {
|
||||
const availableKernels = NotebookTabV2.clientManager.getAvailableKernelSpecs();
|
||||
|
||||
@@ -493,12 +471,4 @@ export default class NotebookTabV2 extends TabsBase {
|
||||
|
||||
this.container.copyNotebook(notebookContent.name, content);
|
||||
};
|
||||
|
||||
private traceTelemetry(actionType: number) {
|
||||
TelemetryProcessor.trace(actionType, ActionModifiers.Mark, {
|
||||
databaseAccountName: this.container.databaseAccount() && this.container.databaseAccount().name,
|
||||
defaultExperience: this.container.defaultExperience && this.container.defaultExperience(),
|
||||
dataExplorerArea: Areas.Notebook
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import SparkMasterTabTemplate from "./SparkMasterTab.html";
|
||||
import NotebookV2TabTemplate from "./NotebookV2Tab.html";
|
||||
import TerminalTabTemplate from "./TerminalTab.html";
|
||||
import MongoDocumentsTabTemplate from "./MongoDocumentsTab.html";
|
||||
import MongoDocumentsTabV2Template from "./MongoDocumentsTabV2.html";
|
||||
import MongoQueryTabTemplate from "./MongoQueryTab.html";
|
||||
import MongoShellTabTemplate from "./MongoShellTab.html";
|
||||
import QueryTabTemplate from "./QueryTab.html";
|
||||
@@ -106,6 +107,15 @@ export class MongoQueryTab {
|
||||
}
|
||||
}
|
||||
|
||||
export class MongoDocumentsTabV2 {
|
||||
constructor() {
|
||||
return {
|
||||
viewModel: TabComponent,
|
||||
template: MongoDocumentsTabV2Template
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class MongoShellTab {
|
||||
constructor() {
|
||||
return {
|
||||
|
||||
@@ -24,6 +24,7 @@ import ConflictsTab from "../Tabs/ConflictsTab";
|
||||
import DocumentsTab from "../Tabs/DocumentsTab";
|
||||
import GraphTab from "../Tabs/GraphTab";
|
||||
import MongoDocumentsTab from "../Tabs/MongoDocumentsTab";
|
||||
import MongoDocumentsTabV2 from "../Tabs/MongoDocumentsTabV2";
|
||||
import MongoQueryTab from "../Tabs/MongoQueryTab";
|
||||
import MongoShellTab from "../Tabs/MongoShellTab";
|
||||
import QueryTab from "../Tabs/QueryTab";
|
||||
@@ -506,11 +507,11 @@ export default class Collection implements ViewModels.Collection {
|
||||
dataExplorerArea: Constants.Areas.ResourceTree
|
||||
});
|
||||
|
||||
const mongoDocumentsTabs: MongoDocumentsTab[] = this.container.tabsManager.getTabs(
|
||||
const mongoDocumentsTabs: MongoDocumentsTabV2[] = this.container.tabsManager.getTabs(
|
||||
ViewModels.CollectionTabKind.Documents,
|
||||
tab => tab.collection && tab.collection.databaseId === this.databaseId && tab.collection.id() === this.id()
|
||||
) as MongoDocumentsTab[];
|
||||
let mongoDocumentsTab: MongoDocumentsTab = mongoDocumentsTabs && mongoDocumentsTabs[0];
|
||||
) as MongoDocumentsTabV2[];
|
||||
let mongoDocumentsTab: MongoDocumentsTabV2 = mongoDocumentsTabs && mongoDocumentsTabs[0];
|
||||
|
||||
if (mongoDocumentsTab) {
|
||||
this.container.tabsManager.activateTab(mongoDocumentsTab);
|
||||
@@ -525,9 +526,8 @@ export default class Collection implements ViewModels.Collection {
|
||||
});
|
||||
this.documentIds([]);
|
||||
|
||||
mongoDocumentsTab = new MongoDocumentsTab({
|
||||
partitionKey: this.partitionKey,
|
||||
documentIds: this.documentIds,
|
||||
mongoDocumentsTab = new MongoDocumentsTabV2({
|
||||
container: this.container,
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "Documents",
|
||||
tabPath: "",
|
||||
|
||||
Reference in New Issue
Block a user