github.com/covergates/covergates@v0.2.2-0.20201009050117-42ef8a19fb95/web/src/store/modules/repository/index.ts (about) 1 import { Module } from 'vuex'; 2 import { 3 updateList, 4 startLoading, 5 stopLoading, 6 setCurrent, 7 setError, 8 setSetting, 9 setOwner, 10 setCommits, 11 setBranches 12 } from './mutations'; 13 import { 14 fetchRepositoryList, 15 updateRepositoryCurrent, 16 updateRepositoryReportID, 17 changeCurrentRepository, 18 fetchRepositorySetting, 19 fetchRepositoryOwner, 20 fetchRepositoryCommits, 21 fetchRepositoryBranches, 22 synchronizeRepository 23 } from './actions'; 24 import { RootState } from '@/store'; 25 26 export enum Mutations { 27 UPDATE_REPOSITORY_LIST = 'UPDATE_REPOSITORY_LIST', 28 START_REPOSITORY_LOADING = 'START_REPOSITORY_LOADING', 29 STOP_REPOSITORY_LOADING = 'STOP_REPOSITORY_LOADING', 30 SET_REPOSITORY_CURRENT = 'SET_REPOSITORY_CURRENT', 31 SET_REPOSITORY_ERROR = 'SET_REPOSITORY_ERROR', 32 SET_REPOSITORY_SETTING = 'SET_REPOSITORY_SETTING', 33 SET_REPOSITORY_OWNER = 'SET_REPOSITORY_OWNER', 34 SET_REPOSITORY_COMMITS = 'SET_REPOSITORY_COMMITS', 35 SET_REPOSITORY_BRANCHES = 'SET_REPOSITORY_BRANCHES' 36 } 37 38 export enum Actions { 39 FETCH_REPOSITORY_LIST = 'FETCH_REPOSITORY_LIST', 40 SYNCHRONIZE_REPOSITORY = 'SYNCHRONIZE_REPOSITORY', 41 UPDATE_REPOSITORY_CURRENT = 'UPDATE_REPOSITORY_CURRENT', 42 UPDATE_REPOSITORY_REPORT_ID = 'UPDATE_REPOSITORY_REPORT_ID', 43 CHANGE_CURRENT_REPOSITORY = 'CHANGE_CURRENT_REPOSITORY', 44 FETCH_REPOSITORY_SETTING = 'FETCH_REPOSITORY_SETTING', 45 FETCH_REPOSITORY_OWNER = 'FETCH_REPOSITORY_OWNER', 46 FETCH_REPOSITORY_COMMITS = 'FETCH_REPOSITORY_COMMITS', 47 FETCH_REPOSITORY_BRANCHES = 'FETCH_REPOSITORY_BRANCHES' 48 } 49 50 export type RepoState = { 51 loading: boolean; 52 current?: Repository; 53 commits: Commit[]; 54 branches: string[]; 55 owner: boolean; 56 setting?: RepositorySetting; 57 list: Repository[]; 58 error?: Error; 59 }; 60 61 const module: Module<RepoState, RootState> = { 62 state: { 63 loading: false, 64 current: undefined, 65 commits: [], 66 branches: [], 67 setting: undefined, 68 list: [], 69 error: undefined, 70 owner: false 71 }, 72 mutations: { 73 [Mutations.UPDATE_REPOSITORY_LIST]: updateList, 74 [Mutations.START_REPOSITORY_LOADING]: startLoading, 75 [Mutations.STOP_REPOSITORY_LOADING]: stopLoading, 76 [Mutations.SET_REPOSITORY_CURRENT]: setCurrent, 77 [Mutations.SET_REPOSITORY_ERROR]: setError, 78 [Mutations.SET_REPOSITORY_SETTING]: setSetting, 79 [Mutations.SET_REPOSITORY_OWNER]: setOwner, 80 [Mutations.SET_REPOSITORY_COMMITS]: setCommits, 81 [Mutations.SET_REPOSITORY_BRANCHES]: setBranches 82 }, 83 actions: { 84 [Actions.FETCH_REPOSITORY_LIST]: fetchRepositoryList, 85 [Actions.UPDATE_REPOSITORY_CURRENT]: updateRepositoryCurrent, 86 [Actions.UPDATE_REPOSITORY_REPORT_ID]: updateRepositoryReportID, 87 [Actions.CHANGE_CURRENT_REPOSITORY]: changeCurrentRepository, 88 [Actions.FETCH_REPOSITORY_SETTING]: fetchRepositorySetting, 89 [Actions.FETCH_REPOSITORY_OWNER]: fetchRepositoryOwner, 90 [Actions.FETCH_REPOSITORY_COMMITS]: fetchRepositoryCommits, 91 [Actions.FETCH_REPOSITORY_BRANCHES]: fetchRepositoryBranches, 92 [Actions.SYNCHRONIZE_REPOSITORY]: synchronizeRepository 93 } 94 }; 95 96 declare module '@/store' { 97 interface State { 98 repository: RepoState; 99 } 100 } 101 102 export default module;