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

#40, #41, #43 - add jbrowse circular #184

Merged
merged 50 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f481a4d
add mobile warning
samrichca Sep 6, 2023
9da35f7
change mobile view
samrichca Sep 6, 2023
1767548
add feature flag
samrichca Sep 6, 2023
6f18860
Update components/pages/explorer/MobileWarning.tsx
samrichca Sep 7, 2023
617dc68
Merge branch 'feat/jbrowsemvp-arranger3' into 26-mobile-message-overlay
samrichca Sep 11, 2023
b647dfc
remove duplicate import
samrichca Sep 12, 2023
9865b7e
rename jbrowse to genome viewer
samrichca Sep 12, 2023
9caa2f5
fix mobile warning css
samrichca Sep 12, 2023
625c268
add basic circular chart
samrichca Sep 14, 2023
a554eb8
Merge branch 'feat/jbrowsemvp-arranger3' into 39-jbrowse-circular
samrichca Sep 14, 2023
f32e815
Merge branch 'feat/jbrowsemvp-arranger3' of github.com:overture-stack…
samrichca Sep 15, 2023
9ec9be9
Merge branch '39-jbrowse-circular' of github.com:overture-stack/dms-u…
samrichca Sep 15, 2023
e6f7abc
formatter
samrichca Sep 15, 2023
edbd196
wip jbrowse button
samrichca Sep 18, 2023
635c79a
add jbrowse button
samrichca Sep 19, 2023
47dc5e0
jbrowse loading
samrichca Sep 19, 2023
e14e78a
wip button
samrichca Sep 19, 2023
42d18c8
WIP error handling
samrichca Sep 19, 2023
3da3f83
wip compatibilty for button
samrichca Sep 20, 2023
847153e
finish tabs
samrichca Sep 20, 2023
ad4b263
update comment
samrichca Sep 20, 2023
a79979b
PR cleanup
samrichca Sep 20, 2023
f61ccdd
formatting
samrichca Sep 20, 2023
234fa46
formatting
samrichca Sep 20, 2023
e7ff70b
formatting
samrichca Sep 20, 2023
0f53cba
adjust button placement & dropdown width
samrichca Sep 20, 2023
ed4ebe5
remove scrollbar on dropdown
samrichca Sep 20, 2023
d972d46
fix scrolling & tooltip
samrichca Sep 20, 2023
d805d6d
Merge branch 'feat/jbrowsemvp-arranger3' into 41-jbrowse-btn-dropdown
samrichca Sep 20, 2023
7424a2c
Update components/pages/explorer/Jbrowse/JbrowseLaunchButton.tsx
samrichca Sep 21, 2023
b379ac1
PR update
samrichca Sep 21, 2023
0b72972
Merge branch '41-jbrowse-btn-dropdown' of github.com:overture-stack/d…
samrichca Sep 21, 2023
4c5d8b1
wip
samrichca Sep 22, 2023
a3e4bd9
wip
samrichca Sep 22, 2023
04d305e
feedback
samrichca Sep 22, 2023
aff2c76
wip
samrichca Sep 25, 2023
e8f9c7e
update types
samrichca Sep 26, 2023
52c0604
update type name
samrichca Sep 26, 2023
ad88f43
make jbrowse titles a constant
samrichca Sep 26, 2023
83f788d
update dms jbrowse
samrichca Sep 27, 2023
a2722bd
start new tab context - types
samrichca Sep 27, 2023
eaa6816
wip revert to specific tabs context
samrichca Sep 27, 2023
a7028da
finish reverting to repo tabs context
samrichca Sep 27, 2023
dda3baf
remove debug
samrichca Sep 27, 2023
96bb151
define onclick function
samrichca Sep 28, 2023
b0aa47b
abstract click handler from render (#188)
justincorrigible Sep 28, 2023
fe61d6c
fix type
samrichca Sep 28, 2023
7104df8
Merge branch '41-jbrowse-btn-dropdown' of github.com:overture-stack/d…
samrichca Sep 28, 2023
850076d
make an arrow func
samrichca Sep 28, 2023
4159830
remove undefined active tab
samrichca Sep 28, 2023
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
67 changes: 33 additions & 34 deletions components/pages/explorer/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,46 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { ColumnsSelectButton, DownloadButton } from '@overture-stack/arranger-components';
import { useTabsContext } from './TabsContext';
import { RepositoryTabNames } from './RepositoryContent';
import JbrowseLaunchButton from './Jbrowse/JbrowseLaunchButton';
import { useRepositoryTabsContext } from './RepositoryTabsContext';
import { RepositoryTabKey } from './types';

export const ButtonWrapper = styled('div')`
margin-left: 0.3rem;
margin-bottom: 0.3rem;
margin-left: 0.3rem;
margin-bottom: 0.3rem;
`;

const ActionBar = () => {
const { activeTab } = useTabsContext();
const { activeTab } = useRepositoryTabsContext();

return (
<div
className="buttons"
css={css`
display: flex;
list-style: none;
margin: 0 0 0 -0.3rem;
justify-content: space-between;
align-items: center;
padding: 0;
`}
>
<JbrowseLaunchButton />
<div
css={css`
display: flex;
`}
>
{activeTab === RepositoryTabNames.FILES && (
<ButtonWrapper>
<ColumnsSelectButton />
</ButtonWrapper>
)}
<ButtonWrapper>
<DownloadButton />
</ButtonWrapper>
</div>
</div>
);
return (
<div
className="buttons"
css={css`
display: flex;
list-style: none;
justify-content: space-between;
align-items: center;
padding: 0;
`}
>
<JbrowseLaunchButton />
<div
css={css`
display: flex;
`}
>
{activeTab === RepositoryTabKey.FILES && (
<ButtonWrapper>
<ColumnsSelectButton />
</ButtonWrapper>
)}
<ButtonWrapper>
<DownloadButton />
</ButtonWrapper>
</div>
</div>
);
};

export default ActionBar;
170 changes: 118 additions & 52 deletions components/pages/explorer/Jbrowse/JbrowseLaunchButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,65 +19,131 @@
*
*/

import Button from '@/components/Button';
import { getDropdownTheme } from '@/components/theme/getDropdownTheme';
samrichca marked this conversation as resolved.
Show resolved Hide resolved
import { Spinner } from '@/components/theme/icons';
import { CustomTooltip } from '@/components/Tooltip';
import { css, useTheme } from '@emotion/react';
import { TransparentButton } from '@overture-stack/arranger-components/dist/Button';
import { MultiSelectDropDown } from '@overture-stack/arranger-components/dist/DropDown';
import { find } from 'lodash';
import { ButtonWrapper } from '../ActionBar';
import { RepositoryTabNames } from '../RepositoryContent';
import { useTabsContext } from '../TabsContext';
import { useRepositoryTabsContext } from '../RepositoryTabsContext';
import { RepositoryTabKey, RepositoryTabName } from '../types';
import useJbrowseCompatibility from './useJbrowseCompatibility';
import { jbrowseDict, JbrowseTitles } from './utils';

const JbrowseLaunchButton = () => {
const theme = useTheme();
const { handleChangeTab, handleOpenTab, openTabs } = useTabsContext();
const { jbrowseEnabled, jbrowseErrorText, jbrowseLoading } = useJbrowseCompatibility();
const theme = useTheme();
const { handleSwitchTab, handleUpdateTab, handleOpenTab, openTabs } = useRepositoryTabsContext();
const { jbrowseCircularError, jbrowseLinearError, jbrowseLoading } = useJbrowseCompatibility();

return (
<CustomTooltip
disabled={jbrowseEnabled}
unmountHTMLWhenHide
arrow
html={
<div
css={css`
${theme.typography.regular};
font-size: 12px;
`}
>
{jbrowseErrorText}
</div>
}
position="right"
>
<ButtonWrapper>
<Button
isLoading={jbrowseLoading}
css={css`
padding: 2px 10px;
`}
disabled={!jbrowseEnabled}
onClick={() => {
// go to jbrowse tab if open, otherwise add jbrowse tab
if (find(openTabs, { name: RepositoryTabNames.GENOME_VIEWER })) {
handleChangeTab(RepositoryTabNames.GENOME_VIEWER);
} else {
handleOpenTab({ name: RepositoryTabNames.GENOME_VIEWER, canClose: true });
}
}}
>
<div
css={css`
display: flex;
align-items: center;
`}
>
<span>{RepositoryTabNames.GENOME_VIEWER}</span>
</div>
</Button>
</ButtonWrapper>
</CustomTooltip>
);
const handleJbrowseSelect = (jbrowseOptionKey: RepositoryTabKey, closeDropDownFn: () => void) => {
const alternateJbrowseTab = find(openTabs, { name: RepositoryTabName.GENOME_VIEWER });
if (find(openTabs, { key: jbrowseOptionKey })) {
// if selected option has a tab open, go to that tab
handleSwitchTab(jbrowseOptionKey);
} else if (alternateJbrowseTab) {
// update existing jbrowse tab if available - only 1 jbrowse tab open at a time
handleUpdateTab(alternateJbrowseTab.key, { key: jbrowseOptionKey });
handleSwitchTab(jbrowseOptionKey);
} else {
handleOpenTab({
name: RepositoryTabName.GENOME_VIEWER,
key: jbrowseOptionKey,
canClose: true,
});
}
closeDropDownFn();
};

const dropdownTheme = getDropdownTheme(theme);

return (
<div
css={css`
.genome-viewer-dropdown * {
// stops scrollbar on dropdown
// positions tooltip properly
overflow: hidden !important;
}
`}
>
<MultiSelectDropDown
theme={{
...dropdownTheme,
width: '140px',
height: '30px',
ListWrapper: {
...dropdownTheme.ListWrapper,
css: css`
left: -2px;
right: auto;
width: 7em;
`,
},
}}
buttonAriaLabelClosed="Open Genome Viewer menu"
buttonAriaLabelOpen="Close Genome Viewer menu"
className="genome-viewer-dropdown"
itemSelectionLegend="Select one of the genome viewer options"
items={jbrowseDict.map(({ title }) => title)}
itemToString={(itemLabel: JbrowseTitles, closeDropDownFn) => {
const error =
(itemLabel === 'Linear View' && jbrowseLinearError) ||
(itemLabel === 'Circular View' && jbrowseCircularError);
samrichca marked this conversation as resolved.
Show resolved Hide resolved
return (
<CustomTooltip
css={css`
width: 100%;
button {
width: 100%;
}
`}
arrow
disabled={!error}
unmountHTMLWhenHide
html={
<div
css={css`
${theme.typography.regular};
font-size: 12px;
`}
>
{error}
</div>
}
position="left"
>
<TransparentButton
onClick={() => {
samrichca marked this conversation as resolved.
Show resolved Hide resolved
const { tabKey } = find(jbrowseDict, { title: itemLabel }) || {};
tabKey && handleJbrowseSelect(tabKey, closeDropDownFn);
}}
disabled={jbrowseLoading || !!error}
css={css`
:disabled {
color: ${theme.colors.grey_4};
}
`}
>
{itemLabel}
</TransparentButton>
</CustomTooltip>
);
}}
>
<div
css={css`
width: 105px;
display: flex;
align-items: center;
justify-content: center;
`}
>
{jbrowseLoading ? <Spinner fill={theme.colors.white} /> : RepositoryTabName.GENOME_VIEWER}
</div>
</MultiSelectDropDown>
</div>
);
};

export default JbrowseLaunchButton;
Loading