mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-07 19:46:53 +00:00
Compare commits
1 Commits
fixed-ts-s
...
fixed-ts-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a227941b9 |
@@ -1,5 +1,7 @@
|
||||
jest.mock("./MessageHandler");
|
||||
import { LogEntryLevel } from "../Contracts/Diagnostics";
|
||||
import * as Logger from "./Logger";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import { sendMessage } from "./MessageHandler";
|
||||
|
||||
describe("Logger", () => {
|
||||
|
||||
@@ -36,7 +36,7 @@ export interface TableEntityProps {
|
||||
onDeleteEntity?: () => void;
|
||||
onEditEntity?: () => void;
|
||||
onEntityPropertyChange: (event: React.FormEvent<HTMLElement>, newInput?: string) => void;
|
||||
onEntityTypeChange: (event: React.FormEvent<HTMLElement>, selectedParam: IDropdownOption) => void;
|
||||
onEntityTypeChange: (event: React.FormEvent<HTMLElement>, selectedParam: IDropdownOption | undefined) => void;
|
||||
onEntityValueChange: (event: React.FormEvent<HTMLElement>, newInput?: string) => void;
|
||||
onSelectDate: (date: Date | null | undefined) => void;
|
||||
onEntityTimeValueChange: (event: React.FormEvent<HTMLElement>, newInput?: string) => void;
|
||||
|
||||
@@ -43,7 +43,7 @@ export interface TreeNode {
|
||||
isLeavesParentsSeparate?: boolean; // Display parents together first, then leaves
|
||||
isLoading?: boolean;
|
||||
isSelected?: () => boolean;
|
||||
onClick?: (isExpanded: boolean) => void; // Only if a leaf, other click will expand/collapse
|
||||
onClick?: (isExpanded?: boolean) => void; // Only if a leaf, other click will expand/collapse
|
||||
onExpanded?: () => void;
|
||||
onCollapsed?: () => void;
|
||||
onContextMenuOpen?: () => void;
|
||||
@@ -73,7 +73,7 @@ interface TreeNodeComponentProps {
|
||||
}
|
||||
|
||||
interface TreeNodeComponentState {
|
||||
isExpanded: boolean;
|
||||
isExpanded?: boolean;
|
||||
isMenuShowing: boolean;
|
||||
}
|
||||
export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, TreeNodeComponentState> {
|
||||
@@ -82,7 +82,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
private static readonly transitionDurationMS = 200;
|
||||
private static readonly callbackDelayMS = 100; // avoid calling at the same time as transition to make it smoother
|
||||
private contextMenuRef = React.createRef<HTMLDivElement>();
|
||||
private isExpanded: boolean;
|
||||
private isExpanded?: boolean;
|
||||
|
||||
constructor(props: TreeNodeComponentProps) {
|
||||
super(props);
|
||||
@@ -93,7 +93,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
};
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: TreeNodeComponentProps, prevState: TreeNodeComponentState) {
|
||||
componentDidUpdate(_prevProps: TreeNodeComponentProps, prevState: TreeNodeComponentState) {
|
||||
// Only call when expand has actually changed
|
||||
if (this.state.isExpanded !== prevState.isExpanded) {
|
||||
if (this.state.isExpanded) {
|
||||
@@ -103,7 +103,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
}
|
||||
}
|
||||
if (this.props.node.isExpanded !== this.isExpanded) {
|
||||
this.isExpanded = this.props.node.isExpanded;
|
||||
this.isExpanded = this.props.node && this.props.node.isExpanded;
|
||||
this.setState({
|
||||
isExpanded: this.props.node.isExpanded,
|
||||
});
|
||||
@@ -114,7 +114,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
return this.renderNode(this.props.node, this.props.generation);
|
||||
}
|
||||
|
||||
private static getSortedChildren(treeNode: TreeNode): TreeNode[] {
|
||||
private static getSortedChildren(treeNode: TreeNode): TreeNode[] | undefined {
|
||||
if (!treeNode || !treeNode.children) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
{node.children && (
|
||||
<AnimateHeight duration={TreeNodeComponent.transitionDurationMS} height={this.state.isExpanded ? "auto" : 0}>
|
||||
<div className="nodeChildren" data-test={node.label}>
|
||||
{TreeNodeComponent.getSortedChildren(node).map((childNode: TreeNode) => (
|
||||
{TreeNodeComponent?.getSortedChildren(node)?.map((childNode: TreeNode) => (
|
||||
<TreeNodeComponent
|
||||
key={`${childNode.label}-${generation + 1}-${childNode.timestamp}`}
|
||||
node={childNode}
|
||||
@@ -214,15 +214,15 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
* Recursive: is the node or any descendant selected
|
||||
* @param node
|
||||
*/
|
||||
|
||||
private static isAnyDescendantSelected(node: TreeNode): boolean {
|
||||
return (
|
||||
node.children &&
|
||||
node.children.reduce(
|
||||
return node.children
|
||||
? node.children.reduce(
|
||||
(previous: boolean, child: TreeNode) =>
|
||||
previous || (child.isSelected && child.isSelected()) || TreeNodeComponent.isAnyDescendantSelected(child),
|
||||
false
|
||||
)
|
||||
);
|
||||
: false;
|
||||
}
|
||||
|
||||
private static createClickEvent(): MouseEvent {
|
||||
@@ -230,7 +230,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
}
|
||||
|
||||
private onRightClick = (): void => {
|
||||
this.contextMenuRef.current.firstChild.dispatchEvent(TreeNodeComponent.createClickEvent());
|
||||
this.contextMenuRef?.current?.firstChild?.dispatchEvent(TreeNodeComponent.createClickEvent());
|
||||
};
|
||||
|
||||
private renderContextMenuButton(node: TreeNode): JSX.Element {
|
||||
@@ -253,18 +253,18 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
coverTarget: true,
|
||||
isBeakVisible: false,
|
||||
directionalHint: DirectionalHint.topAutoEdge,
|
||||
onMenuOpened: (contextualMenu?: IContextualMenuProps) => {
|
||||
onMenuOpened: (_contextualMenu?: IContextualMenuProps) => {
|
||||
this.setState({ isMenuShowing: true });
|
||||
node.onContextMenuOpen && node.onContextMenuOpen();
|
||||
},
|
||||
onMenuDismissed: (contextualMenu?: IContextualMenuProps) => this.setState({ isMenuShowing: false }),
|
||||
onMenuDismissed: (_contextualMenu?: IContextualMenuProps) => this.setState({ isMenuShowing: false }),
|
||||
contextualMenuItemAs: (props: IContextualMenuItemProps) => (
|
||||
<div
|
||||
data-test={`treeComponentMenuItemContainer`}
|
||||
className="treeComponentMenuItemContainer"
|
||||
onContextMenu={(e) => e.target.dispatchEvent(TreeNodeComponent.createClickEvent())}
|
||||
>
|
||||
{props.item.onRenderIcon()}
|
||||
{props.item.onRenderIcon && props.item.onRenderIcon()}
|
||||
<span
|
||||
className={
|
||||
"treeComponentMenuItemLabel" + (props.item.className ? ` ${props.item.className}Label` : "")
|
||||
@@ -274,7 +274,8 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
items: node.contextMenu.map((menuItem: TreeNodeMenuItem) => ({
|
||||
items: node.contextMenu
|
||||
? node.contextMenu.map((menuItem: TreeNodeMenuItem) => ({
|
||||
key: menuItem.label,
|
||||
text: menuItem.label,
|
||||
disabled: menuItem.isDisabled,
|
||||
@@ -285,8 +286,9 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
label: menuItem.label,
|
||||
});
|
||||
},
|
||||
onRenderIcon: (props: any) => <img src={menuItem.iconSrc} alt="" />,
|
||||
})),
|
||||
onRenderIcon: (_props: any) => <img src={menuItem.iconSrc} alt="" />,
|
||||
}))
|
||||
: [],
|
||||
}}
|
||||
styles={buttonStyles}
|
||||
/>
|
||||
@@ -324,7 +326,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
this.props.node.onClick && this.props.node.onClick(this.state.isExpanded);
|
||||
};
|
||||
|
||||
private onNodeKeyPress = (event: React.KeyboardEvent<HTMLDivElement>, node: TreeNode): void => {
|
||||
private onNodeKeyPress = (event: React.KeyboardEvent<HTMLDivElement>, _node: TreeNode): void => {
|
||||
if (event.charCode === Constants.KeyCodes.Space || event.charCode === Constants.KeyCodes.Enter) {
|
||||
event.stopPropagation();
|
||||
this.props.node.onClick && this.props.node.onClick(this.state.isExpanded);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { GraphData, GremlinEdge, GremlinVertex } from "./GraphData";
|
||||
import { GraphData, GremlinVertex, GremlinEdge } from "./GraphData";
|
||||
|
||||
describe("Graph Data", () => {
|
||||
it("should set only one node as root", () => {
|
||||
const graphData = new GraphData<GremlinVertex, GremlinEdge>();
|
||||
const v1: GremlinVertex = { id: "1", label: undefined };
|
||||
const v2: GremlinVertex = { id: "2", label: undefined };
|
||||
const v3: GremlinVertex = { id: "3", label: undefined };
|
||||
const v1: GremlinVertex = { id: "1", label: null };
|
||||
const v2: GremlinVertex = { id: "2", label: null };
|
||||
const v3: GremlinVertex = { id: "3", label: null };
|
||||
v3._isRoot = true;
|
||||
|
||||
graphData.addVertex(v1);
|
||||
@@ -28,9 +28,9 @@ describe("Graph Data", () => {
|
||||
|
||||
it("should properly find root id", () => {
|
||||
const graphData = new GraphData();
|
||||
const v1: GremlinVertex = { id: "1", label: undefined };
|
||||
const v2: GremlinVertex = { id: "2", label: undefined };
|
||||
const v3: GremlinVertex = { id: "3", label: undefined };
|
||||
const v1: GremlinVertex = { id: "1", label: null };
|
||||
const v2: GremlinVertex = { id: "2", label: null };
|
||||
const v3: GremlinVertex = { id: "3", label: null };
|
||||
|
||||
graphData.addVertex(v1);
|
||||
graphData.addVertex(v2);
|
||||
@@ -44,12 +44,12 @@ describe("Graph Data", () => {
|
||||
it("should remove edge from graph", () => {
|
||||
const graphData = new GraphData();
|
||||
|
||||
graphData.addVertex({ id: "v1", label: undefined });
|
||||
graphData.addVertex({ id: "v2", label: undefined });
|
||||
graphData.addVertex({ id: "v3", label: undefined });
|
||||
graphData.addVertex({ id: "v1", label: null });
|
||||
graphData.addVertex({ id: "v2", label: null });
|
||||
graphData.addVertex({ id: "v3", label: null });
|
||||
|
||||
graphData.addEdge({ id: "e1", inV: "v1", outV: "v2", label: "" });
|
||||
graphData.addEdge({ id: "e2", inV: "v1", outV: "v3", label: "" });
|
||||
graphData.addEdge({ id: "e1", inV: "v1", outV: "v2", label: null });
|
||||
graphData.addEdge({ id: "e2", inV: "v1", outV: "v3", label: null });
|
||||
|
||||
// in edge
|
||||
graphData.removeEdge("e1", false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SimulationLinkDatum, SimulationNodeDatum } from "d3";
|
||||
import _ from "underscore";
|
||||
import { SimulationNodeDatum, SimulationLinkDatum } from "d3";
|
||||
|
||||
export interface PaginationInfo {
|
||||
total: number;
|
||||
@@ -10,7 +10,7 @@ export interface PaginationInfo {
|
||||
|
||||
export interface GremlinVertex {
|
||||
id: string;
|
||||
label?: string;
|
||||
label: string;
|
||||
inE?: { [label: string]: GremlinShortInEdge[] };
|
||||
outE?: { [label: string]: GremlinShortOutEdge[] };
|
||||
properties?: { [propName: string]: GremlinProperty[] };
|
||||
|
||||
@@ -66,7 +66,7 @@ interface InitialProps {
|
||||
}
|
||||
|
||||
// Redux
|
||||
const makeMapStateToProps = (_state: AppState, initialProps: InitialProps) => {
|
||||
const makeMapStateToProps = (state: AppState, initialProps: InitialProps) => {
|
||||
const mapStateToProps = (state: AppState): StateProps => ({
|
||||
isNotebookUntrusted: NotebookUtil.isNotebookUntrusted(state, initialProps.contentRef),
|
||||
});
|
||||
|
||||
@@ -2,7 +2,9 @@ import * as DataModels from "../Contracts/DataModels";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export class DefaultExperienceUtility {
|
||||
public static getApiKindFromDefaultExperience(defaultExperience: typeof userContext.apiType): DataModels.ApiKind {
|
||||
public static getApiKindFromDefaultExperience(
|
||||
defaultExperience: typeof userContext.apiType | null
|
||||
): DataModels.ApiKind {
|
||||
if (!defaultExperience) {
|
||||
return DataModels.ApiKind.SQL;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"files": [
|
||||
"./src/Explorer/Graph/GraphExplorerComponent/GraphData.test.ts",
|
||||
"./src/Common/Logger.test.ts",
|
||||
"./src/Explorer/Controls/TreeComponent/TreeComponent.tsx",
|
||||
"./src/AuthType.ts",
|
||||
"./src/Bindings/ReactBindingHandler.ts",
|
||||
"./src/Common/ArrayHashMap.ts",
|
||||
@@ -65,7 +64,6 @@
|
||||
"./src/Explorer/Notebook/NotebookUtil.ts",
|
||||
"./src/Explorer/Notebook/SchemaAnalyzer/SchemaAnalyzerSplashScreen.tsx",
|
||||
"./src/Explorer/Notebook/SchemaAnalyzer/SchemaAnalyzerUtils.ts",
|
||||
"./src/Explorer/Notebook/SecurityWarningBar/SecurityWarningBar.tsx",
|
||||
"./src/Explorer/OpenFullScreen.test.tsx",
|
||||
"./src/Explorer/OpenFullScreen.tsx",
|
||||
"./src/Explorer/Panes/PanelContainerComponent.test.tsx",
|
||||
@@ -101,17 +99,6 @@
|
||||
"./src/SelfServe/Example/SelfServeExample.types.ts",
|
||||
"./src/SelfServe/SelfServeStyles.tsx",
|
||||
"./src/SelfServe/SqlX/SqlxTypes.ts",
|
||||
"./src/Shared/Constants.ts",
|
||||
"./src/Shared/DefaultExperienceUtility.ts",
|
||||
"./src/Shared/ExplorerSettings.ts",
|
||||
"./src/Shared/LocalStorageUtility.ts",
|
||||
"./src/Shared/PriceEstimateCalculator.ts",
|
||||
"./src/Shared/SessionStorageUtility.ts",
|
||||
"./src/Shared/StorageUtility.test.ts",
|
||||
"./src/Shared/StorageUtility.ts",
|
||||
"./src/Shared/StringUtility.test.ts",
|
||||
"./src/Shared/StringUtility.ts",
|
||||
"./src/Shared/appInsights.ts",
|
||||
"./src/UserContext.ts",
|
||||
"./src/Utils/APITypeUtils.ts",
|
||||
"./src/Utils/AutoPilotUtils.ts",
|
||||
@@ -144,7 +131,8 @@
|
||||
"./src/quickstart.ts",
|
||||
"./src/setupTests.ts",
|
||||
"./src/userContext.test.ts",
|
||||
"src/Common/EntityValue.tsx"
|
||||
"src/Common/EntityValue.tsx",
|
||||
"src/Common/TableEntity.tsx"
|
||||
],
|
||||
"include": [
|
||||
"src/CellOutputViewer/transforms/**/*",
|
||||
@@ -166,7 +154,7 @@
|
||||
"src/Localization/**/*",
|
||||
"src/Platform/Emulator/**/*",
|
||||
"src/SelfServe/Documentation/**/*",
|
||||
"src/Shared/Telemetry/**/*",
|
||||
"src/Shared/**/*",
|
||||
"src/Terminal/**/*",
|
||||
"src/Utils/arm/**/*"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user