mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 12:26:22 +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 });
|
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])) {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user