Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
f67ff8e2
Commit
f67ff8e2
authored
Aug 10, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Removes use of window object in all components
Improves performance by removing emojis from data object
parent
f62939e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
65 deletions
+54
-65
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+2
-2
app/assets/javascripts/notes/components/issue_note_awards_list.vue
...s/javascripts/notes/components/issue_note_awards_list.vue
+18
-19
app/assets/javascripts/notes/index.js
app/assets/javascripts/notes/index.js
+34
-44
No files found.
app/assets/javascripts/notes/components/issue_note.vue
View file @
f67ff8e2
...
...
@@ -19,7 +19,6 @@
return
{
isEditing
:
false
,
isDeleting
:
false
,
currentUserId
:
window
.
gon
.
current_user_id
,
};
},
components
:
{
...
...
@@ -31,6 +30,7 @@
computed
:
{
...
mapGetters
([
'
targetNoteHash
'
,
'
getUserData
'
,
]),
author
()
{
return
this
.
note
.
author
;
...
...
@@ -43,7 +43,7 @@
};
},
canReportAsAbuse
()
{
return
this
.
note
.
report_abuse_path
&&
this
.
author
.
id
!==
this
.
currentUserI
d
;
return
this
.
note
.
report_abuse_path
&&
this
.
author
.
id
!==
this
.
getUserData
.
i
d
;
},
noteAnchorId
()
{
return
`note_
${
this
.
note
.
id
}
`
;
...
...
app/assets/javascripts/notes/components/issue_note_awards_list.vue
View file @
f67ff8e2
<
script
>
/* global Flash */
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
emojiSmiling
from
'
icons/_emoji_slightly_smiling_face.svg
'
;
import
emojiSmile
from
'
icons/_emoji_smile.svg
'
;
import
emojiSmiley
from
'
icons/_emoji_smiley.svg
'
;
...
...
@@ -30,18 +30,10 @@
directives
:
{
tooltip
,
},
data
()
{
const
userId
=
window
.
gon
.
current_user_id
;
return
{
emojiSmiling
,
emojiSmile
,
emojiSmiley
,
canAward
:
!!
userId
,
myUserId
:
userId
,
};
},
computed
:
{
...
mapGetters
([
'
getUserData
'
,
]),
// `this.awards` is an array with emojis but they are not grouped by emoji name. See below.
// [ { name: foo, user: user1 }, { name: bar, user: user1 }, { name: foo, user: user2 } ]
// This method will group emojis by their name as an Object. See below.
...
...
@@ -76,7 +68,10 @@
return
Object
.
assign
({},
orderedAwards
,
awards
);
},
isAuthoredByMe
()
{
return
this
.
noteAuthorId
===
window
.
gon
.
current_user_id
;
return
this
.
noteAuthorId
===
this
.
getUserData
.
id
;
},
isLoggedIn
()
{
return
this
.
getUserData
.
id
;
},
},
methods
:
{
...
...
@@ -95,17 +90,16 @@
canInteractWithEmoji
(
awardList
,
awardName
)
{
let
isAllowed
=
true
;
const
restrictedEmojis
=
[
'
thumbsup
'
,
'
thumbsdown
'
];
const
{
myUserId
,
noteAuthorId
}
=
this
;
// Users can not add :+1: and :-1: to their own notes
if
(
myUserId
===
noteAuthorId
&&
restrictedEmojis
.
indexOf
(
awardName
)
>
-
1
)
{
if
(
this
.
getUserData
.
id
===
this
.
noteAuthorId
&&
restrictedEmojis
.
indexOf
(
awardName
)
>
-
1
)
{
isAllowed
=
false
;
}
return
this
.
canAwar
d
&&
isAllowed
;
return
this
.
getUserData
.
i
d
&&
isAllowed
;
},
hasReactionByCurrentUser
(
awardList
)
{
return
awardList
.
filter
(
award
=>
award
.
user
.
id
===
this
.
myUserI
d
).
length
;
return
awardList
.
filter
(
award
=>
award
.
user
.
id
===
this
.
getUserData
.
i
d
).
length
;
},
awardTitle
(
awardsList
)
{
const
hasReactionByCurrentUser
=
this
.
hasReactionByCurrentUser
(
awardsList
);
...
...
@@ -114,7 +108,7 @@
// Filter myself from list if I am awarded.
if
(
hasReactionByCurrentUser
)
{
awardList
=
awardList
.
filter
(
award
=>
award
.
user
.
id
!==
this
.
myUserI
d
);
awardList
=
awardList
.
filter
(
award
=>
award
.
user
.
id
!==
this
.
getUserData
.
i
d
);
}
// Get only 9-10 usernames to show in tooltip text.
...
...
@@ -157,6 +151,11 @@
.
catch
(()
=>
Flash
(
'
Something went wrong on our end.
'
));
},
},
created
()
{
this
.
emojiSmiling
=
emojiSmiling
;
this
.
emojiSmile
=
this
.
emojiSmile
;
this
.
emojiSmiley
=
this
.
emojiSmiley
;
},
};
</
script
>
...
...
@@ -179,7 +178,7 @@
</span>
</button>
<div
v-if=
"
canAward
"
v-if=
"
isLoggedIn
"
class=
"award-menu-holder"
>
<button
v-tooltip
...
...
app/assets/javascripts/notes/index.js
View file @
f67ff8e2
import
Vue
from
'
vue
'
;
import
issueNotesApp
from
'
./components/issue_notes_app.vue
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
vm
=
new
Vue
({
el
:
'
#js-vue-notes
'
,
components
:
{
issueNotesApp
,
},
data
()
{
const
notesDataset
=
document
.
getElementById
(
'
js-vue-notes
'
).
dataset
;
return
{
issueData
:
JSON
.
parse
(
notesDataset
.
issueData
),
currentUserData
:
JSON
.
parse
(
notesDataset
.
currentUserData
),
notesData
:
{
lastFetchedAt
:
notesDataset
.
lastFetchedAt
,
discussionsPath
:
notesDataset
.
discussionsPath
,
newSessionPath
:
notesDataset
.
newSessionPath
,
registerPath
:
notesDataset
.
registerPath
,
notesPath
:
notesDataset
.
notesPath
,
markdownDocs
:
notesDataset
.
markdownDocs
,
quickActionsDocs
:
notesDataset
.
quickActionsDocs
,
},
};
},
render
(
createElement
)
{
return
createElement
(
'
issue-notes-app
'
,
{
attrs
:
{
ref
:
'
notes
'
,
},
props
:
{
issueData
:
this
.
issueData
,
notesData
:
this
.
notesData
,
userData
:
this
.
currentUserData
,
},
});
},
});
// This is used in note_polling_spec
window
.
issueNotes
=
{
refresh
()
{
vm
.
$refs
.
notes
.
$store
.
dispatch
(
'
poll
'
);
},
};
});
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
Vue
({
el
:
'
#js-vue-notes
'
,
components
:
{
issueNotesApp
,
},
data
()
{
const
notesDataset
=
document
.
getElementById
(
'
js-vue-notes
'
).
dataset
;
return
{
issueData
:
JSON
.
parse
(
notesDataset
.
issueData
),
currentUserData
:
JSON
.
parse
(
notesDataset
.
currentUserData
),
notesData
:
{
lastFetchedAt
:
notesDataset
.
lastFetchedAt
,
discussionsPath
:
notesDataset
.
discussionsPath
,
newSessionPath
:
notesDataset
.
newSessionPath
,
registerPath
:
notesDataset
.
registerPath
,
notesPath
:
notesDataset
.
notesPath
,
markdownDocs
:
notesDataset
.
markdownDocs
,
quickActionsDocs
:
notesDataset
.
quickActionsDocs
,
},
};
},
render
(
createElement
)
{
return
createElement
(
'
issue-notes-app
'
,
{
attrs
:
{
ref
:
'
notes
'
,
},
props
:
{
issueData
:
this
.
issueData
,
notesData
:
this
.
notesData
,
userData
:
this
.
currentUserData
,
},
});
},
}));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment