-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDK] Feature: Allow hiding the link profiles button (#5799)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces a feature to hide the "Linked Profiles" button in the `ConnectButton` Details Modal based on the `allowLinkingProfiles` option. It also includes tests for the `ManageWalletScreen` to ensure the button's visibility behaves as expected. ### Detailed summary - Added `manageWallet` option in `ConnectButtonProps` to configure wallet management. - Updated `ManageWalletScreen` to conditionally render the linked profiles button based on `allowLinkingProfiles`. - Created tests for `ManageWalletScreen` to verify button visibility based on `allowLinkingProfiles` settings. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
1 parent
46a426b
commit 90e2b97
Showing
4 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"thirdweb": minor | ||
--- | ||
|
||
Feature: Allows hiding the "Linked Profiles" button in the `ConnectButton` Details Modal | ||
|
||
```tsx | ||
<ConnectButton detailsModal={{ manageWallet: { allowLinkingProfiles: false } }} /> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/ManageWalletScreen.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
import { render, screen } from "../../../../../../test/src/react-render.js"; | ||
import { TEST_CLIENT } from "../../../../../../test/src/test-clients.js"; | ||
import { createWallet } from "../../../../../wallets/create-wallet.js"; | ||
import { useAdminWallet } from "../../../../core/hooks/wallets/useAdminWallet.js"; | ||
import en from "../locale/en.js"; | ||
import { ManageWalletScreen } from "./ManageWalletScreen.js"; | ||
|
||
vi.mock("../../../../core/hooks/wallets/useAdminWallet"); | ||
|
||
describe("ManageWalletScreen", () => { | ||
const mockProps = { | ||
onBack: vi.fn(), | ||
setScreen: vi.fn(), | ||
closeModal: vi.fn(), | ||
locale: en, | ||
client: TEST_CLIENT, | ||
}; | ||
|
||
beforeEach(() => { | ||
vi.mocked(useAdminWallet).mockReturnValue(createWallet("inApp")); | ||
}); | ||
|
||
it("should render the modal header with the correct title", () => { | ||
render(<ManageWalletScreen {...mockProps} />); | ||
expect(screen.getByText(en.manageWallet.title)).toBeInTheDocument(); | ||
}); | ||
|
||
it("should render the linked profiles button if allowLinkingProfiles is true", () => { | ||
render( | ||
<ManageWalletScreen | ||
{...mockProps} | ||
manageWallet={{ allowLinkingProfiles: true }} | ||
/>, | ||
); | ||
expect( | ||
screen.getByText(en.manageWallet.linkedProfiles), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it("should not render the linked profiles button if allowLinkingProfiles is false", () => { | ||
render( | ||
<ManageWalletScreen | ||
{...mockProps} | ||
manageWallet={{ allowLinkingProfiles: false }} | ||
/>, | ||
); | ||
expect( | ||
screen.queryByText(en.manageWallet.linkedProfiles), | ||
).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should default to showing linked profiles button", () => { | ||
render(<ManageWalletScreen {...mockProps} />); | ||
expect( | ||
screen.getByText(en.manageWallet.linkedProfiles), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it("should render the wallet connect receiver button", () => { | ||
render(<ManageWalletScreen {...mockProps} />); | ||
expect(screen.getByText(en.manageWallet.connectAnApp)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters