summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/getters.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-05-04 13:36:50 +0100
committerPhil Hughes <me@iamphill.com>2018-05-04 13:36:50 +0100
commitd9f3af500c1c3135a63014904459e5a4ab6bc395 (patch)
tree14ca96edbc8517d68c275b1501f4ae858e64d642 /app/assets/javascripts/ide/stores/getters.js
parentfa8d70a989f548f55be44ae47fab0f6f68a480c8 (diff)
parent2d23cb1b9fa9fed19ce66998c5b4177ee13ef5f3 (diff)
downloadgitlab-ce-d9f3af500c1c3135a63014904459e5a4ab6bc395.tar.gz
Merge branch 'master' into 44846-improve-web-ide-left-panel-and-modes
Diffstat (limited to 'app/assets/javascripts/ide/stores/getters.js')
-rw-r--r--app/assets/javascripts/ide/stores/getters.js21
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 () => {};