mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 01:11:25 +00:00
Prettier 2.0 (#393)
This commit is contained in:
@@ -4,18 +4,18 @@ import { TreeComponent, TreeNode, TreeNodeComponent } from "./TreeComponent";
|
||||
|
||||
const buildChildren = (): TreeNode[] => {
|
||||
const grandChild11: TreeNode = {
|
||||
label: "ZgrandChild11"
|
||||
label: "ZgrandChild11",
|
||||
};
|
||||
const grandChild12: TreeNode = {
|
||||
label: "AgrandChild12"
|
||||
label: "AgrandChild12",
|
||||
};
|
||||
const child1: TreeNode = {
|
||||
label: "Bchild1",
|
||||
children: [grandChild11, grandChild12]
|
||||
children: [grandChild11, grandChild12],
|
||||
};
|
||||
|
||||
const child2: TreeNode = {
|
||||
label: "2child2"
|
||||
label: "2child2",
|
||||
};
|
||||
|
||||
return [child1, child2];
|
||||
@@ -23,28 +23,28 @@ const buildChildren = (): TreeNode[] => {
|
||||
|
||||
const buildChildren2 = (): TreeNode[] => {
|
||||
const grandChild11: TreeNode = {
|
||||
label: "ZgrandChild11"
|
||||
label: "ZgrandChild11",
|
||||
};
|
||||
const grandChild12: TreeNode = {
|
||||
label: "AgrandChild12"
|
||||
label: "AgrandChild12",
|
||||
};
|
||||
|
||||
const child1: TreeNode = {
|
||||
label: "aChild"
|
||||
label: "aChild",
|
||||
};
|
||||
|
||||
const child2: TreeNode = {
|
||||
label: "bchild",
|
||||
children: [grandChild11, grandChild12]
|
||||
children: [grandChild11, grandChild12],
|
||||
};
|
||||
|
||||
const child3: TreeNode = {
|
||||
label: "cchild"
|
||||
label: "cchild",
|
||||
};
|
||||
|
||||
const child4: TreeNode = {
|
||||
label: "dchild",
|
||||
children: [grandChild11, grandChild12]
|
||||
children: [grandChild11, grandChild12],
|
||||
};
|
||||
|
||||
return [child1, child2, child3, child4];
|
||||
@@ -54,12 +54,12 @@ describe("TreeComponent", () => {
|
||||
it("renders a simple tree", () => {
|
||||
const root = {
|
||||
label: "root",
|
||||
children: buildChildren()
|
||||
children: buildChildren(),
|
||||
};
|
||||
|
||||
const props = {
|
||||
rootNode: root,
|
||||
className: "tree"
|
||||
className: "tree",
|
||||
};
|
||||
|
||||
const wrapper = shallow(<TreeComponent {...props} />);
|
||||
@@ -78,8 +78,8 @@ describe("TreeNodeComponent", () => {
|
||||
label: "menuLabel",
|
||||
onClick: undefined,
|
||||
iconSrc: undefined,
|
||||
isDisabled: true
|
||||
}
|
||||
isDisabled: true,
|
||||
},
|
||||
],
|
||||
iconSrc: undefined,
|
||||
isExpanded: true,
|
||||
@@ -90,13 +90,13 @@ describe("TreeNodeComponent", () => {
|
||||
isSelected: undefined,
|
||||
onClick: undefined,
|
||||
onExpanded: undefined,
|
||||
onCollapsed: undefined
|
||||
onCollapsed: undefined,
|
||||
};
|
||||
|
||||
const props = {
|
||||
node,
|
||||
generation: 12,
|
||||
paddingLeft: 23
|
||||
paddingLeft: 23,
|
||||
};
|
||||
const wrapper = shallow(<TreeNodeComponent {...props} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -106,12 +106,12 @@ describe("TreeNodeComponent", () => {
|
||||
const node: TreeNode = {
|
||||
label: "label",
|
||||
children: buildChildren(),
|
||||
isExpanded: true
|
||||
isExpanded: true,
|
||||
};
|
||||
const props = {
|
||||
node,
|
||||
generation: 2,
|
||||
paddingLeft: 9
|
||||
paddingLeft: 9,
|
||||
};
|
||||
const wrapper = shallow(<TreeNodeComponent {...props} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -121,12 +121,12 @@ describe("TreeNodeComponent", () => {
|
||||
const node: TreeNode = {
|
||||
label: "label",
|
||||
children: buildChildren(),
|
||||
isAlphaSorted: false
|
||||
isAlphaSorted: false,
|
||||
};
|
||||
const props = {
|
||||
node,
|
||||
generation: 2,
|
||||
paddingLeft: 9
|
||||
paddingLeft: 9,
|
||||
};
|
||||
const wrapper = shallow(<TreeNodeComponent {...props} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -148,13 +148,13 @@ describe("TreeNodeComponent", () => {
|
||||
isSelected: undefined,
|
||||
onClick: undefined,
|
||||
onExpanded: undefined,
|
||||
onCollapsed: undefined
|
||||
onCollapsed: undefined,
|
||||
};
|
||||
|
||||
const props = {
|
||||
node,
|
||||
generation: 12,
|
||||
paddingLeft: 23
|
||||
paddingLeft: 23,
|
||||
};
|
||||
const wrapper = shallow(<TreeNodeComponent {...props} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -164,13 +164,13 @@ describe("TreeNodeComponent", () => {
|
||||
const node: TreeNode = {
|
||||
label: "label",
|
||||
children: [],
|
||||
isExpanded: true
|
||||
isExpanded: true,
|
||||
};
|
||||
|
||||
const props = {
|
||||
node,
|
||||
generation: 2,
|
||||
paddingLeft: 9
|
||||
paddingLeft: 9,
|
||||
};
|
||||
const wrapper = shallow(<TreeNodeComponent {...props} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
||||
@@ -12,7 +12,7 @@ import { IconButton, IButtonStyles } from "office-ui-fabric-react/lib/Button";
|
||||
import {
|
||||
DirectionalHint,
|
||||
IContextualMenuItemProps,
|
||||
IContextualMenuProps
|
||||
IContextualMenuProps,
|
||||
} from "office-ui-fabric-react/lib/ContextualMenu";
|
||||
|
||||
import TriangleDownIcon from "../../../../images/Triangle-down.svg";
|
||||
@@ -89,7 +89,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
this.isExpanded = props.node.isExpanded;
|
||||
this.state = {
|
||||
isExpanded: props.node.isExpanded,
|
||||
isMenuShowing: false
|
||||
isMenuShowing: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
if (this.props.node.isExpanded !== this.isExpanded) {
|
||||
this.isExpanded = this.props.node.isExpanded;
|
||||
this.setState({
|
||||
isExpanded: this.props.node.isExpanded
|
||||
isExpanded: this.props.node.isExpanded,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -124,8 +124,8 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
let unsortedChildren;
|
||||
if (treeNode.isLeavesParentsSeparate) {
|
||||
// Separate parents and leave
|
||||
const parents: TreeNode[] = treeNode.children.filter(node => node.children);
|
||||
const leaves: TreeNode[] = treeNode.children.filter(node => !node.children);
|
||||
const parents: TreeNode[] = treeNode.children.filter((node) => node.children);
|
||||
const leaves: TreeNode[] = treeNode.children.filter((node) => !node.children);
|
||||
|
||||
if (treeNode.isAlphaSorted) {
|
||||
parents.sort(compareFct);
|
||||
@@ -235,7 +235,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
private renderContextMenuButton(node: TreeNode): JSX.Element {
|
||||
const menuItemLabel = "More";
|
||||
const buttonStyles: Partial<IButtonStyles> = {
|
||||
rootFocused: { outline: `1px dashed ${Constants.StyleConstants.FocusColor}` }
|
||||
rootFocused: { outline: `1px dashed ${Constants.StyleConstants.FocusColor}` },
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -246,7 +246,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
ariaLabel={menuItemLabel}
|
||||
menuIconProps={{
|
||||
iconName: menuItemLabel,
|
||||
styles: { root: { fontSize: "18px", fontWeight: "bold" } }
|
||||
styles: { root: { fontSize: "18px", fontWeight: "bold" } },
|
||||
}}
|
||||
menuProps={{
|
||||
coverTarget: true,
|
||||
@@ -261,7 +261,7 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
<div
|
||||
data-test={`treeComponentMenuItemContainer`}
|
||||
className="treeComponentMenuItemContainer"
|
||||
onContextMenu={e => e.target.dispatchEvent(TreeNodeComponent.createClickEvent())}
|
||||
onContextMenu={(e) => e.target.dispatchEvent(TreeNodeComponent.createClickEvent())}
|
||||
>
|
||||
{props.item.onRenderIcon()}
|
||||
<span
|
||||
@@ -281,11 +281,11 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps, T
|
||||
onClick: () => {
|
||||
menuItem.onClick();
|
||||
TelemetryProcessor.trace(Action.ClickResourceTreeNodeContextMenuItem, ActionModifiers.Mark, {
|
||||
label: menuItem.label
|
||||
label: menuItem.label,
|
||||
});
|
||||
},
|
||||
onRenderIcon: (props: any) => <img src={menuItem.iconSrc} alt="" />
|
||||
}))
|
||||
onRenderIcon: (props: any) => <img src={menuItem.iconSrc} alt="" />,
|
||||
})),
|
||||
}}
|
||||
styles={buttonStyles}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user