diff --git a/web/console/src/modules/uam/components/strategy/StrategyActionPanel.tsx b/web/console/src/modules/uam/components/strategy/StrategyActionPanel.tsx
index bad89923a..b4cf63cf6 100644
--- a/web/console/src/modules/uam/components/strategy/StrategyActionPanel.tsx
+++ b/web/console/src/modules/uam/components/strategy/StrategyActionPanel.tsx
@@ -61,20 +61,22 @@ const columns = [
{
key: 'name',
header: t('Action名称'),
- render: (cvm) =>
{cvm.name}
,
+ render: cvm => {cvm.name}
},
{
key: 'description',
header: t('描述'),
width: 100,
- render: (cvm) => {
+ render: cvm => {
return (
- {cvm.description}
+
+ {cvm.description}
+
);
- },
- },
+ }
+ }
];
function SourceTable({ dataSource, action, onChange }) {
@@ -87,8 +89,8 @@ function SourceTable({ dataSource, action, onChange }) {
selectable({
value: action,
onChange,
- rowSelect: true,
- }),
+ rowSelect: true
+ })
]}
/>
);
@@ -98,8 +100,8 @@ function TargetTable({ dataSource, onRemove }) {
return ;
}
-export const StrategyActionPanel = (props) => {
- const state = useSelector((state) => state);
+export const StrategyActionPanel = props => {
+ const state = useSelector(state => state);
const dispatch = useDispatch();
const { actions } = bindActionCreators({ actions: allActions }, dispatch);
@@ -114,26 +116,26 @@ export const StrategyActionPanel = (props) => {
effect: '',
resource: [],
selectService: '',
- description: '',
+ description: ''
});
const [actionParamsValue, setActionParamsValue] = useState({
filterKeyword: '',
- action: [],
+ action: []
});
const [messages, setMessages] = useState({
name: '',
effect: '',
action: '',
resource: [],
- description: '',
+ description: ''
});
// 初始化创建弹窗中的服务选项
useEffect(() => {
- if (!formParamsValue.selectService && categoryListRecords) {
+ if (formParamsValue.selectService === '' && categoryListRecords) {
setFormParamsValue({
...formParamsValue,
- selectService: categoryListRecords[0].name,
+ selectService: categoryListRecords?.[0]?.metadata?.name
});
}
}, [formParamsValue, categoryListRecords]);
@@ -146,9 +148,9 @@ export const StrategyActionPanel = (props) => {
if (!name || !effect || !action.length || resource.length === 0) {
disabled = true;
}
- Object.keys(messages).forEach((item) => {
+ Object.keys(messages).forEach(item => {
if (Array.isArray(messages[item])) {
- messages[item].forEach((m) => {
+ messages[item].forEach(m => {
if (m) {
disabled = true;
}
@@ -167,10 +169,10 @@ export const StrategyActionPanel = (props) => {
categoryActions = {};
categoryListRecords &&
- categoryListRecords.forEach((item) => {
+ categoryListRecords.forEach(item => {
options.push({
value: item.metadata.name,
- text: item.Spec.displayName,
+ text: item.Spec.displayName
});
categoryActions[item.metadata.name] = Object.values(item.Spec.actions);
});
@@ -213,7 +215,7 @@ export const StrategyActionPanel = (props) => {
placeholder={t('请输入策略名称')}
style={{ width: '350px' }}
defaultValue={formParamsValue.name}
- onChange={(value) => {
+ onChange={value => {
let msg = '';
if (!value) {
msg = '请输入策略名称';
@@ -233,7 +235,7 @@ export const StrategyActionPanel = (props) => {
>
{
+ onChange={value => {
setFormParamsValue({ ...formParamsValue, effect: value });
setMessages({ ...messages, effect: value ? '' : '请选择效果' });
}}
@@ -252,7 +254,7 @@ export const StrategyActionPanel = (props) => {
size="m"
options={options}
value={formParamsValue.selectService}
- onChange={(value) => {
+ onChange={value => {
// 调用action获取接口
setFormParamsValue({ ...formParamsValue, selectService: value });
}}
@@ -268,14 +270,14 @@ export const StrategyActionPanel = (props) => {
header={
setActionParamsValue({ ...actionParamsValue, filterKeyword: value })}
+ onChange={value => setActionParamsValue({ ...actionParamsValue, filterKeyword: value })}
/>
}
>
i.name.includes(actionParamsValue.filterKeyword))}
+ dataSource={actionList.filter(i => i.name.includes(actionParamsValue.filterKeyword))}
action={actionParamsValue.action}
- onChange={(keys) => {
+ onChange={keys => {
setActionParamsValue({ ...actionParamsValue, action: keys });
setMessages({ ...messages, action: keys.length ? '' : '请选择Action' });
}}
@@ -285,9 +287,9 @@ export const StrategyActionPanel = (props) => {
rightCell={
actionParamsValue.action.includes(i.name))}
- onRemove={(key) => {
- const keys = actionParamsValue.action.filter((i) => i !== key);
+ dataSource={actionList.filter(i => actionParamsValue.action.includes(i.name))}
+ onRemove={key => {
+ const keys = actionParamsValue.action.filter(i => i !== key);
setActionParamsValue({ ...actionParamsValue, action: keys });
setMessages({ ...messages, action: keys.length ? '' : '请选择Action' });
}}
@@ -310,7 +312,7 @@ export const StrategyActionPanel = (props) => {
placeholder={t('eg. cluster:cls-123/deployment:deploy-123/*')}
style={{ width: '350px' }}
defaultValue={resource}
- onChange={(value) => {
+ onChange={value => {
let msg = '';
if (!value) {
msg = '请输入资源名称';
@@ -349,7 +351,7 @@ export const StrategyActionPanel = (props) => {
multiline
placeholder={t('介绍一下这个策略')}
style={{ width: '350px' }}
- onChange={(value) => {
+ onChange={value => {
let msg = '';
if (value && value.length > 255) {
msg = '描述不能超过255个字符';
@@ -395,9 +397,9 @@ export const StrategyActionPanel = (props) => {
statement: {
resources: resource,
effect,
- actions: action,
- },
- },
+ actions: action
+ }
+ }
};
actions.strategy.addStrategy.start([strategyInfo]);