12515: Use workbenchUrl advertised by API server discovery doc.
[arvados.git] / apps / workbench / app / assets / javascripts / components / collections.js
index 60228893d8c016dff6718905f604d1ae4f8528b5..591bf38aa74b162e353c9705da1ecbcbba2d8cde 100644 (file)
@@ -48,13 +48,9 @@ window.CollectionsTable = {
                 loader.items().map(function(item) {
                     return m('tr', [
                         m('td', [
-                            // Guess workbench.{apihostport} is a
-                            // Workbench... unless the host part of
-                            // apihostport is an IPv4 or [IPv6]
-                            // address.
-                            item.session.baseURL.match('://(\\[|\\d+\\.\\d+\\.\\d+\\.\\d+[:/])') ? null :
+                            item.workbenchBaseURL() &&
                                 m('a.btn.btn-xs.btn-default', {
-                                    href: item.session.baseURL.replace('://', '://workbench.')+'collections/'+item.uuid,
+                                    href: item.workbenchBaseURL()+'collections/'+item.uuid,
                                 }, 'Show'),
                         ]),
                         m('td.arvados-uuid', item.uuid),
@@ -98,11 +94,17 @@ window.CollectionsSearch = {
             vnode.state.loader = new MergingLoader({
                 children: Object.keys(sessions).map(function(key) {
                     var session = sessions[key]
+                    var workbenchBaseURL = function() {
+                        return vnode.state.sessionDB.workbenchBaseURL(session)
+                    }
                     return new MultipageLoader({
                         sessionKey: key,
                         loadFunc: function(filters) {
-                            if (q)
-                                filters.push(['any', '@@', q+':*'])
+                            var tsquery = to_tsquery(q)
+                            if (tsquery) {
+                                filters = filters.slice(0)
+                                filters.push(['any', '@@', tsquery])
+                            }
                             return vnode.state.sessionDB.request(session, 'arvados/v1/collections', {
                                 data: {
                                     filters: JSON.stringify(filters),
@@ -110,7 +112,7 @@ window.CollectionsSearch = {
                                 },
                             }).then(function(resp) {
                                 resp.items.map(function(item) {
-                                    item.session = session
+                                    item.workbenchBaseURL = workbenchBaseURL
                                 })
                                 return resp
                             })