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

[Hold for #395046] [Search v1] [$500] Add a search bar on the workspaces list #38854

Closed
roryabraham opened this issue Mar 23, 2024 · 26 comments
Closed
Assignees
Labels
External Added to denote the issue can be worked on by a contributor Monthly KSv2 NewFeature Something to build that is a new item. Not a priority

Comments

@roryabraham
Copy link
Contributor

roryabraham commented Mar 23, 2024

coming from https://expensify.slack.com/archives/C01GTK53T8Q/p1711147247599549...

Problem

If you have many workspaces on your workspaces list, it can be hard to find a particular one.

Solution

Add a search bar to filter the workspaces list.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016fc1028e9b86cc67
  • Upwork Job ID: 1771337546180210688
  • Last Price Increase: 2024-03-30
  • Automatic offers:
    • GandalfGwaihir | Contributor | 0
Issue OwnerCurrent Issue Owner: @GandalfGwaihir
@roryabraham roryabraham added Daily KSv2 NewFeature Something to build that is a new item. labels Mar 23, 2024
@roryabraham roryabraham self-assigned this Mar 23, 2024
@roryabraham roryabraham added Weekly KSv2 and removed Daily KSv2 labels Mar 23, 2024
Copy link

melvin-bot bot commented Mar 23, 2024

@roryabraham roryabraham added the External Added to denote the issue can be worked on by a contributor label Mar 23, 2024
@melvin-bot melvin-bot bot changed the title Add a search bar on the workspaces list [$500] Add a search bar on the workspaces list Mar 23, 2024
Copy link

melvin-bot bot commented Mar 23, 2024

Job added to Upwork: https://www.upwork.com/jobs/~016fc1028e9b86cc67

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 23, 2024
Copy link

melvin-bot bot commented Mar 23, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (External)

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Mar 23, 2024
@hayes102
Copy link

Hi Rory, can i make a proposal for this one? or is it already taken?

Copy link

melvin-bot bot commented Mar 23, 2024

📣 @hayes102! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@nkdengineer
Copy link
Contributor

nkdengineer commented Mar 23, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Add a search bar on the workspaces list

What is the root cause of that problem?

This is a new feature

What changes do you think we should make in order to solve the problem?

We can re-use the filter logic in WorkspaceSwitcherPage to filter the workspace in WorkspaceListPage

  1. Create a state for search term
const [searchTerm, setSearchTerm] = useState('');
  1. Create a textInput component
const textInput = (
        <TextInput 
          defaultValue={searchTerm}
          onChangeText={(value) => {
              setSearchTerm(value);
          }}
          selectTextOnFocus
          spellCheck={false}
          iconLeft={MagnifyingGlass}
          placeholder={translate('workspace.switcher.placeholder')}
      />
  )
  • Note: this is the main idea, other logics like focus, blur, ... of TextInput can be done on the PR
  1. Update listHeaderComponent to include the search bar
const shouldShowTextInput = workspaces.length >= CONST.WORKSPACE_SWITCHER.MINIMUM_WORKSPACES_TO_SHOW_SEARCH;
const listHeaderComponent = useCallback(() => {
  const headerContent = isLessThanMediumScreen ? (
      <View style={styles.mt5} />
  ) : (
      <View style={[styles.flexRow, styles.gap5, styles.p5, styles.pl10, styles.appBG]}>
          {filteredAndSortedUserWorkspaces.length > 0 ? (
              <>
                  <View style={[styles.flexRow, styles.flex1]}>
                      <Text
                          numberOfLines={1}
                          style={[styles.flexGrow1, styles.textLabelSupporting]}
                      >
                          {translate('workspace.common.workspaceName')}
                      </Text>
                  </View>
                  <View style={[styles.flexRow, styles.flex1, styles.workspaceOwnerSectionTitle]}>
                      <Text
                          numberOfLines={1}
                          style={[styles.flexGrow1, styles.textLabelSupporting]}
                      >
                          {translate('workspace.common.workspaceOwner')}
                      </Text>
                  </View>
                  <View style={[styles.flexRow, styles.flex1, styles.workspaceTypeSectionTitle]}>
                      <Text
                          numberOfLines={1}
                          style={[styles.flexGrow1, styles.textLabelSupporting]}
                      >
                          {translate('workspace.common.workspaceType')}
                      </Text>
                  </View>
                  <View style={[styles.ml10, styles.mr2]} />
              </>
          ) : (
              <Text>{translate('common.noResultsFound')}</Text>
          )}
      </View>
  );
  return (
      <>
          <View style={[styles.gap5, styles.p5, styles.pl10, styles.appBG]}>{shouldShowTextInput && textInput}</View>
          {headerContent}
      </>
  );
}, [isLessThanMediumScreen, styles, translate, shouldShowTextInput, filteredAndSortedUserWorkspaces.length]);
  1. Create a filter workspace variable, re-use the logic here
const sortWorkspacesBySelected = (workspace1: WorkspaceItem, workspace2: WorkspaceItem, selectedWorkspaceID: string | undefined): number => {
    if (workspace1.policyID === selectedWorkspaceID) {
        return -1;
    }
    if (workspace2.policyID === selectedWorkspaceID) {
        return 1;
    }
    return workspace1.title?.toLowerCase().localeCompare(workspace2.title?.toLowerCase() ?? '') ?? 0;
};
const filteredAndSortedUserWorkspaces = useMemo(
    () =>
    workspaces
            .filter((policy) => policy.title?.toLowerCase().includes(searchTerm?.toLowerCase() ?? ''))
            .sort((policy1, policy2) => sortWorkspacesBySelected(policy1, policy2, activeWorkspaceID)),
    [searchTerm, workspaces, activeWorkspaceID],
);
  1. Pass filteredAndSortedUserWorkspaces as the data of FlatList
data={filteredAndSortedUserWorkspaces}

What alternative solutions did you explore? (Optional)

NA

Result

Screen.Recording.2024-03-23.at.10.55.20.mov

@nayabatir1
Copy link

nayabatir1 commented Mar 23, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Add search is workspace list

What is the root cause of that problem?

This is a new feature

What changes do you think we should make in order to solve the problem?

Added search bar in workspace list. Based on user input it will filter the list of workspace.

Header Component This is draft structure for demo purpose, will look for reusable component if any once this proposal gets accepted. image
Filter workspace logic Instead of directly filtering on workspaces, I'm creating 2nd memoize variable to filter as if workspace is empty, create workspace section will be shown. Using `useDeferredValue` to smoothly update UI. image
Demo video
Screen.Recording.2024-03-23.at.14.11.23.mov

What alternative solutions did you explore? (Optional)

N.A.

@allgandalf
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Add a search bar on the workspaces list

What is the root cause of that problem?

Feature Request

What changes do you think we should make in order to solve the problem?

Firstly, We don't need to create everything from scratch, we have major logic to filter workspaces in the Workspace Switcher LHN itself:
For the Logic part, We can directly use the logic to filter workspaces from here:

const filteredAndSortedUserWorkspaces = useMemo(
() =>
usersWorkspaces
.filter((policy) => policy.text?.toLowerCase().includes(searchTerm?.toLowerCase() ?? ''))
.sort((policy1, policy2) => sortWorkspacesBySelected(policy1, policy2, activeWorkspaceID)),
[searchTerm, usersWorkspaces, activeWorkspaceID],
);

Then we should define a TextInput which will be used to enter user data, this can be taken fromBaseOptionsSelector :

const textInput = (
<TextInput
ref={(el) => (this.textInput = el)}
label={this.props.textInputLabel}
accessibilityLabel={this.props.textInputLabel}
role={CONST.ROLE.PRESENTATION}
onChangeText={this.debouncedUpdateSearchValue}
errorText={this.state.errorMessage}
onSubmitEditing={this.selectFocusedOption}
placeholder={this.props.placeholderText}
maxLength={this.props.maxLength + CONST.ADDITIONAL_ALLOWED_CHARACTERS}
keyboardType={this.props.keyboardType}
onBlur={(e) => {
if (!this.props.shouldPreventDefaultFocusOnSelectRow) {
return;
}
this.relatedTarget = e.relatedTarget;
}}
selectTextOnFocus
blurOnSubmit={Boolean(this.state.allOptions.length)}
spellCheck={false}
shouldInterceptSwipe={this.props.shouldTextInputInterceptSwipe}
isLoading={this.props.isLoadingNewOptions}
iconLeft={this.props.textIconLeft}
testID="options-selector-input"
/>
);

Over here we also need to define a new Place Holder text for workspace list:
workspaceSearch: 'Search Workspace'

Then we need to add this TextInput in listHeaderComponent in WorkspacesListPage:

const listHeaderComponent = useCallback(() => {

And finally, Update the data parameter in FlatList to show the workspaces according to the filtered values

Note: We should also add a No results found for inputs which do not match workspace names

Test Branch: https://github.com/GandalfGwaihir/App/tree/issue38854

@melvin-bot melvin-bot bot added the Overdue label Mar 25, 2024
@eVoloshchak
Copy link
Contributor

This is a feature request rather than a bug, so the first proposal to correctly explain the general idea of how to implement the feature - is a winning proposal. Extensive code diffs aren't needed (Source), the exact details of the implementation can be worked out during the PR review

Based on that, I think we should proceed with @nkdengineer's proposal
🎀👀🎀 C+ reviewed!

@melvin-bot melvin-bot bot removed the Overdue label Mar 25, 2024
Copy link

melvin-bot bot commented Mar 25, 2024

Current assignee @roryabraham is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@allgandalf
Copy link
Contributor

hello @eVoloshchak , i actually had the first dibs here, context:

@wildan-m
Copy link
Contributor

To prevent such situations, I suggest removing the 'Help Wanted' tag if the issue is specific to a particular individual. If the proposed assignment is unsatisfactory, then we can consider adding the tag to seek alternative solutions. I've experienced the same situation here 😆

@eVoloshchak
Copy link
Contributor

i actually had the first dibs here, context:

@GandalfGwaihir, thanks for linking that!
In that case, @roryabraham, could you assign @GandalfGwaihir to this please?

Copy link

melvin-bot bot commented Mar 30, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 3, 2024
Copy link

melvin-bot bot commented Apr 3, 2024

📣 @GandalfGwaihir 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot removed the Overdue label Apr 3, 2024
@sonialiap
Copy link
Contributor

@GandalfGwaihir all yours, looking forward to having a workspace search! 🙏

@trjExpensify
Copy link
Contributor

I think we should park the breaks on this and wait for search v2 and introducing it consistently. We purposefully left it out of the v1 of the Workspaces page knowing we'd be working into a more holistic search design. CC: @Expensify/design

@shawnborton
Copy link
Contributor

I agree with that.

@allgandalf
Copy link
Contributor

damn , the updated code was ready for one 😢

@JmillsExpensify
Copy link

Agree with pausing this. It hasn't gone through our internal design process yet, though it will within the next 1-2 weeks, and at that point once we have alignment, we can pick this back up.

@trjExpensify trjExpensify changed the title [$500] Add a search bar on the workspaces list [Hold] [Search v1] [$500] Add a search bar on the workspaces list Apr 3, 2024
@trjExpensify
Copy link
Contributor

Going to track it as part of [Search v1] for now to keep it in view, though I'll likely update this to wherever we go with Search v2.

Copy link

melvin-bot bot commented Apr 9, 2024

@eVoloshchak, @sonialiap, @roryabraham, @GandalfGwaihir Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot melvin-bot bot added the Overdue label Apr 9, 2024
@roryabraham roryabraham added Monthly KSv2 and removed Daily KSv2 labels Apr 9, 2024
@melvin-bot melvin-bot bot removed the Overdue label Apr 9, 2024
@eVoloshchak
Copy link
Contributor

Not overdue, this is on HOLD

@melvin-bot melvin-bot bot closed this as completed Jun 24, 2024
Copy link

melvin-bot bot commented Jun 24, 2024

@eVoloshchak, @sonialiap, @roryabraham, @GandalfGwaihir, this Monthly task hasn't been acted upon in 6 weeks; closing.

If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.

@sonialiap sonialiap reopened this Jun 27, 2024
@sonialiap sonialiap changed the title [Hold] [Search v1] [$500] Add a search bar on the workspaces list [Hold for #395046] [Search v1] [$500] Add a search bar on the workspaces list Jun 27, 2024
@sonialiap
Copy link
Contributor

search v2 is being worked on here https://github.com/Expensify/Expensify/issues/395046

@sonialiap
Copy link
Contributor

Closing this out because it's a very long way from being implemented (slack)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Added to denote the issue can be worked on by a contributor Monthly KSv2 NewFeature Something to build that is a new item. Not a priority
Projects
Archived in project
Development

No branches or pull requests