Commit edd86ebc authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Clement Ho

Apply suggestion to...

Apply suggestion to changelogs/unreleased/65764-add-missing-error-handling-to-add-list-dropdown-in-issue-boards.yml
parent 744cb32e
/* eslint-disable func-names, no-new, promise/catch-or-return */ /* eslint-disable func-names, no-new */
import $ from 'jquery'; import $ from 'jquery';
import { __ } from '~/locale';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import flash from '~/flash';
import CreateLabelDropdown from '../../create_label'; import CreateLabelDropdown from '../../create_label';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
...@@ -26,17 +28,22 @@ $(document) ...@@ -26,17 +28,22 @@ $(document)
export default function initNewListDropdown() { export default function initNewListDropdown() {
$('.js-new-board-list').each(function() { $('.js-new-board-list').each(function() {
const $this = $(this); const $dropdownToggle = $(this);
const $dropdown = $dropdownToggle.closest('.dropdown');
new CreateLabelDropdown( new CreateLabelDropdown(
$this.closest('.dropdown').find('.dropdown-new-label'), $dropdown.find('.dropdown-new-label'),
$this.data('namespacePath'), $dropdownToggle.data('namespacePath'),
$this.data('projectPath'), $dropdownToggle.data('projectPath'),
); );
$this.glDropdown({ $dropdownToggle.glDropdown({
data(term, callback) { data(term, callback) {
axios.get($this.attr('data-list-labels-path')).then(({ data }) => { axios
callback(data); .get($dropdownToggle.attr('data-list-labels-path'))
.then(({ data }) => callback(data))
.catch(() => {
$dropdownToggle.data('bs.dropdown').hide();
flash(__('Error fetching labels.'));
}); });
}, },
renderRow(label) { renderRow(label) {
......
---
title: Adds missing error handling
merge_request: 16896
author: toptalo
type: fixed
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