Skip to content

Commit

Permalink
fix: modify the order of storage plugin
Browse files Browse the repository at this point in the history
Signed-off-by: liuying <liu.ying@99cloud.net>
  • Loading branch information
lysign committed Oct 17, 2022
1 parent 9cc5dd1 commit 47bfedb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
15 changes: 13 additions & 2 deletions src/pages/cluster/components/plugin/AddStorage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ import React, { useEffect, useReducer, useRef } from 'react';
import Tabs from 'components/Tabs';
import styles from './index.less';
import RenderForm from './RenderForm';
import { cloneDeep, uniq, omit, set, assign, isArray, isMatch } from 'lodash';
import {
cloneDeep,
uniq,
omit,
set,
assign,
isArray,
isMatch,
orderBy,
} from 'lodash';
import { useParams, useHistory } from 'react-router-dom';
import { encodeProperty } from 'utils';
import Notify from 'components/Notify';
Expand Down Expand Up @@ -62,7 +71,7 @@ const Storage = observer((props) => {
.map((item) => item?.name)
.filter((item) => !!item);

const newTabs = cloneDeep(storageComponents).map((item) => {
let newTabs = cloneDeep(storageComponents).map((item) => {
const { properties = {} } = item.schema;

delete properties.isDefaultSC;
Expand Down Expand Up @@ -111,6 +120,8 @@ const Storage = observer((props) => {
};
});

newTabs = orderBy(newTabs, ['deprecated'], 'asc');

setState({
...state,
tabs: newTabs,
Expand Down
7 changes: 4 additions & 3 deletions src/pages/cluster/components/plugin/StorageForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import React, { useEffect } from 'react';
import { observer } from 'mobx-react';
import Tabs from 'components/Tabs';
import { cloneDeep, uniq, set, isMatch, isEmpty } from 'lodash';
import { cloneDeep, uniq, set, isMatch, isEmpty, orderBy } from 'lodash';
import RenderForm from './RenderForm';
import { Divider, Button } from 'antd';
import { Context } from './Context';
Expand Down Expand Up @@ -55,7 +55,7 @@ const StorageForm = (props) => {
useEffect(() => {
if (!isEmpty(storageTabs)) return;

const newTabs = cloneDeep(storageComponents).map((item) => {
let newTabs = cloneDeep(storageComponents).map((item) => {
const { name } = item;
const { properties = {} } = item.schema;

Expand Down Expand Up @@ -114,9 +114,10 @@ const StorageForm = (props) => {
formInstances: [],
};
});
newTabs = orderBy(newTabs, ['deprecated'], 'asc');

updateContext({
storageCurrent: storageComponents[0]?.name,
storageCurrent: newTabs[0]?.name,
storageTabs: newTabs,
});
}, [storageComponents]);
Expand Down

0 comments on commit 47bfedb

Please sign in to comment.