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
Boxiang Sun
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 @@
...
@@ -19,7 +19,6 @@
return
{
return
{
isEditing
:
false
,
isEditing
:
false
,
isDeleting
:
false
,
isDeleting
:
false
,
currentUserId
:
window
.
gon
.
current_user_id
,
};
};
},
},
components
:
{
components
:
{
...
@@ -31,6 +30,7 @@
...
@@ -31,6 +30,7 @@
computed
:
{
computed
:
{
...
mapGetters
([
...
mapGetters
([
'
targetNoteHash
'
,
'
targetNoteHash
'
,
'
getUserData
'
,
]),
]),
author
()
{
author
()
{
return
this
.
note
.
author
;
return
this
.
note
.
author
;
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
};
};
},
},
canReportAsAbuse
()
{
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
()
{
noteAnchorId
()
{
return
`note_
${
this
.
note
.
id
}
`
;
return
`note_
${
this
.
note
.
id
}
`
;
...
...
app/assets/javascripts/notes/components/issue_note_awards_list.vue
View file @
f67ff8e2
<
script
>
<
script
>
/* global Flash */
/* global Flash */
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
emojiSmiling
from
'
icons/_emoji_slightly_smiling_face.svg
'
;
import
emojiSmiling
from
'
icons/_emoji_slightly_smiling_face.svg
'
;
import
emojiSmile
from
'
icons/_emoji_smile.svg
'
;
import
emojiSmile
from
'
icons/_emoji_smile.svg
'
;
import
emojiSmiley
from
'
icons/_emoji_smiley.svg
'
;
import
emojiSmiley
from
'
icons/_emoji_smiley.svg
'
;
...
@@ -30,18 +30,10 @@
...
@@ -30,18 +30,10 @@
directives
:
{
directives
:
{
tooltip
,
tooltip
,
},
},
data
()
{
const
userId
=
window
.
gon
.
current_user_id
;
return
{
emojiSmiling
,
emojiSmile
,
emojiSmiley
,
canAward
:
!!
userId
,
myUserId
:
userId
,
};
},
computed
:
{
computed
:
{
...
mapGetters
([
'
getUserData
'
,
]),
// `this.awards` is an array with emojis but they are not grouped by emoji name. See below.
// `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 } ]
// [ { 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.
// This method will group emojis by their name as an Object. See below.
...
@@ -76,7 +68,10 @@
...
@@ -76,7 +68,10 @@
return
Object
.
assign
({},
orderedAwards
,
awards
);
return
Object
.
assign
({},
orderedAwards
,
awards
);
},
},
isAuthoredByMe
()
{
isAuthoredByMe
()
{
return
this
.
noteAuthorId
===
window
.
gon
.
current_user_id
;
return
this
.
noteAuthorId
===
this
.
getUserData
.
id
;
},
isLoggedIn
()
{
return
this
.
getUserData
.
id
;
},
},
},
},
methods
:
{
methods
:
{
...
@@ -95,17 +90,16 @@
...
@@ -95,17 +90,16 @@
canInteractWithEmoji
(
awardList
,
awardName
)
{
canInteractWithEmoji
(
awardList
,
awardName
)
{
let
isAllowed
=
true
;
let
isAllowed
=
true
;
const
restrictedEmojis
=
[
'
thumbsup
'
,
'
thumbsdown
'
];
const
restrictedEmojis
=
[
'
thumbsup
'
,
'
thumbsdown
'
];
const
{
myUserId
,
noteAuthorId
}
=
this
;
// Users can not add :+1: and :-1: to their own notes
// 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
;
isAllowed
=
false
;
}
}
return
this
.
canAwar
d
&&
isAllowed
;
return
this
.
getUserData
.
i
d
&&
isAllowed
;
},
},
hasReactionByCurrentUser
(
awardList
)
{
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
)
{
awardTitle
(
awardsList
)
{
const
hasReactionByCurrentUser
=
this
.
hasReactionByCurrentUser
(
awardsList
);
const
hasReactionByCurrentUser
=
this
.
hasReactionByCurrentUser
(
awardsList
);
...
@@ -114,7 +108,7 @@
...
@@ -114,7 +108,7 @@
// Filter myself from list if I am awarded.
// Filter myself from list if I am awarded.
if
(
hasReactionByCurrentUser
)
{
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.
// Get only 9-10 usernames to show in tooltip text.
...
@@ -157,6 +151,11 @@
...
@@ -157,6 +151,11 @@
.
catch
(()
=>
Flash
(
'
Something went wrong on our end.
'
));
.
catch
(()
=>
Flash
(
'
Something went wrong on our end.
'
));
},
},
},
},
created
()
{
this
.
emojiSmiling
=
emojiSmiling
;
this
.
emojiSmile
=
this
.
emojiSmile
;
this
.
emojiSmiley
=
this
.
emojiSmiley
;
},
};
};
</
script
>
</
script
>
...
@@ -179,7 +178,7 @@
...
@@ -179,7 +178,7 @@
</span>
</span>
</button>
</button>
<div
<div
v-if=
"
canAward
"
v-if=
"
isLoggedIn
"
class=
"award-menu-holder"
>
class=
"award-menu-holder"
>
<button
<button
v-tooltip
v-tooltip
...
...
app/assets/javascripts/notes/index.js
View file @
f67ff8e2
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
issueNotesApp
from
'
./components/issue_notes_app.vue
'
;
import
issueNotesApp
from
'
./components/issue_notes_app.vue
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
new
Vue
({
const
vm
=
new
Vue
({
el
:
'
#js-vue-notes
'
,
el
:
'
#js-vue-notes
'
,
components
:
{
components
:
{
issueNotesApp
,
issueNotesApp
,
},
},
data
()
{
data
()
{
const
notesDataset
=
document
.
getElementById
(
'
js-vue-notes
'
).
dataset
;
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
'
);
},
};
});
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