summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo/stores/utils.js
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-11-08 01:46:53 +0900
committerShinya Maeda <shinya@gitlab.com>2017-11-08 01:46:53 +0900
commit4fac95a64d0c04599af9c762edb94414d85bf42f (patch)
treeb87775aff426603984bc547208860ad147fcff69 /app/assets/javascripts/repo/stores/utils.js
parent02878cd958557128cd9c22b27bd2fb97a843266b (diff)
parent396f45ade1dddec36df9861f8a1bb80aabd2ff15 (diff)
downloadgitlab-ce-4fac95a64d0c04599af9c762edb94414d85bf42f.tar.gz
Merge branch 'master' into 38464-k8s-apps
Diffstat (limited to 'app/assets/javascripts/repo/stores/utils.js')
-rw-r--r--app/assets/javascripts/repo/stores/utils.js37
1 files changed, 28 insertions, 9 deletions
diff --git a/app/assets/javascripts/repo/stores/utils.js b/app/assets/javascripts/repo/stores/utils.js
index 797c2b1e5b9..fae1f4439a9 100644
--- a/app/assets/javascripts/repo/stores/utils.js
+++ b/app/assets/javascripts/repo/stores/utils.js
@@ -1,5 +1,6 @@
export const dataStructure = () => ({
id: '',
+ key: '',
type: '',
name: '',
url: '',
@@ -12,7 +13,12 @@ export const dataStructure = () => ({
opened: false,
active: false,
changed: false,
- lastCommit: {},
+ lastCommitPath: '',
+ lastCommit: {
+ url: '',
+ message: '',
+ updatedAt: '',
+ },
tree_url: '',
blamePath: '',
commitsPath: '',
@@ -27,14 +33,13 @@ export const dataStructure = () => ({
base64: false,
});
-export const decorateData = (entity, projectUrl = '') => {
+export const decorateData = (entity) => {
const {
id,
type,
url,
name,
icon,
- last_commit,
tree_url,
path,
renderError,
@@ -51,6 +56,7 @@ export const decorateData = (entity, projectUrl = '') => {
return {
...dataStructure(),
id,
+ key: `${name}-${type}-${id}`,
type,
name,
url,
@@ -66,12 +72,6 @@ export const decorateData = (entity, projectUrl = '') => {
renderError,
content,
base64,
- // eslint-disable-next-line camelcase
- lastCommit: last_commit ? {
- url: `${projectUrl}/commit/${last_commit.id}`,
- message: last_commit.message,
- updatedAt: last_commit.committed_date,
- } : {},
};
};
@@ -106,3 +106,22 @@ export const createTemp = ({ name, path, type, level, changed, content, base64 }
renderError: base64,
});
};
+
+export const createOrMergeEntry = ({ tree, entry, type, parentTreeUrl, level }) => {
+ const found = findEntry(tree, type, entry.name);
+
+ if (found) {
+ return Object.assign({}, found, {
+ id: entry.id,
+ url: entry.url,
+ tempFile: false,
+ });
+ }
+
+ return decorateData({
+ ...entry,
+ type,
+ parentTreeUrl,
+ level,
+ });
+};