Skip to content

Commit

Permalink
Skeleton of Drupal Rest Auth Plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
laceysanderson committed Jul 17, 2024
1 parent ce99a0c commit 4011d73
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 58 deletions.
193 changes: 193 additions & 0 deletions jbrowse_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,197 @@
{
"assemblies": [
{
"name": "volvox",
"aliases": [
"vvx"
],
"sequence": {
"type": "ReferenceSequenceTrack",
"trackId": "volvox_refseq",
"metadata": {
"date": "2020-08-20"
},
"formatAbout": {
"hideUris": true,
"config": "jexl:{extraField:'important data'}"
},
"adapter": {
"type": "TwoBitAdapter",
"twoBitLocation": {
"uri": "test_data/volvox/volvox.2bit",
"locationType": "UriLocation"
}
}
},
"refNameAliases": {
"adapter": {
"type": "FromConfigAdapter",
"adapterId": "W6DyPGJ0UU",
"features": [
{
"refName": "ctgA",
"uniqueId": "alias1",
"aliases": [
"A",
"contigA"
]
},
{
"refName": "ctgB",
"uniqueId": "alias2",
"aliases": [
"B",
"contigB"
]
}
]
}
}
},
{
"name": "volvox_tripalauth",
"sequence": {
"type": "ReferenceSequenceTrack",
"trackId": "volvox_tripalauth-ReferenceSequenceTrack",
"adapter": {
"type": "TwoBitAdapter",
"twoBitLocation": {
"uri": "test_data/volvox/volvox.2bit",
"locationType": "UriLocation",
"internetAccountId": "customTripalAuth"
}
}
}
}
],
"connections": [],
"defaultSession": {
"name": "Integration test example",
"views": [
{
"id": "integration_test",
"type": "LinearGenomeView",
"offsetPx": 2000,
"bpPerPx": 0.05,
"displayedRegions": [
{
"refName": "ctgA",
"start": 0,
"end": 50001,
"assemblyName": "volvox"
}
]
}
],
"widgets": {
"hierarchicalTrackSelector": {
"id": "hierarchicalTrackSelector",
"type": "HierarchicalTrackSelectorWidget",
"filterText": "",
"view": "integration_test"
}
},
"activeWidgets": {
"hierarchicalTrackSelector": "hierarchicalTrackSelector"
}
},
"tracks": [
{
"type": "QuantitativeTrack",
"trackId": "tripalauth_bigwig",
"name": "TripalAuth BigWig",
"category": [
"Authentication"
],
"assemblyNames": [
"volvox"
],
"adapter": {
"type": "BigWigAdapter",
"bigWigLocation": {
"locationType": "UriLocation",
"uri": "test_data/volvox/volvox.bw",
"internetAccountId": "ActivatingCrops"
}
}
},
{
"type": "VariantTrack",
"trackId": "tripalauth_vcf",
"name": "TripalAuth VCF",
"assemblyNames": [
"volvox"
],
"category": [
"Authentication"
],
"adapter": {
"type": "VcfTabixAdapter",
"vcfGzLocation": {
"uri": "test_data/volvox/volvox.filtered.vcf.gz",
"locationType": "UriLocation",
"internetAccountId": "ActivatingCrops"
},
"index": {
"location": {
"uri": "test_data/volvox/volvox.filtered.vcf.gz.tbi",
"locationType": "UriLocation",
"internetAccountId": "ActivatingCrops"
}
}
}
},
{
"type": "QuantitativeTrack",
"trackId": "noauth_bigwig",
"name": "NoAuth BigWig",
"category": [
"Authentication"
],
"assemblyNames": [
"volvox"
],
"adapter": {
"type": "BigWigAdapter",
"bigWigLocation": {
"locationType": "UriLocation",
"uri": "test_data/volvox/volvox.bw"
}
}
},
{
"type": "VariantTrack",
"trackId": "noauth_vcf",
"name": "NoAuth VCF",
"assemblyNames": [
"volvox"
],
"category": [
"Authentication"
],
"adapter": {
"type": "VcfTabixAdapter",
"vcfGzLocation": {
"uri": "test_data/volvox/volvox.filtered.vcf.gz",
"locationType": "UriLocation"
},
"index": {
"location": {
"uri": "test_data/volvox/volvox.filtered.vcf.gz.tbi",
"locationType": "UriLocation"
}
}
}
}
],
"internetAccounts": [
{
"type": "DrupalRestAuthModel",
"internetAccountId": "ActivatingCrops",
"name": "Activating Crops Tripal Authentication",
"description": "Requires login to the Activating Crops website"
}
],
"plugins": [
{
"name": "DrupalRestAuthModel",
Expand Down
68 changes: 68 additions & 0 deletions src/DrupalRestAuthModel/DrupalRestAuthLoginForm.tsx
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>
)
}
43 changes: 43 additions & 0 deletions src/DrupalRestAuthModel/configSchema.ts
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
Loading

0 comments on commit 4011d73

Please sign in to comment.