Pārlūkot izejas kodu

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

Nicolas Meienberger 2 gadi atpakaļ
vecāks
revīzija
7a6b6ed0b6

+ 1 - 1
src/client/modules/AppStore/helpers/table.helpers.ts

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

+ 1 - 1
src/client/modules/AppStore/helpers/table.types.ts

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

+ 1 - 1
src/client/modules/AppStore/state/appStoreState.ts

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

+ 2 - 2
src/server/services/apps/apps.service.test.ts

@@ -502,10 +502,10 @@ describe('List apps', () => {
     fs.__createMockFiles(Object.assign(app1create.MockFiles, app2create.MockFiles));
     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 { 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).toBeDefined();
     expect(apps.length).toBe(2);
     expect(apps.length).toBe(2);

+ 1 - 1
src/server/services/apps/apps.service.ts

@@ -10,7 +10,7 @@ import { Logger } from '../../core/Logger';
 import { createFolder } from '../../common/fs.helpers';
 import { createFolder } from '../../common/fs.helpers';
 import { notEmpty } from '../../common/typescript.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 => {
 const filterApp = (app: AppInfo): boolean => {
   if (!app.supported_architectures) {
   if (!app.supported_architectures) {
     return true;
     return true;