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

Austenem/CAT-883, CAT-914, CAT-870, CAT-868 #3552

Merged
merged 6 commits into from
Oct 1, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG-many-minor-bug-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Fix positioning of dropdown order menu on the tile view of the search page.
- Fix tabs moving around in bulk data transfer section on detail pages.
- Update unified datasets link in "What’s New" section on homepage to point to an example dataset detail page.
- Adjust size of "summary" view in entity headers dynamically based on the length of the content.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function useProcessedDatasetTabs(): { label: string; uuid: string; icon:

// Include dataset status in the label if more than one processed dataset of this type exists.
// This allows us to distinguish between published datasets and QA/New/other statuses.
const processedDatasetTabs = searchHits
const processedDatasetTabs = [...searchHits]
// Prioritize published datasets
.sort((a, b) => {
if (a._source.status === 'Published') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect } from 'react';
import React, { useCallback, useEffect, useRef } from 'react';
import { animated } from '@react-spring/web';
import Box from '@mui/material/Box';

Expand All @@ -19,22 +19,36 @@ const visualizationSelector = (state: VisualizationStore) => ({
});

function Header() {
const { springs, view, setView } = useEntityStore();
const { springs, view, setView, summaryHeight, setSummaryHeight } = useEntityStore();
const startViewChangeSpring = useStartViewChangeSpring();
const isLargeDesktop = useIsLargeDesktop();
const { vizIsFullscreen } = useVisualizationStore(visualizationSelector);

const { entity } = useFlaskDataContext();
const uuid = entity?.uuid;

const summaryBodyRef = useRef<HTMLDivElement | null>(null);

const handleViewChange = useCallback(
(v: SummaryViewsType) => {
setView(v);
startViewChangeSpring(v);

// Delay height ref calculation to allow DOM to fully render
setTimeout(() => {
if (summaryBodyRef.current) {
const newHeight = summaryBodyRef.current.offsetHeight;
setSummaryHeight(newHeight);
}
}, 0);
},
[startViewChangeSpring, setView],
[setView, setSummaryHeight],
);

const { entity } = useFlaskDataContext();

const uuid = entity?.uuid;
useEffect(() => {
if (summaryHeight !== 0) {
startViewChangeSpring(view);
}
}, [summaryHeight, view, startViewChangeSpring]);

useEffect(() => {
if (vizIsFullscreen) {
Expand All @@ -53,7 +67,7 @@ function Header() {
<Box>
<EntityHeaderContent setView={handleViewChange} view={view} />
{isLargeDesktop && (
<Box height={expandedHeights[view]} width="100%" p={2}>
<Box ref={summaryBodyRef} height={expandedHeights[view]} width="100%" p={2}>
{view === 'diagram' && uuid && <DatasetRelationships uuid={uuid} processing="raw" showHeader={false} />}
{view === 'summary' && <SummaryBody direction="row" spacing={2} component={Box} isEntityHeader />}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ export const initialHeaderOffset = headerHeight + 16;

const expandedHeights = {
diagram: 300,
summary: 150,
summary: 'fit-content',
narrow: 0,
};

function useTotalHeaderOffset() {
const { view } = useEntityStore();
const { view, summaryHeight } = useEntityStore();
const contentHeight = view === 'summary' ? summaryHeight : expandedHeights[view];

return expandedHeights[view] + initialEntityHeaderHeight + headerHeight;
return contentHeight + initialEntityHeaderHeight + headerHeight;
}

function useEntityHeaderSprings() {
Expand All @@ -39,25 +40,27 @@ function useEntityHeaderSprings() {
}

function useStartViewChangeSpring() {
const { springs } = useEntityStore();
const { springs, summaryHeight } = useEntityStore();

const [, springAPIs] = springs;

return useCallback(
(view: SummaryViewsType) => {
const isExpanded = view !== 'narrow';
const contentHeight = view === 'summary' ? summaryHeight : expandedHeights[view];

async function startSprings() {
await Promise.all(
springAPIs.start((springIndex: number) => {
if (springIndex === 0) {
return {
height: isExpanded ? expandedHeights[view] + initialEntityHeaderHeight : initialEntityHeaderHeight,
height: isExpanded ? contentHeight + initialEntityHeaderHeight : initialEntityHeaderHeight,
};
}
if (springIndex === 1) {
return {
top: isExpanded
? initialHeaderOffset + expandedHeights[view] + initialEntityHeaderHeight
? contentHeight + initialEntityHeaderHeight + initialHeaderOffset
: initialHeaderOffset + initialEntityHeaderHeight,
};
}
Expand All @@ -68,7 +71,7 @@ function useStartViewChangeSpring() {
}
startSprings().catch((e) => console.error(e));
},
[springAPIs],
[springAPIs, summaryHeight],
);
}

Expand Down
2 changes: 1 addition & 1 deletion context/app/static/js/components/home/Hero/const.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const timelineIconProps = {
export const HOME_TIMELINE_ITEMS: TimelineData[] = [
{
title: 'Raw & Processed Unified Datasets Page',
titleHref: '/search?entity_type[0]=Dataset',
titleHref: '/browse/dataset/8690897fced9931da34d66d669c1d698',
description:
'Dataset page design has been updated to display both raw and processed data on the same page, enhancing the understanding of relationships between datasets.',
date: 'August 2024',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Stack from '@mui/material/Stack';

const StyledDropdownMenuButton = styled(DropdownMenuButton)(({ theme }) => ({
margin: theme.spacing(0, 1),
height: theme.spacing(5),
}));

const StyledInfoIcon = styled(InfoIcon)(({ theme }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ interface StyledButtonProps {

// must use display: none instead of conditional rendering to preserve sort history between views
const StyledButton = styled(Button)<StyledButtonProps>(({ theme, $searchView }) => ({
marginLeft: theme.spacing(1),
color: 'white',
margin: theme.spacing(0, 1),
height: theme.spacing(5),
marginRight: theme.spacing(1),
borderRadius: theme.spacing(0.5),
alignItems: 'center',
justifyContent: 'center',
color: 'white',
width: '185px',
display: $searchView === 'table' ? 'none' : 'block',
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDownRounded';
import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUpRounded';
import ClickAwayListener from '@mui/material/ClickAwayListener';
import MenuList from '@mui/material/MenuList';

import Typography from '@mui/material/Typography';
import Stack from '@mui/material/Stack';
import { StyledPopper, StyledPaper } from './style';

interface DropdownListboxProps<T> {
Expand Down Expand Up @@ -47,8 +48,12 @@ function DropdownListbox<T>({
onClick={() => setIsOpen(true)}
{...buttonProps}
>
{getOptionLabel(options[selectedOptionIndex])}
{isOpen ? <ArrowDropUpIcon /> : <ArrowDropDownIcon />}
<Stack direction="row" alignItems="center" justifyContent="flex-end">
<Typography variant="inherit" flexGrow={1} display="flex" justifyContent="center">
{getOptionLabel(options[selectedOptionIndex])}
</Typography>
{isOpen ? <ArrowDropUpIcon /> : <ArrowDropDownIcon />}
</Stack>
</SelectionButton>
<StyledPopper open={isOpen} anchorEl={anchorRef.current} placement="bottom-start">
<StyledPaper>
Expand Down
4 changes: 4 additions & 0 deletions context/app/static/js/stores/useEntityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface EntityStoreState {
};
assayMetadata: Partial<AssayMetadata>;
shouldDisplaySavedOrEditedAlert: boolean | string;
summaryHeight: number;
view: SummaryViewsType;
springs: ReturnType<typeof useSprings>;
}
Expand All @@ -23,6 +24,7 @@ interface EntityStoreActions {
setSummaryComponentObserver: (inView: boolean, entry: IntersectionObserverEntry) => void;
setAssayMetadata: (val: Partial<AssayMetadata>) => void;
setShouldDisplaySavedOrEditedAlert: (val: boolean | string) => void;
setSummaryHeight: (val: number) => void;
setView: (val: SummaryViewsType) => void;
}

Expand All @@ -41,6 +43,8 @@ export const createEntityStore = ({ springs }: { springs: ReturnType<typeof useS
summaryEntry: entry,
},
}),
summaryHeight: 0,
setSummaryHeight: (val: number) => set({ summaryHeight: val }),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocker, just an idea:

Suggested change
setSummaryHeight: (val: number) => set({ summaryHeight: val }),
setSummaryHeight: (summaryHeight: number) => set({ summaryHeight }),

view: 'narrow' as const,
setView: (val) => set({ view: val }),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, could have the arg be named "view" here 😄

springs,
Expand Down
Loading