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

fix: modify the order of storage plugin #207

Merged
merged 1 commit into from
Oct 17, 2022
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
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