Skip to content

feat(website): Restrict unhealthy application selection during websit…#8269

Merged
f2c-ci-robot[bot] merged 1 commit intodev-v2from
pr@dev-v2@app
Mar 28, 2025
Merged

feat(website): Restrict unhealthy application selection during websit…#8269
f2c-ci-robot[bot] merged 1 commit intodev-v2from
pr@dev-v2@app

Conversation

@zhengkunwang223
Copy link
Copy Markdown
Member

No description provided.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Mar 28, 2025

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.

Details

Instructions 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/test-infra repository.

</el-option>
</el-select>
</el-form-item>
<div v-if="website.appType == 'new'">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the provided code change, it has been updated to make the el-select wider (300px instead of 200px) and ensure that only installed apps with a status of "Running" appear in the dropdown. Additionally, each option now includes a div containing both the app name and its corresponding status, formatted using the <Status> component.

OptimizationSuggestions:

  • Use Vue's computed property for dynamic data binding if appInstalls list frequently changes.
  • Ensure that there is an appropriate error state handling in case no running installations exist.
  • Consider caching the result of checking the application status rather than calling a new API on every render for better performance.

MsgError(res.message);
}
loginVerify();
} finally {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code provided has several minor changes and suggestions to improve it:

  1. Import Update: The MsgSuccess import statement was updated from '@/utils/message' to '@/utils/message'. This is unnecessary since the same module is being imported again.

  2. Console Log Removal: The comment about logging an error during login (console.log('loiin syc');) should be removed as it serves no purpose.

  3. Return Statements:

    • In both cases where the response message is "ErlAuth" or another authentication error, return statements are added after handling these scenarios. This ensures that the function does not proceed past the error checks.

Here's the optimized version of the code:

const login = async (formEl: FormInstance | undefined) => {
    if (!formEl)
        return;

    await formEl.validate((valid) => {
        if (valid) {
            try {
                await loginApi({
                    username: loginForm.username,
                    password: encryptedPassword(loginForm.password),
                    // Add other necessary parameters here if required
                });

                tabsStore.removeAllTabs();
                globalStore.currentNode = 'local';
                MsgSuccess(i18n.t('commons.msg.loginSuccess'));

                router.push({ name: 'home' });
                document.onkeydown = null;
            } catch (res) {
                if (res.message === 'ErrCaptcha') {
                    loginForm.captcha = '';
                    errCaptcha.value = true;
                    errAuthInfo.value = false;
                    return;
                }
                if (res.message === 'ErrAuth' || res.message.includes("error occurred")) {
                    globalStore.ignoreCaptcha = false;
                    errCaptcha.value = false;
                    errAuthInfo.value = true;
                    return;
                }
                MsgError(res.message);
            }

            loginVerify();
        }
    });
};

Key Changes and Suggestions:

  • Removed Import Duplicates: Eliminated redundant imports for readability.
  • Console Logging Removal: Removed unneeded console log statement.
  • Added Return Statements: Ensured functions terminate early when appropriate authentication errors occur.
  • Improved variable names and formatting for better readability.

Comment thread core/app/api/v2/auth.go
if msgKey == "ErrAuth" || msgKey == "ErrEntrance" {
helper.BadAuth(c, msgKey, err)
return
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be an issue with the SaveLoginLogs function call. The method expects a single argument, but you are passing two arguments (c and err). You should modify it to correctly pass just the one required parameter.

Additionally, there's no need to use go keyword here; calling this function directly will suffice. Here is the corrected line:

saveLoginLogs(c, err)

Here's the updated Go function:

func (b *BaseApi) Login(c *gin.Context) {
        
    user, msgKey, err := authService.Login(c, req, string(entrance))

    if msgKey == "ErrAuth" || msgKey == "ErrEntrance" {
        helper.BadAuth(c, msgKey, err)
        return
    }

    // Optionally, handle other scenarios based on msgKey

}

This ensures that the function saveLoginLogs receives only the necessary parameter.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@wanghe-fit2cloud wanghe-fit2cloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@wanghe-fit2cloud
Copy link
Copy Markdown
Member

/approve

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Mar 28, 2025

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot Bot merged commit 076f3f0 into dev-v2 Mar 28, 2025
6 checks passed
@f2c-ci-robot f2c-ci-robot Bot deleted the pr@dev-v2@app branch March 28, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants