@jbrowse/plugin-authentication
Version:
JBrowse 2 Authentication
33 lines (32 loc) • 2.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HTTPBasicLoginForm = HTTPBasicLoginForm;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const ui_1 = require("@jbrowse/core/ui");
const material_1 = require("@mui/material");
function HTTPBasicLoginForm({ internetAccountId, handleClose, }) {
const [username, setUsername] = (0, react_1.useState)('');
const [password, setPassword] = (0, react_1.useState)('');
return ((0, jsx_runtime_1.jsx)(ui_1.Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic", title: `Log in for ${internetAccountId}`, onClose: () => {
handleClose();
}, children: (0, jsx_runtime_1.jsxs)("form", { onSubmit: event => {
if (username && password) {
handleClose(btoa(`${username}:${password}`));
}
else {
handleClose();
}
event.preventDefault();
}, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogContent, { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, label: "Username", variant: "outlined", onChange: event => {
setUsername(event.target.value);
}, margin: "dense", slotProps: {
htmlInput: { 'data-testid': 'login-httpbasic-username' },
} }), (0, jsx_runtime_1.jsx)(material_1.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' },
} })] }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", type: "submit", children: "Submit" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => {
handleClose();
}, children: "Cancel" })] })] }) }));
}