-
Notifications
You must be signed in to change notification settings - Fork 367
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
upcoming: [M3-7599] - Update AGLB Configuration Ports Copy #10079
upcoming: [M3-7599] - Update AGLB Configuration Ports Copy #10079
Conversation
@@ -65,6 +66,8 @@ export const ConfigurationForm = (props: CreateProps | EditProps) => { | |||
const [isAddRouteDrawerOpen, setIsAddRouteDrawerOpen] = useState(false); | |||
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); | |||
|
|||
const [hasChangedPort, setHasChangedPort] = useState(false); |
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.
Is there a better way to handle this?
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.
You'll need to define some defaults first, but then you could do:
const defaultPort = {
http: 80,
https: 443,
tcp: 80,
};
const handleProtocolChange = (protocol: Protocol) => {
const { values, setFormikState } = formik;
const { protocol: currentProtocol, port } = values;
// Calculate the default port directly
const newPort = port === defaultPort[currentProtocol] ? defaultPort[protocol] : port;
setFormikState((prev) => ({
...prev,
values: {
...values,
port: newPort,
protocol,
},
}));
};
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.
That looks clean! I was mainly asking about having to maintain extra state (hasChangedPort
). I don't think I can derive that with formik, but I'm not 100% sure
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.
Well that's what this does, no?
Coverage Report: ✅ |
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.
This looks good regardless
packages/manager/src/features/LoadBalancers/LoadBalancerDetail/Configurations/constants.tsx
Outdated
Show resolved
Hide resolved
…/Configurations/constants.tsx
Description 📝
port
dynamically if you choose HTTP or HTTPS when you haven't provided a custom portPreview 📷
How to test 🧪
Prerequisites
dev-test-aglb
accountVerification steps
Add Configuration
As an Author I have considered 🤔