added missing remove all kabab item

This commit is contained in:
Erik Jan de Wit 2020-12-07 14:42:08 +01:00
parent b59902e3c8
commit b0faaa829a

View file

@ -14,10 +14,10 @@ import {
Dropdown,
DropdownItem,
DropdownToggle,
KebabToggle,
Select,
Spinner,
Split,
SplitItem,
ToolbarItem,
} from "@patternfly/react-core";
import { FilterIcon } from "@patternfly/react-icons";
import ClientScopeRepresentation from "keycloak-admin/lib/defs/clientScopeRepresentation";
@ -128,6 +128,7 @@ export const ClientScopes = ({ clientId, protocol }: ClientScopesProps) => {
const [searchType, setSearchType] = useState<SearchType>("client");
const [addToggle, setAddToggle] = useState(false);
const [addDialogOpen, setAddDialogOpen] = useState(false);
const [kebabOpen, setKebabOpen] = useState(false);
const [rows, setRows] = useState<TableRow[]>();
const [rest, setRest] = useState<ClientScopeRepresentation[]>();
@ -285,13 +286,13 @@ export const ClientScopes = ({ clientId, protocol }: ClientScopesProps) => {
inputGroupPlaceholder={t("searchByName")}
inputGroupOnChange={filterData}
toolbarItem={
<Split hasGutter>
<SplitItem>
<>
<ToolbarItem>
<Button onClick={() => setAddDialogOpen(true)}>
{t("addClientScope")}
</Button>
</SplitItem>
<SplitItem>
</ToolbarItem>
<ToolbarItem>
<Select
id="add-dropdown"
key="add-dropdown"
@ -328,8 +329,53 @@ export const ClientScopes = ({ clientId, protocol }: ClientScopesProps) => {
>
{clientScopeTypesSelectOptions(t)}
</Select>
</SplitItem>
</Split>
</ToolbarItem>
<ToolbarItem>
<Dropdown
onSelect={() => {}}
toggle={
<KebabToggle onToggle={() => setKebabOpen(!kebabOpen)} />
}
isOpen={kebabOpen}
isPlain
dropdownItems={[
<DropdownItem
key="deleteAll"
onClick={async () => {
try {
await Promise.all(
rows.map(async (row) => {
if (row.selected) {
await removeScope(
adminClient,
clientId,
row.clientScope,
row.type
);
}
})
);
setKebabOpen(false);
addAlert(
t("clientScopeRemoveSuccess"),
AlertVariant.success
);
loader();
} catch (error) {
addAlert(
t("clientScopeRemoveError", { error }),
AlertVariant.danger
);
}
}}
>
{t("common:remove")}
</DropdownItem>,
]}
/>
</ToolbarItem>
</>
}
>
<Table