feat: add a toggle for replica sets to be used or not

This commit is contained in:
Shadow
2024-12-18 11:50:30 -06:00
parent 8505236263
commit 06b8c82484
3 changed files with 60 additions and 22 deletions

View File

@@ -35,6 +35,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { Textarea } from "@/components/ui/textarea";
import { slugify } from "@/lib/slug";
import { api } from "@/utils/api";
@@ -95,6 +96,7 @@ const mySchema = z.discriminatedUnion("type", [
.object({
type: z.literal("mongo"),
databaseUser: z.string().default("mongo"),
replicaSets: z.boolean().default(false),
})
.merge(baseDatabaseSchema),
z
@@ -216,6 +218,7 @@ export const AddDatabase = ({ projectId, projectName }: Props) => {
databaseUser:
data.databaseUser || databasesUserDefaultPlaceholder[data.type],
serverId: data.serverId,
replicaSets: data.replicaSets,
});
} else if (data.type === "redis") {
promise = redisMutation.mutateAsync({
@@ -540,6 +543,30 @@ export const AddDatabase = ({ projectId, projectName }: Props) => {
);
}}
/>
{type === "mongo" && (
<FormField
control={form.control}
name="replicaSets"
render={({ field }) => {
return (
<FormItem>
<FormLabel>Use Replica Sets</FormLabel>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
disabled
aria-readonly
/>
</FormControl>
<FormMessage />
</FormItem>
);
}}
/>
)}
</div>
</div>
</form>