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

HelpScout Tasks Search #1120

Merged
merged 4 commits into from
Oct 7, 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const ContactsWrapper: React.FC<Props> = ({ children }) => {
urlFilters ?? {},
);
const [starredFilter, setStarredFilter] = useState<ContactFilterSetInput>({});
const [filterPanelOpen, setFilterPanelOpen] = useState<boolean>(false);
const [filterPanelOpen, setFilterPanelOpen] = useState<boolean>(true);
const sanitizedFilters = useMemo(
() => sanitizeFilters(activeFilters),
[activeFilters],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const TasksPage: React.FC = () => {
const urlFilters =
query?.filters && JSON.parse(decodeURI(query.filters as string));

const [filterPanelOpen, setFilterPanelOpen] = useState<boolean>(false);
const [filterPanelOpen, setFilterPanelOpen] = useState<boolean>(true);
const [activeFilters, setActiveFilters] = useState<TaskFilterSetInput>(
urlFilters ?? {},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { styled } from '@mui/material/styles';
import { DateTime } from 'luxon';
import { useTranslation } from 'react-i18next';
import { InfiniteList } from 'src/components/InfiniteList/InfiniteList';
import { ListHeaderCheckBoxState } from 'src/components/Shared/Header/ListHeader';
import {
ListHeaderCheckBoxState,
PageEnum,
} from 'src/components/Shared/Header/ListHeader';
import { StarFilterButton } from 'src/components/Shared/Header/StarFilterButton/StarFilterButton';
import { TasksMassActionsDropdown } from 'src/components/Shared/MassActions/TasksMassActionsDropdown';
import { TaskModalEnum } from 'src/components/Task/Modal/TaskModal';
Expand Down Expand Up @@ -227,6 +230,7 @@ export const ContactTasksTab: React.FC<ContactTasksTabProps> = ({
showContactSearchIcon={false}
onChange={setSearchTerm}
placeholder={t('Search Tasks')}
page={PageEnum.Task}
/>
</HeaderItemsWrap>
<HeaderItemsWrap>
Expand Down
15 changes: 6 additions & 9 deletions src/components/Dashboard/Welcome/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ const Welcome = ({ firstName }: Props): ReactElement => {
const { appName } = useGetAppSettings();
const currentHour = today.hour;

let greeting = firstName
? t('Good Evening, {{ firstName }}.', { firstName })
: t('Good Evening,');
let greeting = t('Good Evening,');

if (currentHour < 12) {
greeting = firstName
? t('Good Morning, {{ firstName }}.', { firstName })
: t('Good Morning,');
greeting = t('Good Morning,');
} else if (currentHour < 18) {
greeting = firstName
? t('Good Afternoon, {{ firstName }}.', { firstName })
: t('Good Afternoon,');
greeting = t('Good Afternoon,');
}
if (firstName) {
greeting += ` ${firstName}.`;
}

return (
Expand Down
26 changes: 18 additions & 8 deletions src/components/Shared/Header/ListHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,16 @@ const ButtonGroup: React.FC = () => {

describe('ListHeader', () => {
describe('Contact', () => {
it('renders contact header', () => {
const { getByPlaceholderText, getByTestId, getByText } = render(
<Components />,
);
it('renders contact header', async () => {
const { getByPlaceholderText, getByTestId, getByText, findByText } =
render(<Components />);
const searchBox = getByPlaceholderText('Search Contacts');
expect(searchBox).toBeInTheDocument();

expect(getByPlaceholderText('Search Contacts')).toBeInTheDocument();
userEvent.hover(searchBox);
expect(
await findByText('Search by name, phone, email, or partner #'),
).toBeVisible();
expect(getByText('Actions')).toBeInTheDocument();
expect(getByTestId('star-filter-button')).toBeInTheDocument();
expect(getByTestId('showing-text')).toBeInTheDocument();
Expand Down Expand Up @@ -214,12 +218,18 @@ describe('ListHeader', () => {
});

describe('Task', () => {
it('renders task header', () => {
const { getByPlaceholderText } = render(
it('renders task header', async () => {
const { getByPlaceholderText, findByText } = render(
<Components page={PageEnum.Task} />,
);

expect(getByPlaceholderText('Search Tasks')).toBeVisible();
const searchBox = getByPlaceholderText('Search Tasks');
expect(searchBox).toBeVisible();

userEvent.hover(searchBox);
expect(
await findByText('Search by subject, tags, contact name, or comments'),
).toBeVisible();
});
});

Expand Down
1 change: 1 addition & 0 deletions src/components/Shared/Header/ListHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export const ListHeader: React.FC<ListHeaderProps> = ({
placeholder={
page === PageEnum.Task ? t('Search Tasks') : t('Search Contacts')
}
page={page}
/>
<Hidden smDown>
<ItemsShowingText data-testid="showing-text">
Expand Down
90 changes: 51 additions & 39 deletions src/components/common/SearchBox/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
import Icon from '@mdi/react';
import Close from '@mui/icons-material/Close';
import SearchIcon from '@mui/icons-material/Search';
import { IconButton, InputAdornment, TextField } from '@mui/material';
import { IconButton, InputAdornment, TextField, Tooltip } from '@mui/material';
import { styled } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { PageEnum } from 'src/components/Shared/Header/ListHeader';

export interface SearchBoxProps {
onChange: (searchTerm: string) => void;
searchTerm?: string | string[];
placeholder?: string;
showContactSearchIcon: boolean;
page?: PageEnum;
}

const SearchInput = styled(TextField)(() => ({
Expand All @@ -25,6 +27,7 @@
searchTerm,
placeholder,
showContactSearchIcon,
page,
}) => {
const { t } = useTranslation();
const [currentSearchTerm, setSearchTerm] = useState(searchTerm ?? '');
Expand All @@ -41,43 +44,52 @@
};

return (
<SearchInput
size="small"
variant="outlined"
sx={{ width: { sm: '27ch', md: '31ch' } }}
onChange={(e) => handleOnChange(e.target.value)}
placeholder={placeholder ?? t('Search')}
value={currentSearchTerm}
InputProps={{
startAdornment: (
<InputAdornment position="start">
{showContactSearchIcon ? (
<Icon path={mdiAccountSearch} size={1} />
) : (
<SearchIcon />
)}
</InputAdornment>
),
endAdornment: (
<InputAdornment position="end">
{currentSearchTerm && (
<IconButton
onClick={() => handleOnChange('')}
data-testid="SearchInputCloseButton"
>
<Close
titleAccess={t('Close')}
sx={{
width: 14,
height: 14,
color: 'text.primary',
}}
/>
</IconButton>
)}
</InputAdornment>
),
}}
/>
<Tooltip
arrow
title={
page === PageEnum.Task
? t('Search by subject, tags, contact name, or comments')
: t('Search by name, phone, email, or partner #')
}
>
<SearchInput
size="small"
variant="outlined"
sx={{ width: { sm: '27ch', md: '31ch' } }}
onChange={(e) => handleOnChange(e.target.value)}
placeholder={placeholder ?? t('Search')}
value={currentSearchTerm}
InputProps={{
startAdornment: (
<InputAdornment position="start">
{showContactSearchIcon ? (
<Icon path={mdiAccountSearch} size={1} />
) : (
<SearchIcon />
)}
</InputAdornment>
),
endAdornment: (
<InputAdornment position="end">
{currentSearchTerm && (
<IconButton
onClick={() => handleOnChange('')}

Check warning on line 76 in src/components/common/SearchBox/SearchBox.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/common/SearchBox/SearchBox.tsx#L76

Added line #L76 was not covered by tests
data-testid="SearchInputCloseButton"
>
<Close
titleAccess={t('Close')}
sx={{
width: 14,
height: 14,
color: 'text.primary',
}}
/>
</IconButton>
)}
</InputAdornment>
),
}}
/>
</Tooltip>
);
};
Loading