From 2f4bdefc725728473fa339a79c8813e6015a4667 Mon Sep 17 00:00:00 2001
From: Alfredo Sumaran <alfredo@gitlab.com>
Date: Fri, 11 Mar 2016 13:18:38 -0500
Subject: [PATCH] Allow to pass non-asynchronous data to GitLabDropdown

---
 app/assets/javascripts/gl_dropdown.js.coffee | 27 +++++++++++++-------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/app/assets/javascripts/gl_dropdown.js.coffee b/app/assets/javascripts/gl_dropdown.js.coffee
index 4f038477755..e763ca5c780 100644
--- a/app/assets/javascripts/gl_dropdown.js.coffee
+++ b/app/assets/javascripts/gl_dropdown.js.coffee
@@ -83,15 +83,19 @@ class GitLabDropdown
     search_fields = if @options.search then @options.search.fields else [];
 
     if @options.data
-      # Remote data
-      @remote = new GitLabDropdownRemote @options.data, {
-        dataType: @options.dataType,
-        beforeSend: @toggleLoading.bind(@)
-        success: (data) =>
-          @fullData = data
+      # If data is an array
+      if _.isArray @options.data
+        @parseData @options.data
+      else
+        # Remote data
+        @remote = new GitLabDropdownRemote @options.data, {
+          dataType: @options.dataType,
+          beforeSend: @toggleLoading.bind(@)
+          success: (data) =>
+            @fullData = data
 
-          @parseData @fullData
-      }
+            @parseData @fullData
+        }
 
     # Init filiterable
     if @options.filterable
@@ -204,7 +208,12 @@ class GitLabDropdown
     else
       selected = if @options.isSelected then @options.isSelected(data) else false
       url = if @options.url then @options.url(data) else "#"
-      text = if @options.text then @options.text(data) else ""
+
+      if @options.text?
+        text = @options.text(data)
+      else
+        text = data.text if data.text?
+
       cssClass = "";
 
       if selected
-- 
GitLab