diff --git a/src/shell/components/GlobalSearch/components/AdvancedSearch.tsx b/src/shell/components/GlobalSearch/components/AdvancedSearch.tsx index 71826fbec6..3e136d9dc2 100644 --- a/src/shell/components/GlobalSearch/components/AdvancedSearch.tsx +++ b/src/shell/components/GlobalSearch/components/AdvancedSearch.tsx @@ -341,7 +341,7 @@ export const AdvancedSearch: FC = ({ alignItems="center" justifyContent="space-between" > - + Advanced Search @@ -377,6 +377,40 @@ export const AdvancedSearch: FC = ({ onChange={(e) => updateSearchData({ keyword: e.target.value })} /> + + + Resource Type + + + + + + Created By @@ -434,41 +468,7 @@ export const AdvancedSearch: FC = ({ - Resource Type - - - - - - - - - Date + Date Modified { setMediaFolderKeyword(apiQueryTerm); }, [apiQueryTerm]); + useEffect(() => { + const paramsSearchKeyword = params?.get("q"); + + if (paramsSearchKeyword) { + setSearchKeyword(paramsSearchKeyword); + } + }, [params]); + //@ts-ignore TODO fix typing for useMetaKey const shortcutHelpText = useMetaKey("k", () => { textfieldRef.current?.querySelector("input").focus(); @@ -451,8 +459,19 @@ export const GlobalSearch = () => { return; } - // string represents search term entered if (typeof newVal === "string") { + // The user has pressed enter while highlighting a search accelerator option + if (newVal === "SearchAccelerator") { + const isSearchAcceleratorSupportedApp = + Object.keys(SEARCH_ACCELERATORS)?.includes(mainApp); + + if (isSearchAcceleratorSupportedApp) { + setChipSearchAccelerator(mainApp as ResourceType); + return; + } + } + + // The user has pressed enter while typing a query and has NOT highlighted any option if (AdditionalDropdownOptions.includes(newVal)) { return; } @@ -612,7 +631,11 @@ export const GlobalSearch = () => { }} key={option} > - Recent Modified {types[chipSearchAccelerator]} + Recently{" "} + {chipSearchAccelerator === "media" + ? "Uploaded" + : "Modified"}{" "} + {types[chipSearchAccelerator]} ); } @@ -652,11 +675,7 @@ export const GlobalSearch = () => { fullWidth data-cy="global-search-textfield" variant="outlined" - placeholder={ - Boolean(chipSearchAccelerator) - ? "" - : `Search Instance ${shortcutHelpText}` - } + placeholder={`Search Instance ${shortcutHelpText}`} sx={{ height: "40px", "& .Mui-focused": { @@ -702,7 +721,7 @@ export const GlobalSearch = () => { ...params.InputProps, startAdornment: ( - {Boolean(chipSearchAccelerator) && open ? ( + {Boolean(chipSearchAccelerator) ? ( (props: any) => { +export const withCursorPosition = (WrappedComponent: ComponentType) => + forwardRef((props: any, ref: MutableRefObject) => { const [cursorPosition, setCursorPosition] = useState(0); const inputRef = useRef(null); @@ -18,8 +25,9 @@ export const withCursorPosition = return ( ); - }; + }); diff --git a/src/shell/views/SearchPage/SearchPage.tsx b/src/shell/views/SearchPage/SearchPage.tsx index e8e32a6a9e..a3945374bc 100644 --- a/src/shell/views/SearchPage/SearchPage.tsx +++ b/src/shell/views/SearchPage/SearchPage.tsx @@ -306,7 +306,7 @@ export const SearchPage: FC = () => { backgroundColor: "background.paper", }} > - + {isLoading ? ( ) : (