From 97ac2725cd1bf88870531e424a9fd65eb4c5e98b Mon Sep 17 00:00:00 2001 From: Ambroise C Date: Tue, 23 Jan 2024 17:46:11 +0100 Subject: [PATCH] SONAR-21481 Migrate "DevOps Platform Integrations" page to MIUI --- .../AlmBindingDefinitionBox.tsx | 237 +++++++++--------- .../almIntegration/AlmIntegrationRenderer.tsx | 65 ++--- .../almIntegration/AlmTabRenderer.tsx | 61 ++--- 3 files changed, 185 insertions(+), 178 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx index 96677baa354..dca6a27b378 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionBox.tsx @@ -17,17 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { + BasicSeparator, + ButtonSecondary, + DangerButtonSecondary, + FlagErrorIcon, + FlagMessage, + FlagSuccessIcon, + HelperHintIcon, + Spinner, +} from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; -import DocLink from '../../../../components/common/DocLink'; -import { Button } from '../../../../components/controls/buttons'; +import DocumentationLink from '../../../../components/common/DocumentationLink'; import HelpTooltip from '../../../../components/controls/HelpTooltip'; import Tooltip from '../../../../components/controls/Tooltip'; -import AlertErrorIcon from '../../../../components/icons/AlertErrorIcon'; -import AlertSuccessIcon from '../../../../components/icons/AlertSuccessIcon'; -import DeleteIcon from '../../../../components/icons/DeleteIcon'; -import EditIcon from '../../../../components/icons/EditIcon'; -import { Alert } from '../../../../components/ui/Alert'; import { ALM_DOCUMENTATION_PATHS, IMPORT_COMPATIBLE_ALMS } from '../../../../helpers/constants'; import { getEdition, getEditionUrl } from '../../../../helpers/editions'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; @@ -56,25 +60,23 @@ const DEFAULT_STATUS: AlmSettingsBindingStatus = { }; const STATUS_ICON = { - [AlmSettingsBindingStatusType.Failure]: , - [AlmSettingsBindingStatusType.Success]: , + [AlmSettingsBindingStatusType.Failure]: , + [AlmSettingsBindingStatusType.Success]: , + [AlmSettingsBindingStatusType.Validating]:
, }; -function getPRDecorationFeatureStatus( - branchesEnabled: boolean, - type: AlmSettingsBindingStatusType.Success | AlmSettingsBindingStatusType.Failure, -) { +function getPRDecorationFeatureStatus(branchesEnabled: boolean, type: keyof typeof STATUS_ICON) { if (branchesEnabled) { return STATUS_ICON[type]; } return ( -
- +
+ {translate('settings.almintegration.feature.pr_decoration.disabled')} } - /> + > + +
); } @@ -106,23 +110,23 @@ function getPRDecorationFeatureStatus( function getImportFeatureStatus( alm: AlmKeys, definition: AlmBindingDefinitionBase, - type: AlmSettingsBindingStatusType.Success | AlmSettingsBindingStatusType.Failure, + type: keyof typeof STATUS_ICON, ) { - if (!definition.url && alm !== AlmKeys.BitbucketCloud) { - return ( -
- - {translate('settings.almintegration.feature.alm_repo_import.disabled')} - - -
- ); + if (definition.url !== undefined || alm === AlmKeys.BitbucketCloud) { + return STATUS_ICON[type]; } - return STATUS_ICON[type]; + return ( +
+ + {translate('settings.almintegration.feature.alm_repo_import.disabled')} + + +
+ ); } function getPrDecoFeatureDescription(alm: AlmKeys) { @@ -142,9 +146,10 @@ export default function AlmBindingDefinitionBox(props: AlmBindingDefinitionBoxPr const { alm, branchesEnabled, definition, status = DEFAULT_STATUS } = props; return ( -
-
- - +
-
+

{definition.key}

{definition.url && {definition.url}}
- {status.type === AlmSettingsBindingStatusType.Validating ? ( - <> - - {translate('settings.almintegration.checking_configuration')} - - ) : ( - <> - {status.type !== AlmSettingsBindingStatusType.Warning && ( -
-
- - {translate('settings.almintegration.feature.status_reporting.title')} - - {getPRDecorationFeatureStatus(branchesEnabled, status.type)} -
- {IMPORT_COMPATIBLE_ALMS.includes(alm) && ( -
- - - {translate('settings.almintegration.feature.alm_repo_import.title')} - - - {getImportFeatureStatus(alm, definition, status.type)} -
- )} + {status.type !== AlmSettingsBindingStatusType.Warning && ( +
+
+ + {translate('settings.almintegration.feature.status_reporting.title')} + + {getPRDecorationFeatureStatus(branchesEnabled, status.type)} +
+ {IMPORT_COMPATIBLE_ALMS.includes(alm) && ( +
+ + {translate('settings.almintegration.feature.alm_repo_import.title')} + + {getImportFeatureStatus(alm, definition, status.type)}
)} +
+ )} -
- {status.type === AlmSettingsBindingStatusType.Warning && ( - - {translate('settings.almintegration.could_not_validate')} - - )} + {status.type === AlmSettingsBindingStatusType.Warning && ( +
+ + {translate('settings.almintegration.could_not_validate')} + +
+ )} - {status.type === AlmSettingsBindingStatusType.Failure && ( - {status.failureMessage} - )} + {status.type === AlmSettingsBindingStatusType.Failure && ( +
+ {status.failureMessage} +
+ )} - {status.type === AlmSettingsBindingStatusType.Success && status.alertSuccess && ( - <> - - {translate('settings.almintegration.configuration_valid')} - - {alm === AlmKeys.GitHub && ( - - - {translate('learn_more')} - - ), - }} - /> - - )} - - )} + {status.type === AlmSettingsBindingStatusType.Success && status.alertSuccess && ( + <> +
+ + {translate('settings.almintegration.configuration_valid')} +
- - + {alm === AlmKeys.GitHub && ( +
+ +

+ + {translate('learn_more')} + + ), + }} + /> +

+
+
+ )} )} + +
+ props.onCheck(definition.key)} + > + {translate('settings.almintegration.check_configuration')} + + + {status.type === AlmSettingsBindingStatusType.Validating && ( + + {translate('settings.almintegration.checking_configuration')} + + )} +
); } diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegrationRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegrationRenderer.tsx index 15d47b2a654..a0b21bed4f4 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegrationRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegrationRenderer.tsx @@ -17,11 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { FlagMessage, Link, SubTitle, ToggleButton } from 'design-system'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; -import Link from '../../../../components/common/Link'; -import BoxedTabs from '../../../../components/controls/BoxedTabs'; -import { Alert } from '../../../../components/ui/Alert'; import { translate } from '../../../../helpers/l10n'; import { getBaseUrl } from '../../../../helpers/system'; import { useGetValuesQuery } from '../../../../queries/settings'; @@ -56,60 +54,60 @@ export interface AlmIntegrationRendererProps { const tabs = [ { - key: AlmKeys.GitHub, label: ( <> github {translate('settings.almintegration.tab.github')} ), + value: AlmKeys.GitHub, }, { - key: AlmKeys.BitbucketServer, label: ( <> bitbucket {translate('settings.almintegration.tab.bitbucket')} ), + value: AlmKeys.BitbucketServer, }, { - key: AlmKeys.Azure, label: ( <> azure {translate('settings.almintegration.tab.azure')} ), + value: AlmKeys.Azure, }, { - key: AlmKeys.GitLab, label: ( <> gitlab {translate('settings.almintegration.tab.gitlab')} ), + value: AlmKeys.GitLab, }, ]; @@ -138,31 +136,38 @@ export default function AlmIntegrationRenderer(props: AlmIntegrationRendererProp return ( <> -
-

{translate('settings.almintegration.title')}

+
+ {translate('settings.almintegration.title')}
{!hasServerBaseUrl && !isLoading && branchesEnabled && ( - - - {translate('settings.almintegration.empty.server_base_url.setting_link')} - - ), - }} - /> - + +

+ + {translate('settings.almintegration.empty.server_base_url.setting_link')} + + ), + }} + /> +

+
)} -
- {translate('settings.almintegration.description')} -
+
{translate('settings.almintegration.description')}
- +
+ +
) { const preventCreation = loadingProjectCount || (!multipleAlmEnabled && definitions.length > 0); return ( -
-
+
+
{definitions.length === 0 && ( -

{translate('settings.almintegration.empty', almTab)}

+

{translate('settings.almintegration.empty', almTab)}

)} -
0 ? 'spacer-bottom text-right' : 'big-spacer-top'}> +
0 ? 'sw-mb-5' : 'sw-my-3'}> - +
{definitions.map((def) => ( @@ -125,24 +116,26 @@ export default function AlmTabRenderer(props: Readonly) {
{AUTHENTICATION_AVAILABLE_PLATFORMS.includes(almTab) && ( - - - {translate('property.category.authentication')} - - ), - }} - /> - + +

+ + {translate('property.category.authentication')} + + ), + }} + /> +

+
)}
); -- 2.39.5