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: add org search #1620

Merged
merged 5 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add default search to org
  • Loading branch information
shczhen committed Sep 25, 2023
commit c793ed05ce093bc1e31f2df27ee69d72ef7b39e2
2 changes: 1 addition & 1 deletion web/src/components/GeneralSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const isOptionEqual = (a: Option, b: Option) => {
const getOptionLabel = (option: Option) => (option as SearchRepoInfo).fullName || (option as UserInfo | SearchOrgInfo).login || (option as any).label;

const useTabs = () => {
const [type, setType] = useState<SearchType>('user');
const [type, setType] = useState<SearchType>('all');

const handleTypeChange = useEventCallback((_: any, type: SearchType) => {
setType(type);
Expand Down
14 changes: 9 additions & 5 deletions web/src/components/GeneralSearch/useGeneralSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useGeneralSearch<T extends SearchType> (
case 'org':
return ['recommend-org-list-keyword', 'search:org'];
default:
return ['recommend-all-list-keyword', 'search:all'];
return ['', 'search:all'];
}
};

Expand All @@ -43,11 +43,15 @@ export function useGeneralSearch<T extends SearchType> (
} else if (type === 'org') {
return await searchOrg(keyword);
} else {
if (!searchKey) return [];
const tmpKeywords = {
repo: keyword || 'recommend-repo-list-1-keyword',
user: keyword || 'recommend-user-list-keyword',
org: keyword || 'recommend-org-list-keyword',
};
return await Promise.all([
searchRepo(keyword),
searchUser(keyword, 'user'),
searchOrg(keyword),
searchRepo(tmpKeywords.repo),
searchUser(tmpKeywords.user, 'user'),
searchOrg(tmpKeywords.org),
]).then(([repo, user, org]) => {
return [
...repo.map((item) => ({ ...item, type: 'Repo' })),
Expand Down