Skip to content

Commit

Permalink
removed use of deprecated dropdown (keycloak#28928)
Browse files Browse the repository at this point in the history
towards: keycloak#28197

Signed-off-by: Erik Jan de Wit <[email protected]>
  • Loading branch information
edewit authored Apr 22, 2024
1 parent 9a418cc commit 014b644
Showing 1 changed file with 65 additions and 36 deletions.
101 changes: 65 additions & 36 deletions js/apps/account-ui/src/resources/ResourcesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import {
Button,
Chip,
ChipGroup,
Dropdown,
DropdownItem,
DropdownList,
MenuToggle,
OverflowMenu,
OverflowMenuContent,
OverflowMenuControl,
Expand All @@ -10,13 +14,9 @@ import {
OverflowMenuItem,
Spinner,
} from "@patternfly/react-core";
import {
Dropdown,
DropdownItem,
KebabToggle,
} from "@patternfly/react-core/deprecated";
import {
EditAltIcon,
EllipsisVIcon,
ExternalLinkAltIcon,
Remove2Icon,
ShareAltIcon,
Expand Down Expand Up @@ -255,19 +255,32 @@ export const ResourcesTab = ({ isShared = false }: ResourcesTabProps) => {
</OverflowMenuItem>
<OverflowMenuItem>
<Dropdown
position="right"
toggle={
<KebabToggle
onToggle={(_event, open) =>
toggleOpen(resource._id, "contextOpen", open)
}
/>
popperProps={{
position: "right",
}}
onOpenChange={(isOpen) =>
toggleOpen(resource._id, "contextOpen", isOpen)
}
isOpen={details[resource._id]?.contextOpen}
isPlain
dropdownItems={[
toggle={(ref) => (
<MenuToggle
variant="plain"
ref={ref}
onClick={() =>
toggleOpen(
resource._id,
"contextOpen",
!details[resource._id]?.contextOpen,
)
}
isExpanded={details[resource._id]?.contextOpen}
>
<EllipsisVIcon />
</MenuToggle>
)}
isOpen={!!details[resource._id]?.contextOpen}
>
<DropdownList>
<DropdownItem
key="edit"
isDisabled={
details[resource._id]?.permissions?.length ===
0
Expand All @@ -281,9 +294,8 @@ export const ResourcesTab = ({ isShared = false }: ResourcesTabProps) => {
}
>
<EditAltIcon /> {t("edit")}
</DropdownItem>,
</DropdownItem>
<ContinueCancelModal
key="unShare"
buttonTitle={
<>
<Remove2Icon /> {t("unShare")}
Expand All @@ -300,25 +312,39 @@ export const ResourcesTab = ({ isShared = false }: ResourcesTabProps) => {
}
>
{t("unShareAllConfirm")}
</ContinueCancelModal>,
]}
/>
</ContinueCancelModal>
</DropdownList>
</Dropdown>
</OverflowMenuItem>
</OverflowMenuGroup>
</OverflowMenuContent>
<OverflowMenuControl>
<Dropdown
position="right"
toggle={
<KebabToggle
onToggle={(_event, open) =>
toggleOpen(resource._id, "contextOpen", open)
}
/>
popperProps={{
position: "right",
}}
onOpenChange={(isOpen) =>
toggleOpen(resource._id, "contextOpen", isOpen)
}
isOpen={details[resource._id]?.contextOpen}
isPlain
dropdownItems={[
toggle={(ref) => (
<MenuToggle
variant="plain"
ref={ref}
isExpanded={details[resource._id]?.contextOpen}
onClick={() =>
toggleOpen(
resource._id,
"contextOpen",
!details[resource._id]?.contextOpen,
)
}
>
<EllipsisVIcon />
</MenuToggle>
)}
isOpen={!!details[resource._id]?.contextOpen}
>
<DropdownList>
<OverflowMenuDropdownItem
key="share"
isShared
Expand All @@ -327,16 +353,19 @@ export const ResourcesTab = ({ isShared = false }: ResourcesTabProps) => {
}
>
<ShareAltIcon /> {t("share")}
</OverflowMenuDropdownItem>,
</OverflowMenuDropdownItem>
<OverflowMenuDropdownItem
key="edit"
isShared
onClick={() =>
toggleOpen(resource._id, "editDialogOpen", true)
}
isDisabled={
details[resource._id]?.permissions?.length === 0
}
>
<EditAltIcon /> {t("edit")}
</OverflowMenuDropdownItem>,
</OverflowMenuDropdownItem>
<ContinueCancelModal
key="unShare"
buttonTitle={
Expand All @@ -354,9 +383,9 @@ export const ResourcesTab = ({ isShared = false }: ResourcesTabProps) => {
}
>
{t("unShareAllConfirm")}
</ContinueCancelModal>,
]}
/>
</ContinueCancelModal>
</DropdownList>
</Dropdown>
</OverflowMenuControl>
</OverflowMenu>
</Td>
Expand Down

0 comments on commit 014b644

Please sign in to comment.