Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web&server) The number of database copies can be changed #5

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading