Skip to content

Commit

Permalink
Merge pull request #5 from HUAHUAI23/chore/web
Browse files Browse the repository at this point in the history
chore(web&server) The number of database copies can be changed
  • Loading branch information
0fatal authored Jun 15, 2024
2 parents 5086772 + 441ec39 commit 8cb778b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions server/src/application/application.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,12 @@ export class ApplicationController {
if (
dto.dedicatedDatabase?.replicas &&
origin.resource.dedicatedDatabase?.replicas &&
dto.dedicatedDatabase?.replicas !==
dto.dedicatedDatabase?.replicas <
origin.resource.dedicatedDatabase?.replicas
) {
return ResponseUtil.error('cannot change database replicas')
return ResponseUtil.error(
'To reduce the number of database replicas, please contact customer support.',
)
}

const doc = await this.application.updateBundle(appid, dto, isTrialTier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import useGlobalStore from "@/pages/globalStore";

export default function DatabaseBundleControl(props: {
bundle: TypeBundle;
originReplicas?: number;
originCapacity?: number;
resourceOptions: any;
type: "create" | "change";
defaultDedicatedDatabaseBundle?: any;
onBundleItemChange: (k: string, v?: number) => any;
}) {
const { bundle, type, onBundleItemChange, resourceOptions, originCapacity } = props;
const { bundle, onBundleItemChange, resourceOptions, originCapacity, originReplicas } = props;
const { t } = useTranslation();
const darkMode = useColorMode().colorMode === COLOR_MODE.dark;

Expand Down Expand Up @@ -135,7 +136,8 @@ export default function DatabaseBundleControl(props: {
})}
{buildSlider({
type: "replicas",
disable: type === "change",
min: originReplicas,
// disable: type === "change",
value: _.get(bundle, "dedicatedDatabase.replicas") as unknown as number,
specs: find(resourceOptions, { type: "dedicatedDatabaseReplicas" })?.specs || [],
onChange: (value) => {
Expand Down
1 change: 1 addition & 0 deletions web/src/pages/home/mods/CreateAppModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ const CreateAppModal = (props: {
<DatabaseBundleControl
bundle={bundle}
originCapacity={application?.bundle.resource.dedicatedDatabase?.capacity}
originReplicas={application?.bundle.resource.dedicatedDatabase?.replicas}
onBundleItemChange={(k: string, v?: number) => {
setBundle((prev) => {
const v1 = _.cloneDeep(_.set(prev, k, v));
Expand Down

0 comments on commit 8cb778b

Please sign in to comment.