diff options
author | Phil Hughes <me@iamphill.com> | 2018-05-04 13:40:41 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-05-04 13:40:41 +0100 |
commit | 80617b9039ccbeeec07e299e41690be6ce2d95ec (patch) | |
tree | dc34efce00b956309c147ea59a786b58b47805b6 /app/assets/javascripts/ide/stores/getters.js | |
parent | cb8682b841b92cb6f97906bb9289ccbb13f2f31e (diff) | |
parent | d9f3af500c1c3135a63014904459e5a4ab6bc395 (diff) | |
download | gitlab-ce-80617b9039ccbeeec07e299e41690be6ce2d95ec.tar.gz |
Merge branch '44846-improve-web-ide-left-panel-and-modes' into ide-sidebar-commit-box
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 8494f07ed84..28e08c2b679 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,6 +57,7 @@ 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 lastOpenedFile = state => @@ -64,5 +70,20 @@ export const isReviewModeActive = state => state.currentActivityView === activit export const someUncommitedChanges = state => !!(state.changedFiles.length || state.stagedFiles.length); +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 () => {}; |