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/global search phase 7 #2102

Merged
merged 99 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
0ebb736
Global Search: Add search page filters (#2008)
finnar-bin Apr 19, 2023
e408d35
Global Search: Search page wire filters (#2009)
finnar-bin Apr 24, 2023
669a21b
Global Search: Advanced search button & modal (#2012)
finnar-bin Apr 24, 2023
f3dfb63
Global Search: Wire advance search modal (#2015)
finnar-bin Apr 29, 2023
55c9ea4
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin May 2, 2023
349edc3
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin May 4, 2023
ef8f332
Global Search: Save/remove recent searches (#2029)
finnar-bin May 4, 2023
16d6e50
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin May 5, 2023
bce6af4
Global Search: Resource type filter (#2039)
finnar-bin May 15, 2023
42b6975
Global Search Phase 4: Schema searching (#2041)
finnar-bin May 24, 2023
9180b94
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin May 24, 2023
8e40006
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin May 26, 2023
cc473d2
Global Search: Include code files in top suggestions (#2048)
finnar-bin May 28, 2023
895c9d6
task: add files to sesarch page results
finnar-bin May 28, 2023
893df8c
task: add code file results to search page
finnar-bin May 30, 2023
c58497d
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin Jun 5, 2023
d139d8d
Merge branch 'feat/global-search-phase-5' of github.com:zesty-io/mana…
finnar-bin Jun 5, 2023
5fd82ee
task: add media to top suggestion results
finnar-bin Jun 6, 2023
ebe7d09
task: add media to resource filter
finnar-bin Jun 6, 2023
4c3acb7
task: skip media api call when there is no search term
finnar-bin Jun 6, 2023
2e35d2b
chore: cleanup
finnar-bin Jun 6, 2023
8365200
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin Jun 8, 2023
8ea3205
task: show media results in search page
finnar-bin Jun 8, 2023
1da6b60
task: fix incorrect render loading logic
finnar-bin Jun 8, 2023
e91a2d5
task: added skeleton placeholder for results when loading data
finnar-bin Jun 8, 2023
4af5f7a
task: show created at time for media files
finnar-bin Jun 9, 2023
4b32cd4
task: add media folders in top suggestion results
finnar-bin Jun 9, 2023
9edbc2b
chore: add docs
finnar-bin Jun 9, 2023
17cf5eb
task: add media folders in search page results
finnar-bin Jun 9, 2023
6b68e68
task: reset content data when api call fails
finnar-bin Jun 9, 2023
5b280bf
task: reset content data when api call fails
finnar-bin Jun 9, 2023
7beb966
chore: cleanup
finnar-bin Jun 9, 2023
5b3659c
task: add search accelerator buttons
finnar-bin Jun 13, 2023
c452bb5
task: fixed padding
finnar-bin Jun 13, 2023
36c1f5b
task: add search accelerator button click handler
finnar-bin Jun 13, 2023
5fb2af8
task: show selected search accelerator in input field
finnar-bin Jun 13, 2023
81b2115
task: show active search accelerator in search key term option
finnar-bin Jun 13, 2023
5a37533
task: only show search accelerators when no search accelerator is active
finnar-bin Jun 13, 2023
221230d
fix: mui errors
finnar-bin Jun 13, 2023
954dbe4
task: hide search accelerator when textfield is collapsed
finnar-bin Jun 13, 2023
4f26fc9
task: create hook to get active app
finnar-bin Jun 14, 2023
6ba7144
task: add dynamic search accelerator
finnar-bin Jun 14, 2023
665933b
task: wire dynamic search accelerator
finnar-bin Jun 14, 2023
ee35d29
task: only show related suggestions when search accelerator is active
finnar-bin Jun 14, 2023
79fd213
task: show recently modified suggestions when there is no value and s…
finnar-bin Jun 14, 2023
ea6b5e1
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin Jun 14, 2023
fc72279
task: prevent autocomplete dropdown from closing when input field is …
finnar-bin Jun 15, 2023
b00e26b
task: add resource type on search params when search accelerator is a…
finnar-bin Jun 15, 2023
54ddb0a
task: only navigate to search page when there is a value
finnar-bin Jun 15, 2023
754f963
chore: cleanup
finnar-bin Jun 15, 2023
f9e8dda
Merge branch 'feat/global-search-phase-6' of github.com:zesty-io/mana…
finnar-bin Jun 16, 2023
7d7c32e
task: added media chip config
finnar-bin Jun 16, 2023
4fac733
task: automatically set advanced search resource type when search acc…
finnar-bin Jun 16, 2023
370758c
task: fixed issue where media results showing up in schema
finnar-bin Jun 16, 2023
944c457
task: add search accelerator handling when user clicks the first top …
finnar-bin Jun 16, 2023
9d31148
task: add search accelerator handling when user clicks the first top …
finnar-bin Jun 16, 2023
202db90
task: save and render search accelerator in recently searched terms
finnar-bin Jun 16, 2023
ea65e48
task: extract on remove function
finnar-bin Jun 16, 2023
3aa2aea
task: create separate component for recent search item
finnar-bin Jun 16, 2023
5d90581
task: create separate component for the keyword search item
finnar-bin Jun 16, 2023
3c54a12
chore: edit comment
finnar-bin Jun 16, 2023
a908a73
task: set the search accelerator when a recent search item with an ac…
finnar-bin Jun 16, 2023
bbbe41a
task: get all media files when search accel is media and there is no …
finnar-bin Jun 18, 2023
d0165ea
task: render 5 skeleton loaders when an api call is ongoing
finnar-bin Jun 19, 2023
e09e09d
task: renamed ContentSearch to GlobalSearch
finnar-bin Jun 21, 2023
db98ef6
task: use GlobalSearch component in GlobalTopbar
finnar-bin Jun 21, 2023
d09f885
task: remove old global-search folder
finnar-bin Jun 21, 2023
ab39923
task: don't show skeleton loader when there is no value
finnar-bin Jun 21, 2023
33aa709
task: fixed failing test
finnar-bin Jun 21, 2023
9816831
task: cypress tests
finnar-bin Jun 21, 2023
28e932d
fix: fixed search page crashing when list is trying to load content r…
finnar-bin Jun 21, 2023
37aee1a
chore: cleanup
finnar-bin Jun 21, 2023
94d1296
fix: open dropdown when user clicks on the side of the search field o…
finnar-bin Jun 21, 2023
7537238
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin Jun 21, 2023
15eb84e
task: update usecallback deps
finnar-bin Jun 21, 2023
3ba75cc
fix: 2074 hide search accelerator when user inputs a search term
finnar-bin Jun 21, 2023
e7fb21e
chore: rename value to searchKeyword to be more descriptive
finnar-bin Jun 21, 2023
73cef10
fix: [2076] remove placeholder text when search accelerator is selected
finnar-bin Jun 22, 2023
1121bee
fix: [2085] update search accelerator subheader text
finnar-bin Jun 22, 2023
1e88a6a
fix: [2078] updated padding for search accelerator options
finnar-bin Jun 22, 2023
297046b
fix: [2086] do not clear search keyword when clicking search again
finnar-bin Jun 22, 2023
cd7b423
fix: [2077] add highlight styling when search accelerator suggestion …
finnar-bin Jun 23, 2023
aceaa53
task: moved render logic to inline
finnar-bin Jun 23, 2023
866336e
task: show no results screen when there is no search keyword
finnar-bin Jun 23, 2023
7041101
chore: rename query to keyword to be more descriptive
finnar-bin Jun 23, 2023
b46ddc8
fix: [2075] remove search accelerator when backspace is pressed
finnar-bin Jun 23, 2023
0e1f909
task: fixed padding
finnar-bin Jun 27, 2023
7601e7c
task: fixed padding
finnar-bin Jun 27, 2023
7dc9e65
task: changed search accel pill sorting
finnar-bin Jun 27, 2023
e094f4b
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin Jun 27, 2023
fdcfd32
Merge branch 'feat/global-search-phase-6' of github.com:zesty-io/mana…
finnar-bin Jun 27, 2023
4a41da5
chore: arrange imports
finnar-bin Jun 27, 2023
129fbbb
fix: fixed failing test
finnar-bin Jul 5, 2023
e99e6dd
fix: fixed failing test
finnar-bin Jul 5, 2023
917ce33
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin Jul 5, 2023
e4851e3
task: changed list subheader to typography
finnar-bin Jul 10, 2023
5965102
task: stick to default font-size
finnar-bin Jul 10, 2023
d201ee8
task: added readonly and as const
finnar-bin Jul 10, 2023
feedcd4
Merge branch 'master' of github.com:zesty-io/manager-ui into feat/glo…
finnar-bin Jul 10, 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
23 changes: 22 additions & 1 deletion cypress/e2e/search/search-bar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ describe("Global Search: Search Bar", () => {

// Verify that user is navigated to search page with correct search param
cy.location("pathname").should("equal", "/search");
cy.location("search").should("equal", `?q=${encodeURI(SEARCH_TERM)}`);
cy.location("search").should(
"equal",
`?q=${SEARCH_TERM.replaceAll(/\s/g, "+")}`
);
});

it("shows the search accelerators when search bar is opened", () => {
cy.waitOn(
"https://8-f48cf3a682-7fthvk.api.dev.zesty.io/v1/search/items*",
() => {
cy.visit("/search?q=cypress");
}
);

// Activate the global search bar
cy.getBySelector("global-search-textfield")
.find("input")
.should("exist")
.click();

// Verify that search accelerators are present
cy.getBySelector("global-search-accelerators").should("exist");
});
});
11 changes: 5 additions & 6 deletions src/shell/components/GlobalAccountMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ export const GlobalAccountMenu: FC<GlobalAccountMenuProps> = ({
>
<img src={youtubeIcon} alt="youtube" />
</IconButton>
<IconButton size="small">
<img
src={slackIcon}
alt="slack"
onClick={() => handleOpenUrl("https://www.zesty.io/chat/")}
/>
<IconButton
size="small"
onClick={() => handleOpenUrl("https://www.zesty.io/chat/")}
>
<img src={slackIcon} alt="slack" />
</IconButton>
</Stack>
</Menu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import {
import { DateFilterModal } from "../../../components/Filters/DateFilter/DateFilterModal";
import { DateRangeFilterModal } from "../../../components/Filters/DateFilter/DateRangeFilterModal";
import { PRESET_DATES, CUSTOM_DATES, RESOURCE_TYPES } from "./config";
import { ResourceType } from "../../../services/types";

type ResourceType = "content" | "schema" | null;
interface User {
firstName: string;
lastName: string;
Expand All @@ -45,17 +45,19 @@ export interface SearchData {
keyword: string;
user: User | null;
date: DateFilterValue | null;
resourceType: ResourceType;
resourceType: ResourceType | null;
}
interface AdvancedSearch {
keyword: string;
onClose: () => void;
onSearch?: (searchData: SearchData) => void;
searchAccelerator?: ResourceType | null;
}
export const AdvancedSearch: FC<AdvancedSearch> = ({
keyword,
onClose,
onSearch,
searchAccelerator = null,
}) => {
const history = useHistory();
const location = useLocation();
Expand Down Expand Up @@ -95,6 +97,14 @@ export const AdvancedSearch: FC<AdvancedSearch> = ({
}
}, [keyword]);

useEffect(() => {
// Automatically set the resource type value when the user has already set
// a search accelerator on the search box input field
if (Boolean(searchAccelerator)) {
updateSearchData({ resourceType: searchAccelerator });
}
}, [searchAccelerator]);

const handleSetSelectedDate = ({
type,
value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,43 @@ import {
SvgIcon,
ListItemSecondaryAction,
IconButton,
Chip,
} from "@mui/material";
import { SvgIconComponent } from "@mui/icons-material";
import CloseIcon from "@mui/icons-material/Close";

import { ResourceType } from "../../../services/types";
import { SEARCH_ACCELERATORS } from "./config";

type GlobalSearchItemProps = HTMLAttributes<HTMLLIElement> & {
text: string;
icon: SvgIconComponent;
isRemovable?: boolean;
onRemove?: (keyword: string) => void;
searchAccelerator?: ResourceType | null;
};
export const GlobalSearchItem: FC<GlobalSearchItemProps> = ({
text,
icon,
isRemovable = false,
onRemove,
searchAccelerator,
...props
}) => {
const onRequestRemove = () => {
if (!onRemove) {
return;
}

// Makes sure that we're removing the exact option containing the
// search accelerator if it was saved with it.
if (searchAccelerator) {
onRemove(`[in:${searchAccelerator}] ${text}`);
} else {
onRemove(text);
}
};

return (
<ListItem
{...props}
Expand All @@ -49,6 +69,17 @@ export const GlobalSearchItem: FC<GlobalSearchItemProps> = ({
<ListItemIcon sx={{ width: "32px", minWidth: "32px" }}>
<SvgIcon component={icon} fontSize="small" />
</ListItemIcon>
{Boolean(searchAccelerator) && (
<Chip
variant="filled"
color="primary"
size="small"
label={`in: ${SEARCH_ACCELERATORS[searchAccelerator]?.text}`}
sx={{
mr: 1,
}}
/>
)}
<ListItemText
primary={text}
primaryTypographyProps={{ variant: "body2", color: "text.secondary" }}
Expand All @@ -58,7 +89,7 @@ export const GlobalSearchItem: FC<GlobalSearchItemProps> = ({
<IconButton
data-cy="RemoveRecentSearchKeyword"
size="small"
onClick={() => onRemove && onRemove(text)}
onClick={onRequestRemove}
>
<CloseIcon fontSize="small" />
</IconButton>
Expand Down
38 changes: 38 additions & 0 deletions src/shell/components/GlobalSearch/components/KeywordSearchItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { FC, useMemo } from "react";
import { ScheduleRounded, SearchRounded } from "@mui/icons-material";

import { GlobalSearchItem } from "./GlobalSearchItem";
import { ResourceType } from "../../../services/types";

interface KeywordSearchItem {
text: string;
recentSearches: string[];
onItemClick: () => void;
searchAccelerator?: ResourceType | null;
}
export const KeywordSearchItem: FC<KeywordSearchItem> = ({
text,
recentSearches,
onItemClick,
searchAccelerator,
...props
}) => {
const isRecentKeyword: boolean = useMemo(() => {
return recentSearches?.includes(text);
}, [recentSearches, text]);

const icon = useMemo(() => {
return isRecentKeyword ? ScheduleRounded : SearchRounded;
}, [isRecentKeyword]);

return (
<GlobalSearchItem
{...props}
text={text}
data-cy="global-search-term"
icon={icon}
searchAccelerator={searchAccelerator}
onClick={onItemClick}
/>
);
};
42 changes: 42 additions & 0 deletions src/shell/components/GlobalSearch/components/RecentSearchItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { FC, useMemo } from "react";
import { ScheduleRounded } from "@mui/icons-material";

import { GlobalSearchItem } from "./GlobalSearchItem";
import { ResourceType } from "../../../services/types";
import { splitTextAndAccelerator } from "../utils";

interface RecentSearchItemProps {
text: string;
onRemove: (keyword: string) => void;
onItemClick: (term: string, resourceType?: ResourceType | null) => void;
searchAccelerator?: ResourceType | null;
}
export const RecentSearchItem: FC<RecentSearchItemProps> = ({
text,
onRemove,
onItemClick,
searchAccelerator,
...props
}) => {
const splitTextResult = useMemo(() => {
return splitTextAndAccelerator(text);
}, [text]);

return (
<GlobalSearchItem
{...props}
text={splitTextResult.text}
isRemovable
data-cy="global-search-recent-keyword"
icon={ScheduleRounded}
onRemove={onRemove}
searchAccelerator={splitTextResult.resourceType as ResourceType}
onClick={() =>
onItemClick(
splitTextResult.text,
splitTextResult.resourceType as ResourceType
)
}
/>
);
};
99 changes: 99 additions & 0 deletions src/shell/components/GlobalSearch/components/SearchAccelerator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { FC } from "react";
import {
ListItem,
ListSubheader,
Button,
SvgIcon,
ListItemIcon,
ListItemText,
} from "@mui/material";
import ManageSearchRoundedIcon from "@mui/icons-material/ManageSearchRounded";

import { SEARCH_ACCELERATORS } from "./config";
import { ResourceType } from "../../../services/types";
import { useGetActiveApp } from "../../../hooks/useGetActiveApp";

interface SearchAcceleratorProps {
onAcceleratorClick: (type: ResourceType) => void;
}
export const SearchAccelerator: FC<SearchAcceleratorProps> = ({
onAcceleratorClick,
...props
}) => {
const { mainApp } = useGetActiveApp();
const isValidApp = Boolean(SEARCH_ACCELERATORS[mainApp as ResourceType]);

return (
<>
{isValidApp && (
<ListItem
{...props}
key="SearchAcceleratorSuggestion"
sx={{
height: "36px",
"&.Mui-focused": {
borderLeft: "4px solid",
borderColor: "primary.main",
backgroundColor: "action.hover",
pl: 1.5,
},
}}
onClick={() => onAcceleratorClick(mainApp as ResourceType)}
>
<ListItemIcon sx={{ width: "32px", minWidth: "32px" }}>
<ManageSearchRoundedIcon fontSize="small" />
</ListItemIcon>
<ListItemText
primary={`Find in ${
SEARCH_ACCELERATORS[mainApp as ResourceType].text
}`}
primaryTypographyProps={{
variant: "body2",
color: "text.secondary",
}}
/>
</ListItem>
)}
<ListSubheader
sx={{
finnar-bin marked this conversation as resolved.
Show resolved Hide resolved
fontSize: "12px",
fontWeight: 600,
lineHeight: "18px",
letterSpacing: "0.15px",
pt: 1,
px: 1.5,
}}
>
Search in ...
</ListSubheader>
<ListItem
data-cy="global-search-accelerators"
sx={{
gap: 1,
pt: 0.5,
px: 1.5,
}}
>
{Object.entries(SEARCH_ACCELERATORS)?.map(([key, value]) => (
<Button
data-cy={`global-search-accelerator-${key}`}
key={key}
variant="contained"
size="small"
sx={{
height: "24px",
letterSpacing: "0.16px",
lineHeight: "18px",
fontSize: "13px",
finnar-bin marked this conversation as resolved.
Show resolved Hide resolved
fontWeight: 400,
}}
startIcon={<SvgIcon component={value.icon} />}
onClick={() => onAcceleratorClick(key as ResourceType)}
>
{value.text}
</Button>
))}
</ListItem>
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import {
SvgIconComponent,
EditRounded,
CodeRounded,
ImageRounded,
} from "@mui/icons-material";
import { Database } from "@zesty-io/material";

import {
PresetType,
DateFilterModalType,
Expand Down Expand Up @@ -64,3 +72,26 @@ export const RESOURCE_TYPES: Record<ResourceType, string> = {
code: "Code Files",
media: "Media",
};

interface SearchAccelerator {
icon: SvgIconComponent;
text: string;
}
export const SEARCH_ACCELERATORS: Record<ResourceType, SearchAccelerator> = {
content: {
icon: EditRounded,
text: "Content",
},
schema: {
icon: Database as SvgIconComponent,
text: "Schema",
},
media: {
icon: ImageRounded,
text: "Media",
},
code: {
icon: CodeRounded,
text: "Code",
},
};
finnar-bin marked this conversation as resolved.
Show resolved Hide resolved
Loading