diff --git a/scm-ui/ui-components/src/navigation/NavLink.tsx b/scm-ui/ui-components/src/navigation/NavLink.tsx index 9a858dc5af..bff7e71e1c 100644 --- a/scm-ui/ui-components/src/navigation/NavLink.tsx +++ b/scm-ui/ui-components/src/navigation/NavLink.tsx @@ -11,6 +11,7 @@ type Props = { activeOnlyWhenExact?: boolean; activeWhenMatch?: (route: any) => boolean; collapsed: boolean; + title?: string; }; class NavLink extends React.Component { @@ -24,7 +25,7 @@ class NavLink extends React.Component { } renderLink = (route: any) => { - const { to, icon, label, collapsed } = this.props; + const { to, icon, label, collapsed, title } = this.props; let showIcon = null; if (icon) { @@ -36,7 +37,7 @@ class NavLink extends React.Component { } return ( -
  • +
  • void; }; +const SectionContainer = styled.div` + position: ${props => (props.scrollPositionY > 210 ? "fixed" : "absolute")}; + top: ${props => props.scrollPositionY > 210 && "4.5rem"}; + width: ${props => (props.collapsed ? "5.5rem" : "20.5rem")}; +`; + const SmallButton = styled(Button)` height: 1.5rem; width: 1rem; position: absolute; right: 1.5rem; - > { - outline: none; - } `; const MenuLabel = styled.p` @@ -25,19 +27,31 @@ const MenuLabel = styled.p` `; const Section: FC = ({ label, children, collapsed, onCollapse }) => { + const [scrollPositionY, setScrollPositionY] = useState(0); + + useEffect(() => { + window.addEventListener("scroll", () => setScrollPositionY(window.pageYOffset)); + + return () => { + window.removeEventListener("scroll", () => setScrollPositionY(window.pageYOffset)); + }; + }, []); + const childrenWithProps = React.Children.map(children, child => React.cloneElement(child, { collapsed: collapsed })); + const arrowIcon = collapsed ? : ; + return ( -
    + {collapsed ? "" : label} {onCollapse && ( - + {arrowIcon} )}
      {childrenWithProps}
    -
    + ); }; diff --git a/scm-ui/ui-components/src/navigation/SubNavigation.tsx b/scm-ui/ui-components/src/navigation/SubNavigation.tsx index 4cb9d2b306..e254975e0c 100644 --- a/scm-ui/ui-components/src/navigation/SubNavigation.tsx +++ b/scm-ui/ui-components/src/navigation/SubNavigation.tsx @@ -11,6 +11,7 @@ type Props = { children?: ReactNode; collapsed?: boolean; onCollapsed?: (newStatus: boolean) => void; + title?: string }; class SubNavigation extends React.Component { @@ -24,7 +25,7 @@ class SubNavigation extends React.Component { } renderLink = (route: any) => { - const { to, icon, label, collapsed } = this.props; + const { to, icon, label, collapsed, title } = this.props; let defaultIcon = "fas fa-cog"; if (icon) { @@ -37,7 +38,7 @@ class SubNavigation extends React.Component { } return ( -
  • +
  • boolean; activeOnlyWhenExact: boolean; icon?: string; + title?: string; }; /** diff --git a/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx b/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx index 62b482cbaa..96f941c21a 100644 --- a/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx @@ -209,6 +209,7 @@ class RepositoryRoot extends React.Component { to={`${url}/info`} icon="fas fa-info-circle" label={t("repositoryRoot.menu.informationNavLink")} + title={t("repositoryRoot.menu.informationNavLink")} /> { label={t("repositoryRoot.menu.branchesNavLink")} activeWhenMatch={this.matchesBranches} activeOnlyWhenExact={false} + title={t("repositoryRoot.menu.branchesNavLink")} /> { label={t("repositoryRoot.menu.sourcesNavLink")} activeWhenMatch={this.matchesCode} activeOnlyWhenExact={false} + title={t("repositoryRoot.menu.sourcesNavLink")} /> this.onCollapse(false)} + title={t("repositoryRoot.menu.settingsNavLink")} > diff --git a/scm-ui/ui-webapp/src/repos/modules/repos.ts b/scm-ui/ui-webapp/src/repos/modules/repos.ts index ac9e8fd81b..5dde4e4104 100644 --- a/scm-ui/ui-webapp/src/repos/modules/repos.ts +++ b/scm-ui/ui-webapp/src/repos/modules/repos.ts @@ -442,11 +442,11 @@ export function getPermissionsLink(state: object, namespace: string, name: strin return repo && repo._links ? repo._links.permissions.href : undefined; } -const REPOSITORY_NAVIGATION_COLLAPSED = "repository-menu-collapsed"; +const REPOSITORY_MENU_COLLAPSED = "repository-menu-collapsed"; export function isRepositoryMenuCollapsed() { - return localStorage.getItem(REPOSITORY_NAVIGATION_COLLAPSED) === "true"; + return localStorage.getItem(REPOSITORY_MENU_COLLAPSED) === "true"; } -export function switchRepositoryMenuCollapsed(newStatus: boolean) { - localStorage.setItem(REPOSITORY_NAVIGATION_COLLAPSED, String(newStatus)); +export function switchRepositoryMenuCollapsed(status: boolean) { + localStorage.setItem(REPOSITORY_MENU_COLLAPSED, String(status)); }