From 6c444e657927662ba6dc501dd2cfa6295f1b6394 Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Fri, 6 Sep 2019 15:54:05 +0800 Subject: [PATCH] [Code] move RepoState to models RepoState is used by both front end and back end code, so move it to models. --- x-pack/legacy/plugins/code/model/repository.ts | 11 +++++++++++ .../plugins/code/public/actions/status.ts | 18 ++++-------------- .../components/admin_page/project_item.tsx | 4 ++-- .../code/public/components/main/content.tsx | 3 ++- .../plugins/code/public/reducers/status.ts | 2 +- .../code/public/sagas/project_status.ts | 3 +-- .../cluster/node_repositories_service.ts | 3 +-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/x-pack/legacy/plugins/code/model/repository.ts b/x-pack/legacy/plugins/code/model/repository.ts index 89da650ec8dd9..ec2777caf8584 100644 --- a/x-pack/legacy/plugins/code/model/repository.ts +++ b/x-pack/legacy/plugins/code/model/repository.ts @@ -168,3 +168,14 @@ export interface IndexWorkerProgress extends WorkerProgress { // Index progress for commit indexing. commitIndexProgress?: IndexProgress; } + +export enum RepoState { + CLONING, + DELETING, + INDEXING, + READY, + CLONE_ERROR, + DELETE_ERROR, + INDEX_ERROR, + UNKNOWN, +} diff --git a/x-pack/legacy/plugins/code/public/actions/status.ts b/x-pack/legacy/plugins/code/public/actions/status.ts index 9656b6c7a1760..354f593f3a643 100644 --- a/x-pack/legacy/plugins/code/public/actions/status.ts +++ b/x-pack/legacy/plugins/code/public/actions/status.ts @@ -7,26 +7,16 @@ import { createAction } from 'redux-actions'; import { - RepositoryUri, + CloneProgress, CloneWorkerProgress, - WorkerProgress, Repository, - CloneProgress, + RepositoryUri, + RepoState, + WorkerProgress, } from '../../model'; import { FetchFilePayload } from './file'; import { StatusReport } from '../../common/repo_file_status'; -export enum RepoState { - CLONING, - DELETING, - INDEXING, - READY, - CLONE_ERROR, - DELETE_ERROR, - INDEX_ERROR, - UNKNOWN, -} - export interface RepoStatus { uri: string; progress: number; diff --git a/x-pack/legacy/plugins/code/public/components/admin_page/project_item.tsx b/x-pack/legacy/plugins/code/public/components/admin_page/project_item.tsx index c19c6c91f3eac..48a6407b911c0 100644 --- a/x-pack/legacy/plugins/code/public/components/admin_page/project_item.tsx +++ b/x-pack/legacy/plugins/code/public/components/admin_page/project_item.tsx @@ -24,9 +24,9 @@ import React from 'react'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; -import { Repository, WorkerReservedProgress } from '../../../model'; +import { Repository, RepoState, WorkerReservedProgress } from '../../../model'; import { deleteRepo, indexRepo, initRepoCommand } from '../../actions'; -import { RepoState, RepoStatus } from '../../actions/status'; +import { RepoStatus } from '../../actions/status'; const stateColor = { [RepoState.CLONING]: 'secondary', diff --git a/x-pack/legacy/plugins/code/public/components/main/content.tsx b/x-pack/legacy/plugins/code/public/components/main/content.tsx index e06b93b200bce..e9dfd358d3786 100644 --- a/x-pack/legacy/plugins/code/public/components/main/content.tsx +++ b/x-pack/legacy/plugins/code/public/components/main/content.tsx @@ -38,9 +38,10 @@ import { SearchScope, WorkerReservedProgress, Repository, + RepoState, } from '../../../model'; import { CommitInfo, ReferenceInfo } from '../../../model/commit'; -import { changeSearchScope, FetchFileResponse, RepoState, RepoStatus } from '../../actions'; +import { changeSearchScope, FetchFileResponse, RepoStatus } from '../../actions'; import { MainRouteParams, PathTypes } from '../../common/types'; import { RootState } from '../../reducers'; import { diff --git a/x-pack/legacy/plugins/code/public/reducers/status.ts b/x-pack/legacy/plugins/code/public/reducers/status.ts index a44cca41c61ab..fe9e58ffcc488 100644 --- a/x-pack/legacy/plugins/code/public/reducers/status.ts +++ b/x-pack/legacy/plugins/code/public/reducers/status.ts @@ -13,6 +13,7 @@ import { WorkerReservedProgress, IndexWorkerProgress, CloneWorkerProgress, + RepoState, } from '../../model'; import { deleteRepoFinished, @@ -26,7 +27,6 @@ import { updateIndexProgress, StatusSuccessPayload, RepoStatus, - RepoState, FetchRepoFileStatus, } from '../actions'; import { StatusReport } from '../../common/repo_file_status'; diff --git a/x-pack/legacy/plugins/code/public/sagas/project_status.ts b/x-pack/legacy/plugins/code/public/sagas/project_status.ts index 0a392b3959c3b..ed4b95d612182 100644 --- a/x-pack/legacy/plugins/code/public/sagas/project_status.ts +++ b/x-pack/legacy/plugins/code/public/sagas/project_status.ts @@ -21,7 +21,7 @@ import { takeLatest, } from 'redux-saga/effects'; -import { Repository, RepositoryUri, WorkerReservedProgress } from '../../model'; +import { Repository, RepositoryUri, WorkerReservedProgress, RepoState } from '../../model'; import * as ROUTES from '../components/routes'; import { allStatusSelector, repoUriSelector, routeSelector } from '../selectors'; import { @@ -42,7 +42,6 @@ import { pollRepoDeleteStatusStop, pollRepoIndexStatusStop, importRepoSuccess, - RepoState, } from '../actions'; import { cloneCompletedPattern, diff --git a/x-pack/legacy/plugins/code/server/distributed/cluster/node_repositories_service.ts b/x-pack/legacy/plugins/code/server/distributed/cluster/node_repositories_service.ts index 42d68b6f692f9..7d46960af1bab 100644 --- a/x-pack/legacy/plugins/code/server/distributed/cluster/node_repositories_service.ts +++ b/x-pack/legacy/plugins/code/server/distributed/cluster/node_repositories_service.ts @@ -9,9 +9,8 @@ import { ClusterService, ClusterStateListener } from './cluster_service'; import { ClusterStateEvent } from './cluster_state_event'; import { ClusterMembershipService } from './cluster_membership_service'; import { CloneWorker } from '../../queue'; -import { Repository, RepositoryUri } from '../../../model'; +import { Repository, RepositoryUri, RepoState } from '../../../model'; import { Logger } from '../../log'; -import { RepoState } from '../../../public/actions'; export class NodeRepositoriesService implements ClusterStateListener { // visible for test