cosmos-explorer/src/Main.tsx

141 lines
5.5 KiB
TypeScript
Raw Normal View History

2021-01-20 15:15:01 +00:00
// CSS Dependencies
import { initializeIcons } from "@fluentui/react";
2021-01-20 15:15:01 +00:00
import "bootstrap/dist/css/bootstrap.css";
2021-03-15 03:53:16 +00:00
import React, { useState } from "react";
import ReactDOM from "react-dom";
import "../externals/jquery-ui.min.css";
import "../externals/jquery-ui.min.js";
import "../externals/jquery-ui.structure.min.css";
import "../externals/jquery-ui.theme.min.css";
import "../externals/jquery.dataTables.min.css";
import "../externals/jquery.typeahead.min.css";
import "../externals/jquery.typeahead.min.js";
// Image Dependencies
import "../images/CosmosDB_rgb_ui_lighttheme.ico";
import "../images/favicon.ico";
import hdeConnectImage from "../images/HdeConnectCosmosDB.svg";
2021-01-20 15:15:01 +00:00
import "../less/documentDB.less";
import "../less/forms.less";
import "../less/infobox.less";
2021-03-15 03:53:16 +00:00
import "../less/menus.less";
2021-01-20 15:15:01 +00:00
import "../less/messagebox.less";
2021-03-15 03:53:16 +00:00
import "../less/resourceTree.less";
import "../less/TableStyles/CustomizeColumns.less";
import "../less/TableStyles/EntityEditor.less";
import "../less/TableStyles/fulldatatables.less";
import "../less/TableStyles/queryBuilder.less";
import "../less/tree.less";
import { CollapsedResourceTree } from "./Common/CollapsedResourceTree";
2021-07-20 19:40:04 +01:00
import { ResourceTreeContainer } from "./Common/ResourceTreeContainer";
2021-03-15 03:53:16 +00:00
import "./Explorer/Controls/Accordion/AccordionComponent.less";
2021-01-20 15:15:01 +00:00
import "./Explorer/Controls/CollapsiblePanel/CollapsiblePanelComponent.less";
2021-05-20 15:54:26 +01:00
import { Dialog } from "./Explorer/Controls/Dialog";
2021-03-15 03:53:16 +00:00
import "./Explorer/Controls/ErrorDisplayComponent/ErrorDisplayComponent.less";
2021-01-20 15:15:01 +00:00
import "./Explorer/Controls/JsonEditor/JsonEditorComponent.less";
2021-03-15 03:53:16 +00:00
import "./Explorer/Controls/Notebook/NotebookTerminalComponent.less";
import "./Explorer/Controls/TreeComponent/treeComponent.less";
2021-01-20 15:15:01 +00:00
import "./Explorer/Graph/GraphExplorerComponent/graphExplorer.less";
2021-03-15 03:53:16 +00:00
import "./Explorer/Menus/CommandBar/CommandBarComponent.less";
2021-05-28 21:20:59 +01:00
import { CommandBar } from "./Explorer/Menus/CommandBar/CommandBarComponentAdapter";
import "./Explorer/Menus/CommandBar/ConnectionStatusComponent.less";
2021-03-15 03:53:16 +00:00
import "./Explorer/Menus/CommandBar/MemoryTrackerComponent.less";
import "./Explorer/Menus/NotificationConsole/NotificationConsole.less";
import { NotificationConsole } from "./Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
2021-03-15 03:53:16 +00:00
import "./Explorer/Panes/PanelComponent.less";
import { SidePanel } from "./Explorer/Panes/PanelContainerComponent";
2021-03-15 03:53:16 +00:00
import { SplashScreen } from "./Explorer/SplashScreen/SplashScreen";
import "./Explorer/SplashScreen/SplashScreen.less";
2021-04-19 21:11:48 +01:00
import { Tabs } from "./Explorer/Tabs/Tabs";
import { useConfig } from "./hooks/useConfig";
import { useKnockoutExplorer } from "./hooks/useKnockoutExplorer";
import { useTabs } from "./hooks/useTabs";
2021-03-15 03:53:16 +00:00
import "./Libs/jquery";
import "./Shared/appInsights";
2021-01-20 15:15:01 +00:00
initializeIcons();
2021-01-20 15:15:01 +00:00
const App: React.FunctionComponent = () => {
const [isLeftPaneExpanded, setIsLeftPaneExpanded] = useState<boolean>(true);
2021-07-09 05:32:22 +01:00
const openedTabs = useTabs((state) => state.openedTabs);
const config = useConfig();
2021-07-09 05:32:22 +01:00
const explorer = useKnockoutExplorer(config?.platform);
2021-01-20 15:15:01 +00:00
const toggleLeftPaneExpanded = () => {
setIsLeftPaneExpanded(!isLeftPaneExpanded);
if (isLeftPaneExpanded) {
document.getElementById("expandToggleLeftPaneButton").focus();
} else {
document.getElementById("collapseToggleLeftPaneButton").focus();
}
};
2021-03-15 03:53:16 +00:00
if (!explorer) {
return <LoadingExplorer />;
}
2021-01-20 15:15:01 +00:00
return (
<div className="flexContainer">
<div id="divExplorer" className="flexContainer hideOverflows">
Created selfServe landing page (#444) * Portal changes for DedicatedGateway Changes to support creation and deletion of DedicatedGateway resource. Tested locally with various scenarios. * Portal changes for DedicatedGateway. CR feedback * Stylecop changes * created selfServe.html landing page * Removing TODO comments * exposed baselineValues * added getOnSaveNotification * disable UI when onSave is taking place * minro edits * made polling optional * added optional polling * added default * Added portal notifications * merged more changes * minor edits * added label for description * Added correlationids and polling of refresh * Added correlationids and polling of refresh * minor edit * added label tooltip * removed ClassInfo decorator * Added dynamic decription * added info and warninf types for description * more changes to promise retry * promise retry changes * added spinner on selfserve load * compile errors fixed * New changes * added operationstatus link * merged sqlxEdits * undid sqlx changes * added completed notification * passed retryInterval in notif options * more retry changes * more changes * added polling on landing on the page * edits for error display * added keys blade link * added link generation * added link to blade * Modified info and description * fixed format errors * added selfserve contract to output files * addressed PR comments Co-authored-by: Balaji Sridharan <fnbalaji@microsoft.com> Co-authored-by: fnbalaji <75445927+fnbalaji@users.noreply.github.com>
2021-03-10 21:55:05 +00:00
{/* Main Command Bar - Start */}
2021-05-28 21:20:59 +01:00
<CommandBar container={explorer} />
2021-01-20 15:15:01 +00:00
{/* Collections Tree and Tabs - Begin */}
<div className="resourceTreeAndTabs">
{/* Collections Tree - Start */}
<div id="resourcetree" data-test="resourceTreeId" className="resourceTree">
<div className="collectionsTreeWithSplitter">
{/* Collections Tree Expanded - Start */}
2021-07-20 19:40:04 +01:00
<ResourceTreeContainer
container={explorer}
toggleLeftPaneExpanded={toggleLeftPaneExpanded}
isLeftPaneExpanded={isLeftPaneExpanded}
/>
2021-01-20 15:15:01 +00:00
{/* Collections Tree Expanded - End */}
{/* Collections Tree Collapsed - Start */}
<CollapsedResourceTree
toggleLeftPaneExpanded={toggleLeftPaneExpanded}
isLeftPaneExpanded={isLeftPaneExpanded}
/>
2021-01-20 15:15:01 +00:00
{/* Collections Tree Collapsed - End */}
</div>
</div>
{/* Collections Tree - End */}
2021-07-09 05:32:22 +01:00
{openedTabs.length === 0 && <SplashScreen explorer={explorer} />}
<Tabs />
2021-01-20 15:15:01 +00:00
</div>
{/* Collections Tree and Tabs - End */}
<div
className="dataExplorerErrorConsoleContainer"
role="contentinfo"
aria-label="Notification console"
id="explorerNotificationConsole"
>
<NotificationConsole />
</div>
2021-01-20 15:15:01 +00:00
</div>
<SidePanel />
2021-05-20 15:54:26 +01:00
<Dialog />
2021-01-20 15:15:01 +00:00
</div>
);
};
ReactDOM.render(<App />, document.body);
2021-03-15 03:53:16 +00:00
function LoadingExplorer(): JSX.Element {
return (
<div className="splashLoaderContainer">
<div className="splashLoaderContentContainer">
<p className="connectExplorerContent">
<img src={hdeConnectImage} alt="Azure Cosmos DB" />
</p>
<p className="splashLoaderTitle" id="explorerLoadingStatusTitle">
Welcome to Azure Cosmos DB
</p>
<p className="splashLoaderText" id="explorerLoadingStatusText" role="alert">
Connecting...
</p>
</div>
</div>
);
}