summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes/index.js
diff options
context:
space:
mode:
authorSimon Knox <psimyn@gmail.com>2017-12-11 15:31:01 +1100
committerSimon Knox <psimyn@gmail.com>2017-12-12 22:40:52 +1100
commit07271c094d21904aeda0c0cde571b984b4ede9a0 (patch)
tree43eeb44141818643bf2a7d5690df3638c18eec99 /app/assets/javascripts/notes/index.js
parent806a68a81f1baeed07c146b1b5d9eb77796c46ba (diff)
downloadgitlab-ce-40985-notes-data.tar.gz
simplify notes app creation40985-notes-data
Diffstat (limited to 'app/assets/javascripts/notes/index.js')
-rw-r--r--app/assets/javascripts/notes/index.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/app/assets/javascripts/notes/index.js b/app/assets/javascripts/notes/index.js
index a94163a5f87..6b3327527fe 100644
--- a/app/assets/javascripts/notes/index.js
+++ b/app/assets/javascripts/notes/index.js
@@ -17,18 +17,27 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
path: parsedUserData.path,
} : {};
+ function camelize(string) {
+ return string.replace(/(_\w)/g, match => match[1].toUpperCase());
+ }
+
+ function camelizeKeys(notesData) {
+ return Object.keys(notesData).reduce(
+ (acc, curr) => ({
+ ...acc,
+ [camelize(curr)]: notesData[curr],
+ }),
+ {},
+ );
+ }
+
+ const notesDataOrig = JSON.parse(notesDataset.notesData);
+ const notesData = camelizeKeys(notesDataOrig);
+
return {
noteableData: JSON.parse(notesDataset.noteableData),
currentUserData,
- notesData: {
- lastFetchedAt: notesDataset.lastFetchedAt,
- discussionsPath: notesDataset.discussionsPath,
- newSessionPath: notesDataset.newSessionPath,
- registerPath: notesDataset.registerPath,
- notesPath: notesDataset.notesPath,
- markdownDocsPath: notesDataset.markdownDocsPath,
- quickActionsDocsPath: notesDataset.quickActionsDocsPath,
- },
+ notesData,
};
},
render(createElement) {