Skip to content

Commit eb9ece5

Browse files
committed
chore(FR-831): update ResourcePresetSettingModal to display exact memory value
1 parent 69b043b commit eb9ece5

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

react/src/components/ResourceNumber.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const ResourceNumber: React.FC<ResourceNumberProps> = ({
3737
hideTooltip = false,
3838
max,
3939
}) => {
40+
console.log(type);
4041
const { token } = theme.useToken();
4142
const currentGroup = useCurrentResourceGroupValue();
4243
const { mergedResourceSlots } = useResourceSlotsDetails(
@@ -46,7 +47,7 @@ const ResourceNumber: React.FC<ResourceNumberProps> = ({
4647
const formatAmount = (amount: string) => {
4748
return mergedResourceSlots?.[type]?.number_format.binary
4849
? Number(
49-
convertBinarySizeUnit(amount, 'g', 3, true)?.numberFixed,
50+
convertBinarySizeUnit(amount, 'g', 2, true)?.numberFixed,
5051
).toString()
5152
: (mergedResourceSlots?.[type]?.number_format.round_length || 0) > 0
5253
? parseFloat(amount).toFixed(2)

react/src/components/ResourcePresetList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ const ResourcePresetList: React.FC<ResourcePresetListProps> = () => {
103103
title: t('resourcePreset.SharedMemory'),
104104
dataIndex: 'shared_memory',
105105
render: (text) =>
106-
text ? convertBinarySizeUnit(text + '', 'g')?.numberFixed : '-',
106+
text
107+
? Number(
108+
convertBinarySizeUnit(text + '', 'g', 2, true)?.numberFixed,
109+
).toString()
110+
: '-',
107111
},
108112
baiClient?.supports('resource-presets-per-resource-group') && {
109113
title: t('general.ResourceGroup'),

react/src/components/ResourcePresetSettingModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ const ResourcePresetSettingModal: React.FC<ResourcePresetSettingModalProps> = ({
236236
JSON.parse(resourcePreset?.resource_slots || '{}'),
237237
(value, key) =>
238238
_.includes(key, 'mem')
239-
? convertBinarySizeUnit(value + 'b', 'g')?.numberUnit
239+
? convertBinarySizeUnit(value + 'b', 'auto')?.numberUnit
240240
: value,
241241
) || {},
242242
shared_memory: resourcePreset?.shared_memory
243243
? convertBinarySizeUnit(
244244
resourcePreset?.shared_memory + 'b',
245-
'g',
245+
'auto',
246246
)?.numberUnit
247247
: null,
248248
}

0 commit comments

Comments
 (0)