Skip to content

Commit

Permalink
add new elasticache and db types and slight form refactor (#4530)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Apr 12, 2024
1 parent cd5bed4 commit a7fe481
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 40 deletions.
2 changes: 2 additions & 0 deletions dashboard/src/lib/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ const instanceTierValidator = z.enum([
"db.t4g.medium",
"db.t4g.large",
"db.m6g.large",
"db.r6g.4xlarge",
"cache.t4g.micro",
"cache.t4g.small",
"cache.t4g.medium",
"cache.r6g.large",
"cache.r6g.xlarge",
Expand Down
14 changes: 14 additions & 0 deletions dashboard/src/main/home/database-dashboard/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ export const DATASTORE_TEMPLATE_AWS_RDS: DatastoreTemplate = Object.freeze({
ramGigabytes: 8,
storageGigabytes: 512,
},
{
tier: "db.r6g.4xlarge" as const,
label: "Extra Large",
cpuCores: 16,
ramGigabytes: 128,
storageGigabytes: 2048,
},
],
formTitle: "Create an RDS PostgreSQL instance",
creationStateProgression: [
Expand Down Expand Up @@ -169,6 +176,13 @@ export const DATASTORE_TEMPLATE_AWS_ELASTICACHE: DatastoreTemplate =
ramGigabytes: 0.5,
storageGigabytes: 0,
},
{
tier: "cache.t4g.small" as const,
label: "Small",
cpuCores: 2,
ramGigabytes: 1.37,
storageGigabytes: 0,
},
{
tier: "cache.t4g.medium" as const,
label: "Medium",
Expand Down
86 changes: 47 additions & 39 deletions dashboard/src/main/home/database-dashboard/forms/DatastoreForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import ConnectionInfo from "../shared/ConnectionInfo";
import Resources from "../shared/Resources";

const DatastoreForm: React.FC = () => {
const [currentStep, setCurrentStep] = useState(1);
const [currentStep, setCurrentStep] = useState(0);
const [template, setTemplate] = useState<DatastoreTemplate | undefined>(
undefined
);
Expand Down Expand Up @@ -132,42 +132,7 @@ const DatastoreForm: React.FC = () => {
<VerticalSteps
steps={[
<>
<Text size={16}>Datastore name</Text>
<Spacer y={0.5} />
<Text color="helper">
Lowercase letters, numbers, and &quot;-&quot; only.
</Text>
<Spacer y={0.5} />
<ControlledInput
placeholder="ex: academic-sophon-db"
type="text"
width="300px"
error={errors.name?.message}
{...register("name")}
/>
{clusters.length > 1 && (
<>
<Spacer y={1} />
<Selector<string>
activeValue={watchClusterId.toString()}
width="300px"
options={clusters.map((c) => ({
value: c.id.toString(),
label: c.vanity_name,
key: c.id.toString(),
}))}
setActiveValue={(value: string) => {
setValue("clusterId", parseInt(value));
setValue("engine", "UNKNOWN");
setCurrentStep(1);
}}
label={"Cluster"}
/>
</>
)}
</>,
<>
<Text size={16}>Datastore engine</Text>
<Text size={16}>Datastore type</Text>
<Spacer y={0.5} />
<Controller
name="engine"
Expand All @@ -181,15 +146,58 @@ const DatastoreForm: React.FC = () => {
onChange(opt.name);
setValue("workloadType", "unspecified");
setTemplate(undefined);
setCurrentStep(2);
setCurrentStep(1);
}}
/>
)}
/>
</>,
<>
<Text size={16}>Workload type</Text>
<Text size={16}>Datastore name</Text>
{watchEngine !== "UNKNOWN" && (
<>
<Spacer y={0.5} />
<Text color="helper">
Lowercase letters, numbers, and &quot;-&quot; only.
</Text>
<Spacer y={0.5} />
<ControlledInput
placeholder="ex: academic-sophon-db"
type="text"
width="300px"
error={errors.name?.message}
{...register("name")}
onChange={(e) => {
setValue("name", e.target.value);
setCurrentStep(Math.max(2, currentStep));
}}
/>
{clusters.length > 1 && (
<>
<Spacer y={1} />
<Selector<string>
activeValue={watchClusterId.toString()}
width="300px"
options={clusters.map((c) => ({
value: c.id.toString(),
label: c.vanity_name,
key: c.id.toString(),
}))}
setActiveValue={(value: string) => {
setValue("clusterId", parseInt(value));
setValue("workloadType", "unspecified");
setCurrentStep(2);
}}
label={"Cluster"}
/>
</>
)}
</>
)}
</>,
<>
<Text size={16}>Workload type</Text>
{currentStep >= 2 && (
<>
<Spacer y={0.5} />
<Controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ const Resources: React.FC<Props> = ({
- {o.cpuCores} CPU, {o.ramGigabytes} GB RAM
</Text>
</Container>
<StorageTag>{o.storageGigabytes} GB Storage</StorageTag>
{o.storageGigabytes > 1024 ? (
<StorageTag>
{Math.round(o.storageGigabytes / 1024)} TB Storage
</StorageTag>
) : (
<StorageTag>{o.storageGigabytes} GB Storage</StorageTag>
)}
</>
) : (
<>
Expand Down

0 comments on commit a7fe481

Please sign in to comment.