200085: Fix for sharing dialog
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Mon, 20 Mar 2023 20:23:58 +0000 (21:23 +0100)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Mon, 20 Mar 2023 20:23:58 +0000 (21:23 +0100)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/sharing.spec.js
src/components/autocomplete/autocomplete.tsx
src/store/sharing-dialog/sharing-dialog-types.ts
src/views-components/sharing-dialog/sharing-dialog.tsx

index 1d3112c2c8187fd6e0b04309de56e51b8a9fea87..c64f57fd2055841b50758a6a401e161508c7446d 100644 (file)
@@ -140,4 +140,25 @@ describe('Sharing tests', function () {
                 cy.testEditProjectOrCollection('main', mySharedWritableProject.name, newProjectName, newProjectDescription);
             });
     });
+
+    it('can share only when target users are present', () => {
+        const collName = `mySharedCollectionForUsers-${new Date().getTime()}`;
+        cy.createCollection(adminUser.token, {
+            name: collName,
+            owner_uuid: adminUser.uuid,
+        }).as('mySharedCollectionForUsers')
+
+        cy.getAll('@mySharedCollectionForUsers')
+            .then(function ([]) {
+                cy.loginAs(adminUser);
+                cy.get('[data-cy=project-panel]').contains(collName).rightclick();
+                cy.get('[data-cy=context-menu]').contains('Share').click();
+                cy.get('button').contains('Save changes').parent().should('be.disabled');
+                cy.get('[data-cy=invite-people-field] input').type('Anonymous');
+                cy.get('div[role=tooltip]').contains('anonymous').click();
+                cy.get('button').contains('Save changes').parent().should('not.be.disabled');
+                cy.get('[data-cy=invite-people-field] div[role=button]').contains('anonymous').parent().find('svg').click();
+                cy.get('button').contains('Save changes').parent().should('be.disabled');
+            });
+    });
 });
\ No newline at end of file
index b5c634c3d1875016d0a3d14ad7f2fada71aaf6da..17d85e856c3cb53901f468b31ccd5bf4e93c6d40 100644 (file)
@@ -175,17 +175,17 @@ export class Autocomplete<Value, Suggestion> extends React.Component<Autocomplet
             (item, index) => {
                 const tooltip = this.props.renderChipTooltip ? this.props.renderChipTooltip(item) : '';
                 if (tooltip && tooltip.length) {
-                    return <Tooltip title={tooltip}>
+                    return <span key={index}>
+                        <Tooltip title={tooltip}>
                         <Chip
                             label={this.renderChipValue(item)}
                             key={index}
                             onDelete={onDelete && !this.props.disabled ? (() =>  onDelete(item, index)) : undefined} />
-                    </Tooltip>
+                    </Tooltip></span>
                 } else {
-                    return <Chip
+                    return <span key={index}><Chip
                         label={this.renderChipValue(item)}
-                        key={index}
-                        onDelete={onDelete && !this.props.disabled ? (() =>  onDelete(item, index)) : undefined} />
+                        onDelete={onDelete && !this.props.disabled ? (() =>  onDelete(item, index)) : undefined} /></span>
                 }
             }
         );
index a05224e2373753a705821d4d639368545df9d8d2..67da4b21a30864295b0be09c342226272a26804b 100644 (file)
@@ -53,4 +53,4 @@ export const getSharingPublicAccessFormData = (state: any) =>
 export const hasChanges = (state: RootState) =>
     isDirty(SHARING_PUBLIC_ACCESS_FORM_NAME)(state) ||
     isDirty(SHARING_MANAGEMENT_FORM_NAME)(state) ||
-    isDirty(SHARING_INVITATION_FORM_NAME)(state);
+    (isDirty(SHARING_INVITATION_FORM_NAME)(state) && !!state.form[SHARING_INVITATION_FORM_NAME].values?.invitedPeople.length);
index 01cd390b07f7a2263400954fbba3b9c41f17cb5d..db89a83c45c931168e4408aafc8dbee981a8b0c2 100644 (file)
@@ -36,6 +36,7 @@ const mapStateToProps = (state: RootState, { working, ...props }: Props): Sharin
     const dialog = getDialog<SharingDialogData>(state.dialog, SHARING_DIALOG_NAME);
     const sharedResourceUuid = dialog?.data.resourceUuid || '';
     const sharingURLsDisabled = state.auth.config.clusterConfig.Workbench.DisableSharingURLsUI;
+    console.log(state);
     return ({
     ...props,
     saveEnabled: hasChanges(state),