fleet/frontend/components/TableContainer/DataTable/HeaderCell/HeaderCell.tsx

32 lines
689 B
TypeScript
Raw Normal View History

import React from "react";
Feature - add search and sort to host table (#341) * start adding global search filter * update polyfill setup to use async await for react-table * update browerslist to sensible defaults * get global search functionality woring * more progress on the data table * get label network calls working in hostdatatable * get pagination functionality into the HostDataTable * get search query making network call * get ordering making query * make actual sort order network calls * disable cpu column sorting * seperate get table data from get labels * fix issues with input resetting and got search query working * get sort working * ignore vs code editor settings * improve loading spinner to move inside the table * improve styling * add sorting arrows * remove unused sorting arrow component * add host query params to labels endpoint * fix style for query textarea on label hosts * got new pagination working * set server data as source of truth for table global filter * cleanup logs * clean up pagination styles * fix up paginationa and no host styles * add result count to table * remove logs * tweak header styles * fix to sort order * simplify default sort direction * keep sort order of server api responses and use in host table * clean up logs * Add styles for header cell and pagination * fix tests for ManageHostPage * fix tests for HostContainer * fix lower level action reducer and thunk tests * fix tests for hosts client * fix up some host count styling * added back no hosts start message * fix linting errors * remove unused old pagination code * add back scrollToTop utility on pagination * remove unused code in managehostpage test Co-authored-by: Noah Talerman <noahtal@umich.edu>
2021-02-25 12:05:08 +00:00
interface IHeaderCellProps {
value: string;
isSortedDesc?: boolean;
}
const HeaderCell = (props: IHeaderCellProps): JSX.Element => {
const { value, isSortedDesc } = props;
Feature - add search and sort to host table (#341) * start adding global search filter * update polyfill setup to use async await for react-table * update browerslist to sensible defaults * get global search functionality woring * more progress on the data table * get label network calls working in hostdatatable * get pagination functionality into the HostDataTable * get search query making network call * get ordering making query * make actual sort order network calls * disable cpu column sorting * seperate get table data from get labels * fix issues with input resetting and got search query working * get sort working * ignore vs code editor settings * improve loading spinner to move inside the table * improve styling * add sorting arrows * remove unused sorting arrow component * add host query params to labels endpoint * fix style for query textarea on label hosts * got new pagination working * set server data as source of truth for table global filter * cleanup logs * clean up pagination styles * fix up paginationa and no host styles * add result count to table * remove logs * tweak header styles * fix to sort order * simplify default sort direction * keep sort order of server api responses and use in host table * clean up logs * Add styles for header cell and pagination * fix tests for ManageHostPage * fix tests for HostContainer * fix lower level action reducer and thunk tests * fix tests for hosts client * fix up some host count styling * added back no hosts start message * fix linting errors * remove unused old pagination code * add back scrollToTop utility on pagination * remove unused code in managehostpage test Co-authored-by: Noah Talerman <noahtal@umich.edu>
2021-02-25 12:05:08 +00:00
let sortArrowClass = "";
Feature - add search and sort to host table (#341) * start adding global search filter * update polyfill setup to use async await for react-table * update browerslist to sensible defaults * get global search functionality woring * more progress on the data table * get label network calls working in hostdatatable * get pagination functionality into the HostDataTable * get search query making network call * get ordering making query * make actual sort order network calls * disable cpu column sorting * seperate get table data from get labels * fix issues with input resetting and got search query working * get sort working * ignore vs code editor settings * improve loading spinner to move inside the table * improve styling * add sorting arrows * remove unused sorting arrow component * add host query params to labels endpoint * fix style for query textarea on label hosts * got new pagination working * set server data as source of truth for table global filter * cleanup logs * clean up pagination styles * fix up paginationa and no host styles * add result count to table * remove logs * tweak header styles * fix to sort order * simplify default sort direction * keep sort order of server api responses and use in host table * clean up logs * Add styles for header cell and pagination * fix tests for ManageHostPage * fix tests for HostContainer * fix lower level action reducer and thunk tests * fix tests for hosts client * fix up some host count styling * added back no hosts start message * fix linting errors * remove unused old pagination code * add back scrollToTop utility on pagination * remove unused code in managehostpage test Co-authored-by: Noah Talerman <noahtal@umich.edu>
2021-02-25 12:05:08 +00:00
if (isSortedDesc === undefined) {
sortArrowClass = "";
Feature - add search and sort to host table (#341) * start adding global search filter * update polyfill setup to use async await for react-table * update browerslist to sensible defaults * get global search functionality woring * more progress on the data table * get label network calls working in hostdatatable * get pagination functionality into the HostDataTable * get search query making network call * get ordering making query * make actual sort order network calls * disable cpu column sorting * seperate get table data from get labels * fix issues with input resetting and got search query working * get sort working * ignore vs code editor settings * improve loading spinner to move inside the table * improve styling * add sorting arrows * remove unused sorting arrow component * add host query params to labels endpoint * fix style for query textarea on label hosts * got new pagination working * set server data as source of truth for table global filter * cleanup logs * clean up pagination styles * fix up paginationa and no host styles * add result count to table * remove logs * tweak header styles * fix to sort order * simplify default sort direction * keep sort order of server api responses and use in host table * clean up logs * Add styles for header cell and pagination * fix tests for ManageHostPage * fix tests for HostContainer * fix lower level action reducer and thunk tests * fix tests for hosts client * fix up some host count styling * added back no hosts start message * fix linting errors * remove unused old pagination code * add back scrollToTop utility on pagination * remove unused code in managehostpage test Co-authored-by: Noah Talerman <noahtal@umich.edu>
2021-02-25 12:05:08 +00:00
} else if (isSortedDesc) {
sortArrowClass = "descending";
Feature - add search and sort to host table (#341) * start adding global search filter * update polyfill setup to use async await for react-table * update browerslist to sensible defaults * get global search functionality woring * more progress on the data table * get label network calls working in hostdatatable * get pagination functionality into the HostDataTable * get search query making network call * get ordering making query * make actual sort order network calls * disable cpu column sorting * seperate get table data from get labels * fix issues with input resetting and got search query working * get sort working * ignore vs code editor settings * improve loading spinner to move inside the table * improve styling * add sorting arrows * remove unused sorting arrow component * add host query params to labels endpoint * fix style for query textarea on label hosts * got new pagination working * set server data as source of truth for table global filter * cleanup logs * clean up pagination styles * fix up paginationa and no host styles * add result count to table * remove logs * tweak header styles * fix to sort order * simplify default sort direction * keep sort order of server api responses and use in host table * clean up logs * Add styles for header cell and pagination * fix tests for ManageHostPage * fix tests for HostContainer * fix lower level action reducer and thunk tests * fix tests for hosts client * fix up some host count styling * added back no hosts start message * fix linting errors * remove unused old pagination code * add back scrollToTop utility on pagination * remove unused code in managehostpage test Co-authored-by: Noah Talerman <noahtal@umich.edu>
2021-02-25 12:05:08 +00:00
} else {
sortArrowClass = "ascending";
Feature - add search and sort to host table (#341) * start adding global search filter * update polyfill setup to use async await for react-table * update browerslist to sensible defaults * get global search functionality woring * more progress on the data table * get label network calls working in hostdatatable * get pagination functionality into the HostDataTable * get search query making network call * get ordering making query * make actual sort order network calls * disable cpu column sorting * seperate get table data from get labels * fix issues with input resetting and got search query working * get sort working * ignore vs code editor settings * improve loading spinner to move inside the table * improve styling * add sorting arrows * remove unused sorting arrow component * add host query params to labels endpoint * fix style for query textarea on label hosts * got new pagination working * set server data as source of truth for table global filter * cleanup logs * clean up pagination styles * fix up paginationa and no host styles * add result count to table * remove logs * tweak header styles * fix to sort order * simplify default sort direction * keep sort order of server api responses and use in host table * clean up logs * Add styles for header cell and pagination * fix tests for ManageHostPage * fix tests for HostContainer * fix lower level action reducer and thunk tests * fix tests for hosts client * fix up some host count styling * added back no hosts start message * fix linting errors * remove unused old pagination code * add back scrollToTop utility on pagination * remove unused code in managehostpage test Co-authored-by: Noah Talerman <noahtal@umich.edu>
2021-02-25 12:05:08 +00:00
}
return (
<div className={`header-cell ${sortArrowClass}`}>
<span>{value}</span>
<div className="sort-arrows">
<span className="ascending-arrow" />
<span className="descending-arrow" />
</div>
</div>
);
};
export default HeaderCell;