Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
c6fa5e69cf93
Commit
a0175b92
authored
Nov 30, 2017
by
Simon Knox
Committed by
Fatih Acet
Nov 30, 2017
Browse files
issue note store
parent
1ced38b585a0
Changes
24
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
c6fa5e69
...
...
@@ -22,7 +22,7 @@
noteType
:
constants
.
COMMENT
,
// Can't use mapGetters,
// this needs to be in the data object because it belongs to the state
issueState
:
this
.
$store
.
getters
.
get
Issu
eData
.
state
,
issueState
:
this
.
$store
.
getters
.
get
Noteabl
eData
.
state
,
isSubmitting
:
false
,
isSubmitButtonDisabled
:
true
,
};
...
...
@@ -46,7 +46,7 @@
...
mapGetters
([
'
getCurrentUserLastNote
'
,
'
getUserData
'
,
'
get
Issu
eData
'
,
'
get
Noteabl
eData
'
,
'
getNotesData
'
,
]),
isLoggedIn
()
{
...
...
@@ -59,7 +59,7 @@
return
this
.
issueState
===
constants
.
OPENED
||
this
.
issueState
===
constants
.
REOPENED
;
},
canCreateNote
()
{
return
this
.
get
Issu
eData
.
current_user
.
can_create_note
;
return
this
.
get
Noteabl
eData
.
current_user
.
can_create_note
;
},
issueActionButtonTitle
()
{
if
(
this
.
note
.
length
)
{
...
...
@@ -85,16 +85,16 @@
return
this
.
getNotesData
.
quickActionsDocsPath
;
},
markdownPreviewPath
()
{
return
this
.
get
Issu
eData
.
preview_note_path
;
return
this
.
get
Noteabl
eData
.
preview_note_path
;
},
author
()
{
return
this
.
getUserData
;
},
canUpdateIssue
()
{
return
this
.
get
Issu
eData
.
current_user
.
can_update
;
return
this
.
get
Noteabl
eData
.
current_user
.
can_update
;
},
endpoint
()
{
return
this
.
get
Issu
eData
.
create_note_path
;
return
this
.
get
Noteabl
eData
.
create_note_path
;
},
},
methods
:
{
...
...
@@ -119,7 +119,7 @@
data
:
{
note
:
{
noteable_type
:
constants
.
NOTEABLE_TYPE
,
noteable_id
:
this
.
get
Issu
eData
.
id
,
noteable_id
:
this
.
get
Noteabl
eData
.
id
,
note
:
this
.
note
,
},
},
...
...
@@ -207,7 +207,7 @@
},
initAutoSave
()
{
if
(
this
.
isLoggedIn
)
{
this
.
autosave
=
new
Autosave
(
$
(
this
.
$refs
.
textarea
),
[
'
Note
'
,
'
Issue
'
,
this
.
get
Issu
eData
.
id
],
'
issue
'
);
this
.
autosave
=
new
Autosave
(
$
(
this
.
$refs
.
textarea
),
[
'
Note
'
,
'
Issue
'
,
this
.
get
Noteabl
eData
.
id
],
'
issue
'
);
}
},
initTaskList
()
{
...
...
@@ -266,9 +266,9 @@
<div
class=
"error-alert"
></div>
<issue-warning
v-if=
"hasWarning(get
Issu
eData)"
:is-locked=
"isLocked(get
Issu
eData)"
:is-confidential=
"isConfidential(get
Issu
eData)"
v-if=
"hasWarning(get
Noteabl
eData)"
:is-locked=
"isLocked(get
Noteabl
eData)"
:is-confidential=
"isConfidential(get
Noteabl
eData)"
/>
<markdown-field
...
...
app/assets/javascripts/notes/components/issue_discussion.vue
View file @
c6fa5e69
...
...
@@ -41,7 +41,7 @@
],
computed
:
{
...
mapGetters
([
'
get
Issu
eData
'
,
'
get
Noteabl
eData
'
,
]),
discussion
()
{
return
this
.
note
.
notes
[
0
];
...
...
@@ -50,10 +50,10 @@
return
this
.
discussion
.
author
;
},
canReply
()
{
return
this
.
get
Issu
eData
.
current_user
.
can_create_note
;
return
this
.
get
Noteabl
eData
.
current_user
.
can_create_note
;
},
newNotePath
()
{
return
this
.
get
Issu
eData
.
create_note_path
;
return
this
.
get
Noteabl
eData
.
create_note_path
;
},
lastUpdatedBy
()
{
const
{
notes
}
=
this
.
note
;
...
...
app/assets/javascripts/notes/components/issue_note_form.vue
View file @
c6fa5e69
...
...
@@ -46,8 +46,8 @@
computed
:
{
...
mapGetters
([
'
getDiscussionLastNote
'
,
'
get
Issu
eData
'
,
'
get
Issu
eDataByProp
'
,
'
get
Noteabl
eData
'
,
'
get
Noteabl
eDataByProp
'
,
'
getNotesDataByProp
'
,
'
getUserDataByProp
'
,
]),
...
...
@@ -55,7 +55,7 @@
return
`#note_
${
this
.
noteId
}
`
;
},
markdownPreviewPath
()
{
return
this
.
get
Issu
eDataByProp
(
'
preview_note_path
'
);
return
this
.
get
Noteabl
eDataByProp
(
'
preview_note_path
'
);
},
markdownDocsPath
()
{
return
this
.
getNotesDataByProp
(
'
markdownDocsPath
'
);
...
...
@@ -129,9 +129,9 @@
class=
"edit-note common-note-form js-quick-submit gfm-form"
>
<issue-warning
v-if=
"hasWarning(get
Issu
eData)"
:is-locked=
"isLocked(get
Issu
eData)"
:is-confidential=
"isConfidential(get
Issu
eData)"
v-if=
"hasWarning(get
Noteabl
eData)"
:is-locked=
"isLocked(get
Noteabl
eData)"
:is-confidential=
"isConfidential(get
Noteabl
eData)"
/>
<markdown-field
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
c6fa5e69
...
...
@@ -14,7 +14,7 @@
export
default
{
name
:
'
issueNotesApp
'
,
props
:
{
issu
eData
:
{
noteabl
eData
:
{
type
:
Object
,
required
:
true
,
},
...
...
@@ -56,7 +56,7 @@
actionToggleAward
:
'
toggleAward
'
,
scrollToNoteIfNeeded
:
'
scrollToNoteIfNeeded
'
,
setNotesData
:
'
setNotesData
'
,
set
Issu
eData
:
'
set
Issu
eData
'
,
set
Noteabl
eData
:
'
set
Noteabl
eData
'
,
setUserData
:
'
setUserData
'
,
setLastFetchedAt
:
'
setLastFetchedAt
'
,
setTargetNoteHash
:
'
setTargetNoteHash
'
,
...
...
@@ -106,7 +106,7 @@
},
created
()
{
this
.
setNotesData
(
this
.
notesData
);
this
.
set
Issu
eData
(
this
.
issu
eData
);
this
.
set
Noteabl
eData
(
this
.
noteabl
eData
);
this
.
setUserData
(
this
.
userData
);
},
mounted
()
{
...
...
app/assets/javascripts/notes/index.js
View file @
c6fa5e69
...
...
@@ -10,7 +10,7 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
const
notesDataset
=
document
.
getElementById
(
'
js-vue-notes
'
).
dataset
;
return
{
issu
eData
:
JSON
.
parse
(
notesDataset
.
issu
eData
),
noteabl
eData
:
JSON
.
parse
(
notesDataset
.
noteabl
eData
),
currentUserData
:
JSON
.
parse
(
notesDataset
.
currentUserData
),
notesData
:
{
lastFetchedAt
:
notesDataset
.
lastFetchedAt
,
...
...
@@ -26,7 +26,7 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
render
(
createElement
)
{
return
createElement
(
'
issue-notes-app
'
,
{
props
:
{
issu
eData
:
this
.
issu
eData
,
noteabl
eData
:
this
.
noteabl
eData
,
notesData
:
this
.
notesData
,
userData
:
this
.
currentUserData
,
},
...
...
app/assets/javascripts/notes/services/
issue_
notes_service.js
→
app/assets/javascripts/notes/services/notes_service.js
View file @
c6fa5e69
File moved
app/assets/javascripts/notes/stores/actions.js
View file @
c6fa5e69
...
...
@@ -4,7 +4,7 @@ import Poll from '../../lib/utils/poll';
import
*
as
types
from
'
./mutation_types
'
;
import
*
as
utils
from
'
./utils
'
;
import
*
as
constants
from
'
../constants
'
;
import
service
from
'
../services/
issue_
notes_service
'
;
import
service
from
'
../services/notes_service
'
;
import
loadAwardsHandler
from
'
../../awards_handler
'
;
import
sidebarTimeTrackingEventHub
from
'
../../sidebar/event_hub
'
;
import
{
isInViewport
,
scrollToElement
}
from
'
../../lib/utils/common_utils
'
;
...
...
@@ -12,7 +12,7 @@ import { isInViewport, scrollToElement } from '../../lib/utils/common_utils';
let
eTagPoll
;
export
const
setNotesData
=
({
commit
},
data
)
=>
commit
(
types
.
SET_NOTES_DATA
,
data
);
export
const
set
Issu
eData
=
({
commit
},
data
)
=>
commit
(
types
.
SET_
ISSU
E_DATA
,
data
);
export
const
set
Noteabl
eData
=
({
commit
},
data
)
=>
commit
(
types
.
SET_
NOTEABL
E_DATA
,
data
);
export
const
setUserData
=
({
commit
},
data
)
=>
commit
(
types
.
SET_USER_DATA
,
data
);
export
const
setLastFetchedAt
=
({
commit
},
data
)
=>
commit
(
types
.
SET_LAST_FETCHED_AT
,
data
);
export
const
setInitialNotes
=
({
commit
},
data
)
=>
commit
(
types
.
SET_INITIAL_NOTES
,
data
);
...
...
app/assets/javascripts/notes/stores/getters.js
View file @
c6fa5e69
...
...
@@ -6,8 +6,8 @@ export const targetNoteHash = state => state.targetNoteHash;
export
const
getNotesData
=
state
=>
state
.
notesData
;
export
const
getNotesDataByProp
=
state
=>
prop
=>
state
.
notesData
[
prop
];
export
const
get
Issu
eData
=
state
=>
state
.
issu
eData
;
export
const
get
Issu
eDataByProp
=
state
=>
prop
=>
state
.
issu
eData
[
prop
];
export
const
get
Noteabl
eData
=
state
=>
state
.
noteabl
eData
;
export
const
get
Noteabl
eDataByProp
=
state
=>
prop
=>
state
.
noteabl
eData
[
prop
];
export
const
getUserData
=
state
=>
state
.
userData
||
{};
export
const
getUserDataByProp
=
state
=>
prop
=>
state
.
userData
&&
state
.
userData
[
prop
];
...
...
app/assets/javascripts/notes/stores/index.js
View file @
c6fa5e69
...
...
@@ -15,7 +15,7 @@ export default new Vuex.Store({
// holds endpoints and permissions provided through haml
notesData
:
{},
userData
:
{},
issu
eData
:
{},
noteabl
eData
:
{},
},
actions
,
getters
,
...
...
app/assets/javascripts/notes/stores/mutation_types.js
View file @
c6fa5e69
...
...
@@ -3,7 +3,7 @@ export const ADD_NEW_REPLY_TO_DISCUSSION = 'ADD_NEW_REPLY_TO_DISCUSSION';
export
const
DELETE_NOTE
=
'
DELETE_NOTE
'
;
export
const
REMOVE_PLACEHOLDER_NOTES
=
'
REMOVE_PLACEHOLDER_NOTES
'
;
export
const
SET_NOTES_DATA
=
'
SET_NOTES_DATA
'
;
export
const
SET_
ISSU
E_DATA
=
'
SET_
ISSU
E_DATA
'
;
export
const
SET_
NOTEABL
E_DATA
=
'
SET_
NOTEABL
E_DATA
'
;
export
const
SET_USER_DATA
=
'
SET_USER_DATA
'
;
export
const
SET_INITIAL_NOTES
=
'
SET_INITIAL_NOTES
'
;
export
const
SET_LAST_FETCHED_AT
=
'
SET_LAST_FETCHED_AT
'
;
...
...
app/assets/javascripts/notes/stores/mutations.js
View file @
c6fa5e69
...
...
@@ -66,8 +66,8 @@ export default {
Object
.
assign
(
state
,
{
notesData
:
data
});
},
[
types
.
SET_
ISSU
E_DATA
](
state
,
data
)
{
Object
.
assign
(
state
,
{
issu
eData
:
data
});
[
types
.
SET_
NOTEABL
E_DATA
](
state
,
data
)
{
Object
.
assign
(
state
,
{
noteabl
eData
:
data
});
},
[
types
.
SET_USER_DATA
](
state
,
data
)
{
...
...
app/views/projects/issues/_discussion.html.haml
View file @
c6fa5e69
...
...
@@ -13,5 +13,5 @@
quick_actions_docs_path:
help_page_path
(
'user/project/quick_actions'
),
notes_path:
notes_url
,
last_fetched_at:
Time
.
now
.
to_i
,
issu
e_data:
serialize_issuable
(
@issue
),
noteabl
e_data:
serialize_issuable
(
@issue
),
current_user_data:
UserSerializer
.
new
.
represent
(
current_user
).
to_json
}
}
spec/features/issuables/discussion_lock_spec.rb
View file @
c6fa5e69
...
...
@@ -14,7 +14,7 @@
project
.
add_developer
(
user
)
end
context
'when the discussion is unlocked'
do
context
'when the discussion is
unlocked'
do
it
'the user can lock the issue'
do
visit
project_issue_path
(
project
,
issue
)
...
...
spec/javascripts/notes/components/issue_comment_form_spec.js
View file @
c6fa5e69
...
...
@@ -2,7 +2,7 @@ import Vue from 'vue';
import
Autosize
from
'
autosize
'
;
import
store
from
'
~/notes/stores
'
;
import
issueCommentForm
from
'
~/notes/components/issue_comment_form.vue
'
;
import
{
loggedOut
Issu
eData
,
notesDataMock
,
userDataMock
,
issu
eDataMock
}
from
'
../mock_data
'
;
import
{
loggedOut
noteabl
eData
,
notesDataMock
,
userDataMock
,
noteabl
eDataMock
}
from
'
../mock_data
'
;
import
{
keyboardDownEvent
}
from
'
../../issue_show/helpers
'
;
describe
(
'
issue_comment_form component
'
,
()
=>
{
...
...
@@ -23,7 +23,7 @@ describe('issue_comment_form component', () => {
describe
(
'
user is logged in
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
dispatch
(
'
setUserData
'
,
userDataMock
);
store
.
dispatch
(
'
set
Issu
eData
'
,
issu
eDataMock
);
store
.
dispatch
(
'
set
Noteabl
eData
'
,
noteabl
eDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
vm
=
mountComponent
();
...
...
@@ -178,7 +178,7 @@ describe('issue_comment_form component', () => {
describe
(
'
issue is confidential
'
,
()
=>
{
it
(
'
shows information warning
'
,
(
done
)
=>
{
store
.
dispatch
(
'
set
Issu
eData
'
,
Object
.
assign
(
issu
eDataMock
,
{
confidential
:
true
}));
store
.
dispatch
(
'
set
Noteabl
eData
'
,
Object
.
assign
(
noteabl
eDataMock
,
{
confidential
:
true
}));
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.confidential-issue-warning
'
)).
toBeDefined
();
done
();
...
...
@@ -190,7 +190,7 @@ describe('issue_comment_form component', () => {
describe
(
'
user is not logged in
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
dispatch
(
'
setUserData
'
,
null
);
store
.
dispatch
(
'
set
Issu
eData
'
,
loggedOut
Issu
eData
);
store
.
dispatch
(
'
set
Noteabl
eData
'
,
loggedOut
noteabl
eData
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
vm
=
mountComponent
();
...
...
spec/javascripts/notes/components/issue_discussion_spec.js
View file @
c6fa5e69
import
Vue
from
'
vue
'
;
import
store
from
'
~/notes/stores
'
;
import
issueDiscussion
from
'
~/notes/components/issue_discussion.vue
'
;
import
{
issu
eDataMock
,
discussionMock
,
notesDataMock
}
from
'
../mock_data
'
;
import
{
noteabl
eDataMock
,
discussionMock
,
notesDataMock
}
from
'
../mock_data
'
;
describe
(
'
issue_discussion component
'
,
()
=>
{
let
vm
;
...
...
@@ -9,7 +9,7 @@ describe('issue_discussion component', () => {
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
issueDiscussion
);
store
.
dispatch
(
'
set
Issu
eData
'
,
issu
eDataMock
);
store
.
dispatch
(
'
set
Noteabl
eData
'
,
noteabl
eDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
vm
=
new
Component
({
...
...
spec/javascripts/notes/components/issue_note_app_spec.js
View file @
c6fa5e69
import
Vue
from
'
vue
'
;
import
issueNotesApp
from
'
~/notes/components/issue_notes_app.vue
'
;
import
service
from
'
~/notes/services/
issue_
notes_service
'
;
import
service
from
'
~/notes/services/notes_service
'
;
import
*
as
mockData
from
'
../mock_data
'
;
describe
(
'
issue_note_app
'
,
()
=>
{
...
...
@@ -24,7 +24,7 @@ describe('issue_note_app', () => {
mountComponent
=
(
data
)
=>
{
const
props
=
data
||
{
issu
eData
:
mockData
.
issu
eDataMock
,
noteabl
eData
:
mockData
.
noteabl
eDataMock
,
notesData
:
mockData
.
notesDataMock
,
userData
:
mockData
.
userDataMock
,
};
...
...
@@ -60,7 +60,7 @@ describe('issue_note_app', () => {
});
it
(
'
should set issue data
'
,
()
=>
{
expect
(
vm
.
$store
.
state
.
issu
eData
).
toEqual
(
mockData
.
issu
eDataMock
);
expect
(
vm
.
$store
.
state
.
noteabl
eData
).
toEqual
(
mockData
.
noteabl
eDataMock
);
});
it
(
'
should set user data
'
,
()
=>
{
...
...
spec/javascripts/notes/components/issue_note_awards_list_spec.js
View file @
c6fa5e69
import
Vue
from
'
vue
'
;
import
store
from
'
~/notes/stores
'
;
import
awardsNote
from
'
~/notes/components/issue_note_awards_list.vue
'
;
import
{
issu
eDataMock
,
notesDataMock
}
from
'
../mock_data
'
;
import
{
noteabl
eDataMock
,
notesDataMock
}
from
'
../mock_data
'
;
describe
(
'
issue_note_awards_list component
'
,
()
=>
{
let
vm
;
...
...
@@ -10,7 +10,7 @@ describe('issue_note_awards_list component', () => {
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
awardsNote
);
store
.
dispatch
(
'
set
Issu
eData
'
,
issu
eDataMock
);
store
.
dispatch
(
'
set
Noteabl
eData
'
,
noteabl
eDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
awardsMock
=
[
{
...
...
spec/javascripts/notes/components/issue_note_body_spec.js
View file @
c6fa5e69
...
...
@@ -2,7 +2,7 @@
import
Vue
from
'
vue
'
;
import
store
from
'
~/notes/stores
'
;
import
noteBody
from
'
~/notes/components/issue_note_body.vue
'
;
import
{
issu
eDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
import
{
noteabl
eDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
describe
(
'
issue_note_body component
'
,
()
=>
{
let
vm
;
...
...
@@ -10,7 +10,7 @@ describe('issue_note_body component', () => {
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
noteBody
);
store
.
dispatch
(
'
set
Issu
eData
'
,
issu
eDataMock
);
store
.
dispatch
(
'
set
Noteabl
eData
'
,
noteabl
eDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
vm
=
new
Component
({
...
...
spec/javascripts/notes/components/issue_note_form_spec.js
View file @
c6fa5e69
import
Vue
from
'
vue
'
;
import
store
from
'
~/notes/stores
'
;
import
issueNoteForm
from
'
~/notes/components/issue_note_form.vue
'
;
import
{
issu
eDataMock
,
notesDataMock
}
from
'
../mock_data
'
;
import
{
noteabl
eDataMock
,
notesDataMock
}
from
'
../mock_data
'
;
import
{
keyboardDownEvent
}
from
'
../../issue_show/helpers
'
;
describe
(
'
issue_note_form component
'
,
()
=>
{
...
...
@@ -11,7 +11,7 @@ describe('issue_note_form component', () => {
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
issueNoteForm
);
store
.
dispatch
(
'
set
Issu
eData
'
,
issu
eDataMock
);
store
.
dispatch
(
'
set
Noteabl
eData
'
,
noteabl
eDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
props
=
{
...
...
spec/javascripts/notes/components/issue_note_spec.js
View file @
c6fa5e69
...
...
@@ -2,7 +2,7 @@
import
Vue
from
'
vue
'
;
import
store
from
'
~/notes/stores
'
;
import
issueNote
from
'
~/notes/components/issue_note.vue
'
;
import
{
issu
eDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
import
{
noteabl
eDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
describe
(
'
issue_note
'
,
()
=>
{
let
vm
;
...
...
@@ -10,7 +10,7 @@ describe('issue_note', () => {
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
issueNote
);
store
.
dispatch
(
'
set
Issu
eData
'
,
issu
eDataMock
);
store
.
dispatch
(
'
set
Noteabl
eData
'
,
noteabl
eDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
vm
=
new
Component
({
...
...
Prev
1
2
Next
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