Merge remote-tracking branch 'origin/main' into 18692-frozen-projects-workbench-support
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 23 Sep 2022 06:15:03 +0000 (08:15 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 23 Sep 2022 06:15:03 +0000 (08:15 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/project.spec.js
cypress/integration/search.spec.js
src/services/api/filter-builder.ts
src/store/open-in-new-tab/open-in-new-tab.actions.ts

index 3851a665c9f8f536715446fa2680d0aca9eea63a..93e4257b5b55f137eb626f9669e784b2ba7a5172 100644 (file)
@@ -403,5 +403,31 @@ describe('Project tests', function() {
             });
         });
     });
+
+    it('copies project URL to clipboard', () => {
+        const projectName = `Test project (${Math.floor(999999 * Math.random())})`;
+
+        cy.loginAs(activeUser);
+        cy.get('[data-cy=side-panel-button]').click();
+        cy.get('[data-cy=side-panel-new-project]').click();
+        cy.get('[data-cy=form-dialog]')
+            .should('contain', 'New Project')
+            .within(() => {
+                cy.get('[data-cy=name-field]').within(() => {
+                    cy.get('input').type(projectName);
+                });
+                cy.get('[data-cy=form-submit-btn]').click();
+            });
+
+        cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
+        cy.get('[data-cy=project-panel]').contains(projectName).rightclick();
+        cy.get('[data-cy=context-menu]').contains('Copy to clipboard').click();
+        cy.window().then((win) => (
+            win.navigator.clipboard.readText().then((text) => {
+                expect(text).to.match(/https\:\/\/localhost\:[0-9]+\/projects\/[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}/,);
+            })
+        ));
+
+    });
 });
 
index da33c7df02881dfc1d62c5bd9f03fa229e665362..c8e262f011097b43ad9b5902a7d75bacdfa26cf1 100644 (file)
@@ -105,6 +105,39 @@ describe('Search tests', function() {
         });
     });
 
+    it('can search items using quotes', function() {
+        const random = Math.floor(Math.random() * Math.floor(999999));
+        const colName = `Collection ${random}`;
+        const colName2 = `Collection test ${random}`;
+
+        // 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"
+        }).as('collection1');
+
+        cy.createCollection(adminUser.token, {
+            name: colName2,
+            owner_uuid: activeUser.user.uuid,
+            preserve_version: true,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+        }).as('collection2');
+
+        cy.getAll('@collection1', '@collection2')
+            .then(function() {
+                cy.loginAs(activeUser);
+
+                cy.doSearch(colName);
+                cy.get('[data-cy=search-results] table tbody tr').should('have.length', 2);
+
+                cy.doSearch(`"${colName}"`);
+                cy.get('[data-cy=search-results] table tbody tr').should('have.length', 1);
+            });
+    });
+
     it('can display owner of the item', function() {
         const colName = `Collection ${Math.floor(Math.random() * Math.floor(999999))}`;
 
index 4809e7a80c83071b0d5889ce8a81b7b661bc4f83..da67935a1e5d8a44c5bf2c601c3fc639204ca8ab 100644 (file)
@@ -65,7 +65,18 @@ export class FilterBuilder {
     }
 
     public addFullTextSearch(value: string) {
-        const terms = value.trim().split(/(\s+)/);
+        const regex = /"[^"]*"/;
+        const matches: any[] = [];
+
+        let match = value.match(regex);
+
+        while (match) {
+            value = value.replace(match[0], "");
+            matches.push(match[0].replace(/"/g, ''));
+            match = value.match(regex);
+        }
+
+        const terms = value.trim().split(/(\s+)/).concat(matches);
         terms.forEach(term => {
             if (term !== " ") {
                 this.addCondition("any", "ilike", term, "%", "%");
index c465aae8695a51291918aa0fd630e57fe8b327c6..6b9db6a538e1322004f14138b4e45b0bd8b53a73 100644 (file)
@@ -21,7 +21,9 @@ export const copyToClipboardAction = (resource: any) => (dispatch: Dispatch, get
     // Copy to clipboard omits token to avoid accidental sharing
     const url = getNavUrl(resource.uuid, getState().auth, false);
 
-    if (url) {
+    if (url[0] === '/') {
+        copy(`${window.location.origin}${url}`);
+    } else if (url.length) {
         copy(url);
     }
 };