summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/import_projects/store/getters.js
blob: 7d529c94d7d2ed8366e5e76e33fc5be915418345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { STATUSES } from '../constants';

export const isLoading = state => state.isLoadingRepos || state.isLoadingNamespaces;

export const isImportingAnyRepo = state =>
  state.repositories.some(repo =>
    [STATUSES.SCHEDULING, STATUSES.SCHEDULED, STATUSES.STARTED].includes(repo.importStatus),
  );

export const hasIncompatibleRepos = state =>
  state.repositories.some(repo => repo.importSource.incompatible);

export const hasImportableRepos = state =>
  state.repositories.some(repo => repo.importStatus === STATUSES.NONE);

export const getImportTarget = state => repoId => {
  if (state.customImportTargets[repoId]) {
    return state.customImportTargets[repoId];
  }

  const repo = state.repositories.find(r => r.importSource.id === repoId);

  return {
    newName: repo.importSource.sanitizedName,
    targetNamespace: state.defaultTargetNamespace,
  };
};