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
53def4e2
Commit
53def4e2
authored
Aug 29, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding new threads to MR page
parent
6f46b274
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
51 deletions
+70
-51
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
...javascripts/diffs/components/diff_line_gutter_content.vue
+1
-1
app/assets/javascripts/diffs/components/diff_line_note_form.vue
...sets/javascripts/diffs/components/diff_line_note_form.vue
+9
-2
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+2
-1
app/assets/javascripts/diffs/store/mutations.js
app/assets/javascripts/diffs/store/mutations.js
+0
-1
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+36
-25
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+2
-15
app/assets/javascripts/notes/stores/utils.js
app/assets/javascripts/notes/stores/utils.js
+20
-6
No files found.
app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
View file @
53def4e2
...
...
@@ -105,7 +105,7 @@ export default {
methods
:
{
...
mapActions
(
'
diffs
'
,
[
'
loadMoreLines
'
,
'
showCommentForm
'
]),
handleCommentButton
()
{
this
.
showCommentForm
({
lineCode
:
this
.
line
.
c
ode
});
this
.
showCommentForm
({
lineCode
:
this
.
line
.
lineC
ode
});
},
handleLoadMoreLines
()
{
if
(
this
.
isRequesting
)
{
...
...
app/assets/javascripts/diffs/components/diff_line_note_form.vue
View file @
53def4e2
...
...
@@ -6,6 +6,7 @@ import noteForm from '../../notes/components/note_form.vue';
import
{
getNoteFormData
}
from
'
../store/utils
'
;
import
autosave
from
'
../../notes/mixins/autosave
'
;
import
{
DIFF_NOTE_TYPE
}
from
'
../constants
'
;
import
*
as
utils
from
'
../../notes/stores/utils
'
;
export
default
{
components
:
{
...
...
@@ -52,7 +53,7 @@ export default {
}
},
methods
:
{
...
mapActions
(
'
diffs
'
,
[
'
cancelCommentForm
'
]),
...
mapActions
(
'
diffs
'
,
[
'
cancelCommentForm
'
,
'
assignDiscussionsToDiff
'
]),
...
mapActions
([
'
saveNote
'
,
'
refetchDiscussionById
'
]),
handleCancelCommentForm
(
shouldConfirm
,
isDirty
)
{
if
(
shouldConfirm
&&
isDirty
)
{
...
...
@@ -88,7 +89,13 @@ export default {
const
endpoint
=
this
.
getNotesDataByProp
(
'
discussionsPath
'
);
this
.
refetchDiscussionById
({
path
:
endpoint
,
discussionId
:
result
.
discussion_id
})
.
then
(()
=>
{
.
then
(
selectedDiscussion
=>
{
//debugger;
console
.
log
(
'
SEL DISCUSSION:
'
,
selectedDiscussion
);
const
lineCodeDiscussions
=
utils
.
reduceDiscussionsToLineCodes
([
selectedDiscussion
]);
console
.
log
(
'
LINE CODE DISCUSSIONS:
'
,
lineCodeDiscussions
);
this
.
assignDiscussionsToDiff
(
lineCodeDiscussions
);
this
.
handleCancelCommentForm
();
})
.
catch
(()
=>
{
...
...
app/assets/javascripts/diffs/store/actions.js
View file @
53def4e2
...
...
@@ -29,7 +29,8 @@ export const fetchDiffFiles = ({ state, commit }) => {
.
then
(
handleLocationHash
);
};
export
const
assignDiscussionsToDiff
=
({
state
,
commit
},
allLineDiscussions
)
=>
{
export
const
assignDiscussionsToDiff
=
({
state
},
allLineDiscussions
)
=>
{
console
.
log
(
'
ASSIGN DISCS :
'
);
console
.
log
(
'
DIFF :
'
,
state
.
diffFiles
);
console
.
log
(
'
STATE :
'
,
allLineDiscussions
);
...
...
app/assets/javascripts/diffs/store/mutations.js
View file @
53def4e2
...
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
import
_
from
'
underscore
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
findDiffFile
,
addLineReferences
,
removeMatchLine
,
addContextLines
}
from
'
./utils
'
;
import
{
LINES_TO_BE_RENDERED_DIRECTLY
,
MAX_LINES_TO_BE_RENDERED
}
from
'
../constants
'
;
import
{
trimFirstCharOfLineContent
}
from
'
../store/utils
'
;
import
{
LINES_TO_BE_RENDERED_DIRECTLY
,
MAX_LINES_TO_BE_RENDERED
}
from
'
../constants
'
;
import
*
as
types
from
'
./mutation_types
'
;
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
53def4e2
...
...
@@ -43,14 +43,21 @@ export const fetchDiscussions = ({ commit }, path) =>
commit
(
types
.
SET_INITIAL_DISCUSSIONS
,
discussions
);
});
export
const
refetchDiscussionById
=
({
commit
},
{
path
,
discussionId
})
=>
service
.
fetchDiscussions
(
path
)
.
then
(
res
=>
res
.
json
())
.
then
(
discussions
=>
{
const
selectedDiscussion
=
discussions
.
find
(
discussion
=>
discussion
.
id
===
discussionId
);
if
(
selectedDiscussion
)
commit
(
types
.
UPDATE_DISCUSSION
,
selectedDiscussion
);
});
export
const
refetchDiscussionById
=
({
commit
},
{
path
,
discussionId
})
=>
{
return
new
Promise
(
resolve
=>
{
service
.
fetchDiscussions
(
path
)
.
then
(
res
=>
res
.
json
())
.
then
(
discussions
=>
{
const
selectedDiscussion
=
discussions
.
find
(
discussion
=>
discussion
.
id
===
discussionId
);
if
(
selectedDiscussion
)
{
commit
(
types
.
UPDATE_DISCUSSION
,
selectedDiscussion
);
resolve
(
selectedDiscussion
);
}
})
.
catch
(()
=>
{});
});
};
export
const
deleteNote
=
({
commit
},
note
)
=>
service
.
deleteNote
(
note
.
path
).
then
(()
=>
{
...
...
@@ -152,26 +159,28 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
const
replyId
=
noteData
.
data
.
in_reply_to_discussion_id
;
const
methodToDispatch
=
replyId
?
'
replyToDiscussion
'
:
'
createNewNote
'
;
commit
(
types
.
REMOVE_PLACEHOLDER_NOTES
);
// remove previous placeholders
$
(
'
.notes-form .flash-container
'
).
hide
();
// hide previous flash notification
commit
(
types
.
REMOVE_PLACEHOLDER_NOTES
);
// remove previous placeholders
if
(
hasQuickActions
)
{
placeholderText
=
utils
.
stripQuickActions
(
placeholderText
);
}
if
(
replyId
)
{
if
(
hasQuickActions
)
{
placeholderText
=
utils
.
stripQuickActions
(
placeholderText
);
}
if
(
placeholderText
.
length
)
{
commit
(
types
.
SHOW_PLACEHOLDER_NOTE
,
{
noteBody
:
placeholderText
,
replyId
,
});
}
if
(
placeholderText
.
length
)
{
commit
(
types
.
SHOW_PLACEHOLDER_NOTE
,
{
noteBody
:
placeholderText
,
replyId
,
});
}
if
(
hasQuickActions
)
{
commit
(
types
.
SHOW_PLACEHOLDER_NOTE
,
{
isSystemNote
:
true
,
noteBody
:
utils
.
getQuickActionText
(
note
),
replyId
,
});
if
(
hasQuickActions
)
{
commit
(
types
.
SHOW_PLACEHOLDER_NOTE
,
{
isSystemNote
:
true
,
noteBody
:
utils
.
getQuickActionText
(
note
),
replyId
,
});
}
}
return
dispatch
(
methodToDispatch
,
noteData
).
then
(
res
=>
{
...
...
@@ -211,7 +220,9 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
if
(
errors
&&
errors
.
commands_only
)
{
Flash
(
errors
.
commands_only
,
'
notice
'
,
noteData
.
flashContainer
);
}
commit
(
types
.
REMOVE_PLACEHOLDER_NOTES
);
if
(
replyId
)
{
commit
(
types
.
REMOVE_PLACEHOLDER_NOTES
);
}
return
res
;
});
...
...
app/assets/javascripts/notes/stores/getters.js
View file @
53def4e2
import
_
from
'
underscore
'
;
import
*
as
constants
from
'
../constants
'
;
import
{
reduceDiscussionsToLineCodes
}
from
'
./utils
'
;
import
{
collapseSystemNotes
}
from
'
./collapse_utils
'
;
export
const
discussions
=
state
=>
collapseSystemNotes
(
state
.
discussions
);
...
...
@@ -29,21 +30,7 @@ export const notesById = state =>
},
{});
export
const
discussionsStructuredByLineCode
=
state
=>
state
.
discussions
.
reduce
((
acc
,
note
)
=>
{
if
(
note
.
diff_discussion
&&
note
.
line_code
&&
note
.
resolvable
)
{
// For context about line notes: there might be multiple notes with the same line code
const
items
=
acc
[
note
.
line_code
]
||
[];
if
(
note
.
diff_file
)
{
Object
.
assign
(
note
,
{
fileHash
:
note
.
diff_file
.
file_hash
});
// delete note.diff_file;
}
items
.
push
(
note
);
Object
.
assign
(
acc
,
{
[
note
.
line_code
]:
items
});
}
return
acc
;
},
{});
reduceDiscussionsToLineCodes
(
state
.
discussions
);
export
const
noteableType
=
state
=>
{
const
{
ISSUE_NOTEABLE_TYPE
,
MERGE_REQUEST_NOTEABLE_TYPE
,
EPIC_NOTEABLE_TYPE
}
=
constants
;
...
...
app/assets/javascripts/notes/stores/utils.js
View file @
53def4e2
...
...
@@ -2,13 +2,11 @@ import AjaxCache from '~/lib/utils/ajax_cache';
const
REGEX_QUICK_ACTIONS
=
/^
\/\w
+.*$/gm
;
export
const
findNoteObjectById
=
(
notes
,
id
)
=>
notes
.
filter
(
n
=>
n
.
id
===
id
)[
0
];
export
const
findNoteObjectById
=
(
notes
,
id
)
=>
notes
.
filter
(
n
=>
n
.
id
===
id
)[
0
];
export
const
getQuickActionText
=
note
=>
{
let
text
=
'
Applying command
'
;
const
quickActions
=
AjaxCache
.
get
(
gl
.
GfmAutoComplete
.
dataSources
.
commands
)
||
[];
const
quickActions
=
AjaxCache
.
get
(
gl
.
GfmAutoComplete
.
dataSources
.
commands
)
||
[];
const
executedCommands
=
quickActions
.
filter
(
command
=>
{
const
commandRegex
=
new
RegExp
(
`/
${
command
.
name
}
`
);
...
...
@@ -27,7 +25,23 @@ export const getQuickActionText = note => {
return
text
;
};
export
const
reduceDiscussionsToLineCodes
=
selectedDiscussions
=>
selectedDiscussions
.
reduce
((
acc
,
note
)
=>
{
if
(
note
.
diff_discussion
&&
note
.
line_code
&&
note
.
resolvable
)
{
// For context about line notes: there might be multiple notes with the same line code
const
items
=
acc
[
note
.
line_code
]
||
[];
if
(
note
.
diff_file
)
{
Object
.
assign
(
note
,
{
fileHash
:
note
.
diff_file
.
file_hash
});
// delete note.diff_file;
}
items
.
push
(
note
);
Object
.
assign
(
acc
,
{
[
note
.
line_code
]:
items
});
}
return
acc
;
},
{});
export
const
hasQuickActions
=
note
=>
REGEX_QUICK_ACTIONS
.
test
(
note
);
export
const
stripQuickActions
=
note
=>
note
.
replace
(
REGEX_QUICK_ACTIONS
,
''
).
trim
();
export
const
stripQuickActions
=
note
=>
note
.
replace
(
REGEX_QUICK_ACTIONS
,
''
).
trim
();
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