Skip to content

fix(website): fix issue with create website with local php-fpm failed#8379

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

fix(website): fix issue with create website with local php-fpm failed#8379
f2c-ci-robot[bot] merged 1 commit intodev-v2from
pr@dev-v2@common

Conversation

@zhengkunwang223
Copy link
Copy Markdown
Member

No description provided.

@f2c-ci-robot
Copy link
Copy Markdown

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

/>
</template>
<template v-if="!openNginxConfig" #main>
<ComplexTable
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 are minor changes to your code. Here is an updated list of observations:

  1. Removed Duplicate div Element: The line <div class="!ml-2.5">...</div> seems redundant due to the preceding elements.

  2. Consolidated Table Search Component: You consolidated the table search component by removing the duplicate instantiation with different names (searchName).

  3. Renamed Refresh Button to Update: Changed the name of the refresh button from refreshButton to update.

Here's a concise version of the updated code block:

@@ -51,18 +51,17 @@
                     </div>
                 </el-select>
                 <TableSearch @search="search()" v-model:searchName="req.name" />
+                <TableRefresh @update="search()" />
+                <fu-table-column-select
+                    :columns="columns"
+                    trigger="hover"
+                    :title="$t('commons.table.selectColumn')"
+                    popper-class="popper-class"
+                    :only-icon="true"
+                />
             </template>
             <template v-if="!openNginxConfig" #main>
                 <ComplexTable

This should eliminate unnecessary redundancy and improve clarity in the component structure.

return row.status === 'Recreating' || row.status === 'Building' || row.resource == 'local';
case 'edit':
return row.status === 'Recreating' || row.status === 'Building';
case 'extension':
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 is an issue with this code in terms of logic. Specifically, for the "stop" and "restart" cases, the condition includes rows where row.resource equals 'local', but it should ideally only include such conditions when type equals "stop" or "restart". This discrepancy could cause unexpected behavior.

Additionally, for the case where type does not match one of the expected values (e.g., null), the function will still return false because all other checks will return true.

Here's a more precise implementation:

import { Runtime } from '@/api/interface/runtime';

export function disabledButton(row: Runtime.Runtime, type: string): boolean {
    switch (type) {
        case 'stop':
            return (
                row.status === 'Recreating' ||
                row.status === 'Stopped' ||
                row.status === 'Building'
            );
        case 'start':
            return (
                row.status !== 'Started' &&
                row.status !== 'FailedRestarting'
            ) && ( // Ensure we don't start if already started/restarting
                    row.status !== 'Recreating' ||
                    row.status !== 'Stopped' ||
                    row.status !== 'Building'
                )
            ) ? false : true; // True if starting is allowed by resource status

        case 'restart': // Handle restart slightly differently to allow local resources
            return row.status === 'ReCreating' || row.status === 'Building' || row.resource === 'local';

        case 'edit':
            return row.status === 'Recreating' || row.status === 'Building';
        case 'extension':
            return row.status === 'Initializing'; // Assuming Initializing means creating or starting
        default:
            console.warn(`Unsupported operation type ${type}. Returning true.`);
            return true;
    }
}

Changes Made:

  • Corrected conditions for "stop" and "restart".
  • Added additional conditions for handling non-supported types.
  • Ensured that the logic for stopping and restarting accounts for whether the server can run on a local device based on its resource status (rows.resource = 'local').

}
}
}
});
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 is an issue with the line if (runtimeResource.value == 'local') where it should be ===. The use of == can lead to unexpected behavior and errors, especially when comparing numbers versus strings. Additionally, the logic for setting the WebSocket port could be simplified by handling the case when both 'docker' and 'remote' resources exist but no explicit port is set in the configuration.

Here's a corrected version:

const changeRuntime = (runID: number) => {
    runtimes.value.forEach((item) => {
        if (item.id === runID) {
            runtimeResource.value = item.resource;
            runtimePorts.value = item.port ? item.port.split(',').map((port: string) => parseInt(port.trim(), 10)) : [];
            website.value.port = runtime ports.length > 0 ? runtimePorts[0] : null;

            // Optimization suggestion: Handle cases when multiple resource types are present
            if ((item.resource === 'docker' && !website.value.port) || 
                (item.resource === 'remote' && !website.value.port)) {
                console.warn(`No specified port found for resource type '${item.resource}'. Using default port.`);
                website.value.port = 9000;
            }

            break; // Once a matching run ID is found, exit the loop
        }
    });
};

In this version:

  • The comparison operator used for checking runtimeResource.value has been changed to ===.
  • A check for whether Website.value.port is set within the ternary operation ensures that we only update the port if there is one available, avoiding unnecessary checks.
  • An additional conditional block has been added to log warnings and potentially set a default port (9000) if none is explicitly configured for certain types of resources. This simplifies the code by reducing redundant conditions.

@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 11, 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 981037e into dev-v2 Apr 11, 2025
6 checks passed
@f2c-ci-robot f2c-ci-robot Bot deleted the pr@dev-v2@common branch April 11, 2025 07:10
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