mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-12 11:15:16 +00:00
Remove Explorer.mostRecentActivity (#455)
This also moves the UI concerns of MostRecentActivity over to SplashScreen Co-authored-by: Steve Faulkner <stfaul@microsoft.com>
This commit is contained in:
parent
3cd2ec93f2
commit
7188e8d8c2
@ -962,13 +962,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"memoryUsageInfo": [Function],
|
"memoryUsageInfo": [Function],
|
||||||
"mostRecentActivity": MostRecentActivity {
|
|
||||||
"container": [Circular],
|
|
||||||
"storedData": Object {
|
|
||||||
"itemsMap": Object {},
|
|
||||||
"schemaVersion": "1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"newVertexPane": NewVertexPane {
|
"newVertexPane": NewVertexPane {
|
||||||
"buildString": [Function],
|
"buildString": [Function],
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@ -2178,13 +2171,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"memoryUsageInfo": [Function],
|
"memoryUsageInfo": [Function],
|
||||||
"mostRecentActivity": MostRecentActivity {
|
|
||||||
"container": [Circular],
|
|
||||||
"storedData": Object {
|
|
||||||
"itemsMap": Object {},
|
|
||||||
"schemaVersion": "1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"newVertexPane": NewVertexPane {
|
"newVertexPane": NewVertexPane {
|
||||||
"buildString": [Function],
|
"buildString": [Function],
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@ -3407,13 +3393,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"memoryUsageInfo": [Function],
|
"memoryUsageInfo": [Function],
|
||||||
"mostRecentActivity": MostRecentActivity {
|
|
||||||
"container": [Circular],
|
|
||||||
"storedData": Object {
|
|
||||||
"itemsMap": Object {},
|
|
||||||
"schemaVersion": "1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"newVertexPane": NewVertexPane {
|
"newVertexPane": NewVertexPane {
|
||||||
"buildString": [Function],
|
"buildString": [Function],
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@ -4623,13 +4602,6 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"memoryUsageInfo": [Function],
|
"memoryUsageInfo": [Function],
|
||||||
"mostRecentActivity": MostRecentActivity {
|
|
||||||
"container": [Circular],
|
|
||||||
"storedData": Object {
|
|
||||||
"itemsMap": Object {},
|
|
||||||
"schemaVersion": "1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"newVertexPane": NewVertexPane {
|
"newVertexPane": NewVertexPane {
|
||||||
"buildString": [Function],
|
"buildString": [Function],
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
|
@ -3,7 +3,6 @@ import * as ComponentRegisterer from "./ComponentRegisterer";
|
|||||||
import * as Constants from "../Common/Constants";
|
import * as Constants from "../Common/Constants";
|
||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as MostRecentActivity from "./MostRecentActivity/MostRecentActivity";
|
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as SharedConstants from "../Shared/Constants";
|
import * as SharedConstants from "../Shared/Constants";
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
@ -140,7 +139,6 @@ export default class Explorer {
|
|||||||
public queriesClient: QueriesClient;
|
public queriesClient: QueriesClient;
|
||||||
public tableDataClient: TableDataClient;
|
public tableDataClient: TableDataClient;
|
||||||
public splitter: Splitter;
|
public splitter: Splitter;
|
||||||
public mostRecentActivity: MostRecentActivity.MostRecentActivity;
|
|
||||||
|
|
||||||
// Notification Console
|
// Notification Console
|
||||||
private setIsNotificationConsoleExpanded: (isExpanded: boolean) => void;
|
private setIsNotificationConsoleExpanded: (isExpanded: boolean) => void;
|
||||||
@ -924,8 +922,6 @@ export default class Explorer {
|
|||||||
|
|
||||||
featureSubcription.dispose();
|
featureSubcription.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.mostRecentActivity = new MostRecentActivity.MostRecentActivity(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public openEnableSynapseLinkDialog(): void {
|
public openEnableSynapseLinkDialog(): void {
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
|
||||||
import { StorageKey, LocalStorageUtility } from "../../Shared/StorageUtility";
|
import { StorageKey, LocalStorageUtility } from "../../Shared/StorageUtility";
|
||||||
|
|
||||||
import CollectionIcon from "../../../images/tree-collection.svg";
|
|
||||||
import NotebookIcon from "../../../images/notebook/Notebook-resource.svg";
|
|
||||||
import Explorer from "../Explorer";
|
|
||||||
|
|
||||||
export enum Type {
|
export enum Type {
|
||||||
OpenCollection,
|
OpenCollection,
|
||||||
OpenNotebook,
|
OpenNotebook,
|
||||||
@ -36,11 +31,11 @@ interface StoredData {
|
|||||||
/**
|
/**
|
||||||
* Stores most recent activity
|
* Stores most recent activity
|
||||||
*/
|
*/
|
||||||
export class MostRecentActivity {
|
class MostRecentActivity {
|
||||||
private static readonly schemaVersion: string = "1";
|
private static readonly schemaVersion: string = "1";
|
||||||
private static itemsMaxNumber: number = 5;
|
private static itemsMaxNumber: number = 5;
|
||||||
private storedData: StoredData;
|
private storedData: StoredData;
|
||||||
constructor(private container: Explorer) {
|
constructor() {
|
||||||
// Retrieve from local storage
|
// Retrieve from local storage
|
||||||
if (LocalStorageUtility.hasItem(StorageKey.MostRecentActivity)) {
|
if (LocalStorageUtility.hasItem(StorageKey.MostRecentActivity)) {
|
||||||
const rawData = LocalStorageUtility.getEntryString(StorageKey.MostRecentActivity);
|
const rawData = LocalStorageUtility.getEntryString(StorageKey.MostRecentActivity);
|
||||||
@ -121,42 +116,6 @@ export class MostRecentActivity {
|
|||||||
this.saveToLocalStorage();
|
this.saveToLocalStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onItemClicked(item: Item) {
|
|
||||||
switch (item.type) {
|
|
||||||
case Type.OpenCollection: {
|
|
||||||
const openCollectionitem = item.data as OpenCollectionItem;
|
|
||||||
const collection = this.container.findCollection(
|
|
||||||
openCollectionitem.databaseId,
|
|
||||||
openCollectionitem.collectionId
|
|
||||||
);
|
|
||||||
if (collection) {
|
|
||||||
collection.openTab();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Type.OpenNotebook: {
|
|
||||||
const openNotebookItem = item.data as OpenNotebookItem;
|
|
||||||
const notebookItem = this.container.createNotebookContentItemFile(openNotebookItem.name, openNotebookItem.path);
|
|
||||||
notebookItem && this.container.openNotebook(notebookItem);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
console.error("Unknown item type", item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getItemIcon(item: Item): string {
|
|
||||||
switch (item.type) {
|
|
||||||
case Type.OpenCollection:
|
|
||||||
return CollectionIcon;
|
|
||||||
case Type.OpenNotebook:
|
|
||||||
return NotebookIcon;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find items by doing strict comparison and remove from array if duplicate is found
|
* Find items by doing strict comparison and remove from array if duplicate is found
|
||||||
* @param item
|
* @param item
|
||||||
@ -203,3 +162,5 @@ export class MostRecentActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const mostRecentActivity = new MostRecentActivity();
|
||||||
|
@ -18,6 +18,8 @@ import { DataSamplesUtil } from "../DataSamples/DataSamplesUtil";
|
|||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import { FeaturePanelLauncher } from "../Controls/FeaturePanel/FeaturePanelLauncher";
|
import { FeaturePanelLauncher } from "../Controls/FeaturePanel/FeaturePanelLauncher";
|
||||||
|
import CollectionIcon from "../../../images/tree-collection.svg";
|
||||||
|
import NotebookIcon from "../../../images/notebook/Notebook-resource.svg";
|
||||||
|
|
||||||
export interface SplashScreenItem {
|
export interface SplashScreenItem {
|
||||||
iconSrc: string;
|
iconSrc: string;
|
||||||
@ -53,7 +55,7 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private clearMostRecent = (): void => {
|
private clearMostRecent = (): void => {
|
||||||
this.container.mostRecentActivity.clear(userContext.databaseAccount?.id);
|
MostRecentActivity.mostRecentActivity.clear(userContext.databaseAccount?.id);
|
||||||
this.setState({});
|
this.setState({});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -202,6 +204,42 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||||||
return heroes;
|
return heroes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getItemIcon(item: MostRecentActivity.Item): string {
|
||||||
|
switch (item.type) {
|
||||||
|
case MostRecentActivity.Type.OpenCollection:
|
||||||
|
return CollectionIcon;
|
||||||
|
case MostRecentActivity.Type.OpenNotebook:
|
||||||
|
return NotebookIcon;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private onItemClicked(item: MostRecentActivity.Item) {
|
||||||
|
switch (item.type) {
|
||||||
|
case MostRecentActivity.Type.OpenCollection: {
|
||||||
|
const openCollectionitem = item.data as MostRecentActivity.OpenCollectionItem;
|
||||||
|
const collection = this.container.findCollection(
|
||||||
|
openCollectionitem.databaseId,
|
||||||
|
openCollectionitem.collectionId
|
||||||
|
);
|
||||||
|
if (collection) {
|
||||||
|
collection.openTab();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MostRecentActivity.Type.OpenNotebook: {
|
||||||
|
const openNotebookItem = item.data as MostRecentActivity.OpenNotebookItem;
|
||||||
|
const notebookItem = this.container.createNotebookContentItemFile(openNotebookItem.name, openNotebookItem.path);
|
||||||
|
notebookItem && this.container.openNotebook(notebookItem);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
console.error("Unknown item type", item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private createCommonTaskItems(): SplashScreenItem[] {
|
private createCommonTaskItems(): SplashScreenItem[] {
|
||||||
const items: SplashScreenItem[] = [];
|
const items: SplashScreenItem[] = [];
|
||||||
|
|
||||||
@ -292,12 +330,12 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createRecentItems(): SplashScreenItem[] {
|
private createRecentItems(): SplashScreenItem[] {
|
||||||
return this.container.mostRecentActivity.getItems(userContext.databaseAccount?.id).map((item) => ({
|
return MostRecentActivity.mostRecentActivity.getItems(userContext.databaseAccount?.id).map((item) => ({
|
||||||
iconSrc: MostRecentActivity.MostRecentActivity.getItemIcon(item),
|
iconSrc: this.getItemIcon(item),
|
||||||
title: item.title,
|
title: item.title,
|
||||||
description: item.description,
|
description: item.description,
|
||||||
info: SplashScreen.getInfo(item),
|
info: SplashScreen.getInfo(item),
|
||||||
onClick: () => this.container.mostRecentActivity.onItemClicked(item),
|
onClick: () => this.onItemClicked(item),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
collection.openTab();
|
collection.openTab();
|
||||||
// push to most recent
|
// push to most recent
|
||||||
this.container.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
MostRecentActivity.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||||
type: MostRecentActivity.Type.OpenCollection,
|
type: MostRecentActivity.Type.OpenCollection,
|
||||||
title: collection.id(),
|
title: collection.id(),
|
||||||
description: "Data",
|
description: "Data",
|
||||||
@ -625,7 +625,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private pushItemToMostRecent(item: NotebookContentItem) {
|
private pushItemToMostRecent(item: NotebookContentItem) {
|
||||||
this.container.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
MostRecentActivity.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||||
type: MostRecentActivity.Type.OpenNotebook,
|
type: MostRecentActivity.Type.OpenNotebook,
|
||||||
title: item.name,
|
title: item.name,
|
||||||
description: "Notebook",
|
description: "Notebook",
|
||||||
|
@ -13,7 +13,6 @@ const createMockContainer = (): Explorer => {
|
|||||||
let mockContainer = {} as Explorer;
|
let mockContainer = {} as Explorer;
|
||||||
mockContainer.resourceTokenCollection = createMockCollection(mockContainer);
|
mockContainer.resourceTokenCollection = createMockCollection(mockContainer);
|
||||||
mockContainer.selectedNode = ko.observable<ViewModels.TreeNode>();
|
mockContainer.selectedNode = ko.observable<ViewModels.TreeNode>();
|
||||||
mockContainer.mostRecentActivity = new MostRecentActivity.MostRecentActivity(mockContainer);
|
|
||||||
mockContainer.onUpdateTabsButtons = () => {};
|
mockContainer.onUpdateTabsButtons = () => {};
|
||||||
|
|
||||||
return mockContainer;
|
return mockContainer;
|
||||||
|
@ -44,7 +44,7 @@ export class ResourceTreeAdapterForResourceToken implements ReactAdapter {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
collection.onDocumentDBDocumentsClick();
|
collection.onDocumentDBDocumentsClick();
|
||||||
// push to most recent
|
// push to most recent
|
||||||
this.container.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
MostRecentActivity.mostRecentActivity.addItem(userContext.databaseAccount?.id, {
|
||||||
type: MostRecentActivity.Type.OpenCollection,
|
type: MostRecentActivity.Type.OpenCollection,
|
||||||
title: collection.id(),
|
title: collection.id(),
|
||||||
description: "Data",
|
description: "Data",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user