mirror of
				https://github.com/Azure/cosmos-explorer.git
				synced 2025-10-30 22:50:32 +00:00 
			
		
		
		
	Migrate remaining notification console methods to zustand (#873)
This commit is contained in:
		
							parent
							
								
									fc9f4c5583
								
							
						
					
					
						commit
						bcc9f8dd32
					
				| @ -6,7 +6,7 @@ import { | |||||||
|   UserDefinedFunctionDefinition, |   UserDefinedFunctionDefinition, | ||||||
| } from "@azure/cosmos"; | } from "@azure/cosmos"; | ||||||
| import Explorer from "../Explorer/Explorer"; | import Explorer from "../Explorer/Explorer"; | ||||||
| import { ConsoleData } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent"; | import { ConsoleData } from "../Explorer/Menus/NotificationConsole/ConsoleData"; | ||||||
| import { CassandraTableKey, CassandraTableKeys } from "../Explorer/Tables/TableDataClient"; | import { CassandraTableKey, CassandraTableKeys } from "../Explorer/Tables/TableDataClient"; | ||||||
| import ConflictId from "../Explorer/Tree/ConflictId"; | import ConflictId from "../Explorer/Tree/ConflictId"; | ||||||
| import DocumentId from "../Explorer/Tree/DocumentId"; | import DocumentId from "../Explorer/Tree/DocumentId"; | ||||||
|  | |||||||
| @ -71,8 +71,6 @@ exports[`SettingsComponent renders 1`] = ` | |||||||
|                 }, |                 }, | ||||||
|                 "selectedDatabaseId": [Function], |                 "selectedDatabaseId": [Function], | ||||||
|                 "selectedNode": [Function], |                 "selectedNode": [Function], | ||||||
|                 "setInProgressConsoleDataIdToBeDeleted": undefined, |  | ||||||
|                 "setNotificationConsoleData": undefined, |  | ||||||
|                 "sparkClusterConnectionInfo": [Function], |                 "sparkClusterConnectionInfo": [Function], | ||||||
|                 "tabsManager": TabsManager { |                 "tabsManager": TabsManager { | ||||||
|                   "activeTab": [Function], |                   "activeTab": [Function], | ||||||
| @ -142,8 +140,6 @@ exports[`SettingsComponent renders 1`] = ` | |||||||
|               }, |               }, | ||||||
|               "selectedDatabaseId": [Function], |               "selectedDatabaseId": [Function], | ||||||
|               "selectedNode": [Function], |               "selectedNode": [Function], | ||||||
|               "setInProgressConsoleDataIdToBeDeleted": undefined, |  | ||||||
|               "setNotificationConsoleData": undefined, |  | ||||||
|               "sparkClusterConnectionInfo": [Function], |               "sparkClusterConnectionInfo": [Function], | ||||||
|               "tabsManager": TabsManager { |               "tabsManager": TabsManager { | ||||||
|                 "activeTab": [Function], |                 "activeTab": [Function], | ||||||
| @ -226,8 +222,6 @@ exports[`SettingsComponent renders 1`] = ` | |||||||
|                 }, |                 }, | ||||||
|                 "selectedDatabaseId": [Function], |                 "selectedDatabaseId": [Function], | ||||||
|                 "selectedNode": [Function], |                 "selectedNode": [Function], | ||||||
|                 "setInProgressConsoleDataIdToBeDeleted": undefined, |  | ||||||
|                 "setNotificationConsoleData": undefined, |  | ||||||
|                 "sparkClusterConnectionInfo": [Function], |                 "sparkClusterConnectionInfo": [Function], | ||||||
|                 "tabsManager": TabsManager { |                 "tabsManager": TabsManager { | ||||||
|                   "activeTab": [Function], |                   "activeTab": [Function], | ||||||
| @ -297,8 +291,6 @@ exports[`SettingsComponent renders 1`] = ` | |||||||
|               }, |               }, | ||||||
|               "selectedDatabaseId": [Function], |               "selectedDatabaseId": [Function], | ||||||
|               "selectedNode": [Function], |               "selectedNode": [Function], | ||||||
|               "setInProgressConsoleDataIdToBeDeleted": undefined, |  | ||||||
|               "setNotificationConsoleData": undefined, |  | ||||||
|               "sparkClusterConnectionInfo": [Function], |               "sparkClusterConnectionInfo": [Function], | ||||||
|               "tabsManager": TabsManager { |               "tabsManager": TabsManager { | ||||||
|                 "activeTab": [Function], |                 "activeTab": [Function], | ||||||
|  | |||||||
| @ -41,7 +41,6 @@ import * as ComponentRegisterer from "./ComponentRegisterer"; | |||||||
| import { DialogProps, TextFieldProps, useDialog } from "./Controls/Dialog"; | import { DialogProps, TextFieldProps, useDialog } from "./Controls/Dialog"; | ||||||
| import { GalleryTab as GalleryTabKind } from "./Controls/NotebookGallery/GalleryViewerComponent"; | import { GalleryTab as GalleryTabKind } from "./Controls/NotebookGallery/GalleryViewerComponent"; | ||||||
| import { useCommandBar } from "./Menus/CommandBar/CommandBarComponentAdapter"; | import { useCommandBar } from "./Menus/CommandBar/CommandBarComponentAdapter"; | ||||||
| import { ConsoleData } from "./Menus/NotificationConsole/NotificationConsoleComponent"; |  | ||||||
| import * as FileSystemUtil from "./Notebook/FileSystemUtil"; | import * as FileSystemUtil from "./Notebook/FileSystemUtil"; | ||||||
| import { SnapshotRequest } from "./Notebook/NotebookComponent/types"; | import { SnapshotRequest } from "./Notebook/NotebookComponent/types"; | ||||||
| import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem"; | import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem"; | ||||||
| @ -83,8 +82,6 @@ BindingHandlersRegisterer.registerBindingHandlers(); | |||||||
| var tmp = ComponentRegisterer; | var tmp = ComponentRegisterer; | ||||||
| 
 | 
 | ||||||
| export interface ExplorerParams { | export interface ExplorerParams { | ||||||
|   setNotificationConsoleData: (consoleData: ConsoleData) => void; |  | ||||||
|   setInProgressConsoleDataIdToBeDeleted: (id: string) => void; |  | ||||||
|   tabsManager: TabsManager; |   tabsManager: TabsManager; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -96,9 +93,6 @@ export default class Explorer { | |||||||
|   public queriesClient: QueriesClient; |   public queriesClient: QueriesClient; | ||||||
|   public tableDataClient: TableDataClient; |   public tableDataClient: TableDataClient; | ||||||
| 
 | 
 | ||||||
|   private setNotificationConsoleData: (consoleData: ConsoleData) => void; |  | ||||||
|   private setInProgressConsoleDataIdToBeDeleted: (id: string) => void; |  | ||||||
| 
 |  | ||||||
|   // Resource Tree
 |   // Resource Tree
 | ||||||
|   public databases: ko.ObservableArray<ViewModels.Database>; |   public databases: ko.ObservableArray<ViewModels.Database>; | ||||||
|   public selectedDatabaseId: ko.Computed<string>; |   public selectedDatabaseId: ko.Computed<string>; | ||||||
| @ -145,9 +139,6 @@ export default class Explorer { | |||||||
|   private static readonly MaxNbDatabasesToAutoExpand = 5; |   private static readonly MaxNbDatabasesToAutoExpand = 5; | ||||||
| 
 | 
 | ||||||
|   constructor(params?: ExplorerParams) { |   constructor(params?: ExplorerParams) { | ||||||
|     this.setNotificationConsoleData = params?.setNotificationConsoleData; |  | ||||||
|     this.setInProgressConsoleDataIdToBeDeleted = params?.setInProgressConsoleDataIdToBeDeleted; |  | ||||||
| 
 |  | ||||||
|     const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, { |     const startKey: number = TelemetryProcessor.traceStart(Action.InitializeDataExplorer, { | ||||||
|       dataExplorerArea: Constants.Areas.ResourceTree, |       dataExplorerArea: Constants.Areas.ResourceTree, | ||||||
|     }); |     }); | ||||||
| @ -444,14 +435,6 @@ export default class Explorer { | |||||||
|     return this.selectedNode() == null; |     return this.selectedNode() == null; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public logConsoleData(consoleData: ConsoleData): void { |  | ||||||
|     this.setNotificationConsoleData(consoleData); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   public deleteInProgressConsoleDataWithId(id: string): void { |  | ||||||
|     this.setInProgressConsoleDataIdToBeDeleted(id); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   public refreshDatabaseForResourceToken(): Q.Promise<any> { |   public refreshDatabaseForResourceToken(): Q.Promise<any> { | ||||||
|     const databaseId = this.resourceTokenDatabaseId(); |     const databaseId = this.resourceTokenDatabaseId(); | ||||||
|     const collectionId = this.resourceTokenCollectionId(); |     const collectionId = this.resourceTokenCollectionId(); | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ import { queryDocumentsPage } from "../../../Common/dataAccess/queryDocumentsPag | |||||||
| import * as DataModels from "../../../Contracts/DataModels"; | import * as DataModels from "../../../Contracts/DataModels"; | ||||||
| import * as StorageUtility from "../../../Shared/StorageUtility"; | import * as StorageUtility from "../../../Shared/StorageUtility"; | ||||||
| import { TabComponent } from "../../Controls/Tabs/TabComponent"; | import { TabComponent } from "../../Controls/Tabs/TabComponent"; | ||||||
| import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; | import { ConsoleDataType } from "../../Menus/NotificationConsole/ConsoleData"; | ||||||
| import GraphTab from "../../Tabs/GraphTab"; | import GraphTab from "../../Tabs/GraphTab"; | ||||||
| import * as D3ForceGraph from "./D3ForceGraph"; | import * as D3ForceGraph from "./D3ForceGraph"; | ||||||
| import { GraphData } from "./GraphData"; | import { GraphData } from "./GraphData"; | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Ut | |||||||
| import { EditorReact } from "../../Controls/Editor/EditorReact"; | import { EditorReact } from "../../Controls/Editor/EditorReact"; | ||||||
| import * as InputTypeaheadComponent from "../../Controls/InputTypeahead/InputTypeaheadComponent"; | import * as InputTypeaheadComponent from "../../Controls/InputTypeahead/InputTypeaheadComponent"; | ||||||
| import * as TabComponent from "../../Controls/Tabs/TabComponent"; | import * as TabComponent from "../../Controls/Tabs/TabComponent"; | ||||||
| import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; | import { ConsoleDataType } from "../../Menus/NotificationConsole/ConsoleData"; | ||||||
| import { IGraphConfig } from "../../Tabs/GraphTab"; | import { IGraphConfig } from "../../Tabs/GraphTab"; | ||||||
| import { ArraysByKeyCache } from "./ArraysByKeyCache"; | import { ArraysByKeyCache } from "./ArraysByKeyCache"; | ||||||
| import * as D3ForceGraph from "./D3ForceGraph"; | import * as D3ForceGraph from "./D3ForceGraph"; | ||||||
|  | |||||||
| @ -5,21 +5,26 @@ | |||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| import * as React from "react"; | import * as React from "react"; | ||||||
| import { GraphHighlightedNodeData, EditedProperties, EditedEdges, PossibleVertex } from "./GraphExplorer"; |  | ||||||
| import { CollapsiblePanel } from "../../Controls/CollapsiblePanel/CollapsiblePanel"; |  | ||||||
| import { ReadOnlyNodePropertiesComponent } from "./ReadOnlyNodePropertiesComponent"; |  | ||||||
| import { EditorNodePropertiesComponent } from "./EditorNodePropertiesComponent"; |  | ||||||
| import { ReadOnlyNeighborsComponent } from "./ReadOnlyNeighborsComponent"; |  | ||||||
| import * as ViewModels from "../../../Contracts/ViewModels"; |  | ||||||
| import { Item } from "../../Controls/InputTypeahead/InputTypeaheadComponent"; |  | ||||||
| import * as EditorNeighbors from "./EditorNeighborsComponent"; |  | ||||||
| import EditIcon from "../../../../images/edit.svg"; |  | ||||||
| import DeleteIcon from "../../../../images/delete.svg"; |  | ||||||
| import CheckIcon from "../../../../images/check.svg"; |  | ||||||
| import CancelIcon from "../../../../images/cancel.svg"; | import CancelIcon from "../../../../images/cancel.svg"; | ||||||
| import { GraphExplorer } from "./GraphExplorer"; | import CheckIcon from "../../../../images/check.svg"; | ||||||
| import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent"; | import DeleteIcon from "../../../../images/delete.svg"; | ||||||
|  | import EditIcon from "../../../../images/edit.svg"; | ||||||
|  | import * as ViewModels from "../../../Contracts/ViewModels"; | ||||||
| import { AccessibleElement } from "../../Controls/AccessibleElement/AccessibleElement"; | import { AccessibleElement } from "../../Controls/AccessibleElement/AccessibleElement"; | ||||||
|  | import { CollapsiblePanel } from "../../Controls/CollapsiblePanel/CollapsiblePanel"; | ||||||
|  | import { Item } from "../../Controls/InputTypeahead/InputTypeaheadComponent"; | ||||||
|  | import { ConsoleDataType } from "../../Menus/NotificationConsole/ConsoleData"; | ||||||
|  | import * as EditorNeighbors from "./EditorNeighborsComponent"; | ||||||
|  | import { EditorNodePropertiesComponent } from "./EditorNodePropertiesComponent"; | ||||||
|  | import { | ||||||
|  |   EditedEdges, | ||||||
|  |   EditedProperties, | ||||||
|  |   GraphExplorer, | ||||||
|  |   GraphHighlightedNodeData, | ||||||
|  |   PossibleVertex, | ||||||
|  | } from "./GraphExplorer"; | ||||||
|  | import { ReadOnlyNeighborsComponent } from "./ReadOnlyNeighborsComponent"; | ||||||
|  | import { ReadOnlyNodePropertiesComponent } from "./ReadOnlyNodePropertiesComponent"; | ||||||
| 
 | 
 | ||||||
| export enum Mode { | export enum Mode { | ||||||
|   READONLY_PROP, |   READONLY_PROP, | ||||||
|  | |||||||
							
								
								
									
										16
									
								
								src/Explorer/Menus/NotificationConsole/ConsoleData.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/Explorer/Menus/NotificationConsole/ConsoleData.tsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | /** | ||||||
|  |  * Interface for the data/content that will be recorded | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | export interface ConsoleData { | ||||||
|  |   type: ConsoleDataType; | ||||||
|  |   date: string; | ||||||
|  |   message: string; | ||||||
|  |   id?: string; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export enum ConsoleDataType { | ||||||
|  |   Info = 0, | ||||||
|  |   Error = 1, | ||||||
|  |   InProgress = 2, | ||||||
|  | } | ||||||
| @ -1,10 +1,7 @@ | |||||||
| import { shallow } from "enzyme"; | import { shallow } from "enzyme"; | ||||||
| import React from "react"; | import React from "react"; | ||||||
| import { | import { ConsoleDataType } from "./ConsoleData"; | ||||||
|   ConsoleDataType, | import { NotificationConsoleComponent, NotificationConsoleComponentProps } from "./NotificationConsoleComponent"; | ||||||
|   NotificationConsoleComponent, |  | ||||||
|   NotificationConsoleComponentProps, |  | ||||||
| } from "./NotificationConsoleComponent"; |  | ||||||
| 
 | 
 | ||||||
| describe("NotificationConsoleComponent", () => { | describe("NotificationConsoleComponent", () => { | ||||||
|   const createBlankProps = (): NotificationConsoleComponentProps => { |   const createBlankProps = (): NotificationConsoleComponentProps => { | ||||||
|  | |||||||
| @ -17,25 +17,7 @@ import ChevronUpIcon from "../../../../images/QueryBuilder/CollapseChevronUp_16x | |||||||
| import { ClientDefaults, KeyCodes } from "../../../Common/Constants"; | import { ClientDefaults, KeyCodes } from "../../../Common/Constants"; | ||||||
| import { useNotificationConsole } from "../../../hooks/useNotificationConsole"; | import { useNotificationConsole } from "../../../hooks/useNotificationConsole"; | ||||||
| import { userContext } from "../../../UserContext"; | import { userContext } from "../../../UserContext"; | ||||||
| 
 | import { ConsoleData, ConsoleDataType } from "./ConsoleData"; | ||||||
| /** |  | ||||||
|  * Log levels |  | ||||||
|  */ |  | ||||||
| export enum ConsoleDataType { |  | ||||||
|   Info = 0, |  | ||||||
|   Error = 1, |  | ||||||
|   InProgress = 2, |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * Interface for the data/content that will be recorded |  | ||||||
|  */ |  | ||||||
| export interface ConsoleData { |  | ||||||
|   type: ConsoleDataType; |  | ||||||
|   date: string; |  | ||||||
|   message: string; |  | ||||||
|   id?: string; |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| export interface NotificationConsoleComponentProps { | export interface NotificationConsoleComponentProps { | ||||||
|   isConsoleExpanded: boolean; |   isConsoleExpanded: boolean; | ||||||
| @ -323,14 +305,13 @@ const PrPreview = (props: { pr: string }) => { | |||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const NotificationConsole: React.FC< | export const NotificationConsole: React.FC = () => { | ||||||
|   Pick<NotificationConsoleComponentProps, "consoleData" | "inProgressConsoleDataIdToBeDeleted"> |  | ||||||
| > = ({ |  | ||||||
|   consoleData, |  | ||||||
|   inProgressConsoleDataIdToBeDeleted, |  | ||||||
| }: Pick<NotificationConsoleComponentProps, "consoleData" | "inProgressConsoleDataIdToBeDeleted">) => { |  | ||||||
|   const setIsExpanded = useNotificationConsole((state) => state.setIsExpanded); |   const setIsExpanded = useNotificationConsole((state) => state.setIsExpanded); | ||||||
|   const isExpanded = useNotificationConsole((state) => state.isExpanded); |   const isExpanded = useNotificationConsole((state) => state.isExpanded); | ||||||
|  |   const consoleData = useNotificationConsole((state) => state.consoleData); | ||||||
|  |   const inProgressConsoleDataIdToBeDeleted = useNotificationConsole( | ||||||
|  |     (state) => state.inProgressConsoleDataIdToBeDeleted | ||||||
|  |   ); | ||||||
|   // TODO Refactor NotificationConsoleComponent into a functional component and remove this wrapper
 |   // TODO Refactor NotificationConsoleComponent into a functional component and remove this wrapper
 | ||||||
|   // This component only exists so we can use hooks and pass them down to a non-functional component
 |   // This component only exists so we can use hooks and pass them down to a non-functional component
 | ||||||
|   return ( |   return ( | ||||||
|  | |||||||
| @ -43,7 +43,7 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect | |||||||
|               variant="small" |               variant="small" | ||||||
|             > |             > | ||||||
|               <span |               <span | ||||||
|                 className="css-102" |                 className="css-53" | ||||||
|               > |               > | ||||||
|                 Confirm by typing the  |                 Confirm by typing the  | ||||||
|                 container |                 container | ||||||
| @ -347,18 +347,18 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect | |||||||
|                 value="" |                 value="" | ||||||
|               > |               > | ||||||
|                 <div |                 <div | ||||||
|                   className="ms-TextField root-104" |                   className="ms-TextField root-55" | ||||||
|                 > |                 > | ||||||
|                   <div |                   <div | ||||||
|                     className="ms-TextField-wrapper" |                     className="ms-TextField-wrapper" | ||||||
|                   > |                   > | ||||||
|                     <div |                     <div | ||||||
|                       className="ms-TextField-fieldGroup fieldGroup-105" |                       className="ms-TextField-fieldGroup fieldGroup-56" | ||||||
|                     > |                     > | ||||||
|                       <input |                       <input | ||||||
|                         aria-invalid={false} |                         aria-invalid={false} | ||||||
|                         autoFocus={true} |                         autoFocus={true} | ||||||
|                         className="ms-TextField-field field-106" |                         className="ms-TextField-field field-57" | ||||||
|                         id="confirmCollectionId" |                         id="confirmCollectionId" | ||||||
|                         onBlur={[Function]} |                         onBlur={[Function]} | ||||||
|                         onChange={[Function]} |                         onChange={[Function]} | ||||||
| @ -381,7 +381,7 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect | |||||||
|               variant="small" |               variant="small" | ||||||
|             > |             > | ||||||
|               <span |               <span | ||||||
|                 className="css-115" |                 className="css-66" | ||||||
|               > |               > | ||||||
|                 Help us improve Azure Cosmos DB! |                 Help us improve Azure Cosmos DB! | ||||||
|               </span> |               </span> | ||||||
| @ -391,7 +391,7 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect | |||||||
|               variant="small" |               variant="small" | ||||||
|             > |             > | ||||||
|               <span |               <span | ||||||
|                 className="css-115" |                 className="css-66" | ||||||
|               > |               > | ||||||
|                 What is the reason why you are deleting this  |                 What is the reason why you are deleting this  | ||||||
|                 container |                 container | ||||||
| @ -697,17 +697,17 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect | |||||||
|                 value="" |                 value="" | ||||||
|               > |               > | ||||||
|                 <div |                 <div | ||||||
|                   className="ms-TextField ms-TextField--multiline root-104" |                   className="ms-TextField ms-TextField--multiline root-55" | ||||||
|                 > |                 > | ||||||
|                   <div |                   <div | ||||||
|                     className="ms-TextField-wrapper" |                     className="ms-TextField-wrapper" | ||||||
|                   > |                   > | ||||||
|                     <div |                     <div | ||||||
|                       className="ms-TextField-fieldGroup fieldGroup-116" |                       className="ms-TextField-fieldGroup fieldGroup-67" | ||||||
|                     > |                     > | ||||||
|                       <textarea |                       <textarea | ||||||
|                         aria-invalid={false} |                         aria-invalid={false} | ||||||
|                         className="ms-TextField-field field-117" |                         className="ms-TextField-field field-68" | ||||||
|                         id="deleteCollectionFeedbackInput" |                         id="deleteCollectionFeedbackInput" | ||||||
|                         onBlur={[Function]} |                         onBlur={[Function]} | ||||||
|                         onChange={[Function]} |                         onChange={[Function]} | ||||||
| @ -2434,7 +2434,7 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect | |||||||
|                   > |                   > | ||||||
|                     <button |                     <button | ||||||
|                       aria-label="OK" |                       aria-label="OK" | ||||||
|                       className="ms-Button ms-Button--primary root-119" |                       className="ms-Button ms-Button--primary root-70" | ||||||
|                       data-is-focusable={true} |                       data-is-focusable={true} | ||||||
|                       id="sidePanelOkButton" |                       id="sidePanelOkButton" | ||||||
|                       onClick={[Function]} |                       onClick={[Function]} | ||||||
| @ -2446,14 +2446,14 @@ exports[`Delete Collection Confirmation Pane submit() should call delete collect | |||||||
|                       type="submit" |                       type="submit" | ||||||
|                     > |                     > | ||||||
|                       <span |                       <span | ||||||
|                         className="ms-Button-flexContainer flexContainer-120" |                         className="ms-Button-flexContainer flexContainer-71" | ||||||
|                         data-automationid="splitbuttonprimary" |                         data-automationid="splitbuttonprimary" | ||||||
|                       > |                       > | ||||||
|                         <span |                         <span | ||||||
|                           className="ms-Button-textContainer textContainer-121" |                           className="ms-Button-textContainer textContainer-72" | ||||||
|                         > |                         > | ||||||
|                           <span |                           <span | ||||||
|                             className="ms-Button-label label-123" |                             className="ms-Button-label label-74" | ||||||
|                             id="id__6" |                             id="id__6" | ||||||
|                             key="id__6" |                             key="id__6" | ||||||
|                           > |                           > | ||||||
|  | |||||||
| @ -60,8 +60,6 @@ exports[`GitHub Repos Panel should render Default properly 1`] = ` | |||||||
|             }, |             }, | ||||||
|             "selectedDatabaseId": [Function], |             "selectedDatabaseId": [Function], | ||||||
|             "selectedNode": [Function], |             "selectedNode": [Function], | ||||||
|             "setInProgressConsoleDataIdToBeDeleted": undefined, |  | ||||||
|             "setNotificationConsoleData": undefined, |  | ||||||
|             "sparkClusterConnectionInfo": [Function], |             "sparkClusterConnectionInfo": [Function], | ||||||
|             "tabsManager": TabsManager { |             "tabsManager": TabsManager { | ||||||
|               "activeTab": [Function], |               "activeTab": [Function], | ||||||
|  | |||||||
| @ -50,8 +50,6 @@ exports[`StringInput Pane should render Create new directory properly 1`] = ` | |||||||
|       }, |       }, | ||||||
|       "selectedDatabaseId": [Function], |       "selectedDatabaseId": [Function], | ||||||
|       "selectedNode": [Function], |       "selectedNode": [Function], | ||||||
|       "setInProgressConsoleDataIdToBeDeleted": undefined, |  | ||||||
|       "setNotificationConsoleData": undefined, |  | ||||||
|       "sparkClusterConnectionInfo": [Function], |       "sparkClusterConnectionInfo": [Function], | ||||||
|       "tabsManager": TabsManager { |       "tabsManager": TabsManager { | ||||||
|         "activeTab": [Function], |         "activeTab": [Function], | ||||||
|  | |||||||
| @ -52,8 +52,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|       }, |       }, | ||||||
|       "selectedDatabaseId": [Function], |       "selectedDatabaseId": [Function], | ||||||
|       "selectedNode": [Function], |       "selectedNode": [Function], | ||||||
|       "setInProgressConsoleDataIdToBeDeleted": undefined, |  | ||||||
|       "setNotificationConsoleData": undefined, |  | ||||||
|       "sparkClusterConnectionInfo": [Function], |       "sparkClusterConnectionInfo": [Function], | ||||||
|       "tabsManager": TabsManager { |       "tabsManager": TabsManager { | ||||||
|         "activeTab": [Function], |         "activeTab": [Function], | ||||||
| @ -90,7 +88,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|           verticalAlign="center" |           verticalAlign="center" | ||||||
|         > |         > | ||||||
|           <div |           <div | ||||||
|             className="ms-Stack panelInfoErrorContainer css-102" |             className="ms-Stack panelInfoErrorContainer css-53" | ||||||
|           > |           > | ||||||
|             <StyledIconBase |             <StyledIconBase | ||||||
|               aria-label="warning" |               aria-label="warning" | ||||||
| @ -379,7 +377,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|               > |               > | ||||||
|                 <i |                 <i | ||||||
|                   aria-label="warning" |                   aria-label="warning" | ||||||
|                   className="panelWarningIcon root-104" |                   className="panelWarningIcon root-55" | ||||||
|                   data-icon-name="WarningSolid" |                   data-icon-name="WarningSolid" | ||||||
|                   role="img" |                   role="img" | ||||||
|                 > |                 > | ||||||
| @ -398,7 +396,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|               > |               > | ||||||
|                 <span |                 <span | ||||||
|                   aria-label="message" |                   aria-label="message" | ||||||
|                   className="panelWarningErrorMessage css-105" |                   className="panelWarningErrorMessage css-56" | ||||||
|                 > |                 > | ||||||
|                   Warning! The action you are about to take cannot be undone. Continuing will permanently delete this resource and all of its children resources. |                   Warning! The action you are about to take cannot be undone. Continuing will permanently delete this resource and all of its children resources. | ||||||
|                 </span> |                 </span> | ||||||
| @ -422,7 +420,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|             variant="small" |             variant="small" | ||||||
|           > |           > | ||||||
|             <span |             <span | ||||||
|               className="css-105" |               className="css-56" | ||||||
|             > |             > | ||||||
|               Confirm by typing the database id |               Confirm by typing the database id | ||||||
|             </span> |             </span> | ||||||
| @ -722,18 +720,18 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|               validateOnLoad={true} |               validateOnLoad={true} | ||||||
|             > |             > | ||||||
|               <div |               <div | ||||||
|                 className="ms-TextField root-107" |                 className="ms-TextField root-58" | ||||||
|               > |               > | ||||||
|                 <div |                 <div | ||||||
|                   className="ms-TextField-wrapper" |                   className="ms-TextField-wrapper" | ||||||
|                 > |                 > | ||||||
|                   <div |                   <div | ||||||
|                     className="ms-TextField-fieldGroup fieldGroup-108" |                     className="ms-TextField-fieldGroup fieldGroup-59" | ||||||
|                   > |                   > | ||||||
|                     <input |                     <input | ||||||
|                       aria-invalid={false} |                       aria-invalid={false} | ||||||
|                       autoFocus={true} |                       autoFocus={true} | ||||||
|                       className="ms-TextField-field field-109" |                       className="ms-TextField-field field-60" | ||||||
|                       id="confirmDatabaseId" |                       id="confirmDatabaseId" | ||||||
|                       onBlur={[Function]} |                       onBlur={[Function]} | ||||||
|                       onChange={[Function]} |                       onChange={[Function]} | ||||||
| @ -756,7 +754,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|             variant="small" |             variant="small" | ||||||
|           > |           > | ||||||
|             <span |             <span | ||||||
|               className="css-126" |               className="css-77" | ||||||
|             > |             > | ||||||
|               Help us improve Azure Cosmos DB! |               Help us improve Azure Cosmos DB! | ||||||
|             </span> |             </span> | ||||||
| @ -766,7 +764,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|             variant="small" |             variant="small" | ||||||
|           > |           > | ||||||
|             <span |             <span | ||||||
|               className="css-126" |               className="css-77" | ||||||
|             > |             > | ||||||
|               What is the reason why you are deleting this database? |               What is the reason why you are deleting this database? | ||||||
|             </span> |             </span> | ||||||
| @ -1068,17 +1066,17 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|               validateOnLoad={true} |               validateOnLoad={true} | ||||||
|             > |             > | ||||||
|               <div |               <div | ||||||
|                 className="ms-TextField ms-TextField--multiline root-107" |                 className="ms-TextField ms-TextField--multiline root-58" | ||||||
|               > |               > | ||||||
|                 <div |                 <div | ||||||
|                   className="ms-TextField-wrapper" |                   className="ms-TextField-wrapper" | ||||||
|                 > |                 > | ||||||
|                   <div |                   <div | ||||||
|                     className="ms-TextField-fieldGroup fieldGroup-127" |                     className="ms-TextField-fieldGroup fieldGroup-78" | ||||||
|                   > |                   > | ||||||
|                     <textarea |                     <textarea | ||||||
|                       aria-invalid={false} |                       aria-invalid={false} | ||||||
|                       className="ms-TextField-field field-128" |                       className="ms-TextField-field field-79" | ||||||
|                       id="deleteDatabaseFeedbackInput" |                       id="deleteDatabaseFeedbackInput" | ||||||
|                       onBlur={[Function]} |                       onBlur={[Function]} | ||||||
|                       onChange={[Function]} |                       onChange={[Function]} | ||||||
| @ -2804,7 +2802,7 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|                   > |                   > | ||||||
|                     <button |                     <button | ||||||
|                       aria-label="OK" |                       aria-label="OK" | ||||||
|                       className="ms-Button ms-Button--primary root-118" |                       className="ms-Button ms-Button--primary root-69" | ||||||
|                       data-is-focusable={true} |                       data-is-focusable={true} | ||||||
|                       id="sidePanelOkButton" |                       id="sidePanelOkButton" | ||||||
|                       onClick={[Function]} |                       onClick={[Function]} | ||||||
| @ -2816,14 +2814,14 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database | |||||||
|                       type="submit" |                       type="submit" | ||||||
|                     > |                     > | ||||||
|                       <span |                       <span | ||||||
|                         className="ms-Button-flexContainer flexContainer-119" |                         className="ms-Button-flexContainer flexContainer-70" | ||||||
|                         data-automationid="splitbuttonprimary" |                         data-automationid="splitbuttonprimary" | ||||||
|                       > |                       > | ||||||
|                         <span |                         <span | ||||||
|                           className="ms-Button-textContainer textContainer-120" |                           className="ms-Button-textContainer textContainer-71" | ||||||
|                         > |                         > | ||||||
|                           <span |                           <span | ||||||
|                             className="ms-Button-label label-122" |                             className="ms-Button-label label-73" | ||||||
|                             id="id__3" |                             id="id__3" | ||||||
|                             key="id__3" |                             key="id__3" | ||||||
|                           > |                           > | ||||||
|  | |||||||
| @ -1,6 +1,5 @@ | |||||||
| import { HttpStatusCodes } from "../Common/Constants"; | import { HttpStatusCodes } from "../Common/Constants"; | ||||||
| import Explorer from "../Explorer/Explorer"; | import Explorer from "../Explorer/Explorer"; | ||||||
| import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent"; |  | ||||||
| import NotebookManager from "../Explorer/Notebook/NotebookManager"; | import NotebookManager from "../Explorer/Notebook/NotebookManager"; | ||||||
| import { JunoClient } from "../Juno/JunoClient"; | import { JunoClient } from "../Juno/JunoClient"; | ||||||
| import { IGitHubConnectorParams } from "./GitHubConnector"; | import { IGitHubConnectorParams } from "./GitHubConnector"; | ||||||
| @ -17,8 +16,6 @@ describe("GitHubOAuthService", () => { | |||||||
|     originalDataExplorer = window.dataExplorer; |     originalDataExplorer = window.dataExplorer; | ||||||
|     window.dataExplorer = { |     window.dataExplorer = { | ||||||
|       ...originalDataExplorer, |       ...originalDataExplorer, | ||||||
|       logConsoleData: (data): void => |  | ||||||
|         data.type === ConsoleDataType.Error ? console.error(data.message) : console.error(data.message), |  | ||||||
|     } as Explorer; |     } as Explorer; | ||||||
|     window.dataExplorer.notebookManager = new NotebookManager(); |     window.dataExplorer.notebookManager = new NotebookManager(); | ||||||
|     window.dataExplorer.notebookManager.junoClient = junoClient; |     window.dataExplorer.notebookManager.junoClient = junoClient; | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								src/Main.tsx
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/Main.tsx
									
									
									
									
									
								
							| @ -56,16 +56,10 @@ import "./Shared/appInsights"; | |||||||
| initializeIcons(); | initializeIcons(); | ||||||
| 
 | 
 | ||||||
| const App: React.FunctionComponent = () => { | const App: React.FunctionComponent = () => { | ||||||
|   const [notificationConsoleData, setNotificationConsoleData] = useState(undefined); |  | ||||||
|   //TODO: Refactor so we don't need to pass the id to remove a console data
 |  | ||||||
|   const [inProgressConsoleDataIdToBeDeleted, setInProgressConsoleDataIdToBeDeleted] = useState(""); |  | ||||||
|   const [isLeftPaneExpanded, setIsLeftPaneExpanded] = useState<boolean>(true); |   const [isLeftPaneExpanded, setIsLeftPaneExpanded] = useState<boolean>(true); | ||||||
| 
 |  | ||||||
|   const { tabs, activeTab, tabsManager } = useTabs(); |   const { tabs, activeTab, tabsManager } = useTabs(); | ||||||
| 
 | 
 | ||||||
|   const explorerParams: ExplorerParams = { |   const explorerParams: ExplorerParams = { | ||||||
|     setNotificationConsoleData, |  | ||||||
|     setInProgressConsoleDataIdToBeDeleted, |  | ||||||
|     tabsManager, |     tabsManager, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
| @ -117,10 +111,7 @@ const App: React.FunctionComponent = () => { | |||||||
|           aria-label="Notification console" |           aria-label="Notification console" | ||||||
|           id="explorerNotificationConsole" |           id="explorerNotificationConsole" | ||||||
|         > |         > | ||||||
|           <NotificationConsole |           <NotificationConsole /> | ||||||
|             consoleData={notificationConsoleData} |  | ||||||
|             inProgressConsoleDataIdToBeDeleted={inProgressConsoleDataIdToBeDeleted} |  | ||||||
|           /> |  | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|       <SidePanel /> |       <SidePanel /> | ||||||
|  | |||||||
| @ -1,11 +1,8 @@ | |||||||
| import * as _ from "underscore"; | import * as _ from "underscore"; | ||||||
| import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent"; | import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/ConsoleData"; | ||||||
| 
 | import { useNotificationConsole } from "../hooks/useNotificationConsole"; | ||||||
| const _global = typeof self === "undefined" ? window : self; |  | ||||||
| 
 | 
 | ||||||
| function log(type: ConsoleDataType, message: string): () => void { | function log(type: ConsoleDataType, message: string): () => void { | ||||||
|   const dataExplorer = _global.dataExplorer; |  | ||||||
|   if (dataExplorer) { |  | ||||||
|   const id = _.uniqueId(); |   const id = _.uniqueId(); | ||||||
|   const date = new Intl.DateTimeFormat("en-EN", { |   const date = new Intl.DateTimeFormat("en-EN", { | ||||||
|     hour12: true, |     hour12: true, | ||||||
| @ -13,11 +10,8 @@ function log(type: ConsoleDataType, message: string): () => void { | |||||||
|     minute: "numeric", |     minute: "numeric", | ||||||
|   }).format(new Date()); |   }).format(new Date()); | ||||||
| 
 | 
 | ||||||
|     dataExplorer.logConsoleData({ type, date, message, id }); |   useNotificationConsole.getState().setNotificationConsoleData({ type, date, message, id }); | ||||||
|     return () => dataExplorer.deleteInProgressConsoleDataWithId(id); |   return () => useNotificationConsole.getState().setInProgressConsoleDataIdToBeDeleted(id); | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   return () => undefined; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const logConsoleProgress = (msg: string): (() => void) => log(ConsoleDataType.InProgress, msg); | export const logConsoleProgress = (msg: string): (() => void) => log(ConsoleDataType.InProgress, msg); | ||||||
|  | |||||||
| @ -1,14 +1,25 @@ | |||||||
| import create, { UseStore } from "zustand"; | import create, { UseStore } from "zustand"; | ||||||
|  | import { ConsoleData } from "../Explorer/Menus/NotificationConsole/ConsoleData"; | ||||||
| 
 | 
 | ||||||
| export interface NotificationConsoleState { | export interface NotificationConsoleState { | ||||||
|   isExpanded: boolean; |   isExpanded: boolean; | ||||||
|  |   inProgressConsoleDataIdToBeDeleted: string; | ||||||
|  |   consoleData: ConsoleData | undefined; | ||||||
|   expandConsole: () => void; |   expandConsole: () => void; | ||||||
|   // TODO Remove this method. Add a `closeConsole` method instead
 |   // TODO Remove this method. Add a `closeConsole` method instead
 | ||||||
|   setIsExpanded: (isExpanded: boolean) => void; |   setIsExpanded: (isExpanded: boolean) => void; | ||||||
|  |   // TODO These two methods badly need a refactor. Not very react friendly.
 | ||||||
|  |   setNotificationConsoleData: (consoleData: ConsoleData) => void; | ||||||
|  |   setInProgressConsoleDataIdToBeDeleted: (id: string) => void; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const useNotificationConsole: UseStore<NotificationConsoleState> = create((set) => ({ | export const useNotificationConsole: UseStore<NotificationConsoleState> = create((set) => ({ | ||||||
|   isExpanded: false, |   isExpanded: false, | ||||||
|  |   consoleData: undefined, | ||||||
|  |   inProgressConsoleDataIdToBeDeleted: "", | ||||||
|   expandConsole: () => set((state) => ({ ...state, isExpanded: true })), |   expandConsole: () => set((state) => ({ ...state, isExpanded: true })), | ||||||
|   setIsExpanded: (isExpanded) => set((state) => ({ ...state, isExpanded })), |   setIsExpanded: (isExpanded) => set((state) => ({ ...state, isExpanded })), | ||||||
|  |   setNotificationConsoleData: (consoleData: ConsoleData) => set((state) => ({ ...state, consoleData })), | ||||||
|  |   setInProgressConsoleDataIdToBeDeleted: (id: string) => | ||||||
|  |     set((state) => ({ ...state, inProgressConsoleDataIdToBeDeleted: id })), | ||||||
| })); | })); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user