From: Philippe Perrin Date: Thu, 21 Nov 2019 16:43:00 +0000 (+0100) Subject: Rename ComponentBreadcrumb to just Breadcrumb X-Git-Tag: 8.2.0.32929~116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=953cda1da5139483374c898f62a4bf280e17c6cb;p=sonarqube.git Rename ComponentBreadcrumb to just Breadcrumb --- diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx new file mode 100644 index 00000000000..b608d6484a6 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx @@ -0,0 +1,72 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { last } from 'lodash'; +import * as React from 'react'; +import { Link } from 'react-router'; +import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; +import { isMainBranch } from '../../../../helpers/branch-like'; +import { getProjectUrl } from '../../../../helpers/urls'; +import { BranchLike } from '../../../../types/branch-like'; + +interface Props { + component: T.Component; + currentBranchLike: BranchLike | undefined; +} + +export function Breadcrumb(props: Props) { + const { + component: { breadcrumbs }, + currentBranchLike + } = props; + const lastBreadcrumbElement = last(breadcrumbs); + const isNoMainBranch = currentBranchLike && !isMainBranch(currentBranchLike); + + return ( +
+ {breadcrumbs.map((breadcrumbElement, i) => { + const isFirst = i === 0; + const isNotLast = i < breadcrumbs.length - 1; + + return ( + + {isFirst && lastBreadcrumbElement && ( + + )} + {isNoMainBranch || isNotLast ? ( + + {breadcrumbElement.name} + + ) : ( + + {breadcrumbElement.name} + + )} + {isNotLast && } + + ); + })} +
+ ); +} + +export default React.memo(Breadcrumb); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx deleted file mode 100644 index c25c21679ad..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { last } from 'lodash'; -import * as React from 'react'; -import { Link } from 'react-router'; -import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; -import { isMainBranch } from '../../../../helpers/branch-like'; -import { getProjectUrl } from '../../../../helpers/urls'; -import { BranchLike } from '../../../../types/branch-like'; - -interface Props { - component: T.Component; - currentBranchLike: BranchLike | undefined; -} - -export function ComponentBreadcrumb(props: Props) { - const { - component: { breadcrumbs }, - currentBranchLike - } = props; - const lastBreadcrumbElement = last(breadcrumbs); - const isNoMainBranch = currentBranchLike && !isMainBranch(currentBranchLike); - - return ( -
- {breadcrumbs.map((breadcrumbElement, i) => { - const isFirst = i === 0; - const isNotLast = i < breadcrumbs.length - 1; - - return ( - - {isFirst && lastBreadcrumbElement && ( - - )} - {isNoMainBranch || isNotLast ? ( - - {breadcrumbElement.name} - - ) : ( - - {breadcrumbElement.name} - - )} - {isNotLast && } - - ); - })} -
- ); -} - -export default React.memo(ComponentBreadcrumb); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Header.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Header.tsx index 0ed44b073ce..fcc7175f6f8 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/Header.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/Header.tsx @@ -26,7 +26,7 @@ import { getCurrentUser, Store } from '../../../../store/rootReducer'; import { BranchLike } from '../../../../types/branch-like'; import BranchLikeNavigation from './branch-like/BranchLikeNavigation'; import CurrentBranchLikeMergeInformation from './branch-like/CurrentBranchLikeMergeInformation'; -import { ComponentBreadcrumb } from './ComponentBreadcrumb'; +import { Breadcrumb } from './Breadcrumb'; export interface HeaderProps { branchLikes: BranchLike[]; @@ -42,7 +42,7 @@ export function Header(props: HeaderProps) { <>
- + {isLoggedIn(currentUser) && ( { + const wrapper = shallowRender(); + expect(wrapper).toMatchSnapshot(); +}); + +function shallowRender() { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx deleted file mode 100644 index 569fd86adfa..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockMainBranch } from '../../../../../helpers/mocks/branch-like'; -import { mockComponent } from '../../../../../helpers/testMocks'; -import { ComponentQualifier } from '../../../../../types/component'; -import { ComponentBreadcrumb } from '../ComponentBreadcrumb'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); -}); - -function shallowRender() { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Breadcrumb-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Breadcrumb-test.tsx.snap new file mode 100644 index 00000000000..314c7e511a6 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Breadcrumb-test.tsx.snap @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
+ + + + parent-portfolio + + + + + + child-portfolio + + +
+`; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentBreadcrumb-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentBreadcrumb-test.tsx.snap deleted file mode 100644 index 314c7e511a6..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentBreadcrumb-test.tsx.snap +++ /dev/null @@ -1,48 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
- - - - parent-portfolio - - - - - - child-portfolio - - -
-`; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Header-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Header-test.tsx.snap index bf77fa89ed0..dffea76fc4a 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Header-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Header-test.tsx.snap @@ -10,7 +10,7 @@ exports[`should render correctly 1`] = `
-