Merge branch '20085-Sharing-Dialog-Form-Validation-Error-fix' into main
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 31 Mar 2023 15:32:08 +0000 (17:32 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Fri, 31 Mar 2023 15:32:12 +0000 (17:32 +0200)
closes #20085

Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/banner-tooltip.spec.js
cypress/integration/sharing.spec.js
src/components/autocomplete/autocomplete.tsx
src/store/sharing-dialog/sharing-dialog-types.ts
src/views-components/sharing-dialog/participant-select.tsx
src/views-components/virtual-machines-dialog/group-array-input.tsx

index 6156909c89c054228e55e6584733c5f26cc52b37..df84abe916cf4a656915850548615ab778fe0138 100644 (file)
@@ -94,7 +94,6 @@ describe('Collection panel tests', function () {
 
                     cy.getAll('@banner', '@tooltips')
                         .then(([banner, tooltips]) => {
-                            console.log(tooltips)
                             cy.get('[data-cy=drag-and-drop]').upload(banner, 'banner.html', false);
                             cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
                         });
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 02cdeaf2c28e814a3a1d72d24d8cfadfe143eee3..b43940f045e9f69b87b2dbb515826506e23c0a84 100644 (file)
@@ -88,7 +88,7 @@ export const ParticipantSelect = connect()(
                     onSelect={this.handleSelect}
                     onDelete={this.props.onDelete && !this.props.disabled ? this.handleDelete : undefined}
                     onFocus={this.props.onFocus}
-                    onBlur={this.props.onBlur}
+                    onBlur={this.onBlur}
                     renderChipValue={this.renderChipValue}
                     renderChipTooltip={this.renderChipTooltip}
                     renderSuggestion={this.renderSuggestion}
@@ -96,6 +96,13 @@ export const ParticipantSelect = connect()(
             );
         }
 
+        onBlur = (e) => {
+            if (this.props.onBlur) {
+                this.props.onBlur(e);
+            }
+            setTimeout(() => this.setState({ value: '', suggestions: [] }), 200);
+        }
+
         renderChipValue(chipValue: Participant) {
             const { name, uuid } = chipValue;
             return name || uuid;
index 95a86420795b36d22142b4277cd0d4387077ffd3..cba9af636e8eaaf22a1aa6019af47775f68e6fb5 100644 (file)
@@ -46,7 +46,6 @@ const styles = (theme: ArvadosTheme) => ({
 });
 
 export const GroupArrayInput = ({name, input, setPartialGroupInput, hasPartialGroupInput}: GroupArrayInputProps & GroupArrayDataProps) => {
-  console.log(hasPartialGroupInput);
   return <GroupArrayField
       name={name}
       commandInput={input}