From 4934967a2a2958630b8c3e76265a4e1c09a75063 Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Mon, 12 Jun 2023 12:03:50 +0200 Subject: [PATCH] SONAR-19453 Component cleanup --- .../apps/create/project/CreateProjectPage.tsx | 13 +-- ...anceNewCodeDefinitionComplianceWarning.tsx | 95 ------------------- .../resources/org/sonar/l10n/core.properties | 7 -- 3 files changed, 7 insertions(+), 108 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/create/project/components/InstanceNewCodeDefinitionComplianceWarning.tsx diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx index d2f52c438a6..ab76cc0a0ef 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx @@ -30,6 +30,7 @@ import DocLink from '../../../components/common/DocLink'; import { ButtonLink, SubmitButton } from '../../../components/controls/buttons'; import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import NewCodeDefinitionSelector from '../../../components/new-code-definition/NewCodeDefinitionSelector'; +import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; import { getProjectUrl } from '../../../helpers/urls'; import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; @@ -134,10 +135,6 @@ export class CreateProjectPage extends React.PureComponent { - this.props.router.push(getProjectUrl(projectKey)); - }; - handleProjectCreation = async () => { const { selectedNcd } = this.state; if (this.createProjectFnRef && selectedNcd) { @@ -294,7 +291,7 @@ export class CreateProjectPage extends React.PureComponent @@ -331,8 +328,12 @@ export class CreateProjectPage extends React.PureComponent {translate('back')} - + {translate('onboarding.create_project.new_code_definition.create_project')} + diff --git a/server/sonar-web/src/main/js/apps/create/project/components/InstanceNewCodeDefinitionComplianceWarning.tsx b/server/sonar-web/src/main/js/apps/create/project/components/InstanceNewCodeDefinitionComplianceWarning.tsx deleted file mode 100644 index 7e0f2cc78c4..00000000000 --- a/server/sonar-web/src/main/js/apps/create/project/components/InstanceNewCodeDefinitionComplianceWarning.tsx +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import * as React from 'react'; -import { FormattedMessage } from 'react-intl'; -import { getNewCodePeriod } from '../../../../api/newCodePeriod'; -import { AppStateContextProviderProps } from '../../../../app/components/app-state/AppStateContextProvider'; -import withAppStateContext from '../../../../app/components/app-state/withAppStateContext'; -import DocLink from '../../../../components/common/DocLink'; -import Link from '../../../../components/common/Link'; -import { Alert } from '../../../../components/ui/Alert'; -import { translate } from '../../../../helpers/l10n'; -import { isNewCodeDefinitionCompliant } from '../../../../helpers/periods'; - -export type InstanceNewCodeDefinitionComplianceWarningProps = AppStateContextProviderProps; - -export function InstanceNewCodeDefinitionComplianceWarning({ - appState: { canAdmin }, -}: InstanceNewCodeDefinitionComplianceWarningProps) { - const [isCompliant, setIsCompliant] = React.useState(true); - - React.useEffect(() => { - async function fetchInstanceNCDOptionCompliance() { - const newCodeDefinition = await getNewCodePeriod(); - setIsCompliant(isNewCodeDefinitionCompliant(newCodeDefinition)); - } - - fetchInstanceNCDOptionCompliance(); - }, []); - - if (isCompliant) { - return null; - } - - return ( - -

- {translate('onboarding.create_project.new_code_option.warning.title')} -

-

- - {translate( - 'onboarding.create_project.new_code_option.warning.explanation.action.admin.link' - )} - - ), - }} - /> - ) : ( - translate('onboarding.create_project.new_code_option.warning.explanation.action') - ), - }} - /> -

-

- {translate('learn_more')}:  - - {translate('onboarding.create_project.new_code_option.warning.learn_more.link')} - -

-
- ); -} - -export default withAppStateContext(InstanceNewCodeDefinitionComplianceWarning); diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 7bcc51b0e61..80957df45f4 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3920,13 +3920,6 @@ onboarding.create_project.new_code_definition.description2=Learn more: {link} onboarding.create_project.new_code_definition.description2.link=Defining New Code onboarding.create_project.new_code_definition.create_project=Create project -onboarding.create_project.new_code_option.warning.title=Your global new code definition is not compliant with the Clean as You Code methodology -onboarding.create_project.new_code_option.warning.explanation=New projects use the global new code definition by default. {action} so that new projects benefit from the Clean as You Code methodology by default. -onboarding.create_project.new_code_option.warning.explanation.action=We recommend that you ask an administrator of this SonarQube instance to update the global new code definition -onboarding.create_project.new_code_option.warning.explanation.action.admin=We recommend that you update the global new code definition under {link} -onboarding.create_project.new_code_option.warning.explanation.action.admin.link=General Settings - New Code -onboarding.create_project.new_code_option.warning.learn_more.link=Defining New Code - onboarding.token.header=Provide a token onboarding.token.text=The token is used to identify you when an analysis is performed. If it has been compromised, you can revoke it at any point in time in your {link}. onboarding.token.text.PROJECT_ANALYSIS_TOKEN=The project token is used to identify you when an analysis is performed. If it has been compromised, you can revoke it at any point in time in your {link}. -- 2.39.5