mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:17:23 +00:00
refactor: configuration mode, buttons without permission should be displayed, but cannot be clicked (#3421)
This commit is contained in:
parent
5a09774cf6
commit
10e0f6ec1f
@ -233,7 +233,7 @@ export const ACLActionProvider = (props) => {
|
||||
}
|
||||
const params = parseAction(actionPath, { schema, recordPkValue });
|
||||
if (!params) {
|
||||
return null;
|
||||
return <ACLActionParamsContext.Provider value={params}>{props.children}</ACLActionParamsContext.Provider>;
|
||||
}
|
||||
//视图表无编辑权限时不显示
|
||||
if (editablePath.includes(actionPath) || editablePath.includes(actionPath?.split(':')[1])) {
|
||||
|
@ -25,6 +25,7 @@ import { useA } from './hooks';
|
||||
import { useGetAriaLabelOfAction } from './hooks/useGetAriaLabelOfAction';
|
||||
import { ComposedAction } from './types';
|
||||
import { linkageAction } from './utils';
|
||||
import { useACLActionParamsContext } from '../../../acl';
|
||||
|
||||
export const Action: ComposedAction = observer(
|
||||
(props: any) => {
|
||||
@ -44,6 +45,7 @@ export const Action: ComposedAction = observer(
|
||||
disabled: propsDisabled,
|
||||
...others
|
||||
} = useProps(props);
|
||||
const aclCtx = useACLActionParamsContext();
|
||||
const { wrapSSR, componentCls, hashId } = useStyles();
|
||||
const { t } = useTranslation();
|
||||
const [visible, setVisible] = useState(false);
|
||||
@ -99,7 +101,7 @@ export const Action: ComposedAction = observer(
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if (!disabled) {
|
||||
if (!disabled && aclCtx) {
|
||||
const onOk = () => {
|
||||
onClick?.(e);
|
||||
setVisible(true);
|
||||
@ -122,12 +124,12 @@ export const Action: ComposedAction = observer(
|
||||
const buttonStyle = useMemo(() => {
|
||||
return {
|
||||
...style,
|
||||
opacity: designable && field?.data?.hidden && 0.1,
|
||||
opacity: designable && (field?.data?.hidden || !aclCtx) && 0.1,
|
||||
};
|
||||
}, [designable, field?.data?.hidden, style]);
|
||||
|
||||
const renderButton = () => {
|
||||
if (!designable && field?.data?.hidden) {
|
||||
if (!designable && (field?.data?.hidden || !aclCtx)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user