11import type { SelectOption } from '@gravity-ui/uikit' ;
22import { z } from 'zod' ;
33
4- import type { GroupsGroupByField , GroupsRequiredField } from '../../../../types/api/storage' ;
4+ import type {
5+ GroupsGroupByField ,
6+ GroupsRequiredField ,
7+ StorageV2SortValue ,
8+ } from '../../../../types/api/storage' ;
59import type { ValueOf } from '../../../../types/common' ;
610
711import i18n from './i18n' ;
@@ -13,7 +17,6 @@ export const STORAGE_GROUPS_COLUMNS_IDS = {
1317 GroupId : 'GroupId' ,
1418 PoolName : 'PoolName' ,
1519 MediaType : 'MediaType' ,
16- Encryption : 'Encryption' ,
1720 Erasure : 'Erasure' ,
1821 Used : 'Used' ,
1922 Limit : 'Limit' ,
@@ -26,9 +29,7 @@ export const STORAGE_GROUPS_COLUMNS_IDS = {
2629 AllocationUnits : 'AllocationUnits' ,
2730 VDisks : 'VDisks' ,
2831 VDisksPDisks : 'VDisksPDisks' ,
29- MissingDisks : 'MissingDisks' ,
3032 Degraded : 'Degraded' ,
31- State : 'State' ,
3233} as const ;
3334
3435export type StorageGroupsColumnId = ValueOf < typeof STORAGE_GROUPS_COLUMNS_IDS > ;
@@ -57,9 +58,6 @@ export const STORAGE_GROUPS_COLUMNS_TITLES = {
5758 get MediaType ( ) {
5859 return i18n ( 'type' ) ;
5960 } ,
60- get Encryption ( ) {
61- return i18n ( 'encryption' ) ;
62- } ,
6361 get Erasure ( ) {
6462 return i18n ( 'erasure' ) ;
6563 } ,
@@ -102,13 +100,43 @@ export const STORAGE_GROUPS_COLUMNS_TITLES = {
102100 get Degraded ( ) {
103101 return i18n ( 'missing-disks' ) ;
104102 } ,
103+ } as const satisfies Record < StorageGroupsColumnId , string > ;
104+
105+ const STORAGE_GROUPS_COLUMNS_GROUP_BY_TITLES = {
106+ get GroupId ( ) {
107+ return i18n ( 'group-id' ) ;
108+ } ,
109+ get Erasure ( ) {
110+ return i18n ( 'erasure' ) ;
111+ } ,
112+ get Usage ( ) {
113+ return i18n ( 'usage' ) ;
114+ } ,
115+ get DiskSpaceUsage ( ) {
116+ return i18n ( 'disk-usage' ) ;
117+ } ,
118+ get PoolName ( ) {
119+ return i18n ( 'pool-name' ) ;
120+ } ,
121+ get Kind ( ) {
122+ return i18n ( 'type' ) ;
123+ } ,
124+ get Encryption ( ) {
125+ return i18n ( 'encryption' ) ;
126+ } ,
127+ get MediaType ( ) {
128+ return i18n ( 'type' ) ;
129+ } ,
105130 get MissingDisks ( ) {
106131 return i18n ( 'missing-disks' ) ;
107132 } ,
108133 get State ( ) {
109134 return i18n ( 'state' ) ;
110135 } ,
111- } as const satisfies Record < StorageGroupsColumnId , string > ;
136+ get Latency ( ) {
137+ return i18n ( 'latency' ) ;
138+ } ,
139+ } as const satisfies Record < GroupsGroupByField , string > ;
112140
113141const STORAGE_GROUPS_GROUP_BY_PARAMS = [
114142 'PoolName' ,
@@ -126,7 +154,7 @@ export const STORAGE_GROUPS_GROUP_BY_OPTIONS: SelectOption[] = STORAGE_GROUPS_GR
126154 ( param ) => {
127155 return {
128156 value : param ,
129- content : STORAGE_GROUPS_COLUMNS_TITLES [ param ] ,
157+ content : STORAGE_GROUPS_COLUMNS_GROUP_BY_TITLES [ param ] ,
130158 } ;
131159 } ,
132160) ;
@@ -144,7 +172,6 @@ export const GROUPS_COLUMNS_TO_DATA_FIELDS: Record<StorageGroupsColumnId, Groups
144172 PoolName : [ 'PoolName' ] ,
145173 // We display MediaType and Encryption in one Type column
146174 MediaType : [ 'MediaType' , 'Encryption' ] ,
147- Encryption : [ 'Encryption' ] ,
148175 Erasure : [ 'Erasure' ] ,
149176 Used : [ 'Used' ] ,
150177 Limit : [ 'Limit' ] ,
@@ -158,7 +185,35 @@ export const GROUPS_COLUMNS_TO_DATA_FIELDS: Record<StorageGroupsColumnId, Groups
158185 // Read and Write fields make backend to return Whiteboard data
159186 VDisks : [ 'VDisk' , 'PDisk' , 'Read' , 'Write' ] ,
160187 VDisksPDisks : [ 'VDisk' , 'PDisk' , 'Read' , 'Write' ] ,
161- MissingDisks : [ 'MissingDisks' ] ,
162188 Degraded : [ 'MissingDisks' ] ,
163- State : [ 'State' ] ,
164189} ;
190+
191+ const STORAGE_GROUPS_COLUMNS_TO_SORT_FIELDS : Record <
192+ StorageGroupsColumnId ,
193+ StorageV2SortValue | undefined
194+ > = {
195+ GroupId : 'GroupId' ,
196+ PoolName : 'PoolName' ,
197+ MediaType : 'MediaType' ,
198+ Erasure : 'Erasure' ,
199+ Used : 'Used' ,
200+ Limit : 'Limit' ,
201+ Usage : 'Usage' ,
202+ DiskSpaceUsage : 'DiskSpaceUsage' ,
203+ DiskSpace : undefined ,
204+ Read : 'Read' ,
205+ Write : 'Write' ,
206+ Latency : 'Latency' ,
207+ AllocationUnits : 'AllocationUnits' ,
208+ VDisks : undefined ,
209+ VDisksPDisks : undefined ,
210+ Degraded : 'Degraded' ,
211+ } ;
212+
213+ export function getStorageGroupsColumnSortField ( columnId ?: string ) {
214+ return STORAGE_GROUPS_COLUMNS_TO_SORT_FIELDS [ columnId as StorageGroupsColumnId ] ;
215+ }
216+
217+ export function isSortableStorageGroupsColumn ( columnId : string ) {
218+ return Boolean ( getStorageGroupsColumnSortField ( columnId ) ) ;
219+ }
0 commit comments