Skip to content

Commit da2cf18

Browse files
authoredApr 13, 2023
Fixed collection upload permissions and css styling (#3571)
* fixed collection upload permission and css styling Issue: AAH-2276 * fix tests Issue: AAH-2276
1 parent 7e6d29c commit da2cf18

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed
 

‎CHANGES/2276.bug

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed user permissions for uploading collections

‎src/components/cards/cards.scss

+4
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@
6565
overflow: hidden;
6666
}
6767
}
68+
69+
.hidden-menu-space {
70+
margin-right: 8px;
71+
}

‎src/containers/search/search.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { t } from '@lingui/macro';
22
import { Button, DataList, DropdownItem, Switch } from '@patternfly/react-core';
3+
import cx from 'classnames';
34
import * as React from 'react';
45
import { Navigate } from 'react-router-dom';
56
import {
@@ -385,33 +386,33 @@ class Search extends React.Component<RouteProps, IState> {
385386
{collection.is_deprecated ? t`Undeprecate` : t`Deprecate`}
386387
</DropdownItem>
387388
),
388-
];
389-
390-
if (!list) {
391-
menuItems.push(
389+
!list && hasPermission('galaxy.upload_to_namespace') && (
392390
<DropdownItem
393391
onClick={() => this.checkUploadPrivilleges(collection)}
394392
key='upload new version'
395393
>
396394
{t`Upload new version`}
397-
</DropdownItem>,
398-
);
399-
}
395+
</DropdownItem>
396+
),
397+
].filter(Boolean);
398+
399+
const displayMenu = menuItems.length > 0;
400400

401401
return (
402402
<React.Fragment>
403-
{list && (
403+
{list && hasPermission('galaxy.upload_to_namespace') && (
404404
<Button
405405
onClick={() => this.checkUploadPrivilleges(collection)}
406406
variant='secondary'
407407
>
408408
{t`Upload new version`}
409409
</Button>
410410
)}
411-
<StatefulDropdown
412-
items={menuItems.filter(Boolean)}
413-
ariaLabel='collection-kebab'
414-
/>
411+
<span className={cx(!displayMenu && 'hidden-menu-space')}>
412+
{displayMenu && (
413+
<StatefulDropdown items={menuItems} ariaLabel='collection-kebab' />
414+
)}
415+
</span>
415416
</React.Fragment>
416417
);
417418
}

‎test/cypress/e2e/collections/collection_upload.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ describe('Collection Upload Tests', () => {
2525
`${uiPrefix}collections?page_size=10&view_type=list&keywords=testcollection`,
2626
);
2727
cy.contains('testcollection');
28-
cy.contains('Upload new version').click();
29-
cy.contains("You don't have rights to do this operation.");
28+
cy.contains('Upload new version').should('not.exist');
3029
});
3130

3231
it('should not upload new collection version in collection list/cards when user does not have permissions', () => {
@@ -35,9 +34,7 @@ describe('Collection Upload Tests', () => {
3534
`${uiPrefix}collections?page_size=10&view_type=card&keywords=testcollection`,
3635
);
3736
cy.contains('testcollection');
38-
cy.get('[aria-label="Actions"]').click();
39-
cy.contains('Upload new version').click();
40-
cy.contains("You don't have rights to do this operation.");
37+
cy.get('[aria-label="Actions"]').should('not.exist');
4138
});
4239

4340
it('should not upload new collection version in collection detail when user does not have permissions', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.