[ARVADOS-WORKBENCH2] updated: 2.3.0-195-gc77d85e1

Git user git at public.arvados.org
Wed Mar 9 17:10:03 UTC 2022


Summary of changes:
 cypress/integration/search.spec.js                 | 23 ++++++++++++
 .../collection-service/collection-service.ts       | 12 ++++--
 src/services/common-service/common-service.ts      | 14 +++++--
 .../search-results-panel-view.tsx                  | 43 ++++++++++++++--------
 .../search-results-panel/search-results-panel.tsx  | 12 +++++-
 5 files changed, 82 insertions(+), 22 deletions(-)

       via  c77d85e1b722e2140736af692235ceed24952563 (commit)
       via  7ace628b611d7674e420262d9fc5e757e8c686a6 (commit)
      from  8c5bc6e7730ce5f689b03af434c0c482b33c6a58 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit c77d85e1b722e2140736af692235ceed24952563
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Wed Mar 9 18:08:51 2022 +0100

    18549: Cypress test added
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/cypress/integration/search.spec.js b/cypress/integration/search.spec.js
index 8806d12d..95e0bc95 100644
--- a/cypress/integration/search.spec.js
+++ b/cypress/integration/search.spec.js
@@ -81,4 +81,27 @@ describe('Search tests', function() {
             cy.get('[data-cy=search-results]').should('contain', 'version 1');
         });
     });
+
+    it('can search for old collection versions', function() {
+        const colName = `Collection ${Math.floor(Math.random() * Math.floor(999999))}`;
+
+        // Creates the collection using the admin token so we can set up
+        // a bogus manifest text without block signatures.
+        cy.createCollection(adminUser.token, {
+            name: colName,
+            owner_uuid: activeUser.user.uuid,
+            preserve_version: true,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+        }).then(function() {
+            cy.loginAs(activeUser);
+
+            cy.doSearch(colName);
+
+            cy.get('[data-cy=search-results]').should('contain', colName);
+
+            cy.get('[data-cy=search-results]').contains(colName).closest('tr').click();
+
+            cy.get('[data-cy=snackbar]').should('contain', `/ Projects / ${colName}`);
+        });
+    });
 });
\ No newline at end of file

commit 7ace628b611d7674e420262d9fc5e757e8c686a6
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Wed Mar 9 17:36:48 2022 +0100

    18549: New implementation with snackbar
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index b6272650..a3a7cf8f 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -13,6 +13,7 @@ import { ApiActions } from "services/api/api-actions";
 import { customEncodeURI } from "common/url";
 import { FilterBuilder } from "services/api/filter-builder";
 import { ListArguments } from "services/common-service/common-service";
+import { Session } from "models/session";
 
 export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
 
@@ -30,7 +31,7 @@ export class CollectionService extends TrashableResourceService<CollectionResour
         ]);
     }
 
-    async get(uuid: string, showErrors?: boolean, select?: string[]) {
+    async get(uuid: string, showErrors?: boolean, select?: string[], session?: Session) {
         super.validateUuid(uuid);
         // We use a filtered list request to avoid getting the manifest text
         const filters = new FilterBuilder().addEqual('uuid', uuid).getFilters();
@@ -38,8 +39,13 @@ export class CollectionService extends TrashableResourceService<CollectionResour
         if (select) {
             listArgs.select = select;
         }
-        const lst = await super.list(listArgs, showErrors);
-        return lst.items[0];
+
+        if (session) {
+            const lst = await super.list(listArgs, showErrors);
+            return lst.items[0];
+        } else {
+            return super.get(uuid, showErrors, session);
+        }
     }
 
     create(data?: Partial<CollectionResource>) {
diff --git a/src/services/common-service/common-service.ts b/src/services/common-service/common-service.ts
index f66fad74..ddaf2ab0 100644
--- a/src/services/common-service/common-service.ts
+++ b/src/services/common-service/common-service.ts
@@ -3,10 +3,11 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { camelCase, isPlainObject, isArray, snakeCase } from "lodash";
-import { AxiosInstance, AxiosPromise } from "axios";
+import { AxiosInstance, AxiosPromise, AxiosRequestConfig } from "axios";
 import uuid from "uuid/v4";
 import { ApiActions } from "services/api/api-actions";
 import QueryString from "query-string";
+import { Session } from "models/session";
 
 interface Errors {
     status: number;
@@ -113,11 +114,18 @@ export class CommonService<T> {
         );
     }
 
-    get(uuid: string, showErrors?: boolean) {
+    get(uuid: string, showErrors?: boolean, select?: string[], session?: Session) {
         this.validateUuid(uuid);
+
+        const cfg: AxiosRequestConfig = {};
+        if (session) {
+            cfg.baseURL = session.baseUrl;
+            cfg.headers = { 'Authorization': 'Bearer ' + session.token };
+        }
+
         return CommonService.defaultResponse(
             this.serverApi
-                .get<T>(`/${this.resourceType}/${uuid}`),
+                .get<T>(`/${this.resourceType}/${uuid}`, session ? cfg : undefined),
             this.actions,
             true, // mapKeys
             showErrors
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 6febabf2..fd420b83 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,7 @@ 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';
 
 export enum SearchResultsPanelColumnNames {
     CLUSTER = "Cluster",
@@ -110,38 +111,50 @@ 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[] = [];
 
         useEffect(() => {
-            if (selectedItem !== '') {
-                itemPath = [];
+            let itemPath: 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 = itemKind?.replace('arvados#', '');
+                        const service = Object.values(servicesProvider.getServices())
+                            .filter(({resourceType}) => !!resourceType)
+                            .find(({resourceType}) => 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);
+                            itemPath.push(name);
+                            searchUuid = ownerUuid;
+                            itemKind = extractUuidKind(searchUuid);
+                        } else {
+                            break;
+                        }
                     }
 
-                    const rootFolder = props.user.uuid === searchUuid ? 'Projects' : 'Shared with me';
-                    itemPath.push(rootFolder);
+                    itemPath.push(props.user.uuid === searchUuid ? 'Projects' : 'Shared with me');
+                    props.onPathDisplay(`/ ${itemPath.reverse().join(' / ')}`);
+                }
+            })();
 
-                    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'>
+            <DataExplorer
             id={SEARCH_RESULTS_PANEL_ID}
             onRowClick={onItemClick}
             onRowDoubleClick={props.onItemDoubleClick}
diff --git a/src/views/search-results-panel/search-results-panel.tsx b/src/views/search-results-panel/search-results-panel.tsx
index d25682f6..6d1d2bf5 100644
--- a/src/views/search-results-panel/search-results-panel.tsx
+++ b/src/views/search-results-panel/search-results-panel.tsx
@@ -14,6 +14,7 @@ import { SearchBarAdvancedFormData } from 'models/search-bar';
 import { User } from "models/user";
 import { Config } from 'common/config';
 import { Session } from "models/session";
+import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
 
 export interface SearchResultsPanelDataProps {
     data: SearchBarAdvancedFormData;
@@ -28,6 +29,7 @@ export interface SearchResultsPanelActionProps {
     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
     onDialogOpen: (ownerUuid: string) => void;
     onItemDoubleClick: (item: string) => void;
+    onPathDisplay: (path: string) => void;
 }
 
 export type SearchResultsPanelProps = SearchResultsPanelDataProps & SearchResultsPanelActionProps;
@@ -49,7 +51,15 @@ const mapDispatchToProps = (dispatch: Dispatch): SearchResultsPanelActionProps =
     },
     onItemDoubleClick: uuid => {
         dispatch<any>(navigateTo(uuid));
-    }
+    },
+    onPathDisplay: (path: string) => {
+        dispatch(snackbarActions.SHIFT_MESSAGES());
+        dispatch(snackbarActions.OPEN_SNACKBAR({
+            message: path,
+            kind: SnackbarKind.INFO,
+            hideDuration: 9999999999,
+        }));
+    },
 });
 
 export const SearchResultsPanel = connect(mapStateToProps, mapDispatchToProps)(SearchResultsPanelView);

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list