Skip to content

Commit

Permalink
Merge pull request #114 from aliraza556/disable-icon-user-side
Browse files Browse the repository at this point in the history
Display Block Icon on Disabled User Action Buttons `settings and delete`
  • Loading branch information
kevkevinpal authored Feb 1, 2024
2 parents 21767f6 + 6da1f61 commit 385c68e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
60 changes: 60 additions & 0 deletions src/people/widgetViews/__tests__/UsersList.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import Users from '../organization/UsersList.tsx';

jest.mock('store', () => ({
useStores: () => ({
main: {
bountyRoles: []
},
ui: {
meInfo: {
owner_pubkey: 'mocked_pubkey'
}
}
})
}));

const mockedUsers = [
{
owner_pubkey: 'user1_pubkey',
owner_alias: 'User 1',
img: ''
},
{
owner_pubkey: 'mocked_pubkey',
owner_alias: 'User 2',
img: ''
}
];

const props = {
users: mockedUsers,
userRoles: ['VIEW'],
handleDeleteClick: jest.fn(),
handleSettingsClick: jest.fn(),
org: { owner_pubkey: 'org_pubkey' }
};

describe('Users Component', () => {
test('displays not-allowed cursor over disabled settings button', () => {
// @ts-ignore
const { getAllByTestId } = render(<Users {...props} />);
const settingsIcons = getAllByTestId('settings-icon');
// eslint-disable-next-line @typescript-eslint/typedef
settingsIcons.forEach((icon) => {
expect(icon).toHaveStyle('cursor: not-allowed');
});
});

test('displays not-allowed cursor over disabled delete button', () => {
// @ts-ignore
const { getAllByTestId } = render(<Users {...props} />);
const deleteIcons = getAllByTestId('delete-icon');
// eslint-disable-next-line @typescript-eslint/typedef
deleteIcons.forEach((icon) => {
expect(icon).toHaveStyle('cursor: not-allowed');
});
});
});
6 changes: 4 additions & 2 deletions src/people/widgetViews/organization/UsersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ const Users = (props: UserListProps) => {
<ActionBtn disabled={settingsDisabled}>
<MaterialIcon
disabled={settingsDisabled}
data-testid="settings-icon"
icon={'settings'}
style={{
fontSize: 24,
cursor: 'pointer',
cursor: settingsDisabled ? 'not-allowed' : 'pointer',
color: settingsDisabled ? '#b0b7bc' : '#5f6368'
}}
onClick={() => handleSettingsClick(user)}
Expand All @@ -59,10 +60,11 @@ const Users = (props: UserListProps) => {
<IconWrap>
<ActionBtn disabled={deleteUserDisabled}>
<MaterialIcon
data-testid="delete-icon"
icon={'delete'}
style={{
fontSize: 24,
cursor: 'pointer',
cursor: deleteUserDisabled ? 'not-allowed' : 'pointer',
color: deleteUserDisabled ? '#b0b7bc' : '#5f6368'
}}
onClick={() => {
Expand Down

0 comments on commit 385c68e

Please sign in to comment.