diff options
Diffstat (limited to 'app/assets/javascripts/ide/stores/getters.js')
-rw-r--r-- | app/assets/javascripts/ide/stores/getters.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/ide/stores/getters.js b/app/assets/javascripts/ide/stores/getters.js index bbe3083e24b..80de60799f2 100644 --- a/app/assets/javascripts/ide/stores/getters.js +++ b/app/assets/javascripts/ide/stores/getters.js @@ -1,4 +1,9 @@ +<<<<<<< HEAD import { activityBarViews } from '../constants'; +======= +import { __ } from '~/locale'; +import { getChangesCountForFiles, filePathMatches } from './utils'; +>>>>>>> master export const activeFile = state => state.openFiles.find(file => file.active) || null; @@ -52,11 +57,27 @@ export const allBlobs = state => }, []) .sort((a, b) => b.lastOpenedAt - a.lastOpenedAt); +export const getChangedFile = state => path => state.changedFiles.find(f => f.path === path); export const getStagedFile = state => path => state.stagedFiles.find(f => f.path === path); export const isEditModeActive = state => state.currentActivityView === activityBarViews.edit; export const isCommitModeActive = state => state.currentActivityView === activityBarViews.commit; export const isReviewModeActive = state => state.currentActivityView === activityBarViews.review; +export const getChangesInFolder = state => path => { + const changedFilesCount = state.changedFiles.filter(f => filePathMatches(f, path)).length; + const stagedFilesCount = state.stagedFiles.filter( + f => filePathMatches(f, path) && !getChangedFile(state)(f.path), + ).length; + + return changedFilesCount + stagedFilesCount; +}; + +export const getUnstagedFilesCountForPath = state => path => + getChangesCountForFiles(state.changedFiles, path); + +export const getStagedFilesCountForPath = state => path => + getChangesCountForFiles(state.stagedFiles, path); + // prevent babel-plugin-rewire from generating an invalid default during karma tests export default () => {}; |