Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu item redesign and sessions are manually saved to filesystem #2391

Merged
merged 25 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions packages/core/ui/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,47 @@ export function TrackSelector(props: SvgIconProps) {
</SvgIcon>
)
}

// content-save-edit from https://materialdesignicons.com/
export function SaveAs(props: SvgIconProps) {
return (
<SvgIcon {...props}>
<path
fill="currentColor"
d="M10,19L10.14,18.86C8.9,18.5 8,17.36 8,16A3,3 0 0,1 11,13C12.36,13 13.5,13.9 13.86,15.14L20,9V7L16,3H4C2.89,3 2,3.9 2,5V19A2,2 0 0,0 4,21H10V19M4,5H14V9H4V5M20.04,12.13C19.9,12.13 19.76,12.19 19.65,12.3L18.65,13.3L20.7,15.35L21.7,14.35C21.92,14.14 21.92,13.79 21.7,13.58L20.42,12.3C20.31,12.19 20.18,12.13 20.04,12.13M18.07,13.88L12,19.94V22H14.06L20.12,15.93L18.07,13.88Z"
/>
</SvgIcon>
)
}

// content-save from https://materialdesignicons.com/
export function Save(props: SvgIconProps) {
return (
<SvgIcon {...props}>
<path
fill="currentColor"
d="M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z"
/>
</SvgIcon>
)
}

// dna from https://materialdesignicons.com/
export function DNA(props: SvgIconProps) {
return (
<SvgIcon {...props}>
<path
fill="currentColor"
d="M4,2H6V4C6,5.44 6.68,6.61 7.88,7.78C8.74,8.61 9.89,9.41 11.09,10.2L9.26,11.39C8.27,10.72 7.31,10 6.5,9.21C5.07,7.82 4,6.1 4,4V2M18,2H20V4C20,6.1 18.93,7.82 17.5,9.21C16.09,10.59 14.29,11.73 12.54,12.84C10.79,13.96 9.09,15.05 7.88,16.22C6.68,17.39 6,18.56 6,20V22H4V20C4,17.9 5.07,16.18 6.5,14.79C7.91,13.41 9.71,12.27 11.46,11.16C13.21,10.04 14.91,8.95 16.12,7.78C17.32,6.61 18,5.44 18,4V2M14.74,12.61C15.73,13.28 16.69,14 17.5,14.79C18.93,16.18 20,17.9 20,20V22H18V20C18,18.56 17.32,17.39 16.12,16.22C15.26,15.39 14.11,14.59 12.91,13.8L14.74,12.61M7,3H17V4L16.94,4.5H7.06L7,4V3M7.68,6H16.32C16.08,6.34 15.8,6.69 15.42,7.06L14.91,7.5H9.07L8.58,7.06C8.2,6.69 7.92,6.34 7.68,6M9.09,16.5H14.93L15.42,16.94C15.8,17.31 16.08,17.66 16.32,18H7.68C7.92,17.66 8.2,17.31 8.58,16.94L9.09,16.5M7.06,19.5H16.94L17,20V21H7V20L7.06,19.5Z"
/>
</SvgIcon>
)
}

export function Cable(props: SvgIconProps) {
return (
<SvgIcon {...props}>
<path d="M20 5V4c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v1h-1v4c0 .55.45 1 1 1h1v7c0 1.1-.9 2-2 2s-2-.9-2-2V7c0-2.21-1.79-4-4-4S5 4.79 5 7v7H4c-.55 0-1 .45-1 1v4h1v1c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-1h1v-4c0-.55-.45-1-1-1H7V7c0-1.1.9-2 2-2s2 .9 2 2v10c0 2.21 1.79 4 4 4s4-1.79 4-4v-7h1c.55 0 1-.45 1-1V5h-1z" />
</SvgIcon>
)
}
9 changes: 3 additions & 6 deletions packages/core/ui/Snackbar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import IconButton from '@material-ui/core/IconButton'
import Snackbar from '@material-ui/core/Snackbar'
import React, { useEffect, useState } from 'react'
import { IconButton, Snackbar } from '@material-ui/core'
import CloseIcon from '@material-ui/icons/Close'
import Alert from '@material-ui/lab/Alert'
import { observer } from 'mobx-react'
import { IAnyStateTreeNode } from 'mobx-state-tree'
import React, { useEffect, useState } from 'react'
import { AbstractSessionModel, NotificationLevel } from '../util'

type SnackbarMessage = [string, NotificationLevel]
Expand All @@ -20,9 +19,7 @@ function MessageSnackbar({
session: SnackbarSession & IAnyStateTreeNode
}) {
const [open, setOpen] = useState(false)
const [snackbarMessage, setSnackbarMessage] = useState<
SnackbarMessage | undefined
>()
const [snackbarMessage, setSnackbarMessage] = useState<SnackbarMessage>()

const { popSnackbarMessage, snackbarMessages } = session

Expand Down
2 changes: 1 addition & 1 deletion plugins/circular-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class CircularViewPlugin extends Plugin {

configure(pluginManager: PluginManager) {
if (isAbstractMenuManager(pluginManager.rootModel)) {
pluginManager.rootModel.appendToSubMenu(['File', 'Add'], {
pluginManager.rootModel.appendToSubMenu(['Add'], {
label: 'Circular view',
icon: DataUsageIcon,
onClick: (session: AbstractSessionModel) => {
Expand Down
43 changes: 7 additions & 36 deletions plugins/data-management/src/AssemblyManager/AssemblyAddForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ const AdapterInput = observer(
},
)

const blank = { uri: '' } as FileLocation

const AssemblyAddForm = observer(
({
rootModel,
Expand All @@ -169,48 +171,17 @@ const AssemblyAddForm = observer(
const [assemblyName, setAssemblyName] = useState('')
const [assemblyDisplayName, setAssemblyDisplayName] = useState('')
const [adapterSelection, setAdapterSelection] = useState(adapterTypes[0])
const [fastaLocation, setFastaLocation] = useState<{
uri: string
locationType: 'UriLocation'
}>({
uri: '',
locationType: 'UriLocation',
})
const [faiLocation, setFaiLocation] = useState<{
uri: string
locationType: 'UriLocation'
}>({
uri: '',
locationType: 'UriLocation',
})
const [gziLocation, setGziLocation] = useState<{
uri: string
locationType: 'UriLocation'
}>({
uri: '',
locationType: 'UriLocation',
})
const [twoBitLocation, setTwoBitLocation] = useState<{
uri: string
locationType: 'UriLocation'
}>({
uri: '',
locationType: 'UriLocation',
})
const [chromSizesLocation, setChromSizesLocation] = useState<{
uri: string
locationType: 'UriLocation'
}>({
uri: '',
locationType: 'UriLocation',
})
const [fastaLocation, setFastaLocation] = useState(blank)
const [faiLocation, setFaiLocation] = useState(blank)
const [gziLocation, setGziLocation] = useState(blank)
const [twoBitLocation, setTwoBitLocation] = useState(blank)
const [chromSizesLocation, setChromSizesLocation] = useState(blank)

function createAssembly() {
if (assemblyName === '') {
rootModel.session.notify("Can't create an assembly without a name")
} else {
setFormOpen(false)
// setIsAssemblyBeingEdited(true)
let newAssembly
if (adapterSelection === 'IndexedFastaAdapter') {
newAssembly = {
Expand Down
52 changes: 1 addition & 51 deletions plugins/data-management/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import ConnectionType from '@jbrowse/core/pluggableElementTypes/ConnectionType'
import WidgetType from '@jbrowse/core/pluggableElementTypes/WidgetType'
import Plugin from '@jbrowse/core/Plugin'
import PluginManager from '@jbrowse/core/PluginManager'
import { SessionWithWidgets, isAbstractMenuManager } from '@jbrowse/core/util'
import NoteAddIcon from '@material-ui/icons/NoteAdd'
import InputIcon from '@material-ui/icons/Input'
import ExtensionIcon from '@material-ui/icons/Extension'
import {
configSchema as ucscConfigSchema,
modelFactory as ucscModelFactory,
Expand Down Expand Up @@ -105,53 +101,7 @@ export default class extends Plugin {
})
}

configure(pluginManager: PluginManager) {
if (isAbstractMenuManager(pluginManager.rootModel)) {
pluginManager.rootModel.appendToMenu('File', {
label: 'Open track',
icon: NoteAddIcon,
onClick: (session: SessionWithWidgets) => {
if (session.views.length === 0) {
session.notify('Please open a view to add a track first')
} else if (session.views.length >= 1) {
const widget = session.addWidget(
'AddTrackWidget',
'addTrackWidget',
{ view: session.views[0].id },
)
session.showWidget(widget)
if (session.views.length > 1) {
session.notify(
`This will add a track to the first view. Note: if you want to open a track in a specific view open the track selector for that view and use the add track (plus icon) in the bottom right`,
)
}
}
},
})
pluginManager.rootModel.appendToMenu('File', {
label: 'Open connection',
icon: InputIcon,
onClick: (session: SessionWithWidgets) => {
const widget = session.addWidget(
'AddConnectionWidget',
'addConnectionWidget',
)
session.showWidget(widget)
},
})
pluginManager.rootModel.appendToMenu('File', {
label: 'Plugin store',
icon: ExtensionIcon,
onClick: (session: SessionWithWidgets) => {
const widget = session.addWidget(
'PluginStoreWidget',
'pluginStoreWidget',
)
session.showWidget(widget)
},
})
}
}
configure(pluginManager: PluginManager) {}
}

export { AssemblyManager, SetDefaultSession }
2 changes: 1 addition & 1 deletion plugins/dotplot-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export default class DotplotPlugin extends Plugin {

configure(pluginManager: PluginManager) {
if (isAbstractMenuManager(pluginManager.rootModel)) {
pluginManager.rootModel.appendToSubMenu(['File', 'Add'], {
pluginManager.rootModel.appendToSubMenu(['Add'], {
label: 'Dotplot view',
icon: TimelineIcon,
onClick: (session: AbstractSessionModel) => {
Expand Down
24 changes: 15 additions & 9 deletions plugins/linear-comparative-view/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
DialogTitle,
IconButton,
} from '@material-ui/core'
import CloseIcon from '@material-ui/icons/Close'
import AddIcon from '@material-ui/icons/Add'
import CalendarIcon from '@material-ui/icons/CalendarViewDay'

import { ConfigurationSchema, getConf } from '@jbrowse/core/configuration'
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
import DisplayType from '@jbrowse/core/pluggableElementTypes/DisplayType'
Expand All @@ -34,12 +32,20 @@ import {
getContainingTrack,
isAbstractMenuManager,
} from '@jbrowse/core/util'

import {
MismatchParser,
LinearPileupDisplayModel,
} from '@jbrowse/plugin-alignments'
import { getRpcSessionId } from '@jbrowse/core/util/tracks'
import { PluggableElementType } from '@jbrowse/core/pluggableElementTypes'
import ViewType from '@jbrowse/core/pluggableElementTypes/ViewType'

// icons
import CloseIcon from '@material-ui/icons/Close'
import AddIcon from '@material-ui/icons/Add'
import CalendarIcon from '@material-ui/icons/CalendarViewDay'
// locals
//
import {
configSchemaFactory as linearComparativeDisplayConfigSchemaFactory,
ReactComponent as LinearComparativeDisplayReactComponent,
Expand All @@ -59,9 +65,6 @@ import {
AdapterClass as MCScanAnchorsAdapter,
configSchema as MCScanAnchorsConfigSchema,
} from './MCScanAnchorsAdapter'
import { PluggableElementType } from '@jbrowse/core/pluggableElementTypes'
import ViewType from '@jbrowse/core/pluggableElementTypes/ViewType'

const { parseCigar } = MismatchParser

function getLengthOnRef(cigar: string) {
Expand Down Expand Up @@ -189,14 +192,17 @@ interface BasicFeature {
refName: string
}

// hashmap of refName->array of features
type FeaturesPerRef = { [key: string]: BasicFeature[] }

function gatherOverlaps(regions: BasicFeature[]) {
const groups = regions.reduce((memo, x) => {
if (!memo[x.refName]) {
memo[x.refName] = []
}
memo[x.refName].push(x)
return memo
}, {} as { [key: string]: BasicFeature[] })
}, {} as FeaturesPerRef)

return Object.values(groups)
.map(group => mergeIntervals(group.sort((a, b) => a.start - b.start)))
Expand Down Expand Up @@ -707,7 +713,7 @@ export default class extends Plugin {

configure(pluginManager: PluginManager) {
if (isAbstractMenuManager(pluginManager.rootModel)) {
pluginManager.rootModel.appendToSubMenu(['File', 'Add'], {
pluginManager.rootModel.appendToSubMenu(['Add'], {
label: 'Linear synteny view',
icon: CalendarIcon,
onClick: (session: AbstractSessionModel) => {
Expand Down
2 changes: 1 addition & 1 deletion plugins/linear-genome-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default class LinearGenomeViewPlugin extends Plugin {

configure(pluginManager: PluginManager) {
if (isAbstractMenuManager(pluginManager.rootModel)) {
pluginManager.rootModel.appendToSubMenu(['File', 'Add'], {
pluginManager.rootModel.appendToSubMenu(['Add'], {
label: 'Linear genome view',
icon: LineStyleIcon,
onClick: (session: AbstractSessionModel) => {
Expand Down
2 changes: 1 addition & 1 deletion plugins/spreadsheet-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class SpreadsheetViewPlugin extends Plugin {

configure(pluginManager: PluginManager) {
if (isAbstractMenuManager(pluginManager.rootModel)) {
pluginManager.rootModel.appendToSubMenu(['File', 'Add'], {
pluginManager.rootModel.appendToSubMenu(['Add'], {
label: 'Spreadsheet view',
icon: ViewComfyIcon,
onClick: (session: AbstractSessionModel) => {
Expand Down
2 changes: 1 addition & 1 deletion plugins/sv-inspector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class SvInspectorViewPlugin extends Plugin {

configure(pluginManager: PluginManager) {
if (isAbstractMenuManager(pluginManager.rootModel)) {
pluginManager.rootModel.appendToSubMenu(['File', 'Add'], {
pluginManager.rootModel.appendToSubMenu(['Add'], {
label: 'SV inspector',
icon: TableChartIcon,
onClick: (session: AbstractSessionModel) => {
Expand Down
Loading