fleet/frontend/components/TableContainer/TableContainerUtils.ts

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-04-14 16:52:15 +00:00
const DEFAULT_RESULTS_NAME = "results";
2021-04-14 16:52:15 +00:00
const generateResultsCountText = (
name: string = DEFAULT_RESULTS_NAME,
pageIndex: number,
pageSize: number,
resultsCount: number,
filteredCount?: number
): string => {
implement user table with new table and hook up create and edit and delete users (#587) * hook up user and invite data together for data table * added client derived data to user table * hooked up action dropdown to table * hooked up edit modal and password reset * started adding editing user functiaonlity * add query params to /invite call * clean up editing teams * update select team from to handle existing users with teams * update closes modal now * reuse getUser to clean up code in userManagementpage * pass form data to updating user that is not the current User * add dynamic userform submit text and fix tests * fix lint error in table component * added empty state for user table * clean up unused data table props * added delete modal * add delete user functionality * add delete option for invite * Add styles for rows in user table and action dropdown cell * hook up user and invite data together for data table * added client derived data to user table * hooked up action dropdown to table * hooked up edit modal and password reset * started adding editing user functiaonlity * add query params to /invite call * clean up editing teams * update select team from to handle existing users with teams * update closes modal now * reuse getUser to clean up code in userManagementpage * pass form data to updating user that is not the current User * add dynamic userform submit text and fix tests * fix lint error in table component * added empty state for user table * clean up unused data table props * added delete modal * add delete user functionality * add delete option for invite * Merge in generateClassTag * Refactor table styles * Add newline to DropdownCell style sheet Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> * update checking for admin through global_role in nav * added defaultGloablRole for creat user modal * remove unused comment * fix broken tests * reenabled search for users tests Co-authored-by: noahtalerman <47070608+noahtalerman@users.noreply.github.com>
2021-04-09 10:44:57 +00:00
if (resultsCount === 0) return `No ${name}`;
// If there is 1 result and the last 3 letters in the result
// name are "ies," we remove the "ies" and add "y"
// to make the name singular
if (resultsCount === 1 && name.slice(-3) === "ies") {
return `${resultsCount} ${name.slice(0, -3)}y`;
}
// If there is 1 result and the last 2 letters in the result
// name are "es," we remove the "es" to make the name singular
if (resultsCount === 1 && name.slice(-2) === "es") {
return `${resultsCount} ${name.slice(0, -2)}y`;
}
// If there is 1 result and the last letter in the result
// name is "s," we remove the "s" to make the name singular
if (resultsCount === 1 && name[name.length - 1] === "s") {
return `${resultsCount} ${name.slice(0, -1)}`;
}
implement user table with new table and hook up create and edit and delete users (#587) * hook up user and invite data together for data table * added client derived data to user table * hooked up action dropdown to table * hooked up edit modal and password reset * started adding editing user functiaonlity * add query params to /invite call * clean up editing teams * update select team from to handle existing users with teams * update closes modal now * reuse getUser to clean up code in userManagementpage * pass form data to updating user that is not the current User * add dynamic userform submit text and fix tests * fix lint error in table component * added empty state for user table * clean up unused data table props * added delete modal * add delete user functionality * add delete option for invite * Add styles for rows in user table and action dropdown cell * hook up user and invite data together for data table * added client derived data to user table * hooked up action dropdown to table * hooked up edit modal and password reset * started adding editing user functiaonlity * add query params to /invite call * clean up editing teams * update select team from to handle existing users with teams * update closes modal now * reuse getUser to clean up code in userManagementpage * pass form data to updating user that is not the current User * add dynamic userform submit text and fix tests * fix lint error in table component * added empty state for user table * clean up unused data table props * added delete modal * add delete user functionality * add delete option for invite * Merge in generateClassTag * Refactor table styles * Add newline to DropdownCell style sheet Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> * update checking for admin through global_role in nav * added defaultGloablRole for creat user modal * remove unused comment * fix broken tests * reenabled search for users tests Co-authored-by: noahtalerman <47070608+noahtalerman@users.noreply.github.com>
2021-04-09 10:44:57 +00:00
// If there is no filtered count, return pageSize+ name
if (pageSize === resultsCount && !filteredCount)
return `${pageSize}+ ${name}`;
if (pageIndex !== 0 && resultsCount <= pageSize && !filteredCount)
2021-04-14 16:52:15 +00:00
return `${pageSize}+ ${name}`;
return `${resultsCount} ${name}`;
};
export default { generateResultsCountText };