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

Quick search projects #4000

Merged
merged 6 commits into from
May 26, 2023
Merged

Conversation

ayushgml
Copy link
Contributor

@ayushgml ayushgml commented May 26, 2023

This PR closes the following issue:

Changes

  • Added a Quick Project Search filter in All Projects tab. Logic:
if (typeFilter === 'all') {
      return searchInput.trim() === '' ? projects : projects.filter(p => p.name?.toLowerCase().includes(searchInput));
    }

    if (typeFilter === 'git') {
      return searchInput.trim() === ''
        ? projects.filter(p => p.isGitRepo)
        : projects.filter(p => p.name?.toLowerCase().includes(searchInput) && p.isGitRepo);
    }
    return searchInput.trim() === ''
      ? projects.filter(p => !p.isGitRepo)
      : projects.filter(p => p.name?.toLowerCase().includes(searchInput) && !p.isGitRepo);
  • Highlighting of the searched query in the project name. Logic:
  const highlightQuery = (text: string) => {
    if (!query?.trim()) {
      return <S.Span>{text}</S.Span>;
    }
    const parts = text.split(new RegExp(`(${query})`, 'gi'));
    return (
      <S.Span>
        {parts.map(part => (part.toLowerCase() === query.toLowerCase() ? <S.BoldSpan>{part}</S.BoldSpan> : part))}
      </S.Span>
    );
  };

How to test it

  • Run the desktop app and go to "All Projects" tab

Screenshots

Screenshot 2023-05-26 at 2 29 32 PM Screenshot 2023-05-26 at 2 30 16 PM Screenshot 2023-05-26 at 2 30 47 PM

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

Copy link
Member

@devcatalin devcatalin left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, left some quick suggestions!

src/components/molecules/ProjectsList/ProjectsList.tsx Outdated Show resolved Hide resolved
src/components/molecules/ProjectsList/ProjectsList.tsx Outdated Show resolved Hide resolved
src/components/molecules/ProjectsList/ProjectsList.tsx Outdated Show resolved Hide resolved
@ayushgml ayushgml reopened this May 26, 2023
@ayushgml
Copy link
Contributor Author

@devcatalin I have made the changes.

@devcatalin devcatalin self-requested a review May 26, 2023 11:38
@devcatalin
Copy link
Member

Great, thank you, merging this!

@devcatalin devcatalin merged commit b3986c3 into kubeshop:main May 26, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants