Commit 7126ae0a authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '285634-Fix-confusion-button-text-when-importing-from-github' into 'master'

Fix confusing button text when importing from GitHub

See merge request gitlab-org/gitlab!49684
parents c077f27e b731cdbe
...@@ -35,6 +35,7 @@ export default { ...@@ -35,6 +35,7 @@ export default {
...mapGetters([ ...mapGetters([
'isLoading', 'isLoading',
'isImportingAnyRepo', 'isImportingAnyRepo',
'importingRepoCount',
'hasImportableRepos', 'hasImportableRepos',
'hasIncompatibleRepos', 'hasIncompatibleRepos',
'importAllCount', 'importAllCount',
...@@ -60,13 +61,17 @@ export default { ...@@ -60,13 +61,17 @@ export default {
}, },
importAllButtonText() { importAllButtonText() {
return this.hasIncompatibleRepos if (this.isImportingAnyRepo) {
? n__( return n__('Importing %d repository', 'Importing %d repositories', this.importingRepoCount);
'Import %d compatible repository', }
'Import %d compatible repositories',
this.importAllCount, if (this.hasIncompatibleRepos)
) return n__(
: n__('Import %d repository', 'Import %d repositories', this.importAllCount); 'Import %d compatible repository',
'Import %d compatible repositories',
this.importAllCount,
);
return n__('Import %d repository', 'Import %d repositories', this.importAllCount);
}, },
emptyStateText() { emptyStateText() {
......
import { STATUSES } from '../../constants'; import { isProjectImportable, isIncompatible, isImporting } from '../utils';
import { isProjectImportable, isIncompatible } from '../utils';
export const isLoading = (state) => state.isLoadingRepos || state.isLoadingNamespaces; export const isLoading = (state) => state.isLoadingRepos || state.isLoadingNamespaces;
export const isImportingAnyRepo = (state) => export const importingRepoCount = (state) => state.repositories.filter(isImporting).length;
state.repositories.some((repo) =>
[STATUSES.SCHEDULING, STATUSES.SCHEDULED, STATUSES.STARTED].includes( export const isImportingAnyRepo = (state) => state.repositories.some(isImporting);
repo.importedProject?.importStatus,
),
);
export const hasIncompatibleRepos = (state) => state.repositories.some(isIncompatible); export const hasIncompatibleRepos = (state) => state.repositories.some(isIncompatible);
......
...@@ -11,3 +11,9 @@ export function getImportStatus(project) { ...@@ -11,3 +11,9 @@ export function getImportStatus(project) {
export function isProjectImportable(project) { export function isProjectImportable(project) {
return !isIncompatible(project) && getImportStatus(project) === STATUSES.NONE; return !isIncompatible(project) && getImportStatus(project) === STATUSES.NONE;
} }
export function isImporting(repo) {
return [STATUSES.SCHEDULING, STATUSES.SCHEDULED, STATUSES.STARTED].includes(
repo.importedProject?.importStatus,
);
}
---
title: Fix confusing button text when importing from GitHub
merge_request: 49684
author: Kev @KevSlashNull
type: fixed
...@@ -14701,6 +14701,11 @@ msgstr "" ...@@ -14701,6 +14701,11 @@ msgstr ""
msgid "Imported requirements" msgid "Imported requirements"
msgstr "" msgstr ""
msgid "Importing %d repository"
msgid_plural "Importing %d repositories"
msgstr[0] ""
msgstr[1] ""
msgid "Improve Merge Requests and customer support with GitLab Enterprise Edition." msgid "Improve Merge Requests and customer support with GitLab Enterprise Edition."
msgstr "" msgstr ""
......
...@@ -142,6 +142,29 @@ describe('ImportProjectsTable', () => { ...@@ -142,6 +142,29 @@ describe('ImportProjectsTable', () => {
}, },
); );
it.each`
importingRepoCount | buttonMessage
${1} | ${'Importing 1 repository'}
${5} | ${'Importing 5 repositories'}
`(
'sets the button text to "$buttonMessage" when importing repos',
({ importingRepoCount, buttonMessage }) => {
createComponent({
state: {
providerRepos: [providerRepo],
},
getters: {
hasIncompatibleRepos: () => false,
importAllCount: () => 10,
isImportingAnyRepo: () => true,
importingRepoCount: () => importingRepoCount,
},
});
expect(findImportAllButton().text()).toBe(buttonMessage);
},
);
it('renders an empty state if there are no repositories available', () => { it('renders an empty state if there are no repositories available', () => {
createComponent({ state: { repositories: [] } }); createComponent({ state: { repositories: [] } });
...@@ -168,7 +191,7 @@ describe('ImportProjectsTable', () => { ...@@ -168,7 +191,7 @@ describe('ImportProjectsTable', () => {
}); });
it('shows loading spinner when import is in progress', () => { it('shows loading spinner when import is in progress', () => {
createComponent({ getters: { isImportingAnyRepo: () => true } }); createComponent({ getters: { isImportingAnyRepo: () => true, importallCount: () => 1 } });
expect(findImportAllButton().props().loading).toBe(true); expect(findImportAllButton().props().loading).toBe(true);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment