Skip to content

Commit 7b8d9c5

Browse files
authored
fix: adapt APISIX plugin disabled (#2717)
1 parent 5ccb55b commit 7b8d9c5

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

web/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = {
3333
'import/order': 'off',
3434
'simple-import-sort/imports': 'error',
3535
'simple-import-sort/exports': 'error',
36+
'no-underscore-dangle': 'off',
3637
},
3738
settings: {
3839
'import/resolver': {

web/src/components/Plugin/PluginDetail.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const PluginDetail: React.FC<Props> = ({
181181

182182
useEffect(() => {
183183
form.setFieldsValue({
184-
disable: isEnabled ? true : initialData[name] && !initialData[name].disable,
184+
disable: isEnabled ? true : initialData[name] && !initialData[name]._meta.disable,
185185
scope: 'global',
186186
});
187187
if (PLUGIN_UI_LIST.includes(name)) {
@@ -415,7 +415,9 @@ const PluginDetail: React.FC<Props> = ({
415415
name="disable"
416416
>
417417
<Switch
418-
defaultChecked={isEnabled ? true : initialData[name] && !initialData[name].disable}
418+
defaultChecked={
419+
isEnabled ? true : initialData[name] && !initialData[name]._meta.disable
420+
}
419421
disabled={readonly || isEnabled}
420422
/>
421423
</Form.Item>

web/src/components/Plugin/PluginPage.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const PluginPage: React.FC<Props> = ({
101101

102102
useEffect(() => {
103103
const openPluginList = pluginList.filter(
104-
(item) => initialData[item.name] && !initialData[item.name].disable,
104+
(item) => initialData[item.name] && !initialData[item.name]._meta.disable,
105105
);
106106
setPlugins(initialData);
107107
setEnablePluginsList(openPluginList);
@@ -244,16 +244,16 @@ const PluginPage: React.FC<Props> = ({
244244
actions={[
245245
<Button
246246
type={
247-
initialData[item.name] && !initialData[item.name].disable
247+
initialData[item.name] && !initialData[item.name]._meta.disable
248248
? 'primary'
249249
: 'default'
250250
}
251-
danger={initialData[item.name] && !initialData[item.name].disable}
251+
danger={initialData[item.name] && !initialData[item.name]._meta.disable}
252252
onClick={() => {
253253
setName(item.name);
254254
}}
255255
>
256-
{initialData[item.name] && !initialData[item.name].disable
256+
{initialData[item.name] && !initialData[item.name]._meta.disable
257257
? formatMessage({ id: 'component.plugin.disable' })
258258
: formatMessage({ id: 'component.plugin.enable' })}
259259
</Button>,
@@ -315,7 +315,7 @@ const PluginPage: React.FC<Props> = ({
315315
onChange={({ monacoData, formData, shouldDelete }) => {
316316
let newPlugins = {
317317
...initialData,
318-
[name]: { ...monacoData, disable: !formData.disable },
318+
[name]: { ...monacoData, _meta: { disable: !formData.disable } },
319319
};
320320
let handleType = 'edit';
321321
if (shouldDelete === true) {

0 commit comments

Comments
 (0)