Skip to content

Commit

Permalink
fix: adapt APISIX plugin disabled (#2717)
Browse files Browse the repository at this point in the history
  • Loading branch information
Baoyuantop authored Jan 20, 2023
1 parent 5ccb55b commit 7b8d9c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
'import/order': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'no-underscore-dangle': 'off',
},
settings: {
'import/resolver': {
Expand Down
6 changes: 4 additions & 2 deletions web/src/components/Plugin/PluginDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const PluginDetail: React.FC<Props> = ({

useEffect(() => {
form.setFieldsValue({
disable: isEnabled ? true : initialData[name] && !initialData[name].disable,
disable: isEnabled ? true : initialData[name] && !initialData[name]._meta.disable,
scope: 'global',
});
if (PLUGIN_UI_LIST.includes(name)) {
Expand Down Expand Up @@ -415,7 +415,9 @@ const PluginDetail: React.FC<Props> = ({
name="disable"
>
<Switch
defaultChecked={isEnabled ? true : initialData[name] && !initialData[name].disable}
defaultChecked={
isEnabled ? true : initialData[name] && !initialData[name]._meta.disable
}
disabled={readonly || isEnabled}
/>
</Form.Item>
Expand Down
10 changes: 5 additions & 5 deletions web/src/components/Plugin/PluginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const PluginPage: React.FC<Props> = ({

useEffect(() => {
const openPluginList = pluginList.filter(
(item) => initialData[item.name] && !initialData[item.name].disable,
(item) => initialData[item.name] && !initialData[item.name]._meta.disable,
);
setPlugins(initialData);
setEnablePluginsList(openPluginList);
Expand Down Expand Up @@ -244,16 +244,16 @@ const PluginPage: React.FC<Props> = ({
actions={[
<Button
type={
initialData[item.name] && !initialData[item.name].disable
initialData[item.name] && !initialData[item.name]._meta.disable
? 'primary'
: 'default'
}
danger={initialData[item.name] && !initialData[item.name].disable}
danger={initialData[item.name] && !initialData[item.name]._meta.disable}
onClick={() => {
setName(item.name);
}}
>
{initialData[item.name] && !initialData[item.name].disable
{initialData[item.name] && !initialData[item.name]._meta.disable
? formatMessage({ id: 'component.plugin.disable' })
: formatMessage({ id: 'component.plugin.enable' })}
</Button>,
Expand Down Expand Up @@ -315,7 +315,7 @@ const PluginPage: React.FC<Props> = ({
onChange={({ monacoData, formData, shouldDelete }) => {
let newPlugins = {
...initialData,
[name]: { ...monacoData, disable: !formData.disable },
[name]: { ...monacoData, _meta: { disable: !formData.disable } },
};
let handleType = 'edit';
if (shouldDelete === true) {
Expand Down

0 comments on commit 7b8d9c5

Please sign in to comment.