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, Dropdown,
DropdownItem, DropdownItem,
DropdownToggle, DropdownToggle,
KebabToggle,
Select, Select,
Spinner, Spinner,
Split, ToolbarItem,
SplitItem,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { FilterIcon } from "@patternfly/react-icons"; import { FilterIcon } from "@patternfly/react-icons";
import ClientScopeRepresentation from "keycloak-admin/lib/defs/clientScopeRepresentation"; 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 [searchType, setSearchType] = useState<SearchType>("client");
const [addToggle, setAddToggle] = useState(false); const [addToggle, setAddToggle] = useState(false);
const [addDialogOpen, setAddDialogOpen] = useState(false); const [addDialogOpen, setAddDialogOpen] = useState(false);
const [kebabOpen, setKebabOpen] = useState(false);
const [rows, setRows] = useState<TableRow[]>(); const [rows, setRows] = useState<TableRow[]>();
const [rest, setRest] = useState<ClientScopeRepresentation[]>(); const [rest, setRest] = useState<ClientScopeRepresentation[]>();
@ -284,13 +285,13 @@ export const ClientScopes = ({ clientId, protocol }: ClientScopesProps) => {
inputGroupPlaceholder={t("searchByName")} inputGroupPlaceholder={t("searchByName")}
inputGroupOnChange={filterData} inputGroupOnChange={filterData}
toolbarItem={ toolbarItem={
<Split hasGutter> <>
<SplitItem> <ToolbarItem>
<Button onClick={() => setAddDialogOpen(true)}> <Button onClick={() => setAddDialogOpen(true)}>
{t("addClientScope")} {t("addClientScope")}
</Button> </Button>
</SplitItem> </ToolbarItem>
<SplitItem> <ToolbarItem>
<Select <Select
id="add-dropdown" id="add-dropdown"
key="add-dropdown" key="add-dropdown"
@ -327,8 +328,56 @@ export const ClientScopes = ({ clientId, protocol }: ClientScopesProps) => {
> >
{clientScopeTypesSelectOptions(t)} {clientScopeTypesSelectOptions(t)}
</Select> </Select>
</SplitItem> </ToolbarItem>
</Split> <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 <Table