Files
xrpl-dev-portal/content/resources/dev-tools/components/websocket-api/connection-modal.tsx
Caleb Kniffen 5a9b40e8c8 Migrate WebSocket Tool to Redocly
Recreate branch from base, add react-query-params, fix permalinks, fix sidebar

use correct params library and upgrade redocly.

Fix command text not working with permalink and move more modal logic out of main component.

Moved more connection selection logic to connection modal
Removed many `data-*` attributes previously used by bootstrap modal css

Created a shared modal component which removed 38 lines.

WS Tool: Fix Link import

fix UL error

toggle CurlModal to show/hide on button clicks

resolve error: <div> cannot appear as a descendant of <p>

remove <span>

WS tool: sidebar fixes
2024-01-31 16:10:32 -08:00

54 lines
1.8 KiB
TypeScript

import { useTranslate } from "@portal/hooks";
import { Connection } from './types';
import { ChangeEvent } from 'react';
import { Modal } from '../Modal';
interface ConnectionButtonProps {
selectedConnection: Connection;
setSelectedConnection: (value: Connection) => void;
connections: Connection[];
}
interface ConnectionProps extends ConnectionButtonProps {
closeConnectionModal: any;
}
export const ConnectionModal: React.FC<ConnectionProps> = ({
selectedConnection,
setSelectedConnection,
closeConnectionModal,
connections,
}) => {
const { translate } = useTranslate();
const handleConnectionChange = (event: ChangeEvent<HTMLInputElement>) => {
const selectedValue = event.target.value;
const foundConnection = connections.find(
(conn) => conn.id === selectedValue
);
setSelectedConnection(foundConnection);
};
return (
<Modal id="wstool-1-connection-settings" title={translate('Connection Settings')} onClose={closeConnectionModal}>
{connections.map((conn) => (
<div className="form-check" key={conn.id}>
<input
className="form-check-input"
type="radio"
name="wstool-1-connection"
id={conn.id}
value={conn.id}
checked={selectedConnection.id === conn.id}
onChange={handleConnectionChange}
/>
<label className="form-check-label" htmlFor={conn.id}>
<div dangerouslySetInnerHTML={{ __html: conn.longname }} />
</label>
</div>
))}
</Modal>
);
};