From ea34a3048623669bd4602b8dee745e144b503852 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Tue, 24 Oct 2017 16:10:23 +0200 Subject: [PATCH] Fix quality flaws --- .../components/nav/settings/SettingsNav.tsx | 204 ++++++++++-------- .../src/main/js/store/marketplace/actions.ts | 2 +- 2 files changed, 112 insertions(+), 94 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx index 4a983b4feed..db5f9efcf95 100644 --- a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx @@ -79,24 +79,118 @@ export default class SettingsNav extends React.PureComponent { ); }; - render() { - const { customOrganizations, editionStatus, extensions } = this.props; - const isSecurity = this.isSecurityActive(); - const isProjects = this.isProjectsActive(); - const isSystem = this.isSystemActive(); - const isSupport = this.isSomethingActive(['/admin/extension/license/support']); - - const securityClassName = classNames('dropdown-toggle', { active: isSecurity }); - const projectsClassName = classNames('dropdown-toggle', { active: isProjects }); + renderConfigurationTab() { const configurationClassNames = classNames('dropdown-toggle', { - active: !isSecurity && !isProjects && !isSystem && !isSupport && !this.isMarketplace() + active: + !this.isSecurityActive() && + !this.isProjectsActive() && + !this.isSystemActive() && + !this.isSomethingActive(['/admin/extension/license/support']) && + !this.isMarketplace() }); - - const extensionsWithoutSupport = extensions.filter( + const extensionsWithoutSupport = this.props.extensions.filter( extension => extension.key !== 'license/support' ); + return ( +
  • + + {translate('sidebar.project_settings')} + +
      +
    • + + {translate('settings.page')} + +
    • +
    • + + {translate('property.category.security.encryption')} + +
    • +
    • + + {translate('custom_metrics.page')} + +
    • + {extensionsWithoutSupport.map(this.renderExtension)} +
    +
  • + ); + } - const hasSupportExtension = extensionsWithoutSupport.length < extensions.length; + renderProjectsTab() { + const { customOrganizations } = this.props; + const projectsClassName = classNames('dropdown-toggle', { active: this.isProjectsActive() }); + return ( +
  • + + {translate('sidebar.projects')} + +
      + {!customOrganizations && ( +
    • + + {translate('management')} + +
    • + )} +
    • + + {translate('background_tasks.page')} + +
    • +
    +
  • + ); + } + + renderSecurityTab() { + const { customOrganizations } = this.props; + const securityClassName = classNames('dropdown-toggle', { active: this.isSecurityActive() }); + return ( +
  • + + {translate('sidebar.security')} + +
      +
    • + + {translate('users.page')} + +
    • + {!customOrganizations && ( +
    • + + {translate('user_groups.page')} + +
    • + )} + {!customOrganizations && ( +
    • + + {translate('global_permissions.page')} + +
    • + )} + {!customOrganizations && ( +
    • + + {translate('permission_templates')} + +
    • + )} +
    +
  • + ); + } + + render() { + const { editionStatus, extensions } = this.props; + const hasSupportExtension = extensions.find(extension => extension.key === 'license/support'); let notifComponent; if ( @@ -105,6 +199,7 @@ export default class SettingsNav extends React.PureComponent { ) { notifComponent = ; } + return ( { -
  • - - {translate('sidebar.project_settings')} - -
      -
    • - - {translate('settings.page')} - -
    • -
    • - - {translate('property.category.security.encryption')} - -
    • -
    • - - {translate('custom_metrics.page')} - -
    • - {extensionsWithoutSupport.map(this.renderExtension)} -
    -
  • + {this.renderConfigurationTab()} + {this.renderSecurityTab()} + {this.renderProjectsTab()} -
  • - - {translate('sidebar.security')} - -
      -
    • - - {translate('users.page')} - -
    • - {!customOrganizations && ( -
    • - - {translate('user_groups.page')} - -
    • - )} - {!customOrganizations && ( -
    • - - {translate('global_permissions.page')} - -
    • - )} - {!customOrganizations && ( -
    • - - {translate('permission_templates')} - -
    • - )} -
    -
  • - -
  • - - {translate('sidebar.projects')} - -
      - {!customOrganizations && ( -
    • - - {translate('management')} - -
    • - )} -
    • - - {translate('background_tasks.page')} - -
    • -
    -
  • {translate('sidebar.system')} diff --git a/server/sonar-web/src/main/js/store/marketplace/actions.ts b/server/sonar-web/src/main/js/store/marketplace/actions.ts index 92e18cd48a7..e174708803f 100644 --- a/server/sonar-web/src/main/js/store/marketplace/actions.ts +++ b/server/sonar-web/src/main/js/store/marketplace/actions.ts @@ -39,7 +39,7 @@ interface SetEditionStatusAction { export type Action = LoadEditionsAction | SetEditionsAction | SetEditionStatusAction; -export function loadEditions(loading: boolean = true): LoadEditionsAction { +export function loadEditions(loading = true): LoadEditionsAction { return { type: 'LOAD_EDITIONS', loading }; } -- 2.39.5