debian-mirror-gitlab/app/assets/javascripts/import_projects/store/getters.js

31 lines
1,008 B
JavaScript
Raw Normal View History

2020-10-24 23:57:45 +05:30
import { STATUSES } from '../constants';
2020-11-24 15:15:51 +05:30
import { isProjectImportable, isIncompatible } from '../utils';
2019-09-04 21:01:54 +05:30
2020-10-24 23:57:45 +05:30
export const isLoading = state => state.isLoadingRepos || state.isLoadingNamespaces;
2019-07-07 11:18:12 +05:30
2020-10-24 23:57:45 +05:30
export const isImportingAnyRepo = state =>
state.repositories.some(repo =>
2020-11-24 15:15:51 +05:30
[STATUSES.SCHEDULING, STATUSES.SCHEDULED, STATUSES.STARTED].includes(
repo.importedProject?.importStatus,
),
2020-10-24 23:57:45 +05:30
);
2019-07-07 11:18:12 +05:30
2020-11-24 15:15:51 +05:30
export const hasIncompatibleRepos = state => state.repositories.some(isIncompatible);
2019-07-07 11:18:12 +05:30
2020-11-24 15:15:51 +05:30
export const hasImportableRepos = state => state.repositories.some(isProjectImportable);
export const importAllCount = state => state.repositories.filter(isProjectImportable).length;
2019-07-07 11:18:12 +05:30
2020-10-24 23:57:45 +05:30
export const getImportTarget = state => repoId => {
if (state.customImportTargets[repoId]) {
return state.customImportTargets[repoId];
}
2019-12-21 20:55:43 +05:30
2020-10-24 23:57:45 +05:30
const repo = state.repositories.find(r => r.importSource.id === repoId);
2020-06-23 00:09:42 +05:30
2020-10-24 23:57:45 +05:30
return {
newName: repo.importSource.sanitizedName,
targetNamespace: state.defaultTargetNamespace,
};
};