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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3343bf30
Commit
3343bf30
authored
Jul 28, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Remove DOM querying for paths, save them in the store
parent
d34c620f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
42 deletions
+45
-42
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+13
-23
app/assets/javascripts/notes/components/issue_note_signed_out_widget.vue
...scripts/notes/components/issue_note_signed_out_widget.vue
+5
-9
app/assets/javascripts/notes/components/issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+12
-7
app/assets/javascripts/notes/index.js
app/assets/javascripts/notes/index.js
+4
-0
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+7
-1
app/assets/javascripts/notes/stores/index.js
app/assets/javascripts/notes/stores/index.js
+1
-0
app/assets/javascripts/notes/stores/mutations.js
app/assets/javascripts/notes/stores/mutations.js
+0
-1
app/views/projects/issues/_discussion.html.haml
app/views/projects/issues/_discussion.html.haml
+3
-1
No files found.
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
3343bf30
<
script
>
<
script
>
/* global Flash */
/* global Flash */
import
{
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
{
mapActions
}
from
'
vuex
'
;
import
userAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
userAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
markdownField
from
'
../../vue_shared/components/markdown/field.vue
'
;
import
markdownField
from
'
../../vue_shared/components/markdown/field.vue
'
;
import
issueNoteSignedOutWidget
from
'
./issue_note_signed_out_widget.vue
'
;
import
issueNoteSignedOutWidget
from
'
./issue_note_signed_out_widget.vue
'
;
...
@@ -10,18 +10,18 @@
...
@@ -10,18 +10,18 @@
export
default
{
export
default
{
data
()
{
data
()
{
const
{
create_note_path
,
state
}
=
window
.
gl
.
issueData
;
const
{
getUserData
,
getIssueData
}
=
this
.
$store
.
getters
;
const
{
currentUserData
}
=
window
.
gl
;
return
{
return
{
note
:
''
,
note
:
''
,
markdownDocsUrl
:
''
,
markdownDocsUrl
:
getIssueData
.
markdownDocs
,
quickActionsDocsUrl
:
null
,
quickActionsDocsUrl
:
getIssueData
.
quickActionsDocs
,
markdownPreviewUrl
:
g
l
.
i
ssueData
.
preview_note_path
,
markdownPreviewUrl
:
g
etI
ssueData
.
preview_note_path
,
noteType
:
constants
.
COMMENT
,
noteType
:
constants
.
COMMENT
,
issueState
:
state
,
issueState
:
getIssueData
.
state
,
endpoint
:
create_note_path
,
endpoint
:
getIssueData
.
create_note_path
,
author
:
currentUserData
,
author
:
getUserData
,
canUpdateIssue
:
getIssueData
.
current_user
.
can_update
,
};
};
},
},
components
:
{
components
:
{
...
@@ -30,10 +30,6 @@
...
@@ -30,10 +30,6 @@
issueNoteSignedOutWidget
,
issueNoteSignedOutWidget
,
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'
getNotesDataByProp
'
,
'
getIssueDataByProp
'
,
]),
isLoggedIn
()
{
isLoggedIn
()
{
return
window
.
gon
.
current_user_id
;
return
window
.
gon
.
current_user_id
;
},
},
...
@@ -60,9 +56,6 @@
...
@@ -60,9 +56,6 @@
'
js-note-target-reopen
'
:
!
this
.
isIssueOpen
,
'
js-note-target-reopen
'
:
!
this
.
isIssueOpen
,
};
};
},
},
canUpdateIssue
()
{
return
this
.
getIssueDataByProp
(
current_user
).
can_update
;
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
...
mapActions
([
...
@@ -106,12 +99,12 @@
...
@@ -106,12 +99,12 @@
if
(
withIssueAction
)
{
if
(
withIssueAction
)
{
if
(
this
.
isIssueOpen
)
{
if
(
this
.
isIssueOpen
)
{
gl
.
issueData
.
state
=
constants
.
CLOSED
;
this
.
issueState
=
constants
.
CLOSED
;
this
.
issueState
=
constants
.
CLOSED
;
}
else
{
}
else
{
gl
.
issueData
.
state
=
constants
.
REOPENED
;
this
.
issueState
=
constants
.
REOPENED
;
this
.
issueState
=
constants
.
REOPENED
;
}
}
gl
.
issueData
.
state
=
this
.
issueState
;
this
.
isIssueOpen
=
!
this
.
isIssueOpen
;
this
.
isIssueOpen
=
!
this
.
isIssueOpen
;
// This is out of scope for the Notes Vue component.
// This is out of scope for the Notes Vue component.
...
@@ -139,7 +132,7 @@
...
@@ -139,7 +132,7 @@
editMyLastNote
()
{
editMyLastNote
()
{
if
(
this
.
note
===
''
)
{
if
(
this
.
note
===
''
)
{
const
myLastNoteId
=
$
(
'
.js-my-note
'
).
last
().
attr
(
'
id
'
);
const
myLastNoteId
=
$
(
'
.js-my-note
'
).
last
().
attr
(
'
id
'
);
debugger
;
if
(
myLastNoteId
)
{
if
(
myLastNoteId
)
{
eventHub
.
$emit
(
'
enterEditMode
'
,
{
eventHub
.
$emit
(
'
enterEditMode
'
,
{
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'
note_
'
,
''
),
10
),
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'
note_
'
,
''
),
10
),
...
@@ -149,9 +142,6 @@
...
@@ -149,9 +142,6 @@
},
},
},
},
mounted
()
{
mounted
()
{
this
.
markdownDocsUrl
=
this
.
getIssueDataByProp
(
markdownDocs
);
this
.
quickActionsDocsUrl
=
this
.
getIssueDataByProp
(
quickActionsDocs
);
eventHub
.
$on
(
'
issueStateChanged
'
,
(
isClosed
)
=>
{
eventHub
.
$on
(
'
issueStateChanged
'
,
(
isClosed
)
=>
{
this
.
issueState
=
isClosed
?
constants
.
CLOSED
:
constants
.
REOPENED
;
this
.
issueState
=
isClosed
?
constants
.
CLOSED
:
constants
.
REOPENED
;
});
});
...
...
app/assets/javascripts/notes/components/issue_note_signed_out_widget.vue
View file @
3343bf30
<
script
>
<
script
>
export
default
{
export
default
{
data
()
{
data
()
{
const
{
newSessionPath
,
registerPath
}
=
this
.
$store
.
getters
.
notesData
;
return
{
return
{
signInLink
:
'
#
'
,
signInLink
:
newSessionPath
,
registerLink
:
registerPath
,
};
};
},
},
mounted
()
{
const
wrapper
=
document
.
querySelector
(
'
.js-notes-wrapper
'
);
if
(
wrapper
)
{
this
.
signInLink
=
wrapper
.
dataset
.
newSessionPath
;
}
},
};
};
</
script
>
</
script
>
...
@@ -20,7 +16,7 @@
...
@@ -20,7 +16,7 @@
Please
Please
<a
:href=
"signInLink"
>
register
</a>
<a
:href=
"signInLink"
>
register
</a>
or
or
<a
:href=
"
signIn
Link"
>
sign in
</a>
<a
:href=
"
register
Link"
>
sign in
</a>
to reply
to reply
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
3343bf30
...
@@ -25,6 +25,10 @@
...
@@ -25,6 +25,10 @@
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
userData
:
{
type
:
Object
,
required
:
true
,
},
},
},
store
,
store
,
data
()
{
data
()
{
...
@@ -43,21 +47,21 @@
...
@@ -43,21 +47,21 @@
},
},
computed
:
{
computed
:
{
...
mapGetters
([
...
mapGetters
([
'
notes
'
,
'
notesById
'
,
'
getNotesData
'
,
'
getNotesDataByProp
'
,
'
getNotesDataByProp
'
,
'
setLastFetchedAt
'
,
'
setTargetNoteHash
'
,
]),
]),
},
},
methods
:
{
methods
:
{
...
mapGetters
([
'
getNotesDataByProp
'
,
]),
...
mapActions
({
...
mapActions
({
actionFetchNotes
:
'
fetchNotes
'
,
actionFetchNotes
:
'
fetchNotes
'
,
poll
:
'
poll
'
,
poll
:
'
poll
'
,
toggleAward
:
'
toggleAward
'
,
toggleAward
:
'
toggleAward
'
,
scrollToNoteIfNeeded
:
'
scrollToNoteIfNeeded
'
,
scrollToNoteIfNeeded
:
'
scrollToNoteIfNeeded
'
,
setNotesData
:
'
setNotesData
'
setNotesData
:
'
setNotesData
'
,
setIssueData
:
'
setIssueData
'
,
setUserData
:
'
setUserData
'
,
}),
}),
getComponentName
(
note
)
{
getComponentName
(
note
)
{
if
(
note
.
isPlaceholderNote
)
{
if
(
note
.
isPlaceholderNote
)
{
...
@@ -75,7 +79,7 @@
...
@@ -75,7 +79,7 @@
return
note
.
individual_note
?
note
.
notes
[
0
]
:
note
;
return
note
.
individual_note
?
note
.
notes
[
0
]
:
note
;
},
},
fetchNotes
()
{
fetchNotes
()
{
this
.
actionFetchNotes
(
his
.
getNotesDataByProp
(
'
discussionsPath
'
))
this
.
actionFetchNotes
(
t
his
.
getNotesDataByProp
(
'
discussionsPath
'
))
.
then
(()
=>
{
.
then
(()
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
...
@@ -126,6 +130,7 @@
...
@@ -126,6 +130,7 @@
created
()
{
created
()
{
this
.
setNotesData
(
this
.
notesData
);
this
.
setNotesData
(
this
.
notesData
);
this
.
setIssueData
(
this
.
issueData
);
this
.
setIssueData
(
this
.
issueData
);
this
.
setUserData
(
this
.
userData
)
},
},
mounted
()
{
mounted
()
{
this
.
fetchNotes
();
this
.
fetchNotes
();
...
...
app/assets/javascripts/notes/index.js
View file @
3343bf30
...
@@ -15,6 +15,9 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
...
@@ -15,6 +15,9 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
notesData
:
{
notesData
:
{
lastFetchedAt
:
notesDataset
.
lastFetchedAt
,
lastFetchedAt
:
notesDataset
.
lastFetchedAt
,
discussionsPath
:
notesDataset
.
discussionsPath
,
discussionsPath
:
notesDataset
.
discussionsPath
,
newSessionPath
:
notesDataset
.
newSessionPath
,
registerPath
:
notesDataset
.
registerPath
,
notesPath
:
notesDataset
.
notesPath
,
},
},
};
};
},
},
...
@@ -26,6 +29,7 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
...
@@ -26,6 +29,7 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
props
:
{
props
:
{
issueData
:
this
.
issueData
,
issueData
:
this
.
issueData
,
notesData
:
this
.
notesData
,
notesData
:
this
.
notesData
,
userData
:
this
.
currentUserData
,
},
},
});
});
},
},
...
...
app/assets/javascripts/notes/stores/getters.js
View file @
3343bf30
export
const
notes
=
state
=>
state
.
notes
;
export
const
notes
=
state
=>
state
.
notes
;
export
const
targetNoteHash
=
state
=>
state
.
targetNoteHash
;
export
const
targetNoteHash
=
state
=>
state
.
targetNoteHash
;
export
const
getNotesData
=
state
=>
state
.
notesData
;
export
const
getNotesDataByProp
=
state
=>
prop
=>
state
.
notesData
[
prop
];
export
const
getNotesDataByProp
=
state
=>
prop
=>
state
.
notesData
[
prop
];
export
const
getIssueDataByProp
=
state
=>
prop
=>
state
.
notesData
[
prop
];
export
const
getIssueData
=
state
=>
state
.
issueData
;
export
const
getIssueDataByProp
=
state
=>
prop
=>
state
.
issueData
[
prop
];
export
const
getUserData
=
state
=>
state
.
userData
;
export
const
getUserDataByProp
=
state
=>
prop
=>
state
.
notesData
[
prop
];
export
const
getUserDataByProp
=
state
=>
prop
=>
state
.
notesData
[
prop
];
export
const
notesById
=
(
state
)
=>
{
export
const
notesById
=
(
state
)
=>
{
...
...
app/assets/javascripts/notes/stores/index.js
View file @
3343bf30
...
@@ -16,6 +16,7 @@ export default new Vuex.Store({
...
@@ -16,6 +16,7 @@ export default new Vuex.Store({
notesData
:
{},
notesData
:
{},
userData
:
{},
userData
:
{},
issueData
:
{},
issueData
:
{},
paths
:
{},
},
},
actions
,
actions
,
getters
,
getters
,
...
...
app/assets/javascripts/notes/stores/mutations.js
View file @
3343bf30
...
@@ -69,7 +69,6 @@ export default {
...
@@ -69,7 +69,6 @@ export default {
[
types
.
SET_USER_DATA
](
state
,
data
)
{
[
types
.
SET_USER_DATA
](
state
,
data
)
{
state
.
userData
=
data
;
state
.
userData
=
data
;
},
},
[
types
.
SET_INITAL_NOTES
](
state
,
notes
)
{
[
types
.
SET_INITAL_NOTES
](
state
,
notes
)
{
state
.
notes
=
notes
;
state
.
notes
=
notes
;
},
},
...
...
app/views/projects/issues/_discussion.html.haml
View file @
3343bf30
...
@@ -5,8 +5,10 @@
...
@@ -5,8 +5,10 @@
%section
%section
#js-vue-notes
{
data:
{
discussions_path:
discussions_namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
,
format: :json
),
#js-vue-notes
{
data:
{
discussions_path:
discussions_namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
,
format: :json
),
register_path:
"#{new_session_path(:user, redirect_to_referer: 'yes')}#register-pane"
,
new_session_path:
new_session_path
(
:user
,
redirect_to_referer:
'yes'
),
new_session_path:
new_session_path
(
:user
,
redirect_to_referer:
'yes'
),
notes_path:
'
#
{
notes_url
}?
full_data
=
1
'
,
last_fetched_at:
Time
.
now
.
to_i
,
notes_path:
'
#
{
notes_url
}?
full_data
=
1
'
,
last_fetched_at:
Time
.
now
.
to_i
,
issue_data:
serialize_issuable
(
@issue
),
issue_data:
serialize_issuable
(
@issue
),
current_user_data:
UserSerializer
.
new
.
represent
(
current_user
).
to_json
}}
current_user_data:
UserSerializer
.
new
.
represent
(
current_user
).
to_json
}}
-
content_for
:page_specific_javascripts
do
-
content_for
:page_specific_javascripts
do
...
...
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