]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13273 Improve folder exploration
authorJeremy Davis <jeremy.davis@sonarsource.com>
Mon, 9 Aug 2021 15:49:57 +0000 (17:49 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 11 Aug 2021 20:08:07 +0000 (20:08 +0000)
server/sonar-web/src/main/js/apps/code/code.css
server/sonar-web/src/main/js/apps/code/components/Component.tsx
server/sonar-web/src/main/js/apps/code/components/Components.tsx
server/sonar-web/src/main/js/apps/code/components/__tests__/Component-test.tsx
server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Component-test.tsx.snap
server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap

index ced158d3a9e8e77120d59e8bee2fb93fbb2d6e9d..734b3128f5146ff419e2aa8904c0bd6bbc9997b5 100644 (file)
 table > thead > tr.code-components-header > th {
   vertical-align: middle;
 }
+
+.code-child-component-icon {
+  display: inline-block;
+  border-left: 1px solid var(--secondFontColor);
+  border-bottom: 1px solid var(--secondFontColor);
+  margin-left: 8px;
+  margin-bottom: 8px;
+  margin-right: 4px;
+  height: 8px;
+  width: 4px;
+}
index af3ec78024007d0354fd770b98044758df1c1479..d902d22e2c89b869f3456b09c39aed9b547583ac 100644 (file)
@@ -31,6 +31,7 @@ interface Props {
   canBePinned?: boolean;
   canBrowse?: boolean;
   component: T.ComponentMeasure;
+  hasBaseComponent: boolean;
   metrics: T.Metric[];
   previous?: T.ComponentMeasure;
   rootComponent: T.ComponentMeasure;
@@ -44,6 +45,7 @@ export class Component extends React.PureComponent<Props> {
       canBePinned = true,
       canBrowse = false,
       component,
+      hasBaseComponent,
       metrics,
       previous,
       rootComponent,
@@ -73,6 +75,7 @@ export class Component extends React.PureComponent<Props> {
           </td>
         )}
         <td className="code-name-cell">
+          {hasBaseComponent && <div className="code-child-component-icon" />}
           <ComponentName
             branchLike={branchLike}
             canBrowse={canBrowse}
index 61fa64c9828a4ab7831699e689441847510773f8..5191e9d484aa2d5329163fd15c6be1e41cba9c9b 100644 (file)
@@ -35,6 +35,8 @@ interface Props {
   selected?: T.ComponentMeasure;
 }
 
+const BASE_COLUMN_COUNT = 4;
+
 export class Components extends React.PureComponent<Props> {
   render() {
     const { baseComponent, branchLike, components, rootComponent, selected } = this.props;
@@ -43,7 +45,7 @@ export class Components extends React.PureComponent<Props> {
       Object.keys(this.props.metrics)
     );
     const metrics = metricKeys.map(metric => this.props.metrics[metric]);
-    const colSpan = metrics.length + 4;
+    const colSpan = metrics.length + BASE_COLUMN_COUNT;
     const canBePinned = baseComponent && !['APP', 'VW', 'SVW'].includes(baseComponent.qualifier);
 
     return (
@@ -63,13 +65,18 @@ export class Components extends React.PureComponent<Props> {
                 branchLike={branchLike}
                 canBePinned={canBePinned}
                 component={baseComponent}
+                hasBaseComponent={false}
                 key={baseComponent.key}
                 metrics={metrics}
                 rootComponent={rootComponent}
               />
               <tr className="blank">
-                <td colSpan={3}>&nbsp;</td>
-                <td colSpan={colSpan}>&nbsp;</td>
+                <td colSpan={3}>
+                  <hr className="null-spacer-top" />
+                </td>
+                <td colSpan={colSpan}>
+                  <hr className="null-spacer-top" />
+                </td>
               </tr>
             </>
           )}
@@ -81,6 +88,7 @@ export class Components extends React.PureComponent<Props> {
                 canBePinned={canBePinned}
                 canBrowse={true}
                 component={component}
+                hasBaseComponent={baseComponent !== undefined}
                 key={component.key}
                 metrics={metrics}
                 previous={index > 0 ? list[index - 1] : undefined}
index e9e7db22b996979cf2f941648aecd1be979fca9f..42c7322c0897d2ef32aa57e2d432206c2b6a6ae2 100644 (file)
@@ -24,6 +24,7 @@ import { Component } from '../Component';
 
 it('should render correctly', () => {
   expect(shallowRender()).toMatchSnapshot();
+  expect(shallowRender({ hasBaseComponent: true })).toMatchSnapshot('with base component');
 });
 
 it('should render correctly for a file', () => {
@@ -41,6 +42,7 @@ function shallowRender(props: Partial<Component['props']> = {}) {
           { metric: 'vulnerabilities', value: '1' }
         ]
       })}
+      hasBaseComponent={false}
       metrics={[mockMetric({ key: 'bugs' }), mockMetric({ key: 'vulnerabilities' })]}
       rootComponent={mockComponentMeasure()}
       {...props}
index 2bfb85076093ee7153535ab5d225274775a8096c..176787f33f64bc26d459d0db6cd8fea47ad638ee 100644 (file)
@@ -253,3 +253,132 @@ exports[`should render correctly for a file 1`] = `
   />
 </tr>
 `;
+
+exports[`should render correctly: with base component 1`] = `
+<tr
+  className=""
+>
+  <td
+    className="blank"
+  />
+  <td
+    className="thin nowrap"
+  />
+  <td
+    className="code-name-cell"
+  >
+    <div
+      className="code-child-component-icon"
+    />
+    <ComponentName
+      canBrowse={false}
+      component={
+        Object {
+          "key": "bar",
+          "measures": Array [
+            Object {
+              "metric": "bugs",
+              "value": "12",
+            },
+            Object {
+              "metric": "vulnerabilities",
+              "value": "1",
+            },
+          ],
+          "name": "Bar",
+          "qualifier": "TRK",
+        }
+      }
+      rootComponent={
+        Object {
+          "key": "foo",
+          "measures": Array [
+            Object {
+              "bestValue": false,
+              "metric": "bugs",
+              "value": "12",
+            },
+          ],
+          "name": "Foo",
+          "qualifier": "TRK",
+        }
+      }
+    />
+  </td>
+  <td
+    className="thin nowrap text-right"
+    key="bugs"
+  >
+    <div
+      className="code-components-cell"
+    >
+      <ComponentMeasure
+        component={
+          Object {
+            "key": "bar",
+            "measures": Array [
+              Object {
+                "metric": "bugs",
+                "value": "12",
+              },
+              Object {
+                "metric": "vulnerabilities",
+                "value": "1",
+              },
+            ],
+            "name": "Bar",
+            "qualifier": "TRK",
+          }
+        }
+        metric={
+          Object {
+            "id": "bugs",
+            "key": "bugs",
+            "name": "Bugs",
+            "type": "PERCENT",
+          }
+        }
+      />
+    </div>
+  </td>
+  <td
+    className="thin nowrap text-right"
+    key="vulnerabilities"
+  >
+    <div
+      className="code-components-cell"
+    >
+      <ComponentMeasure
+        component={
+          Object {
+            "key": "bar",
+            "measures": Array [
+              Object {
+                "metric": "bugs",
+                "value": "12",
+              },
+              Object {
+                "metric": "vulnerabilities",
+                "value": "1",
+              },
+            ],
+            "name": "Bar",
+            "qualifier": "TRK",
+          }
+        }
+        metric={
+          Object {
+            "id": "vulnerabilities",
+            "key": "vulnerabilities",
+            "name": "Vulnerabilities",
+            "type": "PERCENT",
+          }
+        }
+      />
+    </div>
+  </td>
+  <td
+    className="blank"
+  />
+</tr>
+`;
index e96434724f96d6722d4d68f83e0e6109e6f0bdc7..3a2adbdcacea05940c97fcc51b15bb23ef516e35 100644 (file)
@@ -36,6 +36,7 @@ exports[`renders correctly 1`] = `
           "qualifier": "TRK",
         }
       }
+      hasBaseComponent={false}
       key="foo"
       metrics={
         Array [
@@ -61,12 +62,16 @@ exports[`renders correctly 1`] = `
       <td
         colSpan={3}
       >
-         
+        <hr
+          className="null-spacer-top"
+        />
       </td>
       <td
         colSpan={5}
       >
-         
+        <hr
+          className="null-spacer-top"
+        />
       </td>
     </tr>
     <withScrollTo(Component)
@@ -79,6 +84,7 @@ exports[`renders correctly 1`] = `
           "qualifier": "TRK",
         }
       }
+      hasBaseComponent={true}
       key="foo"
       metrics={
         Array [
@@ -126,6 +132,7 @@ exports[`renders correctly for a search 1`] = `
           "qualifier": "TRK",
         }
       }
+      hasBaseComponent={false}
       key="foo"
       metrics={Array []}
       rootComponent={
@@ -194,6 +201,7 @@ exports[`renders correctly for leak 1`] = `
           "qualifier": "TRK",
         }
       }
+      hasBaseComponent={false}
       key="foo"
       metrics={
         Array [
@@ -219,12 +227,16 @@ exports[`renders correctly for leak 1`] = `
       <td
         colSpan={3}
       >
-         
+        <hr
+          className="null-spacer-top"
+        />
       </td>
       <td
         colSpan={5}
       >
-         
+        <hr
+          className="null-spacer-top"
+        />
       </td>
     </tr>
     <withScrollTo(Component)
@@ -245,6 +257,7 @@ exports[`renders correctly for leak 1`] = `
           "qualifier": "TRK",
         }
       }
+      hasBaseComponent={true}
       key="foo"
       metrics={
         Array [