This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
EVG-19947: Support EC2 Fleet on provider settings page #2050
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
03666c1
EVG-19947: Support EC2 Fleet on provider settings page
minnakt 1dd652d
Codegen
minnakt 1f23cfa
Merge branch 'main' into EVG-19947
minnakt b0a3238
Merge branch 'main' into EVG-19947
minnakt 12bd557
Address comments
minnakt 2032342
Merge branch 'main' into EVG-19947
minnakt d3b7f25
Clean up
minnakt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
import { css } from "@emotion/react"; | ||
import { GetFormSchema } from "components/SpruceForm"; | ||
import { CardFieldTemplate } from "components/SpruceForm/FieldTemplates"; | ||
import { | ||
CardFieldTemplate, | ||
AccordionFieldTemplate, | ||
} from "components/SpruceForm/FieldTemplates"; | ||
import { STANDARD_FIELD_WIDTH } from "components/SpruceForm/utils"; | ||
import { size } from "constants/tokens"; | ||
import { Provider, ContainerPool } from "gql/generated/types"; | ||
import { dockerProviderSettings, staticProviderSettings } from "./schemaFields"; | ||
import { | ||
dockerProviderSettings, | ||
staticProviderSettings, | ||
ec2FleetProviderSettings, | ||
} from "./schemaFields"; | ||
|
||
export const getFormSchema = ({ | ||
awsRegions, | ||
configuredRegions, | ||
poolMappingInfo, | ||
pools, | ||
}: { | ||
awsRegions: string[]; | ||
configuredRegions: string[]; | ||
poolMappingInfo: string; | ||
pools: ContainerPool[]; | ||
}): ReturnType<GetFormSchema> => ({ | ||
|
@@ -96,13 +108,45 @@ export const getFormSchema = ({ | |
})), | ||
}, | ||
poolMappingInfo: dockerProviderSettings.poolMappingInfo, | ||
userData: dockerProviderSettings.userData, | ||
mergeUserData: dockerProviderSettings.mergeUserData, | ||
userData: dockerProviderSettings.userData, | ||
securityGroups: dockerProviderSettings.securityGroups, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
properties: { | ||
provider: { | ||
properties: { | ||
providerName: { | ||
enum: [Provider.Ec2Fleet], | ||
}, | ||
}, | ||
}, | ||
ec2FleetProviderSettings: { | ||
type: "array" as "array", | ||
minItems: 1, | ||
title: "", | ||
items: { | ||
type: "object" as "object", | ||
properties: { | ||
region: { | ||
type: "string" as "string", | ||
title: "Region", | ||
default: "", | ||
oneOf: awsRegions.map((r) => ({ | ||
type: "string" as "string", | ||
title: r, | ||
enum: [r], | ||
})), | ||
}, | ||
...ec2FleetProviderSettings, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
|
@@ -118,6 +162,9 @@ export const getFormSchema = ({ | |
staticProviderSettings: { | ||
"ui:data-cy": "static-provider-settings", | ||
"ui:ObjectFieldTemplate": CardFieldTemplate, | ||
mergeUserData: { | ||
"ui:elementWrapperCSS": mergeCheckboxCSS, | ||
}, | ||
userData: { | ||
"ui:widget": "textarea", | ||
"ui:elementWrapperCSS": textAreaCSS, | ||
|
@@ -130,6 +177,9 @@ export const getFormSchema = ({ | |
dockerProviderSettings: { | ||
"ui:data-cy": "docker-provider-settings", | ||
"ui:ObjectFieldTemplate": CardFieldTemplate, | ||
mergeUserData: { | ||
"ui:elementWrapperCSS": mergeCheckboxCSS, | ||
}, | ||
userData: { | ||
"ui:widget": "textarea", | ||
"ui:elementWrapperCSS": textAreaCSS, | ||
|
@@ -159,12 +209,100 @@ export const getFormSchema = ({ | |
"ui:readonly": true, | ||
}, | ||
}, | ||
ec2FleetProviderSettings: { | ||
"ui:data-cy": "ec2-fleet-provider-settings", | ||
"ui:addable": awsRegions.length !== configuredRegions.length, | ||
"ui:addButtonText": "Add region settings", | ||
"ui:orderable": false, | ||
"ui:useExpandableCard": true, | ||
items: { | ||
"ui:displayTitle": "New AWS Region", | ||
mergeUserData: { | ||
"ui:elementWrapperCSS": mergeCheckboxCSS, | ||
}, | ||
userData: { | ||
"ui:widget": "textarea", | ||
"ui:elementWrapperCSS": textAreaCSS, | ||
}, | ||
Comment on lines
+223
to
+226
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] If you want, you could probably situate the "Merge with existing user data" checkbox on the top-right of the texarea with some CSS like I did here |
||
securityGroups: { | ||
"ui:addButtonText": "Add security group", | ||
"ui:orderable": false, | ||
}, | ||
region: { | ||
"ui:data-cy": "region-select", | ||
"ui:allowDeselect": false, | ||
"ui:enumDisabled": configuredRegions, | ||
}, | ||
amiId: { | ||
"ui:placeholder": "e.g. ami-1ecba176", | ||
}, | ||
instanceType: { | ||
"ui:description": "EC2 instance type for the AMI. Must be available.", | ||
"ui:placeholder": "e.g. t1.micro", | ||
}, | ||
fleetOptions: { | ||
fleetInstanceType: { | ||
"ui:allowDeselect": false, | ||
}, | ||
useCapacityOptimization: { | ||
"ui:data-cy": "use-capacity-optimization", | ||
"ui:bold": true, | ||
"ui:description": | ||
"Use the capacity-optimized allocation strategy for spot (default: lowest-cost)", | ||
"ui:elementWrapperCSS": capacityCheckboxCSS, | ||
}, | ||
}, | ||
vpcOptions: { | ||
useVpc: { | ||
"ui:data-cy": "use-vpc", | ||
}, | ||
subnetId: { | ||
"ui:placeholder": "e.g. subnet-xxxx", | ||
"ui:elementWrapperCSS": indentCSS, | ||
}, | ||
subnetPrefix: { | ||
"ui:description": | ||
"Looks for subnets like <prefix>.subnet_1a, <prefix>.subnet_1b, etc.", | ||
"ui:elementWrapperCSS": indentCSS, | ||
}, | ||
}, | ||
mountPoints: { | ||
"ui:data-cy": "mount-points", | ||
"ui:addButtonText": "Add mount point", | ||
"ui:orderable": false, | ||
"ui:topAlignDelete": true, | ||
items: { | ||
"ui:ObjectFieldTemplate": AccordionFieldTemplate, | ||
"ui:numberedTitle": "Mount Point", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const textAreaCSS = css` | ||
box-sizing: border-box; | ||
max-width: ${STANDARD_FIELD_WIDTH}px; | ||
textarea { | ||
min-height: 140px; | ||
} | ||
`; | ||
|
||
const mergeCheckboxCSS = css` | ||
max-width: ${STANDARD_FIELD_WIDTH}px; | ||
display: flex; | ||
justify-content: flex-end; | ||
margin-bottom: -20px; | ||
`; | ||
|
||
const capacityCheckboxCSS = css` | ||
max-width: ${STANDARD_FIELD_WIDTH}px; | ||
`; | ||
|
||
const indentCSS = css` | ||
box-sizing: border-box; | ||
padding-left: ${size.m}; | ||
`; | ||
|
||
const poolMappingInfoCss = css` | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be great to validate the toast copy in the second parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I want to leave this one as-is since I would have to update multiple other test files for consistency (also I'm not sure that checking the copy is too important, it says the same thing every time)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't explain my reasoning fully. A benefit of being specific is to help with maintaining and debugging the test suite. If an issue occurs where the toast isn't dispatched, including the toast message allows to easily search the codebase for where the toast should have been dispatched. Even though the toast says the same thing every time for this test suite, we dispatch over 60 different success messages in Spruce. I hear you out about updating multiple files and the repetition in checking copy. I think ideally
validateToast
or it's usage should encapsulate the toast copy so we don't need to pass the parameter explicitly for every toast validation statement. It's okay to leave this as is for now but eventually I'll like to clean this up across our Cypress tests in a separate ticket: https://jira.mongodb.org/browse/EVG-20920