Client side search for tables no longer debounce (#2807)

Relates to #2793.

Removed debounce from client-side search for tables because it conflicted with react-table's search mechanism.
This commit is contained in:
Martavis Parker 2021-11-04 21:16:42 -07:00 committed by GitHub
parent 76c5e2944f
commit f1ed172ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 42 additions and 26 deletions

View File

@ -43,7 +43,7 @@ interface IDataTableProps {
onPrimarySelectActionClick: any; // figure out type onPrimarySelectActionClick: any; // figure out type
secondarySelectActions?: IActionButtonProps[]; secondarySelectActions?: IActionButtonProps[];
onSelectSingleRow?: (value: Row) => void; onSelectSingleRow?: (value: Row) => void;
clientSidePagination?: boolean; isClientSidePagination?: boolean;
} }
const CLIENT_SIDE_DEFAULT_PAGE_SIZE = 20; const CLIENT_SIDE_DEFAULT_PAGE_SIZE = 20;
@ -70,7 +70,7 @@ const DataTable = ({
primarySelectActionButtonText, primarySelectActionButtonText,
secondarySelectActions, secondarySelectActions,
onSelectSingleRow, onSelectSingleRow,
clientSidePagination, isClientSidePagination,
}: IDataTableProps): JSX.Element => { }: IDataTableProps): JSX.Element => {
const { resetSelectedRows } = useContext(TableContext); const { resetSelectedRows } = useContext(TableContext);
@ -288,7 +288,7 @@ const DataTable = ({
showMarkAllPages && showMarkAllPages &&
!isAllPagesSelected; !isAllPagesSelected;
const pageOrRows = clientSidePagination ? page : rows; const pageOrRows = isClientSidePagination ? page : rows;
useEffect(() => { useEffect(() => {
setPageSize(CLIENT_SIDE_DEFAULT_PAGE_SIZE); setPageSize(CLIENT_SIDE_DEFAULT_PAGE_SIZE);
@ -396,7 +396,7 @@ const DataTable = ({
</tbody> </tbody>
</table> </table>
</div> </div>
{clientSidePagination && ( {isClientSidePagination && (
<div className={`${baseClass}__pagination`}> <div className={`${baseClass}__pagination`}>
<Button <Button
variant="unstyled" variant="unstyled"

View File

@ -61,7 +61,8 @@ interface ITableContainerProps {
onSelectSingleRow?: (value: Row) => void; onSelectSingleRow?: (value: Row) => void;
filteredCount?: number; filteredCount?: number;
searchToolTipText?: string; searchToolTipText?: string;
clientSidePagination?: boolean; isClientSidePagination?: boolean;
isClientSideSearch?: boolean;
} }
const baseClass = "table-container"; const baseClass = "table-container";
@ -107,7 +108,8 @@ const TableContainer = ({
onSelectSingleRow, onSelectSingleRow,
filteredCount, filteredCount,
searchToolTipText, searchToolTipText,
clientSidePagination, isClientSidePagination,
isClientSideSearch,
}: ITableContainerProps): JSX.Element => { }: ITableContainerProps): JSX.Element => {
const [searchQuery, setSearchQuery] = useState(""); const [searchQuery, setSearchQuery] = useState("");
const [sortHeader, setSortHeader] = useState(defaultSortHeader || ""); const [sortHeader, setSortHeader] = useState(defaultSortHeader || "");
@ -170,7 +172,7 @@ const TableContainer = ({
// Something besides the pageIndex has changed; we want to set it back to 0. // Something besides the pageIndex has changed; we want to set it back to 0.
if (onQueryChange) { if (onQueryChange) {
if (!hasPageIndexChangedRef.current) { if (!hasPageIndexChangedRef.current && !isClientSideSearch) {
const updateQueryData = { const updateQueryData = {
...queryData, ...queryData,
pageIndex: 0, pageIndex: 0,
@ -321,9 +323,9 @@ const TableContainer = ({
onPrimarySelectActionClick={onPrimarySelectActionClick} onPrimarySelectActionClick={onPrimarySelectActionClick}
secondarySelectActions={secondarySelectActions} secondarySelectActions={secondarySelectActions}
onSelectSingleRow={onSelectSingleRow} onSelectSingleRow={onSelectSingleRow}
clientSidePagination={clientSidePagination} isClientSidePagination={isClientSidePagination}
/> />
{!disablePagination && !clientSidePagination && ( {!disablePagination && !isClientSidePagination && (
<Pagination <Pagination
resultsOnCurrentPage={data.length} resultsOnCurrentPage={data.length}
currentPage={pageIndex} currentPage={pageIndex}

View File

@ -31,8 +31,6 @@ export default (WrappedComponent, { fields, validate = defaultValidate }) => {
errors: {}, errors: {},
formData, formData,
}; };
return false;
} }
componentWillMount() { componentWillMount() {

View File

@ -136,6 +136,7 @@ const PackQueriesListWrapper = ({
searchable searchable
disablePagination disablePagination
isAllPagesSelected={false} isAllPagesSelected={false}
isClientSideSearch
/> />
)} )}
</div> </div>

View File

@ -98,6 +98,7 @@ const Software = ({
isAllPagesSelected={false} isAllPagesSelected={false}
searchable searchable
disableActionButton disableActionButton
isClientSideSearch
/> />
</> </>
</Modal> </Modal>

View File

@ -29,8 +29,6 @@ export class RegistrationPage extends Component {
page: 1, page: 1,
pageProgress: 1, pageProgress: 1,
}; };
return false;
} }
componentWillMount() { componentWillMount() {

View File

@ -432,6 +432,7 @@ const MembersPage = ({
showMarkAllPages={false} showMarkAllPages={false}
isAllPagesSelected={false} isAllPagesSelected={false}
searchable={memberIds.length > 0 || searchString !== ""} searchable={memberIds.length > 0 || searchString !== ""}
isClientSideSearch
/> />
)} )}
{showAddMemberModal ? ( {showAddMemberModal ? (

View File

@ -239,6 +239,7 @@ const TeamManagementPage = (): JSX.Element => {
showMarkAllPages={false} showMarkAllPages={false}
isAllPagesSelected={false} isAllPagesSelected={false}
searchable={teams.length > 0 && searchString !== ""} searchable={teams.length > 0 && searchString !== ""}
isClientSideSearch
/> />
)} )}
{showCreateTeamModal ? ( {showCreateTeamModal ? (

View File

@ -630,6 +630,7 @@ export class UserManagementPage extends Component {
resultsTitle={"users"} resultsTitle={"users"}
emptyComponent={EmptyUsers} emptyComponent={EmptyUsers}
searchable searchable
isClientSideSearch
/> />
)} )}
{renderCreateUserModal()} {renderCreateUserModal()}

View File

@ -678,7 +678,8 @@ const HostDetailsPage = ({
searchable searchable
wideSearch wideSearch
filteredCount={usersState.length} filteredCount={usersState.length}
clientSidePagination isClientSidePagination
isClientSideSearch
/> />
)} )}
</div> </div>
@ -724,7 +725,8 @@ const HostDetailsPage = ({
searchable searchable
wideSearch wideSearch
filteredCount={softwareState.length} filteredCount={softwareState.length}
clientSidePagination isClientSidePagination
isClientSideSearch
/> />
)} )}
</> </>

View File

@ -144,6 +144,7 @@ const PacksListWrapper = ({
primarySelectActionButtonText={"Delete"} primarySelectActionButtonText={"Delete"}
secondarySelectActions={secondarySelectActions} secondarySelectActions={secondarySelectActions}
emptyComponent={NoPacksComponent} emptyComponent={NoPacksComponent}
isClientSideSearch
/> />
</div> </div>
); );

View File

@ -106,6 +106,7 @@ const QueriesListWrapper = ({
primarySelectActionButtonText={"Delete"} primarySelectActionButtonText={"Delete"}
emptyComponent={NoQueriesComponent} emptyComponent={NoQueriesComponent}
customControl={customControl} customControl={customControl}
isClientSideSearch
/> />
</div> </div>
) : null; ) : null;

View File

@ -127,7 +127,7 @@ const generateTableHeaders = (currentUser: IUser): IDataColumn[] => {
), ),
accessor: "updated_at", accessor: "updated_at",
Cell: (cellProps: ICellProps): JSX.Element => ( Cell: (cellProps: ICellProps): JSX.Element => (
<TextCell value={format(new Date(cellProps.cell.value), "MM/DD/YY")} /> <TextCell value={format(new Date(cellProps.cell.value), "MM/dd/yy")} />
), ),
}, },
]; ];

3
go.sum
View File

@ -212,6 +212,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denis-tingajkin/go-header v0.4.2 h1:jEeSF4sdv8/3cT/WY8AgDHUoItNSoEZ7qg9dX7pc218= github.com/denis-tingajkin/go-header v0.4.2 h1:jEeSF4sdv8/3cT/WY8AgDHUoItNSoEZ7qg9dX7pc218=
github.com/denis-tingajkin/go-header v0.4.2/go.mod h1:eLRHAVXzE5atsKAnNRDB90WHCFFnBUn4RN0nRcs1LJA= github.com/denis-tingajkin/go-header v0.4.2/go.mod h1:eLRHAVXzE5atsKAnNRDB90WHCFFnBUn4RN0nRcs1LJA=
github.com/denisenkom/go-mssqldb v0.10.0 h1:QykgLZBorFE95+gO3u9esLd0BmbvpWp0/waNNZfHBM8=
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k=
github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE=
@ -345,6 +346,7 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.0.0 h1:RAqyYixv1p7uEnocuy8P1nru5wprCh/MH2BIlW5z5/o= github.com/golang-jwt/jwt/v4 v4.0.0 h1:RAqyYixv1p7uEnocuy8P1nru5wprCh/MH2BIlW5z5/o=
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@ -646,6 +648,7 @@ github.com/kyoh86/exportloopref v0.1.8/go.mod h1:1tUcJeiioIs7VWe5gcOObrux3lb66+s
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8= github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.1 h1:6VXZrLU0jHBYyAqrSPa+MgPfnSvTPuMgK+k0o5kVFWo=
github.com/lib/pq v1.10.1/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.1/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e h1:9MlwzLdW7QSDrhDjFlsEYmxpFyIoXmYRon3dt0io31k= github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e h1:9MlwzLdW7QSDrhDjFlsEYmxpFyIoXmYRon3dt0io31k=
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=

View File

@ -23,6 +23,7 @@
"bourbon": "^5.0.0", "bourbon": "^5.0.0",
"classnames": "2.2.5", "classnames": "2.2.5",
"core-js": "3", "core-js": "3",
"date-fns": "^2.25.0",
"es6-object-assign": "1.1.0", "es6-object-assign": "1.1.0",
"es6-promise": "4.2.4", "es6-promise": "4.2.4",
"expect": "1.20.2", "expect": "1.20.2",
@ -55,7 +56,7 @@
"react-router-redux": "4.0.8", "react-router-redux": "4.0.8",
"react-router-transition": "0.1.1", "react-router-transition": "0.1.1",
"react-select": "^1", "react-select": "^1",
"react-table": "^7.6.3", "react-table": "7.7.0",
"react-tabs": "^3.2.0", "react-tabs": "^3.2.0",
"react-tooltip": "^4.2.15", "react-tooltip": "^4.2.15",
"redux": "4.0.5", "redux": "4.0.5",
@ -166,7 +167,7 @@
"@types/react-router": "^3.0.0", "@types/react-router": "^3.0.0",
"@types/react-router-redux": "^5.0.18", "@types/react-router-redux": "^5.0.18",
"@types/react-select": "1.3.0", "@types/react-select": "1.3.0",
"@types/react-table": "^7.0.28", "@types/react-table": "7.7.7",
"@types/react-tabs": "^2.3.2", "@types/react-tabs": "^2.3.2",
"@types/react-tooltip": "^4.2.4", "@types/react-tooltip": "^4.2.4",
"@typescript-eslint/eslint-plugin": "^4.15.2", "@typescript-eslint/eslint-plugin": "^4.15.2",

View File

@ -1759,10 +1759,10 @@
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"
"@types/react-table@^7.0.28": "@types/react-table@7.7.7":
version "7.0.28" version "7.7.7"
resolved "https://registry.yarnpkg.com/@types/react-table/-/react-table-7.0.28.tgz#763383c3e7a285892ee64f311ee97a9c254b2bb0" resolved "https://registry.yarnpkg.com/@types/react-table/-/react-table-7.7.7.tgz#503be1ce2e06857c11b281629f539358d32671f9"
integrity sha512-crPm70S2KYGj3HJ2zCoeT0t8tdIvKDKCClMd1up3Gi/EDiTZraj3JFUsEL3+oXGSyv+n0EGGAf9a+0XsmdGpXA== integrity sha512-3l2TP4detx9n5Jt44XhdH7Ku6PYwz6kB83P8W+YcBMUkIHtiw2gsCCcq9c4wyCIcdSwcTlWZ9WqH4PF7Yfbprg==
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"
@ -4810,6 +4810,11 @@ date-fns@^1.27.2:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c" resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw== integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==
date-fns@^2.25.0:
version "2.25.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.25.0.tgz#8c5c8f1d958be3809a9a03f4b742eba894fc5680"
integrity sha512-ovYRFnTrbGPD4nqaEqescPEv1mNwvt+UTqI3Ay9SzNtey9NZnYu6E2qCcBBgJ6/2VF1zGGygpyTDITqpQQ5e+w==
date-now@^0.1.4: date-now@^0.1.4:
version "0.1.4" version "0.1.4"
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
@ -11074,10 +11079,10 @@ react-select@^1:
prop-types "^15.5.8" prop-types "^15.5.8"
react-input-autosize "^2.1.2" react-input-autosize "^2.1.2"
react-table@^7.6.3: react-table@7.7.0:
version "7.6.3" version "7.7.0"
resolved "https://registry.yarnpkg.com/react-table/-/react-table-7.6.3.tgz#76434392b3f62344bdb704f5b227c2f29c1ffb14" resolved "https://registry.yarnpkg.com/react-table/-/react-table-7.7.0.tgz#e2ce14d7fe3a559f7444e9ecfe8231ea8373f912"
integrity sha512-hfPF13zDLxPMpLKzIKCE8RZud9T/XrRTsaCIf8zXpWZIZ2juCl7qrGpo3AQw9eAetXV5DP7s2GDm+hht7qq5Dw== integrity sha512-jBlj70iBwOTvvImsU9t01LjFjy4sXEtclBovl3mTiqjz23Reu0DKnRza4zlLtOPACx6j2/7MrQIthIK1Wi+LIA==
react-tabs@^3.2.0: react-tabs@^3.2.0:
version "3.2.0" version "3.2.0"