Skip to content

Commit

Permalink
fix(web): fix the display when app configuration is not in the bundle (
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk authored Aug 12, 2023
1 parent ec20355 commit 3d7631a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
17 changes: 15 additions & 2 deletions web/src/pages/home/mods/CreateAppModal/BundleControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default function BundleControl(props: {
specs: { value: number; price: number }[];
price: number;
}) => {
const value = item.specs.findIndex((spec) => spec.value === bundle[item.type]);
return item.specs.length > 0 ? (
<div className="ml-8 mt-8 flex" key={item.type}>
<span className={clsx("w-2/12", darkMode ? "" : "text-grayModern-600")}>
Expand All @@ -102,7 +103,7 @@ export default function BundleControl(props: {
<Slider
id="slider"
className="mr-12"
value={item.specs.findIndex((spec) => spec.value === bundle[item.type])}
value={value}
min={0}
max={item.specs.length - 1}
colorScheme="primary"
Expand Down Expand Up @@ -131,7 +132,19 @@ export default function BundleControl(props: {
<SliderTrack>
<SliderFilledTrack bg={"primary.200"} />
</SliderTrack>
<SliderThumb bg={"primary.500"} />
{value >= 0 ? (
<SliderThumb bg={"primary.500"} />
) : (
<SliderThumb
onClick={() => {
setBundle({
...bundle,
[item.type]: item.specs[0].value,
});
}}
style={{ opacity: 0 }}
/>
)}
</Slider>
</div>
) : null;
Expand Down
32 changes: 17 additions & 15 deletions web/src/pages/home/mods/CreateAppModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,22 @@ const CreateAppModal = (props: {
autoscaling,
});

const newResource = {
...currentApp.bundle.resource,
limitCPU: bundle.cpu,
limitMemory: bundle.memory,
databaseCapacity: bundle.databaseCapacity,
storageCapacity: bundle.storageCapacity,
};

const newBundle = {
...currentApp.bundle,
resource: newResource,
autoscaling: autoscaling,
};
isCurrentApp && setCurrentApp({ ...currentApp, bundle: newBundle });
if (isCurrentApp) {
const newResource = {
...currentApp.bundle.resource,
limitCPU: bundle.cpu,
limitMemory: bundle.memory,
databaseCapacity: bundle.databaseCapacity,
storageCapacity: bundle.storageCapacity,
};

const newBundle = {
...currentApp.bundle,
resource: newResource,
autoscaling: autoscaling,
};
setCurrentApp({ ...currentApp, bundle: newBundle });
}
break;

case "create":
Expand Down Expand Up @@ -306,7 +308,7 @@ const CreateAppModal = (props: {
)}
<div className="mr-2 flex items-center">
<span className="ml-4 mr-2">
{t("Balance")}:
{t("Balance") + ":"}
<span className="ml-2 text-xl">{formatPrice(accountRes?.data?.balance)}</span>
</span>
{totalPrice > accountRes?.data?.balance! ? (
Expand Down

0 comments on commit 3d7631a

Please sign in to comment.