Commit a4618662 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'ce-backport-5605-epic-autocomplete' into 'master'

CE Backport: Add support for autocompleting Epics within Issues & MRs and Labels within Epics

See merge request gitlab-org/gitlab-ce!20238
parents e7a5a315 aac6b2b7
...@@ -12,7 +12,7 @@ export const defaultAutocompleteConfig = { ...@@ -12,7 +12,7 @@ export const defaultAutocompleteConfig = {
members: true, members: true,
issues: true, issues: true,
mergeRequests: true, mergeRequests: true,
epics: false, epics: true,
milestones: true, milestones: true,
labels: true, labels: true,
}; };
...@@ -493,6 +493,7 @@ GfmAutoComplete.atTypeMap = { ...@@ -493,6 +493,7 @@ GfmAutoComplete.atTypeMap = {
'@': 'members', '@': 'members',
'#': 'issues', '#': 'issues',
'!': 'mergeRequests', '!': 'mergeRequests',
'&': 'epics',
'~': 'labels', '~': 'labels',
'%': 'milestones', '%': 'milestones',
'/': 'commands', '/': 'commands',
......
...@@ -9,6 +9,13 @@ export default class GLForm { ...@@ -9,6 +9,13 @@ export default class GLForm {
this.form = form; this.form = form;
this.textarea = this.form.find('textarea.js-gfm-input'); this.textarea = this.form.find('textarea.js-gfm-input');
this.enableGFM = Object.assign({}, GFMConfig.defaultAutocompleteConfig, enableGFM); this.enableGFM = Object.assign({}, GFMConfig.defaultAutocompleteConfig, enableGFM);
// Disable autocomplete for keywords which do not have dataSources available
const dataSources = (gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources) || {};
Object.keys(this.enableGFM).forEach(item => {
if (item !== 'emojis') {
this.enableGFM[item] = !!dataSources[item];
}
});
// Before we start, we should clean up any previous data for this form // Before we start, we should clean up any previous data for this form
this.destroy(); this.destroy();
// Setup the form // Setup the form
......
...@@ -8,6 +8,7 @@ export default () => { ...@@ -8,6 +8,7 @@ export default () => {
members: false, members: false,
issues: false, issues: false,
mergeRequests: false, mergeRequests: false,
epics: false,
milestones: false, milestones: false,
labels: false, labels: false,
}); });
......
...@@ -8,10 +8,11 @@ export default (initGFM = true) => { ...@@ -8,10 +8,11 @@ export default (initGFM = true) => {
new DueDateSelectors(); // eslint-disable-line no-new new DueDateSelectors(); // eslint-disable-line no-new
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new GLForm($('.milestone-form'), { new GLForm($('.milestone-form'), {
emojis: initGFM, emojis: true,
members: initGFM, members: initGFM,
issues: initGFM, issues: initGFM,
mergeRequests: initGFM, mergeRequests: initGFM,
epics: initGFM,
milestones: initGFM, milestones: initGFM,
labels: initGFM, labels: initGFM,
}); });
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
members: this.enableAutocomplete, members: this.enableAutocomplete,
issues: this.enableAutocomplete, issues: this.enableAutocomplete,
mergeRequests: this.enableAutocomplete, mergeRequests: this.enableAutocomplete,
epics: this.enableAutocomplete,
milestones: this.enableAutocomplete, milestones: this.enableAutocomplete,
labels: this.enableAutocomplete, labels: this.enableAutocomplete,
}); });
......
...@@ -148,6 +148,7 @@ module NotesHelper ...@@ -148,6 +148,7 @@ module NotesHelper
members: autocomplete, members: autocomplete,
issues: autocomplete, issues: autocomplete,
mergeRequests: autocomplete, mergeRequests: autocomplete,
epics: autocomplete,
milestones: autocomplete, milestones: autocomplete,
labels: autocomplete labels: autocomplete
} }
......
...@@ -9,9 +9,9 @@ feature 'Creating a new project milestone', :js do ...@@ -9,9 +9,9 @@ feature 'Creating a new project milestone', :js do
visit new_project_milestone_path(project) visit new_project_milestone_path(project)
end end
it 'description has autocomplete' do it 'description has emoji autocomplete' do
find('#milestone_description').native.send_keys('') find('#milestone_description').native.send_keys('')
fill_in 'milestone_description', with: '@' fill_in 'milestone_description', with: ':'
expect(page).to have_selector('.atwho-view') expect(page).to have_selector('.atwho-view')
end end
......
...@@ -242,7 +242,7 @@ describe "User creates wiki page" do ...@@ -242,7 +242,7 @@ describe "User creates wiki page" do
end end
end end
it "shows the autocompletion dropdown" do it "shows the emoji autocompletion dropdown" do
click_link("New page") click_link("New page")
page.within("#modal-new-wiki") do page.within("#modal-new-wiki") do
...@@ -254,7 +254,7 @@ describe "User creates wiki page" do ...@@ -254,7 +254,7 @@ describe "User creates wiki page" do
page.within(".wiki-form") do page.within(".wiki-form") do
find("#wiki_content").native.send_keys("") find("#wiki_content").native.send_keys("")
fill_in(:wiki_content, with: "@") fill_in(:wiki_content, with: ":")
end end
expect(page).to have_selector(".atwho-view") expect(page).to have_selector(".atwho-view")
......
...@@ -96,11 +96,11 @@ describe 'User updates wiki page' do ...@@ -96,11 +96,11 @@ describe 'User updates wiki page' do
expect(find('textarea#wiki_content').value).to eq('') expect(find('textarea#wiki_content').value).to eq('')
end end
it 'shows the autocompletion dropdown', :js do it 'shows the emoji autocompletion dropdown', :js do
click_link('Edit') click_link('Edit')
find('#wiki_content').native.send_keys('') find('#wiki_content').native.send_keys('')
fill_in(:wiki_content, with: '@') fill_in(:wiki_content, with: ':')
expect(page).to have_selector('.atwho-view') expect(page).to have_selector('.atwho-view')
end end
......
...@@ -75,9 +75,9 @@ feature 'Master creates tag' do ...@@ -75,9 +75,9 @@ feature 'Master creates tag' do
visit new_project_tag_path(project) visit new_project_tag_path(project)
end end
it 'description has autocomplete', :js do it 'description has emoji autocomplete', :js do
find('#release_description').native.send_keys('') find('#release_description').native.send_keys('')
fill_in 'release_description', with: '@' fill_in 'release_description', with: ':'
expect(page).to have_selector('.atwho-view') expect(page).to have_selector('.atwho-view')
end end
......
...@@ -25,13 +25,13 @@ feature 'Master updates tag' do ...@@ -25,13 +25,13 @@ feature 'Master updates tag' do
expect(page).to have_content 'Awesome release notes' expect(page).to have_content 'Awesome release notes'
end end
scenario 'description has autocomplete', :js do scenario 'description has emoji autocomplete', :js do
page.within(first('.content-list .controls')) do page.within(first('.content-list .controls')) do
click_link 'Edit release notes' click_link 'Edit release notes'
end end
find('#release_description').native.send_keys('') find('#release_description').native.send_keys('')
fill_in 'release_description', with: '@' fill_in 'release_description', with: ':'
expect(page).to have_selector('.atwho-view') expect(page).to have_selector('.atwho-view')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment