summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ide/stores/utils.js')
-rw-r--r--app/assets/javascripts/ide/stores/utils.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js
index 63e4de3b17d..bc79ff4a542 100644
--- a/app/assets/javascripts/ide/stores/utils.js
+++ b/app/assets/javascripts/ide/stores/utils.js
@@ -15,6 +15,7 @@ export const dataStructure = () => ({
opened: false,
active: false,
changed: false,
+ staged: false,
lastCommitPath: '',
lastCommit: {
id: '',
@@ -38,6 +39,11 @@ export const dataStructure = () => ({
editorColumn: 1,
fileLanguage: '',
eol: '',
+ viewMode: 'edit',
+ previewMode: null,
+ size: 0,
+ parentPath: null,
+ lastOpenedAt: 0,
});
export const decorateData = entity => {
@@ -57,8 +63,10 @@ export const decorateData = entity => {
changed = false,
parentTreeUrl = '',
base64 = false,
-
+ previewMode,
file_lock,
+ html,
+ parentPath = '',
} = entity;
return {
@@ -79,8 +87,10 @@ export const decorateData = entity => {
renderError,
content,
base64,
-
+ previewMode,
file_lock,
+ html,
+ parentPath,
};
};
@@ -96,7 +106,7 @@ export const setPageTitle = 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,
@@ -114,8 +124,8 @@ const sortTreesByTypeAndName = (a, b) => {
} else if (a.type === 'blob' && b.type === 'tree') {
return 1;
}
- if (a.name.toLowerCase() < b.name.toLowerCase()) return -1;
- if (a.name.toLowerCase() > b.name.toLowerCase()) return 1;
+ if (a.name < b.name) return -1;
+ if (a.name > b.name) return 1;
return 0;
};
@@ -127,3 +137,9 @@ export const sortTree = sortedTree =>
}),
)
.sort(sortTreesByTypeAndName);
+
+export const filePathMatches = (f, path) =>
+ f.path.replace(new RegExp(`${f.name}$`), '').indexOf(`${path}/`) === 0;
+
+export const getChangesCountForFiles = (files, path) =>
+ files.filter(f => filePathMatches(f, path)).length;