]> source.dussan.org Git - sonarqube.git/commitdiff
Rename ComponentBreadcrumb to just Breadcrumb
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Thu, 21 Nov 2019 16:43:00 +0000 (17:43 +0100)
committerSonarTech <sonartech@sonarsource.com>
Mon, 10 Feb 2020 19:46:13 +0000 (20:46 +0100)
server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/nav/component/ComponentBreadcrumb.tsx [deleted file]
server/sonar-web/src/main/js/app/components/nav/component/Header.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/Breadcrumb-test.tsx [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentBreadcrumb-test.tsx [deleted file]
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Breadcrumb-test.tsx.snap [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentBreadcrumb-test.tsx.snap [deleted file]
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/Header-test.tsx.snap

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 (file)
index 0000000..b608d64
--- /dev/null
@@ -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 (
+    <div className="big flex-shrink display-flex-center">
+      {breadcrumbs.map((breadcrumbElement, i) => {
+        const isFirst = i === 0;
+        const isNotLast = i < breadcrumbs.length - 1;
+
+        return (
+          <span className="flex-shrink display-flex-center" key={breadcrumbElement.key}>
+            {isFirst && lastBreadcrumbElement && (
+              <QualifierIcon className="spacer-right" qualifier={lastBreadcrumbElement.qualifier} />
+            )}
+            {isNoMainBranch || isNotLast ? (
+              <Link
+                className="link-no-underline text-ellipsis"
+                title={breadcrumbElement.name}
+                to={getProjectUrl(breadcrumbElement.key)}>
+                {breadcrumbElement.name}
+              </Link>
+            ) : (
+              <span className="text-ellipsis" title={breadcrumbElement.name}>
+                {breadcrumbElement.name}
+              </span>
+            )}
+            {isNotLast && <span className="slash-separator" />}
+          </span>
+        );
+      })}
+    </div>
+  );
+}
+
+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 (file)
index c25c216..0000000
+++ /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 (
-    <div className="big flex-shrink display-flex-center">
-      {breadcrumbs.map((breadcrumbElement, i) => {
-        const isFirst = i === 0;
-        const isNotLast = i < breadcrumbs.length - 1;
-
-        return (
-          <span className="flex-shrink display-flex-center" key={breadcrumbElement.key}>
-            {isFirst && lastBreadcrumbElement && (
-              <QualifierIcon className="spacer-right" qualifier={lastBreadcrumbElement.qualifier} />
-            )}
-            {isNoMainBranch || isNotLast ? (
-              <Link
-                className="link-no-underline text-ellipsis"
-                title={breadcrumbElement.name}
-                to={getProjectUrl(breadcrumbElement.key)}>
-                {breadcrumbElement.name}
-              </Link>
-            ) : (
-              <span className="text-ellipsis" title={breadcrumbElement.name}>
-                {breadcrumbElement.name}
-              </span>
-            )}
-            {isNotLast && <span className="slash-separator" />}
-          </span>
-        );
-      })}
-    </div>
-  );
-}
-
-export default React.memo(ComponentBreadcrumb);
index 0ed44b073ce54916403d418ba839cc390de1f6b6..fcc7175f6f8fd5d307d3c70966f74dcff4cbd9c8 100644 (file)
@@ -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) {
     <>
       <Helmet title={component.name} />
       <header className="display-flex-center flex-shrink">
-        <ComponentBreadcrumb component={component} currentBranchLike={currentBranchLike} />
+        <Breadcrumb component={component} currentBranchLike={currentBranchLike} />
         {isLoggedIn(currentUser) && (
           <Favorite
             className="spacer-left"
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Breadcrumb-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Breadcrumb-test.tsx
new file mode 100644 (file)
index 0000000..0afae10
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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 { Breadcrumb } from '../Breadcrumb';
+
+it('should render correctly', () => {
+  const wrapper = shallowRender();
+  expect(wrapper).toMatchSnapshot();
+});
+
+function shallowRender() {
+  return shallow(
+    <Breadcrumb
+      component={mockComponent({
+        breadcrumbs: [
+          {
+            key: 'parent-portfolio',
+            name: 'parent-portfolio',
+            qualifier: ComponentQualifier.Portfolio
+          },
+          {
+            key: 'child-portfolio',
+            name: 'child-portfolio',
+            qualifier: ComponentQualifier.SubPortfolio
+          }
+        ]
+      })}
+      currentBranchLike={mockMainBranch()}
+    />
+  );
+}
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 (file)
index 569fd86..0000000
+++ /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(
-    <ComponentBreadcrumb
-      component={mockComponent({
-        breadcrumbs: [
-          {
-            key: 'parent-portfolio',
-            name: 'parent-portfolio',
-            qualifier: ComponentQualifier.Portfolio
-          },
-          {
-            key: 'child-portfolio',
-            name: 'child-portfolio',
-            qualifier: ComponentQualifier.SubPortfolio
-          }
-        ]
-      })}
-      currentBranchLike={mockMainBranch()}
-    />
-  );
-}
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 (file)
index 0000000..314c7e5
--- /dev/null
@@ -0,0 +1,48 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly 1`] = `
+<div
+  className="big flex-shrink display-flex-center"
+>
+  <span
+    className="flex-shrink display-flex-center"
+    key="parent-portfolio"
+  >
+    <QualifierIcon
+      className="spacer-right"
+      qualifier="SVW"
+    />
+    <Link
+      className="link-no-underline text-ellipsis"
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      title="parent-portfolio"
+      to={
+        Object {
+          "pathname": "/dashboard",
+          "query": Object {
+            "branch": undefined,
+            "id": "parent-portfolio",
+          },
+        }
+      }
+    >
+      parent-portfolio
+    </Link>
+    <span
+      className="slash-separator"
+    />
+  </span>
+  <span
+    className="flex-shrink display-flex-center"
+    key="child-portfolio"
+  >
+    <span
+      className="text-ellipsis"
+      title="child-portfolio"
+    >
+      child-portfolio
+    </span>
+  </span>
+</div>
+`;
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 (file)
index 314c7e5..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly 1`] = `
-<div
-  className="big flex-shrink display-flex-center"
->
-  <span
-    className="flex-shrink display-flex-center"
-    key="parent-portfolio"
-  >
-    <QualifierIcon
-      className="spacer-right"
-      qualifier="SVW"
-    />
-    <Link
-      className="link-no-underline text-ellipsis"
-      onlyActiveOnIndex={false}
-      style={Object {}}
-      title="parent-portfolio"
-      to={
-        Object {
-          "pathname": "/dashboard",
-          "query": Object {
-            "branch": undefined,
-            "id": "parent-portfolio",
-          },
-        }
-      }
-    >
-      parent-portfolio
-    </Link>
-    <span
-      className="slash-separator"
-    />
-  </span>
-  <span
-    className="flex-shrink display-flex-center"
-    key="child-portfolio"
-  >
-    <span
-      className="text-ellipsis"
-      title="child-portfolio"
-    >
-      child-portfolio
-    </span>
-  </span>
-</div>
-`;
index bf77fa89ed046e08b7790770cb5d13c11762428e..dffea76fc4a40df373deaeb0988b7d8a6ded6b38 100644 (file)
@@ -10,7 +10,7 @@ exports[`should render correctly 1`] = `
   <header
     className="display-flex-center flex-shrink"
   >
-    <ComponentBreadcrumb
+    <Breadcrumb
       component={
         Object {
           "breadcrumbs": Array [],