]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19604 Fixes from validation
authorJeremy Davis <jeremy.davis@sonarsource.com>
Fri, 23 Jun 2023 16:32:42 +0000 (18:32 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 26 Jun 2023 20:03:55 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx
server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx
server/sonar-web/src/main/js/components/activity-graph/EventInner.tsx
server/sonar-web/src/main/js/components/activity-graph/RichQualityGateEventInner.tsx

index f515d35637053217313be7af1e57c603a2e1f367..028d0f6cda44da61d695afabd9fb0e585915f928 100644 (file)
@@ -43,7 +43,7 @@ function Events(props: EventsProps) {
   );
 
   return (
-    <div className="sw-flex sw-flex-1 sw-flex-col sw-gap-1">
+    <div className="sw-flex sw-flex-1 sw-flex-col sw-gap-2 sw-min-w-0">
       {sortedEvents.map((event) => (
         <Event
           analysisKey={analysisKey}
index 5009c41e566d703f617269a4269a773fbf4fa304..7d763e9aafc5efc016cffee30021e8c6d9794849 100644 (file)
@@ -30,6 +30,7 @@ import {
 } from 'design-system';
 import * as React from 'react';
 import { WrappedComponentProps, injectIntl } from 'react-intl';
+import ClickEventBoundary from '../../../components/controls/ClickEventBoundary';
 import HelpTooltip from '../../../components/controls/HelpTooltip';
 import Tooltip from '../../../components/controls/Tooltip';
 import { formatterOption } from '../../../components/intl/DateTimeFormatter';
@@ -115,7 +116,7 @@ function ProjectActivityAnalysis(props: ProjectActivityAnalysisProps) {
         ref={(ref) => (node = ref)}
       >
         <div className="it__project-activity-time">
-          <ActivityTime className="sw-box-border sw-grow-0 sw-shrink-0 sw-h-page sw-body-sm-highlight sw-text-right sw-mr-2">
+          <ActivityTime className="sw-h-page sw-body-sm-highlight sw-text-right sw-mr-2 sw-py-1/2">
             <TimeFormatter date={parsedDate} long={false}>
               {(formattedTime) => <time dateTime={parsedDate.toISOString()}>{formattedTime}</time>}
             </TimeFormatter>
@@ -123,63 +124,65 @@ function ProjectActivityAnalysis(props: ProjectActivityAnalysisProps) {
         </div>
 
         {(canAddVersion || canAddEvent || canDeleteAnalyses) && (
-          <div className="sw-h-page sw-grow-0 sw-shrink-0 sw-mr-4 sw-relative">
-            <ActionsDropdown
-              ariaLabel={translateWithParameters(
-                'project_activity.analysis_X_actions',
-                analysis.buildString || formatDate(parsedDate, formatterOption)
+          <ClickEventBoundary>
+            <div className="sw-h-page sw-grow-0 sw-shrink-0 sw-mr-4 sw-relative">
+              <ActionsDropdown
+                ariaLabel={translateWithParameters(
+                  'project_activity.analysis_X_actions',
+                  analysis.buildString || formatDate(parsedDate, formatterOption)
+                )}
+                buttonSize="small"
+                id="it__analysis-actions"
+                zLevel={PopupZLevel.Absolute}
+              >
+                {canAddVersion && (
+                  <ItemButton className="js-add-version" onClick={() => setAddVersionForm(true)}>
+                    {translate('project_activity.add_version')}
+                  </ItemButton>
+                )}
+                {canAddEvent && (
+                  <ItemButton className="js-add-event" onClick={() => setAddEventForm(true)}>
+                    {translate('project_activity.add_custom_event')}
+                  </ItemButton>
+                )}
+                {(canAddVersion || canAddEvent) && canDeleteAnalyses && <ItemDivider />}
+                {canDeleteAnalyses && (
+                  <ItemDangerButton
+                    className="js-delete-analysis"
+                    onClick={() => setRemoveAnalysisForm(true)}
+                  >
+                    {translate('project_activity.delete_analysis')}
+                  </ItemDangerButton>
+                )}
+              </ActionsDropdown>
+
+              {addVersionForm && (
+                <AddEventForm
+                  addEvent={props.onAddVersion}
+                  addEventButtonText="project_activity.add_version"
+                  analysis={analysis}
+                  onClose={() => setAddVersionForm(false)}
+                />
               )}
-              buttonSize="small"
-              id="it__analysis-actions"
-              zLevel={PopupZLevel.Absolute}
-            >
-              {canAddVersion && (
-                <ItemButton className="js-add-version" onClick={() => setAddVersionForm(true)}>
-                  {translate('project_activity.add_version')}
-                </ItemButton>
-              )}
-              {canAddEvent && (
-                <ItemButton className="js-add-event" onClick={() => setAddEventForm(true)}>
-                  {translate('project_activity.add_custom_event')}
-                </ItemButton>
-              )}
-              {(canAddVersion || canAddEvent) && canDeleteAnalyses && <ItemDivider />}
-              {canDeleteAnalyses && (
-                <ItemDangerButton
-                  className="js-delete-analysis"
-                  onClick={() => setRemoveAnalysisForm(true)}
-                >
-                  {translate('project_activity.delete_analysis')}
-                </ItemDangerButton>
+
+              {addEventForm && (
+                <AddEventForm
+                  addEvent={props.onAddCustomEvent}
+                  addEventButtonText="project_activity.add_custom_event"
+                  analysis={analysis}
+                  onClose={() => setAddEventForm(false)}
+                />
               )}
-            </ActionsDropdown>
-
-            {addVersionForm && (
-              <AddEventForm
-                addEvent={props.onAddVersion}
-                addEventButtonText="project_activity.add_version"
-                analysis={analysis}
-                onClose={() => setAddVersionForm(false)}
-              />
-            )}
-
-            {addEventForm && (
-              <AddEventForm
-                addEvent={props.onAddCustomEvent}
-                addEventButtonText="project_activity.add_custom_event"
-                analysis={analysis}
-                onClose={() => setAddEventForm(false)}
-              />
-            )}
 
-            {removeAnalysisForm && (
-              <RemoveAnalysisForm
-                analysis={analysis}
-                deleteAnalysis={props.onDeleteAnalysis}
-                onClose={() => setRemoveAnalysisForm(false)}
-              />
-            )}
-          </div>
+              {removeAnalysisForm && (
+                <RemoveAnalysisForm
+                  analysis={analysis}
+                  deleteAnalysis={props.onDeleteAnalysis}
+                  onClose={() => setRemoveAnalysisForm(false)}
+                />
+              )}
+            </div>
+          </ClickEventBoundary>
         )}
 
         {analysis.events.length > 0 && (
@@ -213,6 +216,7 @@ function ProjectActivityAnalysis(props: ProjectActivityAnalysisProps) {
 }
 
 const ActivityTime = styled.div`
+  box-sizing: border-box;
   width: 4.5rem;
 `;
 
index e96e601475ab9d4a7a15d37a87868b3702e8a6fd..bba186f2cd6f85b612ef0b3af699f685ab3291b2 100644 (file)
@@ -168,13 +168,11 @@ describe('CRUD', () => {
     await ui.appLoaded();
 
     await ui.addVersionEvent('1.1.0.1', initialValue);
-    // should appear 3x, one for the list, one for the graph and one for the tooltip
-    expect(screen.getAllByText(initialValue).length).toEqual(3);
+    expect(screen.getAllByText(initialValue).length).toBeGreaterThan(0);
 
     await act(async () => {
       await ui.updateEvent(1, updatedValue);
-      // should appear 3x, one for the list, one for the graph and one for the tooltip
-      expect(screen.getAllByText(updatedValue).length).toEqual(3);
+      expect(screen.getAllByText(updatedValue).length).toBeGreaterThan(0);
     });
 
     await ui.deleteEvent(0);
@@ -199,12 +197,12 @@ describe('CRUD', () => {
 
     await act(async () => {
       await ui.addCustomEvent('1.1.0.1', initialValue);
-      expect(screen.getAllByText(initialValue)[0]).toBeInTheDocument();
+      expect(screen.getAllByText(initialValue).length).toBeGreaterThan(0);
     });
 
     await act(async () => {
       await ui.updateEvent(1, updatedValue);
-      expect(screen.getAllByText(updatedValue)[0]).toBeInTheDocument();
+      expect(screen.getAllByText(updatedValue).length).toBeGreaterThan(0);
     });
 
     await ui.deleteEvent(0);
index dafa20f4d6a885ed000ca1909c8e7476859f81d1..bc5379f0a74bc847804896658c2ea8ee5dad2b50 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { BareButton, ChevronDownIcon, StandoutLink } from 'design-system';
+import { BareButton, BranchIcon, ChevronDownIcon, Note, StandoutLink } from 'design-system';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { isMainBranch } from '../../helpers/branch-like';
 import { translate } from '../../helpers/l10n';
-import { limitComponentName } from '../../helpers/path';
 import { getProjectUrl } from '../../helpers/urls';
 import { BranchLike } from '../../types/branch-like';
 import {
@@ -31,7 +30,6 @@ import {
   DefinitionChangeType,
 } from '../../types/project-activity';
 import ClickEventBoundary from '../controls/ClickEventBoundary';
-import BranchIcon from '../icons/BranchIcon';
 
 export type DefinitionChangeEvent = AnalysisEvent &
   Required<Pick<AnalysisEvent, 'definitionChange'>>;
@@ -53,8 +51,6 @@ interface State {
   expanded: boolean;
 }
 
-const NAME_MAX_LENGTH = 28;
-
 export class DefinitionChangeEventInner extends React.PureComponent<Props, State> {
   state: State = { expanded: false };
 
@@ -64,15 +60,19 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State
 
   renderProjectLink = (project: { key: string; name: string }, branch: string | undefined) => (
     <ClickEventBoundary>
-      <StandoutLink title={project.name} to={getProjectUrl(project.key, branch)}>
-        {limitComponentName(project.name, NAME_MAX_LENGTH)}
+      <StandoutLink
+        className="sw-truncate sw-mr-1"
+        title={project.name}
+        to={getProjectUrl(project.key, branch)}
+      >
+        {project.name}
       </StandoutLink>
     </ClickEventBoundary>
   );
 
   renderBranch = (branch = translate('branches.main_branch')) => (
-    <span className="nowrap" title={branch}>
-      <BranchIcon className="little-spacer-left text-text-top" />
+    <span className="sw-flex sw-items-center sw-mr-1" title={branch}>
+      <BranchIcon className="sw-ml-1" />
       {branch}
     </span>
   );
@@ -139,24 +139,29 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State
     const { event, readonly } = this.props;
     const { expanded } = this.state;
     return (
-      <div className="sw-flex sw-basis-full sw-flex-col">
+      <div className="sw-w-full sw-body-sm sw-py-1/2">
         <div className="sw-flex sw-justify-between">
-          <span className="sw-mr-1">{translate('event.category', event.category)}</span>
+          <Note className="sw-mr-1 sw-body-sm-highlight">
+            {translate('event.category', event.category)}
+          </Note>
 
           {!readonly && (
-            <div>
-              <BareButton onClick={this.toggleProjectsList}>
+            <ClickEventBoundary>
+              <BareButton
+                className="sw-flex sw-items-center sw-ml-2"
+                onClick={this.toggleProjectsList}
+              >
                 {expanded ? translate('hide') : translate('more')}
                 <ChevronDownIcon transform={expanded ? 'rotate(180)' : undefined} />
               </BareButton>
-            </div>
+            </ClickEventBoundary>
           )}
         </div>
 
         {expanded && (
           <ul className="sw-mt-2">
             {event.definitionChange.projects.map((project) => (
-              <li className="sw-p-1 sw-text-ellipsis sw-overflow-hidden" key={project.key}>
+              <li className="sw-flex sw-items-center sw-flex-wrap sw-p-1 sw-mb-1" key={project.key}>
                 {this.renderProjectChange(project)}
               </li>
             ))}
index 2d50393af70e35f8a3936483622ade9f40c602f4..31996b65f5a0c152ad9705fd591544a860c95420 100644 (file)
@@ -45,7 +45,7 @@ export default function EventInner({ event, readonly }: EventInnerProps) {
   }
   return (
     <Tooltip overlay={event.description}>
-      <div className="sw-min-w-0 sw-flex-1">
+      <div className="sw-min-w-0 sw-flex-1 sw-py-1/2">
         <div className="sw-flex sw-items-start">
           <span>
             <Note className="sw-mr-1 sw-body-sm-highlight">
index 500a4bd9faa6b718e4a03e606eff9a69af9919df..48d7d6bfada4b9abf78bae768538bbfbec3221e1 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { BareButton, ChevronDownIcon, QualityGateIndicator, StandoutLink } from 'design-system';
+import {
+  BareButton,
+  ChevronDownIcon,
+  Note,
+  QualityGateIndicator,
+  StandoutLink,
+} from 'design-system';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { translate, translateWithParameters } from '../../helpers/l10n';
@@ -51,11 +57,14 @@ export class RichQualityGateEventInner extends React.PureComponent<Props, State>
     const { event, readonly } = this.props;
     const { expanded } = this.state;
     return (
-      <div className="sw-flex sw-basis-full sw-flex-col">
+      <div className="sw-w-full sw-body-sm sw-py-1/2">
         <div className="sw-flex sw-justify-between">
-          <div className="sw-flex sw-justify-between">
-            <span className="sw-mr-1">{translate('event.category', event.category)}:</span>
-            <div className="sw-mx-2">
+          <div className="sw-flex sw-items-center">
+            <Note className="sw-mr-1 sw-body-sm-highlight">
+              {translate('event.category', event.category)}
+            </Note>
+
+            <div className="sw-ml-2 sw-flex sw-items-center">
               {event.qualityGate.stillFailing ? (
                 <FormattedMessage
                   defaultMessage={translate('event.quality_gate.still_x')}
@@ -67,25 +76,31 @@ export class RichQualityGateEventInner extends React.PureComponent<Props, State>
               ) : (
                 <QualityGateIndicator status={event.qualityGate.status} size="sm" />
               )}
+
+              <span className="sw-ml-1">
+                {translate(`event.quality_gate.${event.qualityGate.status}`)}
+              </span>
             </div>
-            <span>{translate(`event.quality_gate.${event.qualityGate.status}`)}</span>
           </div>
 
           {!readonly && event.qualityGate.failing.length > 0 && (
-            <div>
-              <BareButton onClick={this.toggleProjectsList}>
+            <ClickEventBoundary>
+              <BareButton
+                className="sw-flex sw-items-center sw-ml-2"
+                onClick={this.toggleProjectsList}
+              >
                 {expanded ? translate('hide') : translate('more')}
                 <ChevronDownIcon transform={expanded ? 'rotate(180)' : undefined} />
               </BareButton>
-            </div>
+            </ClickEventBoundary>
           )}
         </div>
 
         {expanded && (
-          <ul className="sw-flex sw-flex-col sw-mt-2">
+          <ul className="sw-mt-2">
             {event.qualityGate.failing.map((project) => (
-              <li className="sw-flex sw-p-1" key={project.key}>
-                <div>
+              <li className="sw-flex sw-justify-between sw-p-1" key={project.key}>
+                <div className="sw-truncate">
                   <ClickEventBoundary>
                     <StandoutLink
                       title={project.name}
@@ -97,10 +112,8 @@ export class RichQualityGateEventInner extends React.PureComponent<Props, State>
                     </StandoutLink>
                   </ClickEventBoundary>
                 </div>
-                <div className="sw-shrink sw-flex sw-ml-2">
-                  <div className="sw-items-top">
-                    <QualityGateIndicator status={event.qualityGate.status} size="sm" />
-                  </div>
+                <div className="sw-flex sw-items-center sw-ml-2">
+                  <QualityGateIndicator status={event.qualityGate.status} size="sm" />
                   <span className="sw-ml-2">
                     {translate(`event.quality_gate.${event.qualityGate.status}`)}
                   </span>