From e26f5d7f4d8e6e55e23f5abdba7ef520af9e0779 Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Mon, 22 Aug 2022 08:20:24 -0600 Subject: [PATCH] Revert "Add category to the board search (#3626)" (#3706) This reverts commit c28620594a046f0e9d7dcb01fac39676fa270453. --- .../boardSwitcherDialog.test.tsx.snap | 231 +----------------- .../boardSwitcherDialog.scss | 26 +- .../boardSwitcherDialog.test.tsx | 90 +------ .../boardSwitcherDialog.tsx | 23 +- 4 files changed, 4 insertions(+), 366 deletions(-) diff --git a/webapp/src/components/boardsSwitcherDialog/__snapshots__/boardSwitcherDialog.test.tsx.snap b/webapp/src/components/boardsSwitcherDialog/__snapshots__/boardSwitcherDialog.test.tsx.snap index a236141d2..b16f4982a 100644 --- a/webapp/src/components/boardsSwitcherDialog/__snapshots__/boardSwitcherDialog.test.tsx.snap +++ b/webapp/src/components/boardsSwitcherDialog/__snapshots__/boardSwitcherDialog.test.tsx.snap @@ -20,6 +20,7 @@ exports[`component/BoardSwitcherDialog base case 1`] = ` > -
-
-
-
-

- Find Boards -

-
- Type to find a board. Use - - UP/DOWN - - to browse. - - ENTER - - to select, - - ESC - - to dismiss -
-
- - -
-
-
-
-
- -
- - hello - -
-
- - Boards - -
- - Dunder Mifflin - -
-
-
-
- - - - -`; - -exports[`component/BoardSwitcherDialog find one, with custom category 1`] = ` -
-
-
-
- -
-
-`; diff --git a/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.scss b/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.scss index 03babb02d..c93cc766c 100644 --- a/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.scss +++ b/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.scss @@ -15,6 +15,7 @@ } span { + display: inline-block; height: 100%; overflow: hidden; text-overflow: ellipsis; @@ -23,36 +24,11 @@ .resultTitle { max-width: 60%; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; } .teamTitle { right: auto; margin-left: auto; color: rgba(var(--center-channel-color-rgb), 0.56); - flex: 1; - text-align: right; - } - - - .categoryTitle, - .teamTitle { - max-width: 20%; - width: max-content; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - - .categoryTitle { - margin-left: auto; - flex: 2; - text-align: right; - } - - .resultTitle { - flex: 6; } } diff --git a/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.test.tsx b/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.test.tsx index 4a1064ee1..75e9ae4a5 100644 --- a/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.test.tsx +++ b/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.test.tsx @@ -4,40 +4,22 @@ import React from 'react' import {MockStoreEnhanced} from "redux-mock-store" -import {mocked} from 'jest-mock' import {Provider as ReduxProvider} from 'react-redux' -import {render, screen, act} from '@testing-library/react' -import userEvent from '@testing-library/user-event' +import {render} from "@testing-library/react" import {createMemoryHistory, History} from "history" import {Router} from "react-router-dom" -import octoClient from '../../octoClient' - import {Team} from "../../store/teams" import {TestBlockFactory} from "../../test/testBlockFactory" import {mockStateStore, wrapDNDIntl} from "../../testUtils" -import {Board, createBoard} from '../../../../webapp/src/blocks/board' - -import {Utils} from '../../../../webapp/src/utils' - import BoardSwitcherDialog from "./boardSwitcherDialog" -jest.mock('../../octoClient') -const mockedOctoClient = mocked(octoClient, true) -jest.mock('../../../../webapp/src/utils') -const mockedUtils = mocked(Utils, true) - -const wait = (ms: number) => { - return new Promise((resolve) => { - setTimeout(resolve, ms) - }) -} describe('component/BoardSwitcherDialog', () => { const team1: Team = { @@ -65,9 +47,6 @@ describe('component/BoardSwitcherDialog', () => { teams: { allTeams: [team1, team2], current: team1, - }, - sidebar: { - categoryAttributes: [], } } @@ -94,71 +73,4 @@ describe('component/BoardSwitcherDialog', () => { const {container} = render(component) expect(container).toMatchSnapshot() }) - - test('find one, default category', async () => { - const onCloseHandler = jest.fn() - const newBoard = createBoard({id: 'found-board', title: 'hello', teamId: 'team-id-1'} as Board) - - mockedOctoClient.searchAll.mockResolvedValue([newBoard]) - mockedUtils.uuid.mockReturnValue('Really a UUID') - - const component = wrapDNDIntl( - - - - - - ) - - const {container} = render(component) - await act(async () => { - const inputElement = screen.getByPlaceholderText('Search for boards') - await userEvent.type(inputElement, 'test') - await wait(300) - }) - expect(container).toMatchSnapshot() - }) - - test('find one, with custom category', async () => { - const onCloseHandler = jest.fn() - - const myState = { - users: { - me: me, - }, - teams: { - allTeams: [team1, team2], - current: team1, - }, - sidebar: { - categoryAttributes: [{ - name: 'TestCategory', - boardIDs: ['found-board'] - },], - } - } - - const myStore = mockStateStore([], myState) - - const newBoard = createBoard({id: 'found-board', title: 'hello', teamId: 'team-id-1'} as Board) - - mockedOctoClient.searchAll.mockResolvedValue([newBoard]) - mockedUtils.uuid.mockReturnValue('Really a UUID') - - const component = wrapDNDIntl( - - - - - - ) - - const {container} = render(component) - await act(async () => { - const inputElement = screen.getByPlaceholderText('Search for boards') - await userEvent.type(inputElement, 'test') - await wait(300) - }) - expect(container).toMatchSnapshot() - }) }) diff --git a/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.tsx b/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.tsx index 5495702ae..d8e1ed2f8 100644 --- a/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.tsx +++ b/webapp/src/components/boardsSwitcherDialog/boardSwitcherDialog.tsx @@ -18,12 +18,6 @@ import {Utils} from '../../utils' import {BoardTypeOpen, BoardTypePrivate} from '../../blocks/board' import { Constants } from '../../constants' -import { - CategoryBoards, - DefaultCategory, - getSidebarCategories, -} from '../../store/sidebar' - type Props = { onClose: () => void } @@ -35,7 +29,6 @@ const BoardSwitcherDialog = (props: Props): JSX.Element => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const [IDs, setIDs] = useState({}) const intl = useIntl() - const partialCategories = useAppSelector>(getSidebarCategories) const team = useAppSelector(getCurrentTeam) const me = useAppSelector(getMe) const title = intl.formatMessage({id: 'FindBoardsDialog.Title', defaultMessage: 'Find Boards'}) @@ -76,15 +69,6 @@ const BoardSwitcherDialog = (props: Props): JSX.Element => { return items.map((item, i) => { const resultTitle = item.title || untitledBoardTitle const teamTitle = teamsById[item.teamId].title - - let categoryTitle = DefaultCategory.name - for(const category of partialCategories){ - if(category.boardIDs.find(id => id === item.id)){ - categoryTitle = category.name - break - } - } - // eslint-disable-next-line @typescript-eslint/no-explicit-any setIDs((prevIDs: any) => ({ ...prevIDs, @@ -99,12 +83,7 @@ const BoardSwitcherDialog = (props: Props): JSX.Element => { > {item.type === BoardTypeOpen && } {item.type === BoardTypePrivate && } -
- {resultTitle} -
-
- {categoryTitle} -
+ {resultTitle} {teamTitle}
)