2021-09-17 02:54:24 +05:30
|
|
|
import React, { FunctionComponent, MutableRefObject, useEffect, useRef } from "react";
|
2021-05-26 01:56:36 +05:30
|
|
|
import arrowLeftImg from "../../images/imgarrowlefticon.svg";
|
2022-10-05 17:35:03 -07:00
|
|
|
import { getApiShortDisplayName } from "../Utils/APITypeUtils";
|
2021-09-17 02:54:24 +05:30
|
|
|
import { NormalizedEventKey } from "./Constants";
|
2021-05-26 01:56:36 +05:30
|
|
|
|
|
|
|
export interface CollapsedResourceTreeProps {
|
|
|
|
toggleLeftPaneExpanded: () => void;
|
|
|
|
isLeftPaneExpanded: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const CollapsedResourceTree: FunctionComponent<CollapsedResourceTreeProps> = ({
|
|
|
|
toggleLeftPaneExpanded,
|
|
|
|
isLeftPaneExpanded,
|
|
|
|
}: CollapsedResourceTreeProps): JSX.Element => {
|
2021-09-17 02:54:24 +05:30
|
|
|
const focusButton = useRef<HTMLLIElement>() as MutableRefObject<HTMLLIElement>;
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (focusButton.current) {
|
|
|
|
focusButton.current.focus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const onKeyPressToggleLeftPaneExpanded = (event: React.KeyboardEvent) => {
|
|
|
|
if (event.key === NormalizedEventKey.Space || event.key === NormalizedEventKey.Enter) {
|
|
|
|
toggleLeftPaneExpanded();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-26 01:56:36 +05:30
|
|
|
return (
|
|
|
|
<div id="mini" className={!isLeftPaneExpanded ? "mini toggle-mini" : "hiddenMain"}>
|
|
|
|
<div className="main-nav nav">
|
|
|
|
<ul className="nav">
|
|
|
|
<li
|
|
|
|
className="resourceTreeCollapse"
|
|
|
|
id="collapseToggleLeftPaneButton"
|
|
|
|
role="button"
|
|
|
|
tabIndex={0}
|
2023-04-25 21:03:51 +05:30
|
|
|
aria-label={getApiShortDisplayName() + `Expand tree`}
|
2021-09-17 02:54:24 +05:30
|
|
|
onClick={toggleLeftPaneExpanded}
|
|
|
|
onKeyPress={onKeyPressToggleLeftPaneExpanded}
|
|
|
|
ref={focusButton}
|
2021-05-26 01:56:36 +05:30
|
|
|
>
|
2021-09-17 02:54:24 +05:30
|
|
|
<span className="leftarrowCollapsed">
|
2021-05-26 01:56:36 +05:30
|
|
|
<img className="arrowCollapsed" src={arrowLeftImg} alt="Expand" />
|
|
|
|
</span>
|
2021-09-17 02:54:24 +05:30
|
|
|
<span className="collectionCollapsed">
|
2022-10-05 17:35:03 -07:00
|
|
|
<span>{getApiShortDisplayName()}</span>
|
2021-05-26 01:56:36 +05:30
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|