Skip to content

Commit

Permalink
UIU-2951: change disabled button style (#2568)
Browse files Browse the repository at this point in the history
* UIU-2951: change disabled button style

* tests: fix failing test cases

* UIU-2951: remove css styling and move the logic to stripes-components

* refactor: hide disabled elements

* refactor: hide button for shadow users
  • Loading branch information
alisher-epam authored Oct 11, 2023
1 parent f5c9e37 commit 98a3c5c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class RequestFeeFineBlockButtons extends React.Component {
onToggle: PropTypes.func,
userId: PropTypes.string,
location: PropTypes.object,
disabled: PropTypes.bool,
};

render() {
Expand All @@ -26,7 +25,6 @@ class RequestFeeFineBlockButtons extends React.Component {
onToggle,
userId,
location,
disabled,
} = this.props;
const createRequestUrl = getRequestUrl(barcode, userId);

Expand All @@ -38,7 +36,6 @@ class RequestFeeFineBlockButtons extends React.Component {
data-test-actions-menu-create-request
to={createRequestUrl}
onClick={onToggle}
disabled={disabled}
>
<Icon icon="plus-sign">
<FormattedMessage id="ui-users.requests.createRequest" />
Expand All @@ -51,7 +48,6 @@ class RequestFeeFineBlockButtons extends React.Component {
data-test-actions-menu-create-feesfines
to={{ pathname: `/users/${userId}/charge` }}
onClick={onToggle}
disabled={disabled}
>
<Icon icon="plus-sign">
<FormattedMessage id="ui-users.accounts.chargeManual" />
Expand All @@ -63,7 +59,6 @@ class RequestFeeFineBlockButtons extends React.Component {
buttonStyle="dropdownItem"
data-test-actions-menu-create-patronblocks
id="create-patron-block"
disabled={disabled}
to={{
pathname: `/users/${userId}/patronblocks/create`,
search: location.search,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ describe('RequestFeeFineBlockButtons', () => {
expect(screen.queryByText('ui-users.accounts.chargeManual')).toBeInTheDocument();
expect(screen.queryByText('ui-users.blocks.buttons.add')).toBeInTheDocument();
});

it('should createRequest button to be disabled', () => {
renderRequestFeeFineBlockButtons({ disabled: true });
const buttonElements = screen.getAllByRole('button');

buttonElements.forEach((buttonElement) => {
expect(buttonElement).toBeDisabled();
});
});
});

describe('without ui-requests.all permission', () => {
Expand Down
20 changes: 11 additions & 9 deletions src/views/UserDetail/UserDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,22 +446,24 @@ class UserDetail extends React.Component {
if (showActionMenu) {
return (
<>
<IfInterface name="feesfines">
<RequestFeeFineBlockButtons
barcode={barcode}
onToggle={onToggle}
userId={this.props.match.params.id}
disabled={isShadowUser}
/>
</IfInterface>
{!isShadowUser && (
<IfInterface name="feesfines">
<RequestFeeFineBlockButtons
barcode={barcode}
onToggle={onToggle}
userId={this.props.match.params.id}
disabled={isShadowUser}
/>
</IfInterface>
)}
<ActionMenuEditButton
id={this.props.match.params.id}
suppressList={this.props.resources.suppressEdit}
onToggle={onToggle}
goToEdit={this.goToEdit}
editButton={this.editButton}
/>
<LostItemsLink />
{!isShadowUser && <LostItemsLink />}
<IfInterface name="feesfines">
<ExportFeesFinesReportButton
feesFinesReportData={feesFinesReportData}
Expand Down

0 comments on commit 98a3c5c

Please sign in to comment.