Fleet UI: Queries default to alpha order (#12924)

This commit is contained in:
RachelElysia 2023-07-24 10:46:52 -04:00 committed by GitHub
parent 7bff7447b0
commit fdf89989c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View file

@ -22,7 +22,7 @@ const TAGGED_TEMPLATES = {
};
const DEFAULT_SORT_DIRECTION = "asc";
const DEFAULT_SORT_HEADER = "updated_at";
const DEFAULT_SORT_HEADER = "name";
interface IPoliciesTableProps {
policiesList: IPolicyStats[];

View file

@ -66,8 +66,14 @@ const ManageAutomationsModal = ({
// TODO: Error handling, if any
const [errors, setErrors] = useState<{ [key: string]: string }>({});
// Client side sort queries alphabetically
const sortedAvailableQueries =
availableQueries?.sort((a, b) =>
a.name.toLowerCase().localeCompare(b.name.toLowerCase())
) || [];
const { queryItems, updateQueryItems } = useCheckboxListStateManagement(
availableQueries || [],
sortedAvailableQueries,
automatedQueryIds || []
);

View file

@ -44,8 +44,8 @@ interface IQueriesTableProps {
isInherited?: boolean;
}
const DEFAULT_SORT_DIRECTION = "desc";
const DEFAULT_SORT_HEADER = "updated_at";
const DEFAULT_SORT_DIRECTION = "asc";
const DEFAULT_SORT_HEADER = "name";
const DEFAULT_PAGE_SIZE = 20;
const DEFAULT_PLATFORM = "all";
@ -99,8 +99,7 @@ const QueriesTable = ({
// Functions to avoid race conditions
const initialSearchQuery = (() => queryParams?.query ?? "")();
const initialSortHeader = (() =>
(queryParams?.order_key as "updated_at" | "name" | "author") ??
"updated_at")();
(queryParams?.order_key as "name" | "updated_at" | "author") ?? "name")();
const initialSortDirection = (() =>
(queryParams?.order_direction as "asc" | "desc") ?? "asc")();
const initialPlatform = (() =>