@jbrowse/plugin-authentication
Version:
JBrowse 2 Authentication
30 lines (29 loc) • 2.06 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState } from 'react';
import { Dialog } from '@jbrowse/core/ui';
import { Button, DialogActions, DialogContent, TextField } from '@mui/material';
export function HTTPBasicLoginForm({ internetAccountId, handleClose, }) {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
return (_jsx(Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic", title: `Log in for ${internetAccountId}`, onClose: () => {
handleClose();
}, children: _jsxs("form", { onSubmit: event => {
if (username && password) {
handleClose(btoa(`${username}:${password}`));
}
else {
handleClose();
}
event.preventDefault();
}, children: [_jsxs(DialogContent, { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx(TextField, { required: true, label: "Username", variant: "outlined", onChange: event => {
setUsername(event.target.value);
}, margin: "dense", slotProps: {
htmlInput: { 'data-testid': 'login-httpbasic-username' },
} }), _jsx(TextField, { required: true, label: "Password", type: "password", autoComplete: "current-password", variant: "outlined", onChange: event => {
setPassword(event.target.value);
}, margin: "dense", slotProps: {
htmlInput: { 'data-testid': 'login-httpbasic-password' },
} })] }), _jsxs(DialogActions, { children: [_jsx(Button, { variant: "contained", color: "primary", type: "submit", children: "Submit" }), _jsx(Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => {
handleClose();
}, children: "Cancel" })] })] }) }));
}