12519: Updated search box placeholder message
[arvados.git] / apps / workbench / app / assets / javascripts / components / collections.js
index 33fca6c7b770bf35354244e1d783de77c571cb80..b1233d0ce8f0b5fc6b8e365365eb0ec7d4cc6669 100644 (file)
@@ -48,14 +48,11 @@ 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,
-                                }, 'Show'),
+                                    title: 'Show '+item.objectType.description,
+                                    href: item.workbenchBaseURL()+'/'+item.objectType.wb_path+'/'+item.uuid,
+                                }, item.objectType.label),
                         ]),
                         m('td.arvados-uuid', item.uuid),
                         m('td', item.name || '(unnamed)'),
@@ -98,26 +95,57 @@ window.CollectionsSearch = {
             vnode.state.loader = new MergingLoader({
                 children: Object.keys(sessions).map(function(key) {
                     var session = sessions[key]
-                    return new MultipageLoader({
+                    var workbenchBaseURL = function() {
+                        return vnode.state.sessionDB.workbenchBaseURL(session)
+                    }
+                    var searchable_objects = [
+                        {
+                            wb_path: 'groups',
+                            api_path: 'arvados/v1/groups',
+                            filters: [['group_class', '=', 'project']],
+                            label: 'P',
+                            description: 'Project',
+                        },
+                        {
+                            wb_path: 'collections',
+                            api_path: 'arvados/v1/collections',
+                            filters: [],
+                            label: 'C',
+                            description: 'Collection',
+                        },
+                    ]
+                    return new MergingLoader({
                         sessionKey: key,
-                        loadFunc: function(filters) {
-                            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),
-                                    count: 'none',
+                        // For every session, search for every object type
+                        children: searchable_objects.map(function(obj_type){
+                            return new MultipageLoader({
+                                sessionKey: key,
+                                objectKind: obj_type.label,
+                                loadFunc: function(filters) {
+                                    var tsquery = to_tsquery(q)
+                                    if (tsquery) {
+                                        filters = filters.slice(0)
+                                        filters.push(['any', '@@', tsquery])
+                                    }
+                                    // Apply additional type dependant filters, if any.
+                                    for (var f of obj_type.filters) {
+                                        filters.push(f)
+                                    }
+                                    return vnode.state.sessionDB.request(session, obj_type.api_path, {
+                                        data: {
+                                            filters: JSON.stringify(filters),
+                                            count: 'none',
+                                        },
+                                    }).then(function(resp) {
+                                        resp.items.map(function(item) {
+                                            item.workbenchBaseURL = workbenchBaseURL
+                                            item.objectType = obj_type
+                                        })
+                                        return resp
+                                    })
                                 },
-                            }).then(function(resp) {
-                                resp.items.map(function(item) {
-                                    item.session = session
-                                })
-                                return resp
                             })
-                        },
+                        })
                     })
                 })
             })
@@ -142,7 +170,7 @@ window.CollectionsSearch = {
                 m('.row', [
                     m('.col-md-6', [
                         m('.input-group', [
-                            m('input#search.form-control[placeholder=Search]', {
+                            m('input#search.form-control[placeholder=Search collections and projects]', {
                                 oninput: m.withAttr('value', vnode.state.searchEntered),
                                 value: vnode.state.searchEntered(),
                             }),