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

feat: archive movement informational tooltip #8617

Merged
merged 1 commit into from
Nov 1, 2024
Merged
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
56 changes: 52 additions & 4 deletions frontend/src/component/filter/AddFilterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { Icon, styled } from '@mui/material';
import Add from '@mui/icons-material/Add';
import { Box } from '@mui/system';
import type { IFilterItem } from './Filters/Filters';
import { FILTERS_MENU } from '../../utils/testIds';
import { FILTERS_MENU } from 'utils/testIds';
import { useUiFlag } from 'hooks/useUiFlag';
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
import useSplashApi from 'hooks/api/actions/useSplashApi/useSplashApi';
import { useAuthSplash } from 'hooks/api/getters/useAuth/useAuthSplash';

const StyledButton = styled(Button)(({ theme }) => ({
padding: theme.spacing(0, 1.25, 0, 1.25),
Expand Down Expand Up @@ -42,7 +46,14 @@ export const AddFilterButton = ({
setHiddenOptions,
availableFilters,
}: IAddFilterButtonProps) => {
const simplifyProjectOverview = useUiFlag('simplifyProjectOverview');
const { setSplashSeen } = useSplashApi();
const { splash } = useAuthSplash();

const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const [archiveTooltipOpen, setArchiveTooltipOpen] = useState(
!splash?.simplifyProjectOverview,
);

const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
Expand All @@ -60,11 +71,48 @@ export const AddFilterButton = ({
handleClose();
};

const ArchiveTooltip = () => {
return (
<Box>
<Box>
Archived flags are now accessible via the{' '}
<b>Show only archived</b> filter option.
</Box>
<Box
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a button, I think.

onClick={() => {
setArchiveTooltipOpen(false);
setSplashSeen('simplifyProjectOverview');
}}
sx={(theme) => ({
color: theme.palette.primary.dark,
cursor: 'pointer',
})}
>
Got it
</Box>
</Box>
);
};
return (
<div>
<StyledButton onClick={handleClick} startIcon={<Add />}>
Add Filter
</StyledButton>
{simplifyProjectOverview ? (
<HtmlTooltip
placement='right'
arrow
title={<ArchiveTooltip />}
describeChild
open={archiveTooltipOpen}
>
<StyledButton onClick={handleClick} startIcon={<Add />}>
Add Filter
</StyledButton>
</HtmlTooltip>
) : (
<StyledButton onClick={handleClick} startIcon={<Add />}>
Add Filter
</StyledButton>
)}

<Menu
id='simple-menu'
data-testid={FILTERS_MENU}
Expand Down
Loading