Skip to content

Commit 7e04081

Browse files
p-eyejay-choea1tair6
authored
[FE] Add RBAC actions for copy topic button (#3549)
* enable 'Copy Selected Topic' button when action is Action.CREATE Co-authored-by: jay-choe <[email protected]> Co-authored-by: a1tair6 <[email protected]> * fix lint: remove unused imports Co-authored-by: jay-choe <[email protected]> Co-authored-by: a1tair6 <[email protected]> --------- Co-authored-by: jay-choe <[email protected]> Co-authored-by: a1tair6 <[email protected]>
1 parent dc08701 commit 7e04081

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

kafka-ui-react-app/src/components/Topics/List/BatchActionsBar.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
useDeleteTopic,
1010
} from 'lib/hooks/api/topics';
1111
import { useConfirm } from 'lib/hooks/useConfirm';
12-
import { Button } from 'components/common/Button/Button';
1312
import { clusterTopicCopyRelativePath } from 'lib/paths';
1413
import { useQueryClient } from '@tanstack/react-query';
1514
import { ActionCanButton } from 'components/common/ActionComponent';
@@ -108,6 +107,19 @@ const BatchActionsbar: React.FC<BatchActionsbarProps> = ({
108107
);
109108
}, [selectedTopics, clusterName, roles]);
110109

110+
const canCopySelectedTopic = useMemo(() => {
111+
return selectedTopics.every((value) =>
112+
isPermitted({
113+
roles,
114+
resource: ResourceType.TOPIC,
115+
action: Action.CREATE,
116+
value,
117+
clusterName,
118+
rbacFlag,
119+
})
120+
);
121+
}, [selectedTopics, clusterName, roles]);
122+
111123
const canPurgeSelectedTopics = useMemo(() => {
112124
return selectedTopics.every((value) =>
113125
isPermitted({
@@ -132,14 +144,15 @@ const BatchActionsbar: React.FC<BatchActionsbarProps> = ({
132144
>
133145
Delete selected topics
134146
</ActionCanButton>
135-
<Button
147+
<ActionCanButton
136148
buttonSize="M"
137149
buttonType="secondary"
138150
disabled={selectedTopics.length !== 1}
151+
canDoAction={canCopySelectedTopic}
139152
to={getCopyTopicPath()}
140153
>
141154
Copy selected topic
142-
</Button>
155+
</ActionCanButton>
143156
<ActionCanButton
144157
buttonSize="M"
145158
buttonType="secondary"

0 commit comments

Comments
 (0)