+export const SearchResultsPanelView = withStyles(styles, { withTheme: true })(
+ (props: SearchResultsPanelProps & WithStyles<CssRules, true>) => {
+ const homeCluster = props.user.uuid.substring(0, 5);
+ const loggedIn = props.sessions.filter((ss) => ss.loggedIn && ss.userIsActive);
+ const [selectedItem, setSelectedItem] = useState('');
+ const [itemPath, setItemPath] = useState<string[]>([]);
+
+ useEffect(() => {
+ let tmpPath: string[] = [];
+
+ (async () => {
+ if (selectedItem !== '') {
+ let searchUuid = selectedItem;
+ let itemKind = extractUuidKind(searchUuid);
+
+ while (itemKind !== ResourceKind.USER) {
+ 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, session);
+ tmpPath.push(name);
+ searchUuid = ownerUuid;
+ itemKind = extractUuidKind(searchUuid);
+ } else {
+ break;
+ }
+ }
+
+ tmpPath.push(props.user.uuid === searchUuid ? 'Projects' : 'Shared with me');
+ setItemPath(tmpPath);
+ }
+ })();
+
+ // 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' 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>
+ {loggedIn.length === 1 ?
+ <span>Searching local cluster <ResourceCluster uuid={props.localCluster} /></span>
+ : <span>Searching clusters: {loggedIn.map((ss) => <span key={ss.clusterId}>
+ <a href={props.remoteHostsConfig[ss.clusterId] && props.remoteHostsConfig[ss.clusterId].workbench2Url} style={{ textDecoration: 'none' }}> <ResourceCluster uuid={ss.clusterId} /></a>
+ </span>)}</span>}
+ {loggedIn.length === 1 && props.localCluster !== homeCluster ?
+ <span>To search multiple clusters, <a href={props.remoteHostsConfig[homeCluster] && props.remoteHostsConfig[homeCluster].workbench2Url}> start from your home Workbench.</a></span>
+ : <span style={{ marginLeft: "2em" }}>Use <Link to={Routes.SITE_MANAGER} >Site Manager</Link> to manage which clusters will be searched.</span>}
+ </div >
+ }
+ /></span>;
+ });