fix: sort apps list by id and not by name in order to avoid lowercase names being put at the end

This commit is contained in:
Nicolas Meienberger 2023-05-05 22:06:32 +02:00 committed by Nicolas Meienberger
parent 9547a2233b
commit 7a6b6ed0b6
5 changed files with 6 additions and 6 deletions

View file

@ -3,7 +3,7 @@ import { AppTableData } from './table.types';
type SortParams = {
data: AppTableData;
col: keyof Pick<AppInfo, 'name'>;
col: keyof Pick<AppInfo, 'id'>;
direction: 'asc' | 'desc';
category?: AppCategory;
search: string;

View file

@ -1,6 +1,6 @@
import { AppInfo } from '../../../core/types';
export type SortableColumns = keyof Pick<AppInfo, 'name'>;
export type SortableColumns = keyof Pick<AppInfo, 'id'>;
export type SortDirection = 'asc' | 'desc';
export type AppTableData = Omit<AppInfo, 'description' | 'form_fields' | 'source' | 'status' | 'url_suffix' | 'version'>[];

View file

@ -18,7 +18,7 @@ export const useAppStoreState = create<Store>((set) => ({
search: '',
setSearch: (search) => set({ search }),
setCategory: (category) => set({ category }),
sort: 'name',
sort: 'id',
setSort: (sort) => set({ sort }),
sortDirection: 'asc',
setSortDirection: (sortDirection) => set({ sortDirection }),

View file

@ -502,10 +502,10 @@ describe('List apps', () => {
fs.__createMockFiles(Object.assign(app1create.MockFiles, app2create.MockFiles));
});
it('Should correctly list apps sorted by name', async () => {
it('Should correctly list apps sorted by id', async () => {
const { apps } = await AppServiceClass.listApps();
const sortedApps = [app1, app2].sort((a, b) => a.name.localeCompare(b.name));
const sortedApps = [app1, app2].sort((a, b) => a.id.localeCompare(b.name));
expect(apps).toBeDefined();
expect(apps.length).toBe(2);

View file

@ -10,7 +10,7 @@ import { Logger } from '../../core/Logger';
import { createFolder } from '../../common/fs.helpers';
import { notEmpty } from '../../common/typescript.helpers';
const sortApps = (a: AppInfo, b: AppInfo) => a.name.localeCompare(b.name);
const sortApps = (a: AppInfo, b: AppInfo) => a.id.localeCompare(b.id);
const filterApp = (app: AppInfo): boolean => {
if (!app.supported_architectures) {
return true;