Merge pull request #249 from edewit/remove-all

added missing remove all kabab item
This commit is contained in:
mfrances17 2020-12-09 09:23:04 -05:00 committed by GitHub
commit 66d3c844f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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[]>();
@ -284,13 +285,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"
@ -327,8 +328,56 @@ 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"
isDisabled={
rows.filter((row) => row.selected).length === 0
}
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