@@ -95,8 +95,9 @@ export default class RemoteRepositories extends React.PureComponent<Props, State | |||
); | |||
}; | |||
filterBySearch = (repo: T.AlmRepository) => | |||
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<Props, State | |||
const isPaidOrg = isPaidOrganization(organization); | |||
const filterByPlan = (repo: T.AlmRepository) => (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<Props, State | |||
}; | |||
if (nextState.checkAllRepositories) { | |||
const validRepositories = (search | |||
? repositories.filter(this.filterBySearch) | |||
: repositories | |||
).filter(filterByPlan); | |||
const validRepositories = repositories.filter( | |||
repo => | |||
this.filterBySearch(search)(repo) && filterByPlan(repo) && filterByImportable(repo) | |||
); | |||
nextState.selectedRepositories = keyBy(validRepositories, 'installationKey'); | |||
} | |||
@@ -174,7 +176,7 @@ export default class RemoteRepositories extends React.PureComponent<Props, State | |||
const showCheckAll = repositories.length > 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 ( | |||
<div className="create-project"> |
@@ -115,7 +115,10 @@ it('should allow to select all repositories', async () => { | |||
it('should select all repositories', async () => { | |||
(getRepositories as jest.Mock<any>).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(); |
@@ -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", | |||
}, | |||
} | |||
`; |
@@ -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. |