Skip to content

Commit f77ede4

Browse files
adityathebemoshloop
authored andcommitted
fix: rely on runnable playbooks for dropdown visibility
The playbooks dropdown was gated by a frontend-only playbook_runs:write permission, which does not reflect backend RBAC/ABAC checks for playbook:run access. Remove the synthetic frontend authorization wrapper so visibility is determined by the runnable playbooks returned for the current resource.
1 parent d1cfc57 commit f77ede4

1 file changed

Lines changed: 50 additions & 53 deletions

File tree

src/components/Playbooks/Runs/Submit/PlaybooksDropdownMenu.tsx

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { AuthorizationAccessCheck } from "@flanksource-ui/components/Permissions/AuthorizationAccessCheck";
21
import { Icon } from "@flanksource-ui/ui/Icons/Icon";
32
import {
43
Menu,
@@ -61,58 +60,56 @@ export default function PlaybooksDropdownMenu({
6160
);
6261

6362
return (
64-
<AuthorizationAccessCheck resource={"playbook_runs"} action={"write"}>
65-
<div className={containerClassName}>
66-
<Menu as="div" className="relative inline-block text-left">
67-
<MenuButton className={buttonClassName}>
68-
<Icon name="playbook" className="mr-2 mt-0.5 h-5 w-5" />
69-
<span>Playbooks</span>
70-
<ChevronDownIcon
71-
className={clsx(
72-
"-mr-1 ml-2 h-5 w-5",
73-
highlight ? "text-blue-500" : "text-gray-400"
74-
)}
75-
aria-hidden="true"
76-
/>
77-
</MenuButton>
78-
79-
{/* @ts-ignore */}
80-
<Transition
81-
as={Fragment as any}
82-
enter="transition ease-out duration-100"
83-
enterFrom="transform opacity-0 scale-95"
84-
enterTo="transform opacity-100 scale-100"
85-
leave="transition ease-in duration-75"
86-
leaveFrom="transform opacity-100 scale-100"
87-
leaveTo="transform opacity-0 scale-95"
88-
>
89-
<MenuItems portal className="menu-items" anchor="bottom start">
90-
{playbooks?.map((playbook) => (
91-
<MenuItem
92-
as="button"
93-
className="menu-item w-full"
94-
onClick={() => setSelectedPlaybookSpec(playbook)}
95-
key={playbook.id}
96-
>
97-
<PlaybookSpecIcon playbook={playbook} showLabel showTag />
98-
</MenuItem>
99-
))}
100-
</MenuItems>
101-
</Transition>
102-
</Menu>
103-
{selectedPlaybookSpec && (
104-
<SubmitPlaybookRunForm
105-
componentId={component_id}
106-
checkId={check_id}
107-
configId={config_id}
108-
isOpen={!!selectedPlaybookSpec}
109-
onClose={() => {
110-
setSelectedPlaybookSpec(undefined);
111-
}}
112-
playbook={selectedPlaybookSpec}
63+
<div className={containerClassName}>
64+
<Menu as="div" className="relative inline-block text-left">
65+
<MenuButton className={buttonClassName}>
66+
<Icon name="playbook" className="mr-2 mt-0.5 h-5 w-5" />
67+
<span>Playbooks</span>
68+
<ChevronDownIcon
69+
className={clsx(
70+
"-mr-1 ml-2 h-5 w-5",
71+
highlight ? "text-blue-500" : "text-gray-400"
72+
)}
73+
aria-hidden="true"
11374
/>
114-
)}
115-
</div>
116-
</AuthorizationAccessCheck>
75+
</MenuButton>
76+
77+
{/* @ts-ignore */}
78+
<Transition
79+
as={Fragment as any}
80+
enter="transition ease-out duration-100"
81+
enterFrom="transform opacity-0 scale-95"
82+
enterTo="transform opacity-100 scale-100"
83+
leave="transition ease-in duration-75"
84+
leaveFrom="transform opacity-100 scale-100"
85+
leaveTo="transform opacity-0 scale-95"
86+
>
87+
<MenuItems portal className="menu-items" anchor="bottom start">
88+
{playbooks?.map((playbook) => (
89+
<MenuItem
90+
as="button"
91+
className="menu-item w-full"
92+
onClick={() => setSelectedPlaybookSpec(playbook)}
93+
key={playbook.id}
94+
>
95+
<PlaybookSpecIcon playbook={playbook} showLabel showTag />
96+
</MenuItem>
97+
))}
98+
</MenuItems>
99+
</Transition>
100+
</Menu>
101+
{selectedPlaybookSpec && (
102+
<SubmitPlaybookRunForm
103+
componentId={component_id}
104+
checkId={check_id}
105+
configId={config_id}
106+
isOpen={!!selectedPlaybookSpec}
107+
onClose={() => {
108+
setSelectedPlaybookSpec(undefined);
109+
}}
110+
playbook={selectedPlaybookSpec}
111+
/>
112+
)}
113+
</div>
117114
);
118115
}

0 commit comments

Comments
 (0)