refactor: configuration mode, buttons without permission should be displayed, but cannot be clicked (#3421)

This commit is contained in:
katherinehhh 2024-01-23 15:33:48 +08:00 committed by GitHub
parent 5a09774cf6
commit 10e0f6ec1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -233,7 +233,7 @@ export const ACLActionProvider = (props) => {
} }
const params = parseAction(actionPath, { schema, recordPkValue }); const params = parseAction(actionPath, { schema, recordPkValue });
if (!params) { if (!params) {
return null; return <ACLActionParamsContext.Provider value={params}>{props.children}</ACLActionParamsContext.Provider>;
} }
//视图表无编辑权限时不显示 //视图表无编辑权限时不显示
if (editablePath.includes(actionPath) || editablePath.includes(actionPath?.split(':')[1])) { if (editablePath.includes(actionPath) || editablePath.includes(actionPath?.split(':')[1])) {

View File

@ -25,6 +25,7 @@ import { useA } from './hooks';
import { useGetAriaLabelOfAction } from './hooks/useGetAriaLabelOfAction'; import { useGetAriaLabelOfAction } from './hooks/useGetAriaLabelOfAction';
import { ComposedAction } from './types'; import { ComposedAction } from './types';
import { linkageAction } from './utils'; import { linkageAction } from './utils';
import { useACLActionParamsContext } from '../../../acl';
export const Action: ComposedAction = observer( export const Action: ComposedAction = observer(
(props: any) => { (props: any) => {
@ -44,6 +45,7 @@ export const Action: ComposedAction = observer(
disabled: propsDisabled, disabled: propsDisabled,
...others ...others
} = useProps(props); } = useProps(props);
const aclCtx = useACLActionParamsContext();
const { wrapSSR, componentCls, hashId } = useStyles(); const { wrapSSR, componentCls, hashId } = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
@ -99,7 +101,7 @@ export const Action: ComposedAction = observer(
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
if (!disabled) { if (!disabled && aclCtx) {
const onOk = () => { const onOk = () => {
onClick?.(e); onClick?.(e);
setVisible(true); setVisible(true);
@ -122,12 +124,12 @@ export const Action: ComposedAction = observer(
const buttonStyle = useMemo(() => { const buttonStyle = useMemo(() => {
return { return {
...style, ...style,
opacity: designable && field?.data?.hidden && 0.1, opacity: designable && (field?.data?.hidden || !aclCtx) && 0.1,
}; };
}, [designable, field?.data?.hidden, style]); }, [designable, field?.data?.hidden, style]);
const renderButton = () => { const renderButton = () => {
if (!designable && field?.data?.hidden) { if (!designable && (field?.data?.hidden || !aclCtx)) {
return null; return null;
} }