瀏覽代碼

Show GB when instance RAM is larger than 1GB

This applies to Wizard instances selection screen.
Sergiu Miclea 3 年之前
父節點
當前提交
82c3c4d328
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/components/modules/WizardModule/WizardInstances/WizardInstances.tsx

+ 8 - 1
src/components/modules/WizardModule/WizardInstances/WizardInstances.tsx

@@ -30,6 +30,9 @@ import type { Instance as InstanceType } from "@src/@types/Instance";
 import instanceImage from "./images/instance.svg";
 import bigInstanceImage from "./images/instance-big.svg";
 
+const mbToGbString = (mb: number) =>
+  mb >= 1024 ? `${(mb / 1024).toFixed(2)} GB` : `${mb} MB`;
+
 const Wrapper = styled.div<any>`
   width: 100%;
   display: flex;
@@ -374,7 +377,11 @@ class WizardInstances extends React.Component<Props, State> {
                     <LabelSubtitle>{instanceId}</LabelSubtitle>
                   ) : null}
                 </Label>
-                <Details>{`${instance.num_cpu} vCPU | ${instance.memory_mb} MB RAM${flavorName}`}</Details>
+                <Details>
+                  {`${instance.num_cpu} vCPU | ${mbToGbString(
+                    instance.memory_mb
+                  )} RAM${flavorName}`}
+                </Details>
               </InstanceContent>
             </Instance>
           );