From: Siegfried Ehret <49895321+siegfried-ehret-sonarsource@users.noreply.github.com> Date: Tue, 14 May 2019 15:04:45 +0000 (+0200) Subject: SONARCLOUD-643 Fix select all repositories for import (#1617) X-Git-Tag: 7.8~231 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d2dce9be30a2171c98dcfdb31e759f3d0fc39670;p=sonarqube.git SONARCLOUD-643 Fix select all repositories for import (#1617) --- diff --git a/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx b/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx index 22692ba9f7a..646cee5b172 100644 --- a/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx @@ -95,8 +95,9 @@ export default class RemoteRepositories extends React.PureComponent - repo.label.toLowerCase().includes(this.state.search.toLowerCase()); + filterBySearch = (search: String) => (repo: T.AlmRepository) => { + return repo.label.toLowerCase().includes(search.toLowerCase()); + }; handleHighlightUpgradeBox = (highlight: boolean) => { this.setState({ highlight }); @@ -136,6 +137,7 @@ export default class RemoteRepositories extends React.PureComponent (isPaidOrg ? true : !repo.private); + const filterByImportable = (repo: T.AlmRepository) => !repo.linkedProjectKey; const nextState = { selectedRepositories: {}, @@ -143,10 +145,10 @@ export default class RemoteRepositories extends React.PureComponent + this.filterBySearch(search)(repo) && filterByPlan(repo) && filterByImportable(repo) + ); nextState.selectedRepositories = keyBy(validRepositories, 'installationKey'); } @@ -174,7 +176,7 @@ export default class RemoteRepositories extends React.PureComponent 1; const showUpgradebox = !isPaidOrg && hasPrivateRepositories && organization.actions && organization.actions.admin; - const filteredRepositories = search ? repositories.filter(this.filterBySearch) : repositories; + const filteredRepositories = repositories.filter(this.filterBySearch(search)); return (
diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/RemoteRepositories-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/RemoteRepositories-test.tsx index a4e7c3d0455..113d220bfba 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/RemoteRepositories-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/RemoteRepositories-test.tsx @@ -115,7 +115,10 @@ it('should allow to select all repositories', async () => { it('should select all repositories', async () => { (getRepositories as jest.Mock).mockResolvedValueOnce({ - repositories: times(6, i => ({ label: `Project ${i}`, installationKey: `key-${i}` })) + repositories: [ + { label: 'Project 1', installationKey: 'key-1' }, + { label: 'Project 2', installationKey: 'key-2', linkedProjectKey: 'key-2' } + ] }); const wrapper = shallowRender(); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/RemoteRepositories-test.tsx.snap b/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/RemoteRepositories-test.tsx.snap index cc41eb68a89..d5f81a64131 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/RemoteRepositories-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/RemoteRepositories-test.tsx.snap @@ -178,29 +178,9 @@ exports[`should display the organization upgrade box 1`] = ` exports[`should select all repositories 1`] = ` Object { - "key-0": Object { - "installationKey": "key-0", - "label": "Project 0", - }, "key-1": Object { "installationKey": "key-1", "label": "Project 1", }, - "key-2": Object { - "installationKey": "key-2", - "label": "Project 2", - }, - "key-3": Object { - "installationKey": "key-3", - "label": "Project 3", - }, - "key-4": Object { - "installationKey": "key-4", - "label": "Project 4", - }, - "key-5": Object { - "installationKey": "key-5", - "label": "Project 5", - }, } `; 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 7c99cfb0977..65990566c98 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2812,7 +2812,7 @@ onboarding.create_project.display_name.help=Some scanners might override the val onboarding.create_project.repository_imported=Already imported: {link} onboarding.create_project.see_project=See the project onboarding.create_project.select_repositories=Select repositories -onboarding.create_project.select_all_repositories=Select all repositories +onboarding.create_project.select_all_repositories=Select all available repositories onboarding.create_project.subscribe_to_import_private_repositories=You need to subscribe your organization to a paid plan to import private projects onboarding.create_project.encourage_to_subscribe=Subscribe your organization to our paid plan to get unlimited private projects. onboarding.create_project.subscribtion_success_x={0} has been successfully upgraded to paid plan. You can now import and analyze private projects.