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
211c946a
Commit
211c946a
authored
Jan 10, 2019
by
Constance Okoghenun
Committed by
Phil Hughes
Jan 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Discussion filters - ensured note links resolves to the right note
parent
be855cc6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
7 deletions
+67
-7
app/assets/javascripts/notes/components/discussion_filter.vue
...assets/javascripts/notes/components/discussion_filter.vue
+21
-2
changelogs/unreleased/54484-anchor-links-to-comments-or-system-notes-can-break-with-discussion-filters.yml
...nts-or-system-notes-can-break-with-discussion-filters.yml
+5
-0
spec/javascripts/notes/components/discussion_filter_spec.js
spec/javascripts/notes/components/discussion_filter_spec.js
+41
-5
No files found.
app/assets/javascripts/notes/components/discussion_filter.vue
View file @
211c946a
<
script
>
import
$
from
'
jquery
'
;
import
{
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
{
getLocationHash
}
from
'
../../lib/utils/url_utility
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
{
DISCUSSION_FILTERS_DEFAULT_VALUE
,
...
...
@@ -44,29 +45,47 @@ export default {
eventHub
.
$on
(
'
MergeRequestTabChange
'
,
this
.
toggleFilters
);
this
.
toggleFilters
(
currentTab
);
}
window
.
addEventListener
(
'
hashchange
'
,
this
.
handleLocationHash
);
this
.
handleLocationHash
();
},
mounted
()
{
this
.
toggleCommentsForm
();
},
destroyed
()
{
window
.
removeEventListener
(
'
hashchange
'
,
this
.
handleLocationHash
);
},
methods
:
{
...
mapActions
([
'
filterDiscussion
'
,
'
setCommentsDisabled
'
]),
...
mapActions
([
'
filterDiscussion
'
,
'
setCommentsDisabled
'
,
'
setTargetNoteHash
'
]),
selectFilter
(
value
)
{
const
filter
=
parseInt
(
value
,
10
);
// close dropdown
$
(
this
.
$refs
.
dropdownToggle
).
dropdown
(
'
toggle
'
);
this
.
toggleDropdown
(
);
if
(
filter
===
this
.
currentValue
)
return
;
this
.
currentValue
=
filter
;
this
.
filterDiscussion
({
path
:
this
.
getNotesDataByProp
(
'
discussionsPath
'
),
filter
});
this
.
toggleCommentsForm
();
},
toggleDropdown
()
{
$
(
this
.
$refs
.
dropdownToggle
).
dropdown
(
'
toggle
'
);
},
toggleCommentsForm
()
{
this
.
setCommentsDisabled
(
this
.
currentValue
===
HISTORY_ONLY_FILTER_VALUE
);
},
toggleFilters
(
tab
)
{
this
.
displayFilters
=
tab
===
DISCUSSION_TAB_LABEL
;
},
handleLocationHash
()
{
const
hash
=
getLocationHash
();
if
(
/^note_/
.
test
(
hash
)
&&
this
.
currentValue
!==
DISCUSSION_FILTERS_DEFAULT_VALUE
)
{
this
.
selectFilter
(
this
.
defaultValue
);
this
.
toggleDropdown
();
// close dropdown
this
.
setTargetNoteHash
(
hash
);
}
},
},
};
</
script
>
...
...
changelogs/unreleased/54484-anchor-links-to-comments-or-system-notes-can-break-with-discussion-filters.yml
0 → 100644
View file @
211c946a
---
title
:
Ensured links to a comment or system note anchor resolves to the right note if a user has a discussion filter.
merge_request
:
24228
author
:
type
:
changed
spec/javascripts/notes/components/discussion_filter_spec.js
View file @
211c946a
import
Vue
from
'
vue
'
;
import
createStore
from
'
~/notes/stores
'
;
import
DiscussionFilter
from
'
~/notes/components/discussion_filter.vue
'
;
import
{
DISCUSSION_FILTERS_DEFAULT_VALUE
}
from
'
~/notes/constants
'
;
import
{
mountComponentWithStore
}
from
'
../../helpers/vue_mount_component_helper
'
;
import
{
discussionFiltersMock
,
discussionMock
}
from
'
../mock_data
'
;
...
...
@@ -20,16 +21,14 @@ describe('DiscussionFilter component', () => {
},
];
const
Component
=
Vue
.
extend
(
DiscussionFilter
);
const
selectedValue
=
discussionFiltersMock
[
0
].
value
;
const
selectedValue
=
DISCUSSION_FILTERS_DEFAULT_VALUE
;
const
props
=
{
filters
:
discussionFiltersMock
,
selectedValue
};
store
.
state
.
discussions
=
discussions
;
return
mountComponentWithStore
(
Component
,
{
el
:
null
,
store
,
props
:
{
filters
:
discussionFiltersMock
,
selectedValue
,
},
props
,
});
};
...
...
@@ -115,4 +114,41 @@ describe('DiscussionFilter component', () => {
});
});
});
describe
(
'
URL with Links to notes
'
,
()
=>
{
afterEach
(()
=>
{
window
.
location
.
hash
=
''
;
});
it
(
'
updates the filter when the URL links to a note
'
,
done
=>
{
window
.
location
.
hash
=
`note_
${
discussionMock
.
notes
[
0
].
id
}
`
;
vm
.
currentValue
=
discussionFiltersMock
[
2
].
value
;
vm
.
handleLocationHash
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
currentValue
).
toEqual
(
DISCUSSION_FILTERS_DEFAULT_VALUE
);
done
();
});
});
it
(
'
does not update the filter when the current filter is "Show all activity"
'
,
done
=>
{
window
.
location
.
hash
=
`note_
${
discussionMock
.
notes
[
0
].
id
}
`
;
vm
.
handleLocationHash
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
currentValue
).
toEqual
(
DISCUSSION_FILTERS_DEFAULT_VALUE
);
done
();
});
});
it
(
'
only updates filter when the URL links to a note
'
,
done
=>
{
window
.
location
.
hash
=
`testing123`
;
vm
.
handleLocationHash
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
currentValue
).
toEqual
(
DISCUSSION_FILTERS_DEFAULT_VALUE
);
done
();
});
});
});
});
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