Skip to content

Commit 15d4f89

Browse files
committed
feature: synce permission permission checked before the action
1 parent 5a6dcfd commit 15d4f89

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

app/containers/Permission/index.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ const CreateRoutePermission = {
5656
path: '/permissions',
5757
};
5858

59+
const SyncPermission = {
60+
resource: 'permission',
61+
method: POST,
62+
path: '/permissions/sync',
63+
};
64+
5965
const Permission = () => {
6066
const dispatch = useDispatch();
6167
const intl = useIntl();
@@ -119,22 +125,24 @@ const Permission = () => {
119125
</Button>
120126
) : null}
121127

122-
<Button
123-
type="primary"
124-
// icon={<SyncOutlined />}
125-
onClick={() => {
126-
Modal.confirm({
127-
okText: intl.formatMessage(messages.syncOk),
128-
okType: 'danger',
129-
cancelText: intl.formatMessage(messages.cancelBtn),
130-
icon: <ExclamationCircleOutlined />,
131-
title: intl.formatMessage(messages.syncConfirmationMessage),
132-
onOk: (close) => onSync() && close(),
133-
});
134-
}}
135-
>
136-
<SyncOutlined /> <FormattedMessage {...messages.syncLabel} />
137-
</Button>
128+
{checkPermissionForComponent(user.role, SyncPermission) ? (
129+
<Button
130+
type="primary"
131+
// icon={<SyncOutlined />}
132+
onClick={() => {
133+
Modal.confirm({
134+
okText: intl.formatMessage(messages.syncOk),
135+
okType: 'danger',
136+
cancelText: intl.formatMessage(messages.cancelBtn),
137+
icon: <ExclamationCircleOutlined />,
138+
title: intl.formatMessage(messages.syncConfirmationMessage),
139+
onOk: (close) => onSync() && close(),
140+
});
141+
}}
142+
>
143+
<SyncOutlined /> <FormattedMessage {...messages.syncLabel} />
144+
</Button>
145+
) : null}
138146
<div></div>
139147
</div>
140148
<div className="d-flex ml-auto search-wrap">

0 commit comments

Comments
 (0)