Skip to content

feat: Add workspace sorting and enhanced search functionality#5759

Open
KUNDAN1334 wants to merge 1 commit intoFlowiseAI:mainfrom
KUNDAN1334:feature/workspace-sorting-and-search
Open

feat: Add workspace sorting and enhanced search functionality#5759
KUNDAN1334 wants to merge 1 commit intoFlowiseAI:mainfrom
KUNDAN1334:feature/workspace-sorting-and-search

Conversation

@KUNDAN1334
Copy link

Description

Implements comprehensive workspace management improvements as requested in #5449.

Changes

This PR adds the following features to the Workspaces management page:

1. Workspace Sorting (3 sort options)

  • Name (A-Z) - Default, alphanumeric sorting using localeCompare with numeric and base sensitivity
  • Creation Date - Sorts workspaces by creation date (earliest first)
  • Last Updated - Sorts workspaces by last updated date (most recent first)

2. Enhanced Search

  • Search now works on both workspace name and workspace description
  • Case-insensitive search for better usability
  • Updated search placeholder text to indicate both search options

3. UX Improvements

  • Added 'Sort By' dropdown in the ViewHeader for easy access
  • Sort dropdown is responsive and hidden on mobile devices
  • Default sorting is alphabetical for better initial organization

Technical Details

Modified Files:

  • packages/ui/src/views/workspace/index.jsx

Changes Made:

  1. Added Material-UI imports: FormControl, Select, MenuItem, InputLabel
  2. Added 'sortBy' state with default value 'name'
  3. Enhanced filterWorkspaces() function to search name and description
  4. Added sortWorkspaces() function with three sorting strategies
  5. Added sort dropdown UI in ViewHeader filters section
  6. Applied sorting to workspace display list

Related Issue

Closes #5449

How to Test

  1. Navigate to the Workspaces page
  2. Verify workspaces are sorted alphabetically by default
  3. Test the 'Sort By' dropdown:
    • Select 'Name (A-Z)' - should sort alphabetically
    • Select 'Creation Date' - should sort by creation date
    • Select 'Last Updated' - should sort by most recent first
  4. Test the search functionality:
    • Search by workspace name
    • Search by workspace description
    • Verify both work correctly

Checklist

  • Code follows project style guidelines
  • Tested locally on Workspaces page
  • No existing tests broken
  • Updated search placeholder text
  • Responsive design maintained

…eAI#5449)

- Add 'Sort By' dropdown with three sorting options:
  * Name (A-Z) - default, alphanumeric sorting
  * Creation Date - sorted by creation date
  * Last Updated - most recent first

- Enhance search functionality to search by both:
  * Workspace name
  * Workspace description

- Update search placeholder to indicate both search options

- Apply sorting to filtered workspaces list

Changes:
- Added FormControl, Select, MenuItem, InputLabel to Material-UI imports
- Added 'sortBy' state with default value 'name'
- Enhanced filterWorkspaces() to search name and description
- Added sortWorkspaces() function with three sorting strategies
- Added sort dropdown UI in ViewHeader filters section
- Applied sorting to workspace display list
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @KUNDAN1334, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the workspace management page by introducing robust sorting capabilities and an expanded search function. Users can now organize their workspaces by name, creation date, or last updated date, and search not only by name but also by description, providing a more flexible and efficient user experience for navigating and managing workspaces.

Highlights

  • Workspace Sorting: Implemented three sorting options for workspaces: by Name (A-Z), Creation Date (earliest first), and Last Updated (most recent first). The default sorting is alphabetical by name.
  • Enhanced Search Functionality: Improved the search feature to allow case-insensitive searching across both workspace names and descriptions. The search placeholder text has been updated to reflect this change.
  • User Experience Improvements: Added a 'Sort By' dropdown menu to the ViewHeader for easy access to sorting options. This dropdown is responsive and will be hidden on smaller mobile devices.
Changelog
  • packages/ui/src/views/workspace/index.jsx
    • Imported new Material-UI components (Select, MenuItem, FormControl, InputLabel) to support the new UI elements.
    • Added a new React state variable sortBy to manage the currently selected sorting preference, defaulting to 'name'.
    • Modified the filterWorkspaces function to include searching by workspace description in addition to the name, and introduced a new sortWorkspaces function to handle different sorting logic based on the sortBy state.
    • Integrated a 'Sort By' dropdown menu into the ViewHeader component, allowing users to select their preferred sorting method, and updated the search input's placeholder text.
    • Applied the sortWorkspaces function to the list of filtered workspaces before rendering them, ensuring the displayed list is always sorted according to the user's selection.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces workspace sorting and enhances the search functionality to include workspace descriptions. The implementation is functionally sound and addresses the feature request. I've provided two main pieces of feedback. First, a high-severity recommendation to use stable keys instead of array indices when rendering the list of workspaces to prevent potential rendering bugs. Second, a medium-severity suggestion to use the useMemo hook for filtering and sorting the workspaces, which will improve performance by avoiding unnecessary re-computations on every render.

Comment on lines 353 to 381
function filterWorkspaces(data) {
return data.name.toLowerCase().indexOf(search.toLowerCase()) > -1
const searchLower = search.toLowerCase()
return (
data.name.toLowerCase().indexOf(searchLower) > -1 ||
(data.description && data.description.toLowerCase().indexOf(searchLower) > -1)
)
}

function sortWorkspaces(workspacesToSort) {
const sorted = [...workspacesToSort]
switch (sortBy) {
case 'name':
return sorted.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }))
case 'createdDate':
return sorted.sort((a, b) => {
const dateA = new Date(a.createdDate || 0)
const dateB = new Date(b.createdDate || 0)
return dateA - dateB
})
case 'updatedDate':
return sorted.sort((a, b) => {
const dateA = new Date(a.updatedDate || 0)
const dateB = new Date(b.updatedDate || 0)
return dateB - dateA // descending order for updated (most recent first)
})
default:
return sorted
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To optimize performance and improve readability, you can use the useMemo hook to compute the filtered and sorted workspaces. This avoids re-running the filter and sort logic on every render and only re-computes when workspaces, search, or sortBy change. This also allows you to consolidate the filtering and sorting logic.

After replacing the filterWorkspaces and sortWorkspaces functions with this useMemo, you'll need to update the map call to use the new displayedWorkspaces variable, for example: {displayedWorkspaces.map(...).

    const displayedWorkspaces = useMemo(() => {
        const searchLower = search.toLowerCase();
        const filtered = workspaces.filter(
            (data) =>
                data.name.toLowerCase().includes(searchLower) ||
                (data.description && data.description.toLowerCase().includes(searchLower))
        );

        const sorted = [...filtered];
        switch (sortBy) {
            case 'name':
                return sorted.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }));
            case 'createdDate':
                return sorted.sort((a, b) => new Date(a.createdDate || 0) - new Date(b.createdDate || 0));
            case 'updatedDate':
                return sorted.sort((a, b) => new Date(b.updatedDate || 0) - new Date(a.updatedDate || 0));
            default:
                return sorted;
        }
    }, [workspaces, search, sortBy]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Management of workspaces - sorted, sorting, and searchable

1 participant

Comments