summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/utils.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-03-21 10:05:08 +0000
committerPhil Hughes <me@iamphill.com>2018-03-22 10:33:19 +0000
commit51c64f3fc7180732621d60f939bfe6157165040f (patch)
treeeaa1154ec945cfc289de9d2fd3f54a906d74d43b /app/assets/javascripts/ide/stores/utils.js
parent4718f22f5751f8d50bd7897ff4a967ccc5625c80 (diff)
downloadgitlab-ce-51c64f3fc7180732621d60f939bfe6157165040f.tar.gz
Added staged files state to IDE
Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/4541
Diffstat (limited to 'app/assets/javascripts/ide/stores/utils.js')
-rw-r--r--app/assets/javascripts/ide/stores/utils.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js
index 487ea1ead8e..da0069b63a8 100644
--- a/app/assets/javascripts/ide/stores/utils.js
+++ b/app/assets/javascripts/ide/stores/utils.js
@@ -13,6 +13,7 @@ export const dataStructure = () => ({
opened: false,
active: false,
changed: false,
+ staged: false,
lastCommitPath: '',
lastCommit: {
id: '',
@@ -38,7 +39,7 @@ export const dataStructure = () => ({
eol: '',
});
-export const decorateData = (entity) => {
+export const decorateData = entity => {
const {
id,
projectId,
@@ -57,7 +58,6 @@ export const decorateData = (entity) => {
base64 = false,
file_lock,
-
} = entity;
return {
@@ -80,24 +80,23 @@ export const decorateData = (entity) => {
base64,
file_lock,
-
};
};
-export const findEntry = (tree, type, name, prop = 'name') => tree.find(
- f => f.type === type && f[prop] === name,
-);
+export const findEntry = (tree, type, name, prop = 'name') =>
+ tree.find(f => f.type === type && f[prop] === name);
-export const findIndexOfFile = (state, file) => state.findIndex(f => f.path === file.path);
+export const findIndexOfFile = (state, file) =>
+ state.findIndex(f => f.path === file.path);
-export const setPageTitle = (title) => {
+export const setPageTitle = title => {
document.title = title;
};
export const createCommitPayload = (branch, newBranch, state, rootState) => ({
branch,
commit_message: state.commitMessage,
- actions: rootState.changedFiles.map(f => ({
+ actions: rootState.stagedFiles.map(f => ({
action: f.tempFile ? 'create' : 'update',
file_path: f.path,
content: f.content,
@@ -120,6 +119,11 @@ const sortTreesByTypeAndName = (a, b) => {
return 0;
};
-export const sortTree = sortedTree => sortedTree.map(entity => Object.assign(entity, {
- tree: entity.tree.length ? sortTree(entity.tree) : [],
-})).sort(sortTreesByTypeAndName);
+export const sortTree = sortedTree =>
+ sortedTree
+ .map(entity =>
+ Object.assign(entity, {
+ tree: entity.tree.length ? sortTree(entity.tree) : [],
+ }),
+ )
+ .sort(sortTreesByTypeAndName);