Merge pull request #249 from edewit/remove-all
added missing remove all kabab item
This commit is contained in:
commit
66d3c844f9
1 changed files with 57 additions and 8 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue