Skip to content

feat: Website list supports filtering by type.#8414

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

feat: Website list supports filtering by type.#8414
f2c-ci-robot[bot] merged 1 commit intodev-v2from
pr@dev-v2@website

Conversation

@zhengkunwang223
Copy link
Copy Markdown
Member

Refs #6409

@f2c-ci-robot
Copy link
Copy Markdown

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

import { WebsiteTypes } from '@/global/mimetype';

const websiteForm = ref<FormInstance>();

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 code snippet contains some stylistic choices that could be improved for readability and maintainability, particularly regarding comments, formatting, and type imports. Here are a few recommendations:

Improvements

  1. Consistently Use PascalCase: Ensure consistent use of camelCase or PascalCase throughout the file.

  2. Import Statements: If WebsiteTypes is imported within the same module or if it's part of global configuration/constants, remove the need to import it multiple times. However, since you've mentioned importing it locally in this snippet, the issue doesn't apply here specifically but should be avoided elsewhere.

  3. Code Formatting:

    • Add indentation levels more consistently (e.g., using two spaces instead of three).
    • Proper alignment and spacing after commas in array initializations.
  4. Variable Declaration Consistency: Maintain consistency with variable declarations and types where applicable.

Here’s the slightly cleaned-up version of your code:

@@ -2,32 +2,7 @@
 <DrawerPro v-model="open" :header="$t('website.create')" size="large" @close="handleClose">
     <template #buttons>
         <span class="drawer-header-button">
-            <template 
-                v-for="(item) in (
-                    [
-                        {
-                            label: $t('website.deployment'), 
-                            value: 'deployment'
-                        },
-                        {
-                            label: $t('runtime.runtime'), 
-                            value: 'runtime'
-                        },
-                        {
-                            label: $t('website.proxy'), 
-                            value: 'proxy'
-                        },
-                        {
-                            label: $t('website.static'), 
-                            value: 'static'
-                        },
-                        {
-                            label: $t('website.subsite'), 
-                            value: 'subsite'
-                        }
-                    ]
-                )"
-                :key="item.value"
-           >        
+              <template v-for="(item) in WebsiteTypes" :key="item.value">
                   <el-button
                       :class="
                           `${website.type === item.value ? 'active-button' : ''}` 
                       "
                       @click="changeType(item.value)"
                 />
             </template>
         </span>
@@ -572,7 +549,8 @@ import { dateFormatSimple, getProvider, getAccountName } from '@/utils/util';

 import { FormInstance } from "element-plus"; // Replace with correct import statement if needed

import DomainCreate from "@/views/website/website/domain-create/index.vue";
import { getPathByType } from '@/api/modules/files';
-import { WebsiteTypes } from '@/global/mimetype'; // Assuming WebsiteTypes is globally accessible

const websiteForm = ref<FormInstance>();

These changes improve overall clarity and maintainability while adhering to best practices in JavaScript programming.

label: i18n.global.t('website.subsite'),
value: 'subsite',
},
];
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 appears clean and well structured with appropriate comments. The changes made to WebsiteTypes are consistent with existing patterns used in the other arrays. No significant errors or performance optimizations seem necessary here.

type: '',
});
const mobile = computed(() => {
return globalStore.isMobile();
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 appear to be minor formatting changes and an addition to the code snippet. Here are my observations:

  1. Formatting Changes: The line const shortcuts = [...] is now indented differently at the beginning, which might affect its functionality slightly in certain contexts but should not cause any significant issues.

  2. New Variable Declaration: There is a new WebsiteTypes array being declared with type annotations: let WebsiteTypes: unknown[]. This is added within the function scope where it will be used without immediately assigning a value. This can lead to unexpected behavior if this list doesn't contain data before usage, so it's generally recommended to initialize such lists explicitly with some default values or empty arrays until they're populated with actual data.

Considering further improvement points based on best practices:

  1. Global Constant Initialization: It would improve readability if you declare constants or variables that won't change throughout the lifecycle of the component outside the initialization block (const globalStore = GlobalStore();). For example, defining them at top level could help avoid redundant assignments later in the script (though TypeScript does not prevent overwriting unless marked as constant).

Overall, this code looks functional and well-documented for Vue.js development with typescript support, making use of Vuex for state management.

@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 Apr 17, 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 7792601 into dev-v2 Apr 17, 2025
6 checks passed
@f2c-ci-robot f2c-ci-robot Bot deleted the pr@dev-v2@website branch April 17, 2025 14:24
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