From 0b4f58e938e95b28c918a825d09b5cbb47be2074 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 12 Apr 2024 16:36:05 -0400 Subject: [PATCH] Rename panel to separate dialog --- packages/product-core/src/ui/AboutDialog.tsx | 6 +- .../src/ui/AboutDialogContents.tsx | 47 ++++++---- ...ameInfoPanel.tsx => RefNameInfoDialog.tsx} | 85 +++++++++++-------- 3 files changed, 87 insertions(+), 51 deletions(-) rename packages/product-core/src/ui/{RefNameInfoPanel.tsx => RefNameInfoDialog.tsx} (53%) diff --git a/packages/product-core/src/ui/AboutDialog.tsx b/packages/product-core/src/ui/AboutDialog.tsx index cbedf91198..66a6ec2ba8 100644 --- a/packages/product-core/src/ui/AboutDialog.tsx +++ b/packages/product-core/src/ui/AboutDialog.tsx @@ -3,7 +3,9 @@ import { AnyConfigurationModel } from '@jbrowse/core/configuration' import Dialog from '@jbrowse/core/ui/Dialog' import { getSession, getEnv } from '@jbrowse/core/util' import { getTrackName } from '@jbrowse/core/util/tracks' -import AboutContents from './AboutDialogContents' + +// locals +import AboutDialogContents from './AboutDialogContents' export function AboutDialog({ config, @@ -18,7 +20,7 @@ export function AboutDialog({ const AboutComponent = pluginManager.evaluateExtensionPoint( 'Core-replaceAbout', - AboutContents, + AboutDialogContents, { session, config }, // eslint-disable-next-line @typescript-eslint/no-explicit-any ) as React.FC diff --git a/packages/product-core/src/ui/AboutDialogContents.tsx b/packages/product-core/src/ui/AboutDialogContents.tsx index f45e0a323d..7ec34e3fc9 100644 --- a/packages/product-core/src/ui/AboutDialogContents.tsx +++ b/packages/product-core/src/ui/AboutDialogContents.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { Suspense, lazy, useState } from 'react' import clone from 'clone' import copy from 'copy-to-clipboard' import { Button } from '@mui/material' @@ -13,8 +13,12 @@ import { BaseCard, Attributes, } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail' + +// locals import FileInfoPanel from './FileInfoPanel' -import RefNamePanel from './RefNameInfoPanel' + +// lazies +const RefNameDialog = lazy(() => import('./RefNameInfoDialog')) const useStyles = makeStyles()({ content: { @@ -36,7 +40,7 @@ function removeAttr(obj: Record, attr: string) { return obj } -export default function AboutContents({ +export default function AboutDialogContents({ config, }: { config: AnyConfigurationModel @@ -45,7 +49,7 @@ export default function AboutContents({ const conf = readConfObject(config) const session = getSession(config) const { classes } = useStyles() - + const [shown, setShown] = useState(false) const hideUris = getConf(session, ['formatAbout', 'hideUris']) || readConfObject(config, ['formatAbout', 'hideUris']) @@ -74,20 +78,29 @@ export default function AboutContents({ return (
- {!hideUris ? ( +
+ {!hideUris ? ( + + ) : null} - ) : null} +
) : null} - + {shown ? ( + + setShown(false)} /> + + ) : null}
) } diff --git a/packages/product-core/src/ui/RefNameInfoPanel.tsx b/packages/product-core/src/ui/RefNameInfoDialog.tsx similarity index 53% rename from packages/product-core/src/ui/RefNameInfoPanel.tsx rename to packages/product-core/src/ui/RefNameInfoDialog.tsx index 1989599fdc..382cfb663d 100644 --- a/packages/product-core/src/ui/RefNameInfoPanel.tsx +++ b/packages/product-core/src/ui/RefNameInfoDialog.tsx @@ -1,15 +1,15 @@ import React, { useState, useEffect } from 'react' -import { Button, Typography } from '@mui/material' +import { Button, DialogContent, Typography } from '@mui/material' +import { observer } from 'mobx-react' +import { makeStyles } from 'tss-react/mui' +import { getSession } from '@jbrowse/core/util' import { readConfObject, AnyConfigurationModel, } from '@jbrowse/core/configuration' import LoadingEllipses from '@jbrowse/core/ui/LoadingEllipses' -import { getSession } from '@jbrowse/core/util' -import { BaseCard } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail' -import { observer } from 'mobx-react' -import { makeStyles } from 'tss-react/mui' import FieldName from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail/FieldName' +import { Dialog } from '@jbrowse/core/ui' import copy from 'copy-to-clipboard' const MAX_REF_NAMES = 10_000 @@ -24,12 +24,17 @@ const useStyles = makeStyles()(theme => ({ button: { float: 'right', }, + content: { + minWidth: 800, + }, })) const RefNamePanel = observer(function ({ config, + handleClose, }: { config: AnyConfigurationModel + handleClose: () => void }) { const [error, setError] = useState() const [refNames, setRefNames] = useState() @@ -72,36 +77,48 @@ const RefNamePanel = observer(function ({ }, [config, rpcManager]) return ( - - {error ? ( - {`${error}`} - ) : refNames === undefined ? ( - - ) : ( - <> - -
- -
-              {refNames.slice(0, MAX_REF_NAMES).join('\n')}
-              {refNames.length > MAX_REF_NAMES
-                ? '\nToo many refNames to show in browser, use "Copy ref names" button to copy to clipboard'
-                : ''}
-            
+ + + {error ? ( + {`${error}`} + ) : refNames === undefined ? ( + + ) : ( +
+ + + Reference sequence names used in track, listed one per line + +
+
+ +
+                  {refNames.slice(0, MAX_REF_NAMES).join('\n')}
+                  {refNames.length > MAX_REF_NAMES
+                    ? '\nToo many refNames to show in browser, use "Copy ref names" button to copy to clipboard'
+                    : ''}
+                
+
+
- - )} - + )} +
+
) })