Skip to content

Commit

Permalink
PR review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
  • Loading branch information
edewit committed Apr 5, 2024
1 parent 5fd2600 commit da39d43
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions js/apps/admin-ui/src/components/group/GroupPickerDialog.tsx
Expand Up @@ -27,7 +27,6 @@ import { PaginatingTableToolbar } from "../table-toolbar/PaginatingTableToolbar"
import { GroupPath } from "./GroupPath";

import "./group-picker-dialog.css";
import { countGroups } from "../../groups/components/GroupTree";

export type GroupPickerDialogProps = {
id?: string;
Expand Down Expand Up @@ -79,7 +78,7 @@ export const GroupPickerDialog = ({

if (!groupId) {
const args: GroupQuery = {
first: first,
first,
max: max + 1,
};
if (isSearching) {
Expand All @@ -95,8 +94,8 @@ export const GroupPickerDialog = ({
}

const args: SubGroupQuery = {
first: first,
max: max + 1,
first,
max,
parentId: groupId,
};
groups = await adminClient.groups.listSubGroups(args);
Expand All @@ -121,8 +120,8 @@ export const GroupPickerDialog = ({
group.checked = !!selectedRows.find((r) => r.id === group.id);
});
setGroups(groups);
if (isSearching) {
setCount(countGroups(groups));
if (isSearching || !groupId) {
setCount(groups.length);
}
},
[groupId, filter, first, max],
Expand Down Expand Up @@ -222,22 +221,22 @@ export const GroupPickerDialog = ({
))}
</Breadcrumb>
<DataList aria-label={t("groups")} isCompact>
{groups.map((group: SelectableGroup) => (
{groups.slice(0, max).map((group: SelectableGroup) => (
<Fragment key={group.id}>
{(!isSearching || group.name?.includes(filter)) && (
<GroupRow
key={group.id}
group={group}
isRowDisabled={isRowDisabled}
onSelect={setGroupId}
type={type}
isSearching={isSearching}
setIsSearching={setIsSearching}
selectedRows={selectedRows}
setSelectedRows={setSelectedRows}
canBrowse={canBrowse}
/>
)}
{(!isSearching || group.name?.includes(filter)) && (
<GroupRow
key={group.id}
group={group}
isRowDisabled={isRowDisabled}
onSelect={setGroupId}
type={type}
isSearching={isSearching}
setIsSearching={setIsSearching}
selectedRows={selectedRows}
setSelectedRows={setSelectedRows}
canBrowse={canBrowse}
/>
)}
{isSearching &&
group.subGroups?.map((g) => (
<GroupRow
Expand Down Expand Up @@ -307,7 +306,10 @@ const GroupRow = ({
onClick={(e) => {
if (type === "selectOne") {
onSelect(group.id!);
} else if ((e.target as HTMLInputElement).type !== "checkbox") {
} else if (
(e.target as HTMLInputElement).type !== "checkbox" &&
group.subGroupCount !== 0
) {
onSelect(group.id!);
setIsSearching(false);
}
Expand Down

0 comments on commit da39d43

Please sign in to comment.