]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10209 handle deleted Quality Profile on project page
authorPascal Mugnier <pascal.mugnier@sonarsource.com>
Wed, 8 Aug 2018 13:48:24 +0000 (15:48 +0200)
committerSonarTech <sonartech@sonarsource.com>
Fri, 10 Aug 2018 18:21:33 +0000 (20:21 +0200)
server/sonar-web/src/main/js/app/types.ts
server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx
server/sonar-web/src/main/js/apps/overview/styles.css
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 4b55b604c22d68ead37b1c9092a30a09473d5f46..f081619542fe379f233cf20bfc921283bb0c0c4c 100644 (file)
@@ -72,7 +72,7 @@ export interface Component extends LightComponent {
   name: string;
   path?: string;
   refKey?: string;
-  qualityProfiles?: { key: string; language: string; name: string }[];
+  qualityProfiles?: ComponentQualityProfile[];
   qualityGate?: { isDefault?: boolean; key: string; name: string };
   tags?: string[];
   version?: string;
@@ -92,6 +92,13 @@ interface ComponentConfiguration {
   showUpdateKey?: boolean;
 }
 
+export interface ComponentQualityProfile {
+  deleted?: boolean;
+  key: string;
+  language: string;
+  name: string;
+}
+
 export interface Condition {
   error: string;
   id: number;
index d55ad3cc8229eb796a147fed0f52273e60b347b0..a4628b8fa6e14f49c7dee56e1e74fd5cd7482ef6 100644 (file)
@@ -26,6 +26,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n';
 import { getQualityProfileUrl } from '../../../helpers/urls';
 import { searchRules } from '../../../api/rules';
 import { getLanguages } from '../../../store/rootReducer';
+import { ComponentQualityProfile } from '../../../app/types';
 
 interface StateProps {
   languages: { [key: string]: { name: string } };
@@ -34,7 +35,7 @@ interface StateProps {
 interface OwnProps {
   headerClassName?: string;
   organization?: string;
-  profiles: { key: string; language: string; name: string }[];
+  profiles: ComponentQualityProfile[];
 }
 
 interface State {
@@ -55,9 +56,9 @@ class MetaQualityProfiles extends React.PureComponent<StateProps & OwnProps, Sta
   }
 
   loadDeprecatedRules() {
-    const requests = this.props.profiles.map(profile =>
-      this.loadDeprecatedRulesForProfile(profile.key)
-    );
+    const requests = this.props.profiles
+      .filter(p => !p.deleted)
+      .map(profile => this.loadDeprecatedRulesForProfile(profile.key));
     Promise.all(requests).then(
       responses => {
         if (this.mounted) {
@@ -89,19 +90,32 @@ class MetaQualityProfiles extends React.PureComponent<StateProps & OwnProps, Sta
     return count || 0;
   }
 
-  renderProfile(profile: { key: string; language: string; name: string }) {
+  renderProfile(profile: ComponentQualityProfile) {
     const languageFromStore = this.props.languages[profile.language];
     const languageName = languageFromStore ? languageFromStore.name : profile.language;
 
-    const path = getQualityProfileUrl(profile.name, profile.language, this.props.organization);
-
     const inner = (
       <div className="text-ellipsis">
         <span className="note spacer-right">{'(' + languageName + ')'}</span>
-        <Link to={path}>{profile.name}</Link>
+        {profile.deleted ? (
+          profile.name
+        ) : (
+          <Link to={getQualityProfileUrl(profile.name, profile.language, this.props.organization)}>
+            {profile.name}
+          </Link>
+        )}
       </div>
     );
 
+    if (profile.deleted) {
+      const tooltip = translateWithParameters('overview.deleted_profile', profile.name);
+      return (
+        <Tooltip key={profile.key} overlay={tooltip}>
+          <li className="overview-deleted-profile">{inner}</li>
+        </Tooltip>
+      );
+    }
+
     const count = this.getDeprecatedRulesCount(profile);
 
     if (count > 0) {
index 92ed309cda0cae057ff3b2364259604fdf08c72d..4abad4a7f59c49a78cd1bd98fc04d397005d0b18 100644 (file)
   background-color: transparent !important;
 }
 
+.overview-deleted-profile,
 .overview-deprecated-rules {
   margin: 4px -6px 4px;
   padding: 3px 6px !important;
index 13d8d40376f32ae51c5a58f68189dc558f9bcb41..e9dd6677ef6d7cfd6c27b8f5e1ff6ea172c0c1bf 100644 (file)
@@ -2423,6 +2423,7 @@ overview.complexity_tooltip.function={0} functions have complexity around {1}
 overview.complexity_tooltip.file={0} files have complexity around {1}
 
 overview.deprecated_profile=This quality profile uses {0} deprecated rules and should be updated.
+overview.deleted_profile={0} has been deleted since the last analysis.
 
 
 overview.badges.get_badge.TRK=Get project badges