generated from GMOD/jbrowse-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skeleton of Drupal Rest Auth Plugin.
- Loading branch information
1 parent
ce99a0c
commit 4011d73
Showing
9 changed files
with
425 additions
and
58 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
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,68 @@ | ||
import React, { useState } from 'react' | ||
import { Button, DialogContent, DialogActions, TextField } from '@mui/material' | ||
import { Dialog } from '@jbrowse/core/ui' | ||
|
||
export function DrupalRestAuthLoginForm({ | ||
internetAccountId, | ||
handleClose, | ||
}: { | ||
internetAccountId: string | ||
handleClose: (arg?: string) => void | ||
}) { | ||
const [username, setUsername] = useState('') | ||
const [password, setPassword] = useState('') | ||
|
||
return ( | ||
<Dialog | ||
open | ||
maxWidth="xl" | ||
data-testid="login-DrupalRestAuth" | ||
title={`Log in for ${internetAccountId}`} | ||
> | ||
<form | ||
onSubmit={event => { | ||
if (username && password) { | ||
handleClose(btoa(`${username}:${password}`)) | ||
} else { | ||
handleClose() | ||
} | ||
event.preventDefault() | ||
}} | ||
> | ||
<DialogContent style={{ display: 'flex', flexDirection: 'column' }}> | ||
<TextField | ||
required | ||
label="Username" | ||
variant="outlined" | ||
inputProps={{ 'data-testid': 'login-DrupalRestAuth-username' }} | ||
onChange={event => setUsername(event.target.value)} | ||
margin="dense" | ||
/> | ||
<TextField | ||
required | ||
label="Password" | ||
type="password" | ||
autoComplete="current-password" | ||
variant="outlined" | ||
inputProps={{ 'data-testid': 'login-DrupalRestAuth-password' }} | ||
onChange={event => setPassword(event.target.value)} | ||
margin="dense" | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button variant="contained" color="primary" type="submit"> | ||
Submit | ||
</Button> | ||
<Button | ||
variant="contained" | ||
color="secondary" | ||
type="submit" | ||
onClick={() => handleClose()} | ||
> | ||
Cancel | ||
</Button> | ||
</DialogActions> | ||
</form> | ||
</Dialog> | ||
) | ||
} |
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,43 @@ | ||
import { ConfigurationSchema } from '@jbrowse/core/configuration' | ||
import { Instance } from 'mobx-state-tree' | ||
import { BaseInternetAccountConfig } from '@jbrowse/core/pluggableElementTypes/models' | ||
|
||
/** | ||
* #config DrupalRestAuthModel | ||
*/ | ||
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars | ||
|
||
const DrupalRestConfigSchema = ConfigurationSchema( | ||
'DrupalRestAuthInternetAccount', | ||
{ | ||
/** | ||
* #slot | ||
*/ | ||
tokenType: { | ||
description: 'a custom name for a token to include in the header', | ||
type: 'string', | ||
defaultValue: 'Basic', | ||
}, | ||
/** | ||
* #slot | ||
*/ | ||
validateWithHEAD: { | ||
description: 'validate the token with a HEAD request before using it', | ||
type: 'boolean', | ||
defaultValue: true, | ||
}, | ||
}, | ||
{ | ||
/** | ||
* #baseConfiguration | ||
*/ | ||
baseConfiguration: BaseInternetAccountConfig, | ||
explicitlyTyped: true, | ||
}, | ||
) | ||
|
||
export type DrupalRestAuthInternetAccountConfigModel = typeof DrupalRestConfigSchema | ||
|
||
export type DrupalRestAuthInternetAccountConfig = | ||
Instance<DrupalRestAuthInternetAccountConfigModel> | ||
export default DrupalRestConfigSchema |
Oops, something went wrong.