From 5621fe5a6f0493db6ad2dbd694de68808006b8a4 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 --- .../__snapshots__/index.test.tsx.snap | 4 +- packages/product-core/src/ui/AboutDialog.tsx | 6 +- .../src/ui/AboutDialogContents.tsx | 47 ++++++---- ...ameInfoPanel.tsx => RefNameInfoDialog.tsx} | 85 +++++++++++-------- .../__snapshots__/index.test.tsx.snap | 1 - .../VariantFeatureWidget.test.tsx.snap | 1 - 6 files changed, 88 insertions(+), 56 deletions(-) rename packages/product-core/src/ui/{RefNameInfoPanel.tsx => RefNameInfoDialog.tsx} (53%) diff --git a/packages/core/BaseFeatureWidget/__snapshots__/index.test.tsx.snap b/packages/core/BaseFeatureWidget/__snapshots__/index.test.tsx.snap index 312e8ff114..b7da2e829e 100644 --- a/packages/core/BaseFeatureWidget/__snapshots__/index.test.tsx.snap +++ b/packages/core/BaseFeatureWidget/__snapshots__/index.test.tsx.snap @@ -16,9 +16,7 @@ exports[`open up a widget 1`] = ` > - - + />
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'
+                    : ''}
+                
+
+
- - )} - + )} +
+
) }) diff --git a/plugins/alignments/src/AlignmentsFeatureDetail/__snapshots__/index.test.tsx.snap b/plugins/alignments/src/AlignmentsFeatureDetail/__snapshots__/index.test.tsx.snap index da2408f543..4822e633fe 100644 --- a/plugins/alignments/src/AlignmentsFeatureDetail/__snapshots__/index.test.tsx.snap +++ b/plugins/alignments/src/AlignmentsFeatureDetail/__snapshots__/index.test.tsx.snap @@ -21,7 +21,6 @@ exports[`open up a widget 1`] = ` - ctgA_3_555_0:0:0_2:0... - match
diff --git a/plugins/variants/src/VariantFeatureWidget/__snapshots__/VariantFeatureWidget.test.tsx.snap b/plugins/variants/src/VariantFeatureWidget/__snapshots__/VariantFeatureWidget.test.tsx.snap index 78f198f136..3934e89853 100644 --- a/plugins/variants/src/VariantFeatureWidget/__snapshots__/VariantFeatureWidget.test.tsx.snap +++ b/plugins/variants/src/VariantFeatureWidget/__snapshots__/VariantFeatureWidget.test.tsx.snap @@ -21,7 +21,6 @@ exports[`renders with just the required model elements 1`] = ` - rs123