Skip to content

Commit e6bc7a1

Browse files
authored
fix: [M3-10533] - Fix misleading "Receive a transfer" tooltip when user lacks permissions (linode#12813)
* save work * updates * changeset * remove s * update tests
1 parent fe793ca commit e6bc7a1

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Fixed
3+
---
4+
5+
Misleading 'Receive a transfer' tooltip message when user lacks permission ([#12813](https://github.com/linode/manager/pull/12813))

packages/manager/src/features/EntityTransfers/EntityTransfersLanding/TransferControls.test.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('TransferControls', () => {
4949
expect(makeServiceTransferBtn).not.toHaveAttribute('aria-disabled', 'true');
5050
});
5151

52-
it('should disable "Review Details" button if the user does not have accept_service_transfer permission', async () => {
52+
it('should disable "Review Details" button and transfer textfield if the user does not have accept_service_transfer permission', async () => {
5353
const { getByRole } = renderWithTheme(
5454
<TransferControls permissions={queryMocks.userPermissions().data} />
5555
);
@@ -58,6 +58,15 @@ describe('TransferControls', () => {
5858
name: 'Review Details',
5959
});
6060
expect(reviewBtn).toHaveAttribute('aria-disabled', 'true');
61+
expect(reviewBtn).toHaveAttribute(
62+
'data-qa-tooltip',
63+
'You do not have permission to receive service transfers.'
64+
);
65+
66+
const tokenTextfield = getByRole('textbox', {
67+
name: 'Receive a Service Transfer',
68+
});
69+
expect(tokenTextfield).toBeDisabled();
6170
});
6271

6372
it('should enable "Review Details" button if the user has accept_service_transfer permission', async () => {
@@ -72,6 +81,13 @@ describe('TransferControls', () => {
7281
<TransferControls permissions={queryMocks.userPermissions().data} />
7382
);
7483

84+
const reviewBtnBeforeInput = getByRole('button', {
85+
name: 'Review Details',
86+
});
87+
expect(reviewBtnBeforeInput).toHaveAttribute(
88+
'data-qa-tooltip',
89+
'Enter a service transfer token to review the details and accept the transfer.'
90+
);
7591
const input = getByPlaceholderText('Enter a token');
7692
await userEvent.type(input, 'test-token');
7793

packages/manager/src/features/EntityTransfers/EntityTransfersLanding/TransferControls.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const TransferControls = React.memo((props: Props) => {
6666
direction="row"
6767
>
6868
<StyledTextField
69+
disabled={!permissions.accept_service_transfer}
6970
hideLabel
7071
label="Receive a Service Transfer"
7172
onChange={handleInputChange}
@@ -76,7 +77,11 @@ export const TransferControls = React.memo((props: Props) => {
7677
buttonType="primary"
7778
disabled={!permissions.accept_service_transfer || token === ''}
7879
onClick={() => setConfirmDialogOpen(true)}
79-
tooltipText="Enter a service transfer token to review the details and accept the transfer."
80+
tooltipText={
81+
!permissions.accept_service_transfer
82+
? 'You do not have permission to receive service transfers.'
83+
: 'Enter a service transfer token to review the details and accept the transfer.'
84+
}
8085
>
8186
Review Details
8287
</StyledReviewButton>

0 commit comments

Comments
 (0)