Skip to content
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

[release-1.3] fix: use plugin template error & operaiton list cached by cluster detail #241

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions src/pages/cluster/components/plugin/AddPlugin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,37 +111,26 @@ const Plugin = (props) => {
};

const handleFRChange = (name, formInstance, formData, index) => {
if (typeof formData === 'object' && formData.pluginTemplate) {
if (formData.pluginTemplate) {
if (formData.pluginTemplate !== 'notUseTemplate') {
const { flatData = {} } = templates.find(
(item) => item.id === formData.pluginTemplate
const selectedTemplate = templates.find(
(item) => item.name === formData.pluginTemplate
);
if (!isMatch(formData, flatData)) {

if (!isMatch(formData, selectedTemplate.flatData)) {
formInstance.setValues({
...formData,
pluginTemplate: '',
...selectedTemplate.flatData,
pluginTemplate: formData.pluginTemplate,
enable: true,
});
}
}
}

if (typeof formData === 'string') {
if (formData === 'notUseTemplate') {
} else {
const { baseFormData } = tabs.find((item) => item.name === current);
formInstance.setValues({
...baseFormData,
pluginTemplate: 'notUseTemplate',
enable: true,
});
} else {
const [{ flatData = {} }] = templates.filter(
(item) => item.name === formData
);
formInstance.setValues({
...flatData,
pluginTemplate: formData,
enable: true,
});
}
}

Expand Down
28 changes: 8 additions & 20 deletions src/pages/cluster/components/plugin/PluginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,37 +115,25 @@ const PluginForm = (props) => {
};

const handleFRChange = (name, formInstance, formData) => {
if (typeof formData === 'object' && formData.pluginTemplate) {
if (formData.pluginTemplate) {
if (formData.pluginTemplate !== 'notUseTemplate') {
const { flatData = {} } = templates.find(
(item) => item.id === formData.pluginTemplate
const selectedTemplate = templates.find(
(item) => item.name === formData.pluginTemplate
);
if (!isMatch(formData, flatData)) {
if (!isMatch(formData, selectedTemplate.flatData)) {
formInstance.setValues({
...formData,
pluginTemplate: '',
...selectedTemplate.flatData,
pluginTemplate: formData.pluginTemplate,
enable: true,
});
}
}
}

if (typeof formData === 'string') {
if (formData === 'notUseTemplate') {
} else {
const { baseFormData } = tabs.find((item) => item.name === current);
formInstance.setValues({
...baseFormData,
pluginTemplate: 'notUseTemplate',
enable: true,
});
} else {
const [{ flatData = {} }] = templates.filter(
(item) => item.name === formData
);
formInstance.setValues({
...flatData,
pluginTemplate: formData,
enable: true,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import React, { useMemo } from 'react';
import BaseList from 'containers/List';
import { operationStatus } from 'resources/cluster';
import { useRootStore } from 'stores';
import { observer } from 'mobx-react';
import actionConfigs from './actions';
import { useParams } from 'react-router-dom';

Expand Down Expand Up @@ -71,7 +72,7 @@ function OperationList() {
await store.fetchList({ labelSelector, ...params });
}

return <BaseList {...currentProps} />;
return useMemo(() => <BaseList {...currentProps} />, [store.detail]);
}

export default OperationList;
export default observer(OperationList);