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

refactor(wallet-dashboard): Clean up settings #4540

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ export function SettingsDialog({

return (
<Dialog open={isOpen} onOpenChange={() => handleClose()}>
<>
{view === SettingsDialogView.SelectSetting && (
<SettingsListView handleClose={handleClose} setView={setView} />
)}
{view === SettingsDialogView.NetworkSettings && (
<NetworkSelectorView handleClose={handleClose} onBack={onBack} />
)}
</>
{view === SettingsDialogView.SelectSetting && (
<SettingsListView handleClose={handleClose} setView={setView} />
)}
{view === SettingsDialogView.NetworkSettings && (
<NetworkSelectorView handleClose={handleClose} onBack={onBack} />
)}
</Dialog>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export function NetworkSelectorView({
}: NetworkSelectorViewProps): JSX.Element {
const clientContext = useIotaClientContext();
const activeNetwork = clientContext.network;
// Dashboard doesn't support RPCs yet
const networks = clientContext.networks as Record<string, NetworkConfiguration>;

async function handleNetworkChange(network: NetworkConfiguration) {
if (activeNetwork === network.id) {
Expand All @@ -27,25 +29,21 @@ export function NetworkSelectorView({
clientContext.selectNetwork(network.id);
toast.success(`Switched to ${network.name}`);
}

return (
<DialogLayout>
<Header title="Network" onClose={handleClose} onBack={onBack} titleCentered />
<DialogLayoutBody>
<div className="flex w-full flex-col gap-md">
{Object.keys(clientContext.networks).map((network) => {
const networkConfig = clientContext.networks[
network
] as NetworkConfiguration;
return (
<div className="px-md" key={networkConfig.id}>
<RadioButton
label={networkConfig.name}
isChecked={activeNetwork === networkConfig.id}
onChange={() => handleNetworkChange(networkConfig)}
/>
</div>
);
})}
{Object.values(networks).map((network) => (
<div className="px-md" key={network.id}>
<RadioButton
label={network.name}
isChecked={activeNetwork === network.id}
onChange={() => handleNetworkChange(network)}
/>
</div>
))}
</div>
</DialogLayoutBody>
</DialogLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ interface SettingsListViewProps {
export function SettingsListView({ handleClose, setView }: SettingsListViewProps): JSX.Element {
const { network } = useIotaClientContext();
const { name: networkName } = getNetwork(network);
function onSelectSettingClick(view: SettingsDialogView): void {
setView(view);
}

const MENU_ITEMS = [
{
title: 'Network',
subtitle: networkName,
icon: <Globe />,
onClick: () => onSelectSettingClick(SettingsDialogView.NetworkSettings),
onClick: () => setView(SettingsDialogView.NetworkSettings),
},
];

return (
<DialogLayout>
<Header title="Settings" onClose={handleClose} onBack={handleClose} titleCentered />
Expand Down
Loading