diff options
author | Belen Pruvost <belen.pruvost@sonarsource.com> | 2020-11-26 10:34:18 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-11-26 20:06:29 +0000 |
commit | 74f7665414df2b65cd7e3be3e3b1ca96280ffe0a (patch) | |
tree | b0841758769f67d8c83034a009a3d8ddaeb5cb07 /server/sonar-web | |
parent | a8ec651e57d21bacfe7bfdd32f2f6a79ad1d5359 (diff) | |
download | sonarqube-74f7665414df2b65cd7e3be3e3b1ca96280ffe0a.tar.gz sonarqube-74f7665414df2b65cd7e3be3e3b1ca96280ffe0a.zip |
SONAR-14061 Azure DevOps settings validation
Diffstat (limited to 'server/sonar-web')
6 files changed, 53 insertions, 130 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 fa55dca833d..41c8c384ffe 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 @@ -33,7 +33,6 @@ import { AlmSettingsBindingStatus, AlmSettingsBindingStatusType } from '../../../../types/alm-settings'; -import { VALIDATED_ALMS } from './utils'; export interface AlmBindingDefinitionBoxProps { alm: AlmKeys; @@ -121,87 +120,56 @@ export default function AlmBindingDefinitionBox(props: AlmBindingDefinitionBoxPr {definition.url && <span>{definition.url}</span>} </div> - {!VALIDATED_ALMS.includes(alm) && ( + {status.type === AlmSettingsBindingStatusType.Validating ? ( <> - <div className="display-flex-row spacer-bottom"> - <div className="huge-spacer-right"> + <i className="spinner spacer-right" /> + {translate('settings.almintegration.checking_configuration')} + </> + ) : ( + <> + {status.type !== AlmSettingsBindingStatusType.Warning && ( + <div className="display-flex-row spacer-bottom"> <Tooltip overlay={importFeatureDescription}> - <span>{importFeatureTitle}</span> - </Tooltip> - <AlertSuccessIcon className="spacer-left" /> - </div> - <div> - <Tooltip - overlay={translate('settings.almintegration.feature.alm_repo_import.description')}> - <span>{translate('settings.almintegration.feature.alm_repo_import.title')}</span> + <div className="huge-spacer-right"> + {importFeatureTitle} + {STATUS_ICON[status.type]} + </div> </Tooltip> - {getImportFeatureStatus( - definition, - multipleDefinitions, - AlmSettingsBindingStatusType.Success - )} + <div> + <Tooltip + overlay={translate( + 'settings.almintegration.feature.alm_repo_import.description' + )}> + <span>{translate('settings.almintegration.feature.alm_repo_import.title')}</span> + </Tooltip> + {getImportFeatureStatus(definition, multipleDefinitions, status.type)} + </div> </div> - </div> + )} <div className="width-50"> - <Alert variant="info">{translate('settings.almintegration.no_validation')}</Alert> - </div> - </> - )} - - {VALIDATED_ALMS.includes(alm) && - (status.type === AlmSettingsBindingStatusType.Validating ? ( - <> - <i className="spinner spacer-right" /> - {translate('settings.almintegration.checking_configuration')} - </> - ) : ( - <> - {status.type !== AlmSettingsBindingStatusType.Warning && ( - <div className="display-flex-row spacer-bottom"> - <Tooltip overlay={importFeatureDescription}> - <div className="huge-spacer-right"> - {importFeatureTitle} - {STATUS_ICON[status.type]} - </div> - </Tooltip> - <div> - <Tooltip - overlay={translate( - 'settings.almintegration.feature.alm_repo_import.description' - )}> - <span> - {translate('settings.almintegration.feature.alm_repo_import.title')} - </span> - </Tooltip> - {getImportFeatureStatus(definition, multipleDefinitions, status.type)} - </div> - </div> + {status.type === AlmSettingsBindingStatusType.Warning && ( + <Alert variant="warning"> + {translate('settings.almintegration.could_not_validate')} + </Alert> )} - <div className="width-50"> - {status.type === AlmSettingsBindingStatusType.Warning && ( - <Alert variant="warning"> - {translate('settings.almintegration.could_not_validate')} - </Alert> - )} - - {status.type === AlmSettingsBindingStatusType.Failure && ( - <Alert variant="error">{status.failureMessage}</Alert> - )} + {status.type === AlmSettingsBindingStatusType.Failure && ( + <Alert variant="error">{status.failureMessage}</Alert> + )} - {status.type === AlmSettingsBindingStatusType.Success && status.alertSuccess && ( - <Alert variant="success"> - {translate('settings.almintegration.configuration_valid')} - </Alert> - )} - </div> + {status.type === AlmSettingsBindingStatusType.Success && status.alertSuccess && ( + <Alert variant="success"> + {translate('settings.almintegration.configuration_valid')} + </Alert> + )} + </div> - <Button className="big-spacer-top" onClick={() => props.onCheck(definition.key)}> - {translate('settings.almintegration.check_configuration')} - </Button> - </> - ))} + <Button className="big-spacer-top" onClick={() => props.onCheck(definition.key)}> + {translate('settings.almintegration.check_configuration')} + </Button> + </> + )} </div> ); } diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx index ed6c0c964f0..0bb9f013a85 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx @@ -33,7 +33,7 @@ import { AlmSettingsBindingStatusType } from '../../../../types/alm-settings'; import AlmIntegrationRenderer from './AlmIntegrationRenderer'; -import { VALIDATED_ALMS } from './utils'; +import { ALM_KEY_LIST } from './utils'; interface Props { appState: Pick<T.AppState, 'branchesEnabled' | 'multipleAlmEnabled'>; @@ -70,7 +70,7 @@ export class AlmIntegration extends React.PureComponent<Props, State> { return this.fetchPullRequestDecorationSetting().then(definitions => { if (definitions) { // Validate all alms on load: - VALIDATED_ALMS.forEach(alm => { + ALM_KEY_LIST.forEach(alm => { this.state.definitions[alm].forEach((def: AlmBindingDefinition) => this.handleCheck(def.key, false) ); diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTab.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTab.tsx index 34a31756ac7..5fbb9ffcdfa 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTab.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTab.tsx @@ -25,7 +25,6 @@ import { } from '../../../../types/alm-settings'; import { AlmBindingDefinitionFormChildrenProps } from './AlmBindingDefinitionForm'; import AlmTabRenderer from './AlmTabRenderer'; -import { VALIDATED_ALMS } from './utils'; interface Props<B> { alm: AlmKeys; @@ -98,9 +97,7 @@ export default class AlmTab<B extends AlmBindingDefinition> extends React.PureCo }) .then(this.props.onUpdateDefinitions) .then(() => { - if (VALIDATED_ALMS.includes(this.props.alm)) { - this.props.onCheck(config.key); - } + this.props.onCheck(config.key); }) .catch(() => { if (this.mounted) { diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx index 2bb0d844580..d24361dbfde 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx @@ -32,7 +32,9 @@ import { AlmIntegration } from '../AlmIntegration'; jest.mock('../../../../../api/alm-settings', () => ({ countBindedProjects: jest.fn().mockResolvedValue(0), deleteConfiguration: jest.fn().mockResolvedValue(undefined), - getAlmDefinitions: jest.fn().mockResolvedValue({ bitbucket: [], github: [], gitlab: [] }), + getAlmDefinitions: jest + .fn() + .mockResolvedValue({ azure: [], bitbucket: [], github: [], gitlab: [] }), validateAlmSettings: jest.fn().mockResolvedValue('') })); @@ -56,7 +58,8 @@ it('should validate existing configurations', async () => { await waitAndUpdate(wrapper); - expect(validateAlmSettings).toBeCalledTimes(4); + expect(validateAlmSettings).toBeCalledTimes(5); + expect(validateAlmSettings).toBeCalledWith('a1'); expect(validateAlmSettings).toBeCalledWith('b1'); expect(validateAlmSettings).toBeCalledWith('gh1'); expect(validateAlmSettings).toBeCalledWith('gh2'); diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap index 2fd332649c6..5a3af1e5260 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmBindingDefinitionBox-test.tsx.snap @@ -32,55 +32,10 @@ exports[`should render correctly: Azure DevOps 1`] = ` key </h3> </div> - <div - className="display-flex-row spacer-bottom" - > - <div - className="huge-spacer-right" - > - <Tooltip - overlay="settings.almintegration.feature.pr_decoration.description" - > - <span> - settings.almintegration.feature.pr_decoration.title - </span> - </Tooltip> - <AlertSuccessIcon - className="spacer-left" - /> - </div> - <div> - <Tooltip - overlay="settings.almintegration.feature.alm_repo_import.description" - > - <span> - settings.almintegration.feature.alm_repo_import.title - </span> - </Tooltip> - <div - className="display-inline-flex-center" - > - <strong - className="spacer-left" - > - settings.almintegration.feature.alm_repo_import.disabled - </strong> - <HelpTooltip - className="little-spacer-left" - overlay="settings.almintegration.feature.alm_repo_import.disabled.no_url" - /> - </div> - </div> - </div> - <div - className="width-50" - > - <Alert - variant="info" - > - settings.almintegration.no_validation - </Alert> - </div> + <i + className="spinner spacer-right" + /> + settings.almintegration.checking_configuration </div> `; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/utils.ts b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/utils.ts index 5de5535b294..7eb61aa7977 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/utils.ts +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/utils.ts @@ -19,4 +19,4 @@ */ import { AlmKeys } from '../../../../types/alm-settings'; -export const VALIDATED_ALMS = [AlmKeys.Bitbucket, AlmKeys.GitHub, AlmKeys.GitLab]; +export const ALM_KEY_LIST = [AlmKeys.Azure, AlmKeys.Bitbucket, AlmKeys.GitHub, AlmKeys.GitLab]; |