Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed collection upload permissions and css styling #3571

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/2276.bug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed user permissions for uploading collections
4 changes: 4 additions & 0 deletions src/components/cards/cards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@
overflow: hidden;
}
}

.hidden-menu-space {
margin-right: 8px;
}
25 changes: 13 additions & 12 deletions src/containers/search/search.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { t } from '@lingui/macro';
import { Button, DataList, DropdownItem, Switch } from '@patternfly/react-core';
import cx from 'classnames';
import * as React from 'react';
import { Navigate } from 'react-router-dom';
import {
Expand Down Expand Up @@ -385,33 +386,33 @@ class Search extends React.Component<RouteProps, IState> {
{collection.is_deprecated ? t`Undeprecate` : t`Deprecate`}
</DropdownItem>
),
];

if (!list) {
menuItems.push(
!list && hasPermission('galaxy.upload_to_namespace') && (
<DropdownItem
onClick={() => this.checkUploadPrivilleges(collection)}
key='upload new version'
>
{t`Upload new version`}
</DropdownItem>,
);
}
</DropdownItem>
),
].filter(Boolean);

const displayMenu = menuItems.length > 0;

return (
<React.Fragment>
{list && (
{list && hasPermission('galaxy.upload_to_namespace') && (
<Button
onClick={() => this.checkUploadPrivilleges(collection)}
variant='secondary'
>
{t`Upload new version`}
</Button>
)}
<StatefulDropdown
items={menuItems.filter(Boolean)}
ariaLabel='collection-kebab'
/>
<span className={cx(!displayMenu && 'hidden-menu-space')}>
{displayMenu && (
<StatefulDropdown items={menuItems} ariaLabel='collection-kebab' />
)}
</span>
</React.Fragment>
);
}
Expand Down
7 changes: 2 additions & 5 deletions test/cypress/e2e/collections/collection_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ describe('Collection Upload Tests', () => {
`${uiPrefix}collections?page_size=10&view_type=list&keywords=testcollection`,
);
cy.contains('testcollection');
cy.contains('Upload new version').click();
cy.contains("You don't have rights to do this operation.");
cy.contains('Upload new version').should('not.exist');
});

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

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