12515: Use workbenchUrl advertised by API server discovery doc.
[arvados.git] / apps / workbench / app / assets / javascripts / components / collections.js
index a2054c1a03673cebcdef0b4f549e4c9ae8a74f31..591bf38aa74b162e353c9705da1ecbcbba2d8cde 100644 (file)
@@ -47,7 +47,12 @@ window.CollectionsTable = {
             m('tbody', [
                 loader.items().map(function(item) {
                     return m('tr', [
-                        m('td', m('a.btn.btn-xs.btn-default', {href: item.session.baseURL.replace('://', '://workbench.')+'collections/'+item.uuid}, 'Show')),
+                        m('td', [
+                            item.workbenchBaseURL() &&
+                                m('a.btn.btn-xs.btn-default', {
+                                    href: item.workbenchBaseURL()+'collections/'+item.uuid,
+                                }, 'Show'),
+                        ]),
                         m('td.arvados-uuid', item.uuid),
                         m('td', item.name || '(unnamed)'),
                         m('td', m(LocalizedDateTime, {parse: item.modified_at})),
@@ -89,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),
@@ -101,7 +112,7 @@ window.CollectionsSearch = {
                                 },
                             }).then(function(resp) {
                                 resp.items.map(function(item) {
-                                    item.session = session
+                                    item.workbenchBaseURL = workbenchBaseURL
                                 })
                                 return resp
                             })
@@ -116,14 +127,14 @@ window.CollectionsSearch = {
         return m('form', {
             onsubmit: function() {
                 vnode.state.searchActive(vnode.state.searchEntered())
-                vnode.state.forgetSavedState = true
+                vnode.state.forgetSavedHeight = true
                 return false
             },
         }, [
             m(SaveUIState, {
                 defaultState: '',
                 currentState: vnode.state.searchActive,
-                forgetSavedState: vnode.state.forgetSavedState,
+                forgetSavedHeight: vnode.state.forgetSavedHeight,
                 saveBodyHeight: true,
             }),
             vnode.state.loader && [