]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11090 Use rulesUpdatedAt date for stagnant quality profiles
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 7 Aug 2018 14:11:31 +0000 (16:11 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 9 Aug 2018 18:20:50 +0000 (20:20 +0200)
12 files changed:
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileHeader.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowOfType.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesRowTotal.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRulesSonarWayComparison-test.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx
server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListRow.tsx
server/sonar-web/src/main/js/apps/quality-profiles/utils.ts

index 5338b2197b73a117efb859f6678646bd38f43d4d..922d57fd12bfbf92ec6a748d41b6e100c337df10 100644 (file)
@@ -59,9 +59,9 @@ export default class ProfileExporters extends React.PureComponent<Props> {
           <ul>
             {exportersForLanguage.map((exporter, index) => (
               <li
-                key={exporter.key}
+                className={index > 0 ? 'spacer-top' : undefined}
                 data-key={exporter.key}
-                className={index > 0 ? 'spacer-top' : undefined}>
+                key={exporter.key}>
                 <a href={this.getExportUrl(exporter)} target="_blank">
                   {exporter.name}
                 </a>
index d658ab13be702732b1c012a55b26726806dcbfb3..2315bfcb57b2d06126c8ece962be02dcf67ac018 100644 (file)
@@ -44,7 +44,7 @@ export default class ProfileHeader extends React.PureComponent<Props> {
     const { profile } = this.props;
     let inner = (
       <span>
-        {translate('quality_profiles.updated_')} <ProfileDate date={profile.userUpdatedAt} />
+        {translate('quality_profiles.updated_')} <ProfileDate date={profile.rulesUpdatedAt} />
       </span>
     );
     if (isStagnant(profile)) {
@@ -73,13 +73,13 @@ export default class ProfileHeader extends React.PureComponent<Props> {
     return (
       <header className="page-header quality-profile-header">
         <div className="note spacer-bottom">
-          <IndexLink to={getProfilesPath(organization)} className="text-muted">
+          <IndexLink className="text-muted" to={getProfilesPath(organization)}>
             {translate('quality_profiles.page')}
           </IndexLink>
           {' / '}
           <Link
-            to={getProfilesForLanguagePath(profile.language, organization)}
-            className="text-muted">
+            className="text-muted"
+            to={getProfilesForLanguagePath(profile.language, organization)}>
             {profile.languageName}
           </Link>
         </div>
@@ -103,8 +103,8 @@ export default class ProfileHeader extends React.PureComponent<Props> {
             {this.renderUsageDate()}
             <li>
               <Link
-                to={getProfileChangelogPath(profile.name, profile.language, organization)}
-                className="button">
+                className="button"
+                to={getProfileChangelogPath(profile.name, profile.language, organization)}>
                 {translate('changelog')}
               </Link>
             </li>
index 08e39200ed60c1724c193c4086d36f73b7e4beda..6db2eeb7e3311dc286004daa3fef2de1c87990d0 100644 (file)
@@ -95,14 +95,14 @@ export default class ProfilePermissionsFormSelect extends React.PureComponent<Pr
         autoFocus={true}
         className="Select-big"
         clearable={false}
-        isLoading={this.state.loading}
         // disable default react-select filtering
         filterOptions={identity}
+        isLoading={this.state.loading}
         noResultsText={noResultsText}
-        optionRenderer={optionRenderer}
-        options={options}
         onChange={this.props.onChange}
         onInputChange={this.handleInputChange}
+        optionRenderer={optionRenderer}
+        options={options}
         placeholder=""
         searchable={true}
         value={this.props.selected && getStringValue(this.props.selected)}
index 261f5998c7505429b6b319fbb9b3da12f66cbb45..a5866f1cc8a7193a20deccf5f521e421293cd056 100644 (file)
@@ -173,8 +173,8 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
               />
               {TYPES.map(type => (
                 <ProfileRulesRowOfType
-                  key={type}
                   count={this.getRulesCountForType(type)}
+                  key={type}
                   organization={organization}
                   qprofile={profile.key}
                   total={this.getRulesTotalForType(type)}
@@ -188,7 +188,7 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
             profile.actions.edit &&
             !profile.isBuiltIn && (
               <div className="text-right big-spacer-top">
-                <Link to={activateMoreUrl} className="button js-activate-rules">
+                <Link className="button js-activate-rules" to={activateMoreUrl}>
                   {translate('quality_profiles.activate_more')}
                 </Link>
               </div>
@@ -207,8 +207,8 @@ export default class ProfileRules extends React.PureComponent<Props, State> {
               language={profile.language}
               organization={organization}
               profile={profile.key}
-              sonarway={compareToSonarWay.profile}
               sonarWayMissingRules={compareToSonarWay.missingRuleCount}
+              sonarway={compareToSonarWay.profile}
             />
           )}
       </div>
index 659e9a2a961f6ea7d7271f3322042cc1e63ba838..1fe8ab53480d84a60c592a6859e980a98b5f1007 100644 (file)
@@ -50,7 +50,7 @@ export default function ProfileRulesRowOfType(props: Props) {
     <tr>
       <td>
         <span>
-          <IssueTypeIcon query={props.type} className="little-spacer-right" />
+          <IssueTypeIcon className="little-spacer-right" query={props.type} />
           {translate('issue.type', props.type, 'plural')}
         </span>
       </td>
@@ -62,7 +62,7 @@ export default function ProfileRulesRowOfType(props: Props) {
       <td className="thin nowrap text-right">
         {inactiveCount != null &&
           (inactiveCount > 0 ? (
-            <Link to={inactiveRulesUrl} className="small text-muted">
+            <Link className="small text-muted" to={inactiveRulesUrl}>
               {formatMeasure(inactiveCount, 'SHORT_INT', null)}
             </Link>
           ) : (
index e75e2b5cd9dd22daed7b278103bb98cb108116f8..8027c625e0a3a8498f58d534be6049e9edb74a3d 100644 (file)
@@ -59,7 +59,7 @@ export default function ProfileRulesRowTotal(props: Props) {
       <td className="thin nowrap text-right">
         {inactiveCount != null &&
           (inactiveCount > 0 ? (
-            <Link to={inactiveRulesUrl} className="small text-muted">
+            <Link className="small text-muted" to={inactiveRulesUrl}>
               <strong>{formatMeasure(inactiveCount, 'SHORT_INT', null)}</strong>
             </Link>
           ) : (
index 223c1495e76bf0bbab366667a6ddc5393a6c7525..0df4f130d58258ec65ac115f815bbcfa714344a8 100644 (file)
@@ -28,8 +28,8 @@ it('should render correctly', () => {
         language="Java"
         organization="foo"
         profile="bar"
-        sonarway="baz"
         sonarWayMissingRules={158}
+        sonarway="baz"
       />
     )
   ).toMatchSnapshot();
index 993afcd1d8ee9cb92933b337ef01123689cf0543..19323d0685d48f423dce710a1314cc526a2ea31e 100644 (file)
@@ -54,7 +54,7 @@ export default function EvolutionDeprecated(props: Props) {
       </div>
       <ul>
         {sortedProfiles.map(profile => (
-          <li key={profile.key} className="spacer-top">
+          <li className="spacer-top" key={profile.key}>
             <div className="text-ellipsis">
               <ProfileLink
                 className="link-no-underline"
@@ -68,8 +68,8 @@ export default function EvolutionDeprecated(props: Props) {
               {profile.languageName}
               {', '}
               <Link
-                to={getDeprecatedActiveRulesUrl({ qprofile: profile.key }, props.organization)}
-                className="text-muted">
+                className="text-muted"
+                to={getDeprecatedActiveRulesUrl({ qprofile: profile.key }, props.organization)}>
                 {translateWithParameters(
                   'quality_profile.x_rules',
                   profile.activeDeprecatedRuleCount
index 5a9415f8c741481e77119022d2437b6f22e8b154..dc6d9fcef31210327b83a3c5f5091a441536c2dc 100644 (file)
@@ -30,9 +30,7 @@ interface Props {
 }
 
 export default function EvolutionStagnant(props: Props) {
-  // TODO filter built-in out
-
-  const outdated = props.profiles.filter(isStagnant);
+  const outdated = props.profiles.filter(profile => !profile.isBuiltIn && isStagnant(profile));
 
   if (outdated.length === 0) {
     return null;
@@ -48,7 +46,7 @@ export default function EvolutionStagnant(props: Props) {
       </div>
       <ul>
         {outdated.map(profile => (
-          <li key={profile.key} className="spacer-top">
+          <li className="spacer-top" key={profile.key}>
             <div className="text-ellipsis">
               <ProfileLink
                 className="link-no-underline"
index b5be91be3307f5d9e2587be764837e54bbcee51c..05faaa8ef8f5ec00411927b9607e3b77a665cb32 100644 (file)
@@ -80,8 +80,8 @@ export default class ProfilesList extends React.PureComponent<Props> {
 
   renderLanguage = (languageKey: string, profiles: Profile[] | undefined) => {
     return (
-      <div key={languageKey} className="boxed-group boxed-group-inner quality-profiles-table">
-        <table data-language={languageKey} className="data zebra zebra-hover">
+      <div className="boxed-group boxed-group-inner quality-profiles-table" key={languageKey}>
+        <table className="data zebra zebra-hover" data-language={languageKey}>
           {profiles !== undefined && this.renderHeader(languageKey, profiles.length)}
           <tbody>{profiles !== undefined && this.renderProfiles(profiles)}</tbody>
         </table>
index 69fbf16ae2e4340404b5830564f80723c58890eb..5fb2c5e1fac82100cd15d35c332a31f0bfc6696a 100644 (file)
@@ -96,7 +96,7 @@ export default class ProfilesListRow extends React.PureComponent<Props> {
         {profile.activeDeprecatedRuleCount > 0 && (
           <span className="spacer-right">
             <Tooltip overlay={translate('quality_profiles.deprecated_rules')}>
-              <Link to={deprecatedRulesUrl} className="badge badge-normal-size badge-danger-light">
+              <Link className="badge badge-normal-size badge-danger-light" to={deprecatedRulesUrl}>
                 {profile.activeDeprecatedRuleCount}
               </Link>
             </Tooltip>
@@ -109,7 +109,7 @@ export default class ProfilesListRow extends React.PureComponent<Props> {
   }
 
   renderUpdateDate() {
-    const date = <ProfileDate date={this.props.profile.userUpdatedAt} />;
+    const date = <ProfileDate date={this.props.profile.rulesUpdatedAt} />;
     if (isStagnant(this.props.profile)) {
       return <span className="badge badge-normal-size badge-focus">{date}</span>;
     } else {
index c0e23eeaf9f7f0284a9266c95c827c5a76c98894..e8f7c1460522c72670c2a895f1b8fa9a31253656 100644 (file)
@@ -67,8 +67,8 @@ export function createFakeProfile(overrides?: any) {
 }
 
 export function isStagnant(profile: Profile): boolean {
-  if (profile.userUpdatedAt) {
-    const updateDate = parseDate(profile.userUpdatedAt);
+  if (profile.rulesUpdatedAt) {
+    const updateDate = parseDate(profile.rulesUpdatedAt);
     if (isValidDate(updateDate)) {
       return differenceInYears(new Date(), updateDate) >= 1;
     }