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

add a history of recent searches #8785

Open
Vadman97 opened this issue Jun 18, 2024 — with Linear · 2 comments
Open

add a history of recent searches #8785

Vadman97 opened this issue Jun 18, 2024 — with Linear · 2 comments
Labels
blocked:design Blocked until we complete some design work

Comments

Copy link
Member

https://www.loom.com/share/3635973fd10840f0a24743080f79a6ec

@Vadman97 Vadman97 added the blocked:design Blocked until we complete some design work label Jun 18, 2024 — with Linear
Copy link

linear bot commented Jun 18, 2024

Copy link

greptile-apps bot commented Jun 18, 2024

To add a history of recent searches:

  1. Update State in SearchIssues.tsx:

    • Add a state to store recent searches.
    const [recentSearches, setRecentSearches] = useState<SearchOption[]>([]);
  2. Modify onSelect Handler:

    • Update the onSelect handler to store the selected search in the recent searches state.
    onSelect={(newValue: string) => {
      const option = options.find((o) => o.value === newValue);
      if (option) {
        onSelect(option);
        setSelectOption(option);
        setRecentSearches((prev) => [option, ...prev.filter(o => o.id !== option.id)].slice(0, 5)); // Keep only the last 5 searches
      }
    }}
  3. Display Recent Searches:

    • Add a section to display recent searches.
    <div className={styles.recentSearches}>
      <h4>Recent Searches</h4>
      <ul>
        {recentSearches.map((search) => (
          <li key={search.id} onClick={() => onSelect(search.value)}>{search.label}</li>
        ))}
      </ul>
    </div>
  4. Add CSS for Recent Searches:

    • Update SearchIssues.module.css to style the recent searches section.
    .recentSearches {
      margin-top: 20px;
    }
    .recentSearches ul {
      list-style-type: none;
      padding: 0;
    }
    .recentSearches li {
      cursor: pointer;
      padding: 5px 0;
    }
    .recentSearches li:hover {
      text-decoration: underline;
    }

References

/frontend/src/components/SearchIssues/SearchIssues.tsx
/frontend/src/hooks/useSearchTime.ts
/frontend/src/pages/LogsPage/LogsPage.tsx

Ask Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked:design Blocked until we complete some design work
Projects
None yet
Development

No branches or pull requests

1 participant