From a6b824e63de4df4296a17d74d80ff2101820762d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Mon, 20 Mar 2023 21:23:58 +0100 Subject: [PATCH] 200085: Fix for sharing dialog MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- cypress/integration/sharing.spec.js | 21 +++++++++++++++++++ src/components/autocomplete/autocomplete.tsx | 10 ++++----- .../sharing-dialog/sharing-dialog-types.ts | 2 +- .../sharing-dialog/sharing-dialog.tsx | 1 + 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/cypress/integration/sharing.spec.js b/cypress/integration/sharing.spec.js index 1d3112c2..c64f57fd 100644 --- a/cypress/integration/sharing.spec.js +++ b/cypress/integration/sharing.spec.js @@ -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 diff --git a/src/components/autocomplete/autocomplete.tsx b/src/components/autocomplete/autocomplete.tsx index b5c634c3..17d85e85 100644 --- a/src/components/autocomplete/autocomplete.tsx +++ b/src/components/autocomplete/autocomplete.tsx @@ -175,17 +175,17 @@ export class Autocomplete extends React.Component { const tooltip = this.props.renderChipTooltip ? this.props.renderChipTooltip(item) : ''; if (tooltip && tooltip.length) { - return + return + onDelete(item, index)) : undefined} /> - + } else { - return onDelete(item, index)) : undefined} /> + onDelete={onDelete && !this.props.disabled ? (() => onDelete(item, index)) : undefined} /> } } ); diff --git a/src/store/sharing-dialog/sharing-dialog-types.ts b/src/store/sharing-dialog/sharing-dialog-types.ts index a05224e2..67da4b21 100644 --- a/src/store/sharing-dialog/sharing-dialog-types.ts +++ b/src/store/sharing-dialog/sharing-dialog-types.ts @@ -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); diff --git a/src/views-components/sharing-dialog/sharing-dialog.tsx b/src/views-components/sharing-dialog/sharing-dialog.tsx index 01cd390b..db89a83c 100644 --- a/src/views-components/sharing-dialog/sharing-dialog.tsx +++ b/src/views-components/sharing-dialog/sharing-dialog.tsx @@ -36,6 +36,7 @@ const mapStateToProps = (state: RootState, { working, ...props }: Props): Sharin const dialog = getDialog(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), -- 2.30.2