diff --git a/scm-ui/ui-components/src/contexts/index.ts b/scm-ui/ui-components/src/contexts/index.ts deleted file mode 100644 index 56f9c0126a..0000000000 --- a/scm-ui/ui-components/src/contexts/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -// @create-index - -export { MenuContext, storeMenuCollapsed, isMenuCollapsed } from "./MenuContext"; diff --git a/scm-ui/ui-components/src/index.ts b/scm-ui/ui-components/src/index.ts index 566bcf38aa..46ccbb48ec 100644 --- a/scm-ui/ui-components/src/index.ts +++ b/scm-ui/ui-components/src/index.ts @@ -67,7 +67,6 @@ export * from "./navigation"; export * from "./repos"; export * from "./table"; export * from "./toast"; -export * from "./contexts"; export { File, diff --git a/scm-ui/ui-components/src/contexts/MenuContext.ts b/scm-ui/ui-components/src/navigation/MenuContext.ts similarity index 100% rename from scm-ui/ui-components/src/contexts/MenuContext.ts rename to scm-ui/ui-components/src/navigation/MenuContext.ts diff --git a/scm-ui/ui-components/src/navigation/Section.tsx b/scm-ui/ui-components/src/navigation/Section.tsx index 5b1ba58aa3..eb4e94be73 100644 --- a/scm-ui/ui-components/src/navigation/Section.tsx +++ b/scm-ui/ui-components/src/navigation/Section.tsx @@ -7,32 +7,39 @@ type Props = { children: ReactElement[]; collapsed?: boolean; onCollapse?: (newStatus: boolean) => void; + scrollTransitionAt?: number; }; -type StylingProps = { - scrollPositionY: number; +type CollapsedProps = { collapsed: boolean; }; -const SectionContainer = styled.div` - position: ${(props: StylingProps) => (props.scrollPositionY > 210 && window.innerWidth > 770 ? "fixed" : "inherit")}; - top: ${(props: StylingProps) => props.scrollPositionY > 210 && window.innerWidth > 770 && "4.5rem"}; - width: ${(props: StylingProps) => (props.collapsed ? "5.5rem" : "20.5rem")}; +type PositionProps = CollapsedProps & { + scrollPositionY: number; + scrollTransitionAt: number; +}; + +const SectionContainer = styled.div` + position: ${props => + props.scrollPositionY > props.scrollTransitionAt && window.innerWidth > 770 ? "fixed" : "inherit"}; + top: ${props => props.scrollPositionY > props.scrollTransitionAt && window.innerWidth > 770 && "2rem"}; + width: ${props => (props.collapsed ? "5.5rem" : "20.5rem")}; `; -const SmallButton = styled(Button)` +const SmallButton = styled(Button)` padding-left: 1rem; padding-right: 1rem; + margin-right: ${(props: CollapsedProps) => (props.collapsed ? "0" : "0.5rem")}; height: 1.5rem; `; -const MenuLabel = styled.p` +const MenuLabel = styled.p` min-height: 2.5rem; display: flex; - justify-content: ${(props: { collapsed: boolean }) => (props.collapsed ? "center" : "space-between")}; + justify-content: ${props => (props.collapsed ? "center" : "left")}; `; -const Section: FC = ({ label, children, collapsed, onCollapse }) => { +const Section: FC = ({ label, children, collapsed, onCollapse, scrollTransitionAt }) => { const [scrollPositionY, setScrollPositionY] = useState(0); useEffect(() => { @@ -49,14 +56,23 @@ const Section: FC = ({ label, children, collapsed, onCollapse }) => { const arrowIcon = collapsed ? : ; return ( - + - {collapsed ? "" : label} {onCollapse && ( - onCollapse(!collapsed)}> + onCollapse(!collapsed)} + collapsed={collapsed ? collapsed : false} + > {arrowIcon} )} + {collapsed ? "" : label}
    {childrenWithProps}
diff --git a/scm-ui/ui-components/src/navigation/SubNavigation.tsx b/scm-ui/ui-components/src/navigation/SubNavigation.tsx index 6e0d3d17d0..0f3c8b40a7 100644 --- a/scm-ui/ui-components/src/navigation/SubNavigation.tsx +++ b/scm-ui/ui-components/src/navigation/SubNavigation.tsx @@ -1,6 +1,7 @@ -import React, { ReactNode } from "react"; +import React, { FC, ReactElement, useContext } from "react"; import { Link, Route } from "react-router-dom"; import classNames from "classnames"; +import { MenuContext } from "./MenuContext"; type Props = { to: string; @@ -8,57 +9,57 @@ type Props = { label: string; activeOnlyWhenExact?: boolean; activeWhenMatch?: (route: any) => boolean; - children?: ReactNode; + children?: ReactElement[]; collapsed?: boolean; title?: string; }; -class SubNavigation extends React.Component { - static defaultProps = { - activeOnlyWhenExact: false +const SubNavigation: FC = ({ + to, + icon, + label, + activeOnlyWhenExact, + activeWhenMatch, + children, + collapsed, + title +}) => { + const menuContext = useContext(MenuContext); + + const isActive = (route: any) => { + return route.match || activeWhenMatch && activeWhenMatch(route); }; - isActive(route: any) { - const { activeWhenMatch } = this.props; - return route.match || (activeWhenMatch && activeWhenMatch(route)); - } - - renderLink = (route: any) => { - const { to, icon, label, collapsed, title } = this.props; - + const renderLink = (route: any) => { let defaultIcon = "fas fa-cog"; if (icon) { defaultIcon = icon; } - let children = null; - if (this.isActive(route)) { - children =
    {this.props.children}
; + let childrenList = null; + if (isActive(route)) { + if (menuContext.menuCollapsed) { + menuContext.setMenuCollapsed(false); + } + childrenList =
    {children}
; } return (
  • - + {collapsed ? "" : label} - {children} + {childrenList}
  • ); }; - render() { - const { to, activeOnlyWhenExact } = this.props; + // removes last part of url + const parents = to.split("/"); + parents.splice(-1, 1); + const parent = parents.join("/"); - // removes last part of url - const parents = to.split("/"); - parents.splice(-1, 1); - const parent = parents.join("/"); - - return ; - } -} + return ; +}; export default SubNavigation; diff --git a/scm-ui/ui-components/src/navigation/index.ts b/scm-ui/ui-components/src/navigation/index.ts index 6c83ffc86d..30ca96bc51 100644 --- a/scm-ui/ui-components/src/navigation/index.ts +++ b/scm-ui/ui-components/src/navigation/index.ts @@ -7,3 +7,4 @@ export { default as SubNavigation } from "./SubNavigation"; export { default as PrimaryNavigation } from "./PrimaryNavigation"; export { default as PrimaryNavigationLink } from "./PrimaryNavigationLink"; export { default as Section } from "./Section"; +export { MenuContext, storeMenuCollapsed, isMenuCollapsed } from "./MenuContext"; diff --git a/scm-ui/ui-components/src/repos/DiffFile.tsx b/scm-ui/ui-components/src/repos/DiffFile.tsx index 3cbd7020dc..0dbabbc6db 100644 --- a/scm-ui/ui-components/src/repos/DiffFile.tsx +++ b/scm-ui/ui-components/src/repos/DiffFile.tsx @@ -101,12 +101,12 @@ class DiffFile extends React.Component { } }; - toggleSideBySide = (callback: (collapsed: boolean) => void) => { + toggleSideBySide = (callback: () => void) => { this.setState( state => ({ sideBySide: !state.sideBySide }), - () => callback(true) + () => callback() ); }; diff --git a/scm-ui/ui-webapp/public/locales/de/admin.json b/scm-ui/ui-webapp/public/locales/de/admin.json index 7a40dff908..2bfc2d6b5b 100644 --- a/scm-ui/ui-webapp/public/locales/de/admin.json +++ b/scm-ui/ui-webapp/public/locales/de/admin.json @@ -1,7 +1,7 @@ { "admin": { "menu": { - "navigationLabel": "Administrations Navigation", + "navigationLabel": "Administration", "informationNavLink": "Informationen", "settingsNavLink": "Einstellungen", "generalNavLink": "Generell" diff --git a/scm-ui/ui-webapp/public/locales/de/commons.json b/scm-ui/ui-webapp/public/locales/de/commons.json index 310c14ead3..8b9e9942e7 100644 --- a/scm-ui/ui-webapp/public/locales/de/commons.json +++ b/scm-ui/ui-webapp/public/locales/de/commons.json @@ -61,7 +61,7 @@ "previous": "Zurück" }, "profile": { - "navigationLabel": "Profil Navigation", + "navigationLabel": "Profil", "informationNavLink": "Information", "changePasswordNavLink": "Passwort ändern", "settingsNavLink": "Einstellungen", diff --git a/scm-ui/ui-webapp/public/locales/de/config.json b/scm-ui/ui-webapp/public/locales/de/config.json index 4cbfff2afc..99e810215b 100644 --- a/scm-ui/ui-webapp/public/locales/de/config.json +++ b/scm-ui/ui-webapp/public/locales/de/config.json @@ -1,6 +1,6 @@ { "config": { - "navigationLabel": "Administrations Navigation", + "navigationLabel": "Administration", "title": "Globale Einstellungen", "errorTitle": "Fehler", "errorSubtitle": "Unbekannter Einstellungen Fehler", diff --git a/scm-ui/ui-webapp/public/locales/de/groups.json b/scm-ui/ui-webapp/public/locales/de/groups.json index 2e8c7aeb88..43cdd51f7e 100644 --- a/scm-ui/ui-webapp/public/locales/de/groups.json +++ b/scm-ui/ui-webapp/public/locales/de/groups.json @@ -18,7 +18,7 @@ "errorTitle": "Fehler", "errorSubtitle": "Unbekannter Gruppen Fehler", "menu": { - "navigationLabel": "Gruppen Navigation", + "navigationLabel": "Gruppen", "informationNavLink": "Informationen", "settingsNavLink": "Einstellungen", "generalNavLink": "Generell", diff --git a/scm-ui/ui-webapp/public/locales/de/repos.json b/scm-ui/ui-webapp/public/locales/de/repos.json index 27909f338c..bb353f6b67 100644 --- a/scm-ui/ui-webapp/public/locales/de/repos.json +++ b/scm-ui/ui-webapp/public/locales/de/repos.json @@ -28,7 +28,7 @@ "errorTitle": "Fehler", "errorSubtitle": "Unbekannter Repository Fehler", "menu": { - "navigationLabel": "Repository Navigation", + "navigationLabel": "Repository", "informationNavLink": "Informationen", "branchesNavLink": "Branches", "sourcesNavLink": "Code", diff --git a/scm-ui/ui-webapp/public/locales/de/users.json b/scm-ui/ui-webapp/public/locales/de/users.json index 60f9f64423..fd744e768d 100644 --- a/scm-ui/ui-webapp/public/locales/de/users.json +++ b/scm-ui/ui-webapp/public/locales/de/users.json @@ -32,7 +32,7 @@ "errorTitle": "Fehler", "errorSubtitle": "Unbekannter Benutzer Fehler", "menu": { - "navigationLabel": "Benutzer Navigation", + "navigationLabel": "Benutzer", "informationNavLink": "Informationen", "settingsNavLink": "Einstellungen", "generalNavLink": "Generell", diff --git a/scm-ui/ui-webapp/public/locales/en/admin.json b/scm-ui/ui-webapp/public/locales/en/admin.json index 0357a5dc34..b061901df2 100644 --- a/scm-ui/ui-webapp/public/locales/en/admin.json +++ b/scm-ui/ui-webapp/public/locales/en/admin.json @@ -1,7 +1,7 @@ { "admin": { "menu": { - "navigationLabel": "Administration Navigation", + "navigationLabel": "Administration", "informationNavLink": "Information", "settingsNavLink": "Settings", "generalNavLink": "General" diff --git a/scm-ui/ui-webapp/public/locales/en/commons.json b/scm-ui/ui-webapp/public/locales/en/commons.json index f57a944c65..6b7b6c8fb6 100644 --- a/scm-ui/ui-webapp/public/locales/en/commons.json +++ b/scm-ui/ui-webapp/public/locales/en/commons.json @@ -62,7 +62,7 @@ "previous": "Previous" }, "profile": { - "navigationLabel": "Profile Navigation", + "navigationLabel": "Profile", "informationNavLink": "Information", "changePasswordNavLink": "Change password", "settingsNavLink": "Settings", diff --git a/scm-ui/ui-webapp/public/locales/en/config.json b/scm-ui/ui-webapp/public/locales/en/config.json index a3720cd67c..068238f132 100644 --- a/scm-ui/ui-webapp/public/locales/en/config.json +++ b/scm-ui/ui-webapp/public/locales/en/config.json @@ -1,6 +1,6 @@ { "config": { - "navigationLabel": "Administration Navigation", + "navigationLabel": "Administration", "title": "Global Configuration", "errorTitle": "Error", "errorSubtitle": "Unknown Config Error", diff --git a/scm-ui/ui-webapp/public/locales/en/groups.json b/scm-ui/ui-webapp/public/locales/en/groups.json index 6911f897f8..069013e5d0 100644 --- a/scm-ui/ui-webapp/public/locales/en/groups.json +++ b/scm-ui/ui-webapp/public/locales/en/groups.json @@ -18,7 +18,7 @@ "errorTitle": "Error", "errorSubtitle": "Unknown group error", "menu": { - "navigationLabel": "Group Navigation", + "navigationLabel": "Group", "informationNavLink": "Information", "settingsNavLink": "Settings", "generalNavLink": "General", diff --git a/scm-ui/ui-webapp/public/locales/en/repos.json b/scm-ui/ui-webapp/public/locales/en/repos.json index 793c01388d..004cf594ea 100644 --- a/scm-ui/ui-webapp/public/locales/en/repos.json +++ b/scm-ui/ui-webapp/public/locales/en/repos.json @@ -28,7 +28,7 @@ "errorTitle": "Error", "errorSubtitle": "Unknown repository error", "menu": { - "navigationLabel": "Repository Navigation", + "navigationLabel": "Repository", "informationNavLink": "Information", "branchesNavLink": "Branches", "sourcesNavLink": "Code", diff --git a/scm-ui/ui-webapp/public/locales/en/users.json b/scm-ui/ui-webapp/public/locales/en/users.json index 0fab330e6f..3353977a18 100644 --- a/scm-ui/ui-webapp/public/locales/en/users.json +++ b/scm-ui/ui-webapp/public/locales/en/users.json @@ -32,7 +32,7 @@ "errorTitle": "Error", "errorSubtitle": "Unknown user error", "menu": { - "navigationLabel": "User Navigation", + "navigationLabel": "User", "informationNavLink": "Information", "settingsNavLink": "Settings", "generalNavLink": "General", diff --git a/scm-ui/ui-webapp/public/locales/es/admin.json b/scm-ui/ui-webapp/public/locales/es/admin.json index 6d7ac4ccc5..e329076b22 100644 --- a/scm-ui/ui-webapp/public/locales/es/admin.json +++ b/scm-ui/ui-webapp/public/locales/es/admin.json @@ -1,7 +1,7 @@ { "admin": { "menu": { - "navigationLabel": "Menú de administración", + "navigationLabel": "Administración", "informationNavLink": "Información", "settingsNavLink": "Ajustes", "generalNavLink": "General" diff --git a/scm-ui/ui-webapp/public/locales/es/commons.json b/scm-ui/ui-webapp/public/locales/es/commons.json index 06db500845..47638c1d6e 100644 --- a/scm-ui/ui-webapp/public/locales/es/commons.json +++ b/scm-ui/ui-webapp/public/locales/es/commons.json @@ -62,7 +62,7 @@ "previous": "Anterior" }, "profile": { - "navigationLabel": "Menú de sección", + "navigationLabel": "Sección", "informationNavLink": "Información", "changePasswordNavLink": "Cambiar contraseña", "settingsNavLink": "Ajustes", diff --git a/scm-ui/ui-webapp/public/locales/es/config.json b/scm-ui/ui-webapp/public/locales/es/config.json index 8357e72546..4749546a22 100644 --- a/scm-ui/ui-webapp/public/locales/es/config.json +++ b/scm-ui/ui-webapp/public/locales/es/config.json @@ -1,6 +1,6 @@ { "config": { - "navigationLabel": "Menú de administración", + "navigationLabel": "Administración", "title": "Configuración global", "errorTitle": "Error", "errorSubtitle": "Error de configuración desconocido", diff --git a/scm-ui/ui-webapp/public/locales/es/groups.json b/scm-ui/ui-webapp/public/locales/es/groups.json index f62cfc62cb..ecb01ffd89 100644 --- a/scm-ui/ui-webapp/public/locales/es/groups.json +++ b/scm-ui/ui-webapp/public/locales/es/groups.json @@ -18,7 +18,7 @@ "errorTitle": "Error", "errorSubtitle": "Error de grupo desconocido", "menu": { - "navigationLabel": "Menú de grupo", + "navigationLabel": "Grupo", "informationNavLink": "Información", "settingsNavLink": "Ajustes", "generalNavLink": "General", diff --git a/scm-ui/ui-webapp/public/locales/es/repos.json b/scm-ui/ui-webapp/public/locales/es/repos.json index bd1d7d49ab..6758a4841c 100644 --- a/scm-ui/ui-webapp/public/locales/es/repos.json +++ b/scm-ui/ui-webapp/public/locales/es/repos.json @@ -28,7 +28,7 @@ "errorTitle": "Error", "errorSubtitle": "Error de repositorio desconocido", "menu": { - "navigationLabel": "Menú de repositorio", + "navigationLabel": "Repositorio", "informationNavLink": "Información", "branchesNavLink": "Ramas", "sourcesNavLink": "Código", diff --git a/scm-ui/ui-webapp/public/locales/es/users.json b/scm-ui/ui-webapp/public/locales/es/users.json index 7c8fa4d35e..05f8fa14e3 100644 --- a/scm-ui/ui-webapp/public/locales/es/users.json +++ b/scm-ui/ui-webapp/public/locales/es/users.json @@ -32,7 +32,7 @@ "errorTitle": "Error", "errorSubtitle": "Error de usuario desconocido", "menu": { - "navigationLabel": "Menú de usuario", + "navigationLabel": "Usuario", "informationNavLink": "Información", "settingsNavLink": "Ajustes", "generalNavLink": "General", diff --git a/scm-ui/ui-webapp/src/admin/containers/Admin.tsx b/scm-ui/ui-webapp/src/admin/containers/Admin.tsx index 82b564a607..9f112f9f6d 100644 --- a/scm-ui/ui-webapp/src/admin/containers/Admin.tsx +++ b/scm-ui/ui-webapp/src/admin/containers/Admin.tsx @@ -12,7 +12,8 @@ import { Section, SubNavigation, isMenuCollapsed, - MenuContext + MenuContext, + storeMenuCollapsed } from "@scm-manager/ui-components"; import { getAvailablePluginsLink, getInstalledPluginsLink, getLinks } from "../../modules/indexResource"; import AdminDetails from "./AdminDetails"; @@ -21,7 +22,6 @@ import GlobalConfig from "./GlobalConfig"; import RepositoryRoles from "../roles/containers/RepositoryRoles"; import SingleRepositoryRole from "../roles/containers/SingleRepositoryRole"; import CreateRepositoryRole from "../roles/containers/CreateRepositoryRole"; -import { storeMenuCollapsed } from "@scm-manager/ui-components/src"; type Props = RouteComponentProps & WithTranslation & { @@ -32,7 +32,6 @@ type Props = RouteComponentProps & type State = { menuCollapsed: boolean; - setMenuCollapsed: (collapsed: boolean) => void; }; class Admin extends React.Component { @@ -40,21 +39,10 @@ class Admin extends React.Component { super(props); this.state = { - menuCollapsed: isMenuCollapsed(), - setMenuCollapsed: (collapsed: boolean) => this.setState({ menuCollapsed: collapsed }) + menuCollapsed: isMenuCollapsed() }; } - componentDidUpdate() { - if (this.state.menuCollapsed && this.isCollapseForbidden()) { - this.setState({ menuCollapsed: false }); - } - } - - isCollapseForbidden = () => { - return this.props.location.pathname.includes("/settings/") || this.props.location.pathname.includes("/plugins/"); - }; - onCollapseAdminMenu = (collapsed: boolean) => { this.setState({ menuCollapsed: collapsed }, () => storeMenuCollapsed(collapsed)); }; @@ -90,7 +78,9 @@ class Admin extends React.Component { }; return ( - + this.setState({ menuCollapsed: collapsed }) }} + >
    @@ -136,8 +126,9 @@ class Admin extends React.Component {
    this.onCollapseAdminMenu(!menuCollapsed)} + onCollapse={() => this.onCollapseAdminMenu(!menuCollapsed)} collapsed={menuCollapsed} + scrollTransitionAt={220} > void; }; class Profile extends React.Component { @@ -38,21 +37,10 @@ class Profile extends React.Component { super(props); this.state = { - menuCollapsed: isMenuCollapsed(), - setMenuCollapsed: (collapsed: boolean) => this.setState({ menuCollapsed: collapsed }) + menuCollapsed: isMenuCollapsed() }; } - componentDidUpdate() { - if (this.state.menuCollapsed && this.isCollapseForbidden()) { - this.setState({ menuCollapsed: false }); - } - } - - isCollapseForbidden = () => { - return this.props.location.pathname.includes("/settings/"); - }; - onCollapseProfileMenu = (collapsed: boolean) => { this.setState({ menuCollapsed: collapsed }, () => storeMenuCollapsed(collapsed)); }; @@ -93,7 +81,9 @@ class Profile extends React.Component { }; return ( - + this.setState({ menuCollapsed: collapsed }) }} + >
    @@ -105,7 +95,7 @@ class Profile extends React.Component {
    this.onCollapseProfileMenu(!menuCollapsed)} + onCollapse={() => this.onCollapseProfileMenu(!menuCollapsed)} collapsed={menuCollapsed} > void; }; class SingleGroup extends React.Component { @@ -45,8 +44,7 @@ class SingleGroup extends React.Component { super(props); this.state = { - menuCollapsed: isMenuCollapsed(), - setMenuCollapsed: (collapsed: boolean) => this.setState({ menuCollapsed: collapsed }) + menuCollapsed: isMenuCollapsed() }; } @@ -54,16 +52,6 @@ class SingleGroup extends React.Component { this.props.fetchGroupByName(this.props.groupLink, this.props.name); } - componentDidUpdate() { - if (this.state.menuCollapsed && this.isCollapseForbidden()) { - this.setState({ menuCollapsed: false }); - } - } - - isCollapseForbidden = () => { - return this.props.location.pathname.includes("/settings/"); - }; - onCollapseGroupMenu = (collapsed: boolean) => { this.setState({ menuCollapsed: collapsed }, () => storeMenuCollapsed(collapsed)); }; @@ -99,7 +87,9 @@ class SingleGroup extends React.Component { }; return ( - + this.setState({ menuCollapsed: collapsed }) }} + >
    @@ -116,7 +106,7 @@ class SingleGroup extends React.Component {
    this.onCollapseGroupMenu(!menuCollapsed)} + onCollapse={() => this.onCollapseGroupMenu(!menuCollapsed)} collapsed={menuCollapsed} > { fetchChangesets(repository, branch, page); } - shouldComponentUpdate(nextProps: Readonly, nextState: Readonly<{}>, nextContext: any): boolean { + shouldComponentUpdate(nextProps: Readonly): boolean { return this.props.changesets !== nextProps.changesets; } diff --git a/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx b/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx index 58eb18391d..78c55e2475 100644 --- a/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/RepositoryRoot.tsx @@ -47,7 +47,6 @@ type Props = RouteComponentProps & type State = { menuCollapsed: boolean; - setMenuCollapsed: (collapsed: boolean) => void; }; class RepositoryRoot extends React.Component { @@ -55,8 +54,7 @@ class RepositoryRoot extends React.Component { super(props); this.state = { - menuCollapsed: isMenuCollapsed(), - setMenuCollapsed: (collapsed: boolean) => this.setState({ menuCollapsed: collapsed }) + menuCollapsed: isMenuCollapsed() }; } @@ -65,16 +63,6 @@ class RepositoryRoot extends React.Component { fetchRepoByName(repoLink, namespace, name); } - componentDidUpdate() { - if (this.state.menuCollapsed && this.isCollapseForbidden()) { - this.setState({ menuCollapsed: false }); - } - } - - isCollapseForbidden = () => { - return this.props.location.pathname.includes("/settings/"); - }; - stripEndingSlash = (url: string) => { if (url.endsWith("/")) { return url.substring(0, url.length - 1); @@ -138,7 +126,7 @@ class RepositoryRoot extends React.Component { const url = this.matchedUrl(); - const extensionProps: any = { + const extensionProps = { repository, url, indexLinks, @@ -154,10 +142,15 @@ class RepositoryRoot extends React.Component { } return ( - -
    -
    - + this.setState({ menuCollapsed: collapsed }) + }} + > + +
    +
    @@ -206,59 +199,58 @@ class RepositoryRoot extends React.Component { } /> - -
    -
    - -
    this.onCollapseRepositoryMenu(!menuCollapsed) - } - collapsed={menuCollapsed} - > - - - - - - +
    + +
    this.onCollapseRepositoryMenu(!menuCollapsed)} + collapsed={menuCollapsed} + scrollTransitionAt={250} > - - - - -
    -
    + + + + + + + + + + +
    +
    +
    -
    - + + ); } } diff --git a/scm-ui/ui-webapp/src/users/containers/SingleUser.tsx b/scm-ui/ui-webapp/src/users/containers/SingleUser.tsx index d2718650bd..64ffda8db2 100644 --- a/scm-ui/ui-webapp/src/users/containers/SingleUser.tsx +++ b/scm-ui/ui-webapp/src/users/containers/SingleUser.tsx @@ -38,7 +38,6 @@ type Props = RouteComponentProps & type State = { menuCollapsed: boolean; - setMenuCollapsed: (collapsed: boolean) => void; }; class SingleUser extends React.Component { @@ -46,8 +45,7 @@ class SingleUser extends React.Component { super(props); this.state = { - menuCollapsed: isMenuCollapsed(), - setMenuCollapsed: (collapsed: boolean) => this.setState({ menuCollapsed: collapsed }) + menuCollapsed: isMenuCollapsed() }; } @@ -55,12 +53,6 @@ class SingleUser extends React.Component { this.props.fetchUserByName(this.props.usersLink, this.props.name); } - componentDidUpdate() { - if (this.state.menuCollapsed && this.isCollapseForbidden()) { - this.setState({ menuCollapsed: false }); - } - } - stripEndingSlash = (url: string) => { if (url.endsWith("/")) { return url.substring(0, url.length - 2); @@ -68,10 +60,6 @@ class SingleUser extends React.Component { return url; }; - isCollapseForbidden = () => { - return this.props.location.pathname.includes("/settings/"); - }; - onCollapseUserMenu = (collapsed: boolean) => { this.setState({ menuCollapsed: collapsed }, () => storeMenuCollapsed(collapsed)); }; @@ -100,7 +88,9 @@ class SingleUser extends React.Component { }; return ( - + this.setState({ menuCollapsed: collapsed }) }} + >
    @@ -117,7 +107,7 @@ class SingleUser extends React.Component {
    this.onCollapseUserMenu(!menuCollapsed)} + onCollapse={() => this.onCollapseUserMenu(!menuCollapsed)} collapsed={menuCollapsed} >