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(console): create computer can't add label (for master) #2119

Merged
merged 2 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export function InputLabelsPanel({
}
});

function setValue(v: LabelKeyValue[]) {
function setValue(_v: LabelKeyValue[]) {
const v = JSON.parse(JSON.stringify(_v));

setKVList(v);
let isValid = true;
v.forEach(item => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ export class CreateComputerPanel extends React.Component<RootProps, CreateComput
<React.Fragment>
<Button
className="m"
style={{ marginRight: 10 }}
type="primary"
disabled={workflow.operationState === OperationState.Performing}
disabled={workflow.operationState === OperationState.Performing || !canSave}
onClick={perform}
>
{failed ? t('重试') : t('提交')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ const { useState, useEffect } = React;
const { scrollable, selectable, removeable } = Table.addons;

export function RoleModifyDialog(props) {
const state = useSelector((state) => state);
const state = useSelector(state => state);
const dispatch = useDispatch();
const { actions } = bindActionCreators({ actions: allActions }, dispatch);

console.log('PrivateEditorDialog state:', state);
const { policyPlainList } = state;
let strategyList = policyPlainList.list.data.records || [];
strategyList = strategyList.filter((item) => ['平台管理员', '平台用户', '租户'].includes(item.displayName) === false);
strategyList = strategyList.filter(item => ['平台管理员', '平台用户', '租户'].includes(item.displayName) === false);

const { isShowing, toggle, user } = props;

Expand All @@ -54,8 +54,8 @@ export function RoleModifyDialog(props) {
{
id: uuid(),
...user,
spec: { ...user.spec, extra: extraObj },
},
spec: { ...user.spec, extra: extraObj }
}
]);
actions.group.detail.updateGroupWorkflow.perform();
setTimeout(form.reset);
Expand All @@ -71,16 +71,16 @@ export function RoleModifyDialog(props) {
initialValuesEqual: () => true,
initialValues: { role: '' },
validate: ({ role }) => ({
role: !role ? t('请选择平台角色') : undefined,
}),
role: !role ? t('请选择平台角色') : undefined
})
});
const role = useField('role', form);

useEffect(() => {
if (user) {
const {
tenantID,
extra: { policies },
extra: { policies }
} = user.spec;
setTenantID(tenantID);
const policiesParse = JSON.parse(policies);
Expand Down Expand Up @@ -148,20 +148,22 @@ export function RoleModifyDialog(props) {
scrollable={false}
title="为这个用户自定义独立的权限"
tip="支持按住 shift 键进行多选"
header={<SearchBox value={inputValue} onChange={(value) => setInputValue(value)} />}
header={<SearchBox value={inputValue} onChange={value => setInputValue(value)} />}
>
<SourceTable
dataSource={strategyList}
dataSource={strategyList?.filter(({ displayName, description }) =>
inputValue ? displayName?.includes(inputValue) || description?.includes(inputValue) : true
)}
targetKeys={targetKeys}
onChange={(keys) => setTargetKeys(keys)}
onChange={keys => setTargetKeys(keys)}
/>
</Transfer.Cell>
}
rightCell={
<Transfer.Cell title={`已选择 (${targetKeys.length})`}>
<TargetTable
dataSource={strategyList.filter((i) => targetKeys.includes(i.id))}
onRemove={(key) => setTargetKeys(targetKeys.filter((i) => i !== key))}
dataSource={strategyList.filter(i => targetKeys.includes(i.id))}
onRemove={key => setTargetKeys(targetKeys.filter(i => i !== key))}
/>
</Transfer.Cell>
}
Expand Down Expand Up @@ -195,14 +197,14 @@ const columns = [
{
key: 'displayName',
header: '策略名称',
render: (strategy) => <p>{strategy.displayName}</p>,
render: strategy => <p>{strategy.displayName}</p>
},
{
key: 'description',
header: '描述',
width: 150,
render: (strategy) => <p>{strategy.description || '-'}</p>,
},
render: strategy => <p>{strategy.description || '-'}</p>
}
];

function SourceTable({ dataSource, targetKeys, onChange }) {
Expand All @@ -214,13 +216,13 @@ function SourceTable({ dataSource, targetKeys, onChange }) {
addons={[
scrollable({
maxHeight: 310,
onScrollBottom: () => console.log('到达底部'),
onScrollBottom: () => console.log('到达底部')
}),
selectable({
value: targetKeys,
onChange,
rowSelect: true,
}),
rowSelect: true
})
]}
/>
);
Expand Down