Skip to content

fix: Fix the problem that the theme color display is abnormal after t…#8330

Merged
f2c-ci-robot[bot] merged 1 commit intodev-v2from
pr@dev-v2@fix_theme
Apr 7, 2025
Merged

fix: Fix the problem that the theme color display is abnormal after t…#8330
f2c-ci-robot[bot] merged 1 commit intodev-v2from
pr@dev-v2@fix_theme

Conversation

@ssongliu
Copy link
Copy Markdown
Member

@ssongliu ssongliu commented Apr 7, 2025

…he upgrade

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Apr 7, 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.

globalStore.setThemeConfig({ ...themeConfig.value, theme: res.data.theme, panelName: res.data.panelName });
} catch (error) {}
};

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 provided getSetting function is largely consistent with other code patterns, but there's one small optimization suggestion:

-        globalStore.setThemeConfig({ ...themeConfig.value, theme: theme, panelName: res.data.panelName });
+        globalStore.setThemeConfig({

Replace the last line of your change block with the corrected version to ensure all necessary fields are included in the object you're passing to globalStore.setThemeConfig(). This makes sure that the updated configuration includes both the new theme and the new panel name, rather than just merging them without explicitly specifying the field names.

globalStore.themeConfig.theme = form.theme;
}
};

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 snippet you've provided contains a few potential issues:

  1. In version 330, globalStore.themeConfig.theme is set to the same value from res.data.theme using an assignment (= ). This means that res.data.theme cannot be used again later in this scope without losing its original value.

To fix this issue, update globalStore.themeConfig.theme = form.theme;.

  1. The variable xpackRes might not be defined before attempting to use it inside the if-statement.

Additionally, there's no need to reassign globalStore.themeConfig.theme = form.theme; since you can directly access form.theme without affecting other parts of the program. A more readable approach would be to use ternary operator or conditional statement instead.

Optimization suggestion:
Use template literals for string concatenation, which makes the code more compact and easier to read.

After making these changes, the corrected code should look like this:

const search = async () => {
    // ... previous lines ...

    globalStore.themeConfig.theme = form.theme;

    if (isMasterProductPro.value) {
        const xpackRes = await getXpackSetting();
        // ... rest of the code ...
    } else {
        // Reuse the value of form.theme stored previously 
        // No need to assign it here again.
    }

    // Further processing using form.theme...
};

With these updates, your code will behave correctly and efficiently.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 7, 2025

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 Apr 7, 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 added the approved label Apr 7, 2025
@f2c-ci-robot f2c-ci-robot Bot merged commit afbfd6b into dev-v2 Apr 7, 2025
6 checks passed
@f2c-ci-robot f2c-ci-robot Bot deleted the pr@dev-v2@fix_theme branch April 7, 2025 07:41
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