-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: add domain validate for appinstall webUI #8939
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
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| } | ||
| await updateInstallConfig(req); | ||
| MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); | ||
| handleClose(); |
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.
Some of the changes have been suggested to improve readability and maintainability:
- In
acceptParams, add a line to log parameters before updating:
params.value = [];
console.log("Received params:", JSON.stringify(props));- Update comment style consistency:
// Potential issue: The comments on lines 114, 129, and 165 should be consistent about their content type (e.g., all function docs).Replace with something like:
/*
* Function description goes here...
*/
- Add spacing after commas in imports and declarations:
import { reactive, ref } from 'vue';
+import { FormInstance } from 'element-plus';
interface ParamProps {
// ...
}
let webUI = reactive({
serverUrl: '',
username: '',
password: '',
domainName: '',
+ isDeployed: true,
});- Refactor check functions:
- Rename
MsgErrortoshowErrorMessagefor clarity. - Move duplicate
if (!check...) {} else return false;checks into separate functions.
Here's an optimized version:
function showErrorMessage(message) {
MsgError(i18n.global.t(`commons.msg.${message}`));
throw new Error(); // Or some other mechanism to indicate failure
}
async function validateWebUI() {
if (!webUI.domain || webUI.domain === '') {
showErrorMessage('emptyHost');
}
try {
const [host, port] = webUI.domain.split(':').map(item => item.trim());
if (!/^\d+$/.test(port)) {
showErrorMessage('invalidPort');
}
if (!(await checkIpAddressOrDomain(host)) || !isHostValid(port)) {
showErrorMessage('invalidHost');
}
} catch (error) {
console.error(error);
} finally {
return !!webUI.domain;
}
}
const acceptParams = async (props: ParamProps): Promise<void> => {
submitModel.value.installId = props.id;
let errorOccurred = false;
if (!validateWebUI()) {
errorOccurred = true;
}
// Continue processing based on validation errors
};Additional notes: Ensure that checkIpAddressOrDomain and isHostValid are implemented correctly according to your specific needs. Always include proper comments and documentation for these functions to avoid future maintenance challenges.
|
wanghe-fit2cloud
left a comment
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.
/lgtm
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wanghe-fit2cloud The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |



Refs #8936