X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8c5bc6e7730ce5f689b03af434c0c482b33c6a58..0534b585de71147120e880fe670ebd0e61dcf68f:/src/views/search-results-panel/search-results-panel-view.tsx

diff --git a/src/views/search-results-panel/search-results-panel-view.tsx b/src/views/search-results-panel/search-results-panel-view.tsx
index 6febabf2eb..e281035c30 100644
--- a/src/views/search-results-panel/search-results-panel-view.tsx
+++ b/src/views/search-results-panel/search-results-panel-view.tsx
@@ -27,6 +27,8 @@ import { Routes } from 'routes/routes';
 import { Link } from 'react-router-dom';
 import { StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
 import { ArvadosTheme } from 'common/custom-theme';
+import { getSearchSessions } from 'store/search-bar/search-bar-actions';
+import { camelCase } from 'lodash';
 
 export enum SearchResultsPanelColumnNames {
     CLUSTER = "Cluster",
@@ -38,9 +40,12 @@ export enum SearchResultsPanelColumnNames {
     LAST_MODIFIED = "Last modified"
 }
 
-export type CssRules = 'siteManagerLink';
+export type CssRules = 'siteManagerLink' | 'searchResults';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    searchResults: {
+        width: '100%'
+    },
     siteManagerLink: {
         marginRight: theme.spacing.unit * 2,
         float: 'right'
@@ -110,43 +115,57 @@ export const SearchResultsPanelView = withStyles(styles, { withTheme: true })(
         const homeCluster = props.user.uuid.substring(0, 5);
         const loggedIn = props.sessions.filter((ss) => ss.loggedIn && ss.userIsActive);
         const [selectedItem, setSelectedItem] = useState('');
-        let itemPath: string[] = [];
+        const [itemPath, setItemPath] = useState<string[]>([]);
 
         useEffect(() => {
-            if (selectedItem !== '') {
-                itemPath = [];
+            let tmpPath: string[] = [];
 
-                (async () => {
+            (async () => {
+                if (selectedItem !== '') {
                     let searchUuid = selectedItem;
                     let itemKind = extractUuidKind(searchUuid);
 
                     while (itemKind !== ResourceKind.USER) {
-                        console.log(itemKind);
-                        const { name, ownerUuid } = await servicesProvider.getServices().groupsService.get(searchUuid);
-                        itemKind = extractUuidKind(ownerUuid);
-                        searchUuid = ownerUuid;
-                        itemPath.push(name);
+                        const clusterId = searchUuid.split('-')[0];
+                        const serviceType = camelCase(itemKind?.replace('arvados#', ''));
+                        const service = Object.values(servicesProvider.getServices())
+                            .filter(({resourceType}) => !!resourceType)
+                            .find(({resourceType}) => camelCase(resourceType).indexOf(serviceType) > -1);
+                        const sessions = getSearchSessions(clusterId, props.sessions);
+
+                        if (sessions.length > 0) {
+                            const session = sessions[0];
+                            const { name, ownerUuid } = await (service as any).get(searchUuid, false, undefined, session);
+                            tmpPath.push(name);
+                            searchUuid = ownerUuid;
+                            itemKind = extractUuidKind(searchUuid);
+                        } else {
+                            break;
+                        }
                     }
 
-                    const rootFolder = props.user.uuid === searchUuid ? 'Projects' : 'Shared with me';
-                    itemPath.push(rootFolder);
+                    tmpPath.push(props.user.uuid === searchUuid ? 'Projects' : 'Shared with me');
+                    setItemPath(tmpPath);
+                }
+            })();
 
-                    console.log(itemPath.reverse().join('/'));
-                })();
-            }
+        // eslint-disable-next-line react-hooks/exhaustive-deps
         }, [selectedItem]);
 
         const onItemClick = useCallback((uuid) => {
             setSelectedItem(uuid);
             props.onItemClick(uuid);
+        // eslint-disable-next-line react-hooks/exhaustive-deps
         },[props.onItemClick]);
 
-        return <span data-cy='search-results'><DataExplorer
+        return <span data-cy='search-results' className={props.classes.searchResults}>
+            <DataExplorer
             id={SEARCH_RESULTS_PANEL_ID}
             onRowClick={onItemClick}
             onRowDoubleClick={props.onItemDoubleClick}
             onContextMenu={props.onContextMenu}
             contextMenuColumn={false}
+            elementPath={`/ ${itemPath.reverse().join(' / ')}`}
             hideSearchInput
             title={
                 <div>
