Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ const monitorFieldApi = baseApi.injectEndpoints({
query: ({
path: { monitor_config_id, action_type },
query: { search, diff_status, confidence_score, ...arrayQueryParams },
...body
body,
}) => {
const queryParams = buildArrayQueryParams({
...arrayQueryParams,
...(search ? { search: [search] } : {}),
...(diff_status ? { diff_status } : {}),
...(confidence_score ? { confidence_score } : {}),
});

return {
url: `/plus/discovery-monitor/${monitor_config_id}/fields/${action_type}?${queryParams.toString()}`,
method: "POST",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,12 @@ const ActionCenterFields: NextPage = () => {
);
const {
excludedListItems,
indeterminate,
isBulkSelect,
listSelectMode,
resetListSelect,
selectedListItems,
updateListItems,
updateListSelectMode,
updateSelectedListItem,
checkboxProps,
} = useBulkListSelect<
DatastoreStagedResourceAPIResponse & { itemKey: React.Key }
>({ activeListItem, enableKeyboardShortcuts: true });
Expand All @@ -171,7 +169,7 @@ const ActionCenterFields: NextPage = () => {
};

const onActionDropdownOpenChange = (open: boolean) => {
if (open && isBulkSelect) {
if (open && listSelectMode === "exclusive") {
allowedActionsTrigger({
...baseMonitorFilters,
query: {
Expand All @@ -193,13 +191,14 @@ const ActionCenterFields: NextPage = () => {
[hotkeysHelperModalOpen],
);

const availableActions = isBulkSelect
? allowedActionsResult?.allowed_actions
: getAvailableActions(
selectedListItems.flatMap(({ diff_status }) =>
diff_status ? [diff_status] : [],
),
);
const availableActions =
listSelectMode === "exclusive"
? allowedActionsResult?.allowed_actions
: getAvailableActions(
selectedListItems.flatMap(({ diff_status }) =>
diff_status ? [diff_status] : [],
),
);
const responseCount = fieldsDataResponse?.total ?? 0;
const selectedListItemCount =
listSelectMode === "exclusive" && fieldsDataResponse?.total
Expand Down Expand Up @@ -345,7 +344,7 @@ const ActionCenterFields: NextPage = () => {
isFetchingAllowedActions ||
!availableActions?.includes(actionType),
onClick: async () => {
if (isBulkSelect) {
if (listSelectMode === "exclusive") {
await bulkActions[actionType](
baseMonitorFilters,
excludedListItems.map((k) =>
Expand Down Expand Up @@ -387,16 +386,7 @@ const ActionCenterFields: NextPage = () => {
</Flex>
</Flex>
<Flex gap="middle" align="center">
<Checkbox
id="select-all"
checked={isBulkSelect}
indeterminate={indeterminate}
onChange={(e) =>
updateListSelectMode(
e.target.checked ? "exclusive" : "inclusive",
)
}
/>
<Checkbox id="select-all" {...checkboxProps} />
<label htmlFor="select-all">Select all</label>
{!!selectedListItemCount && (
<Text strong>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AntCheckboxProps as CheckboxProps } from "fidesui";
import _ from "lodash";
import { useState } from "react";
import { useHotkeys } from "react-hotkeys-hook";
Expand Down Expand Up @@ -111,23 +112,29 @@ export const useBulkListSelect = <T extends ListItem>(
[activeListItem, selectedListItems, updateSelectedListItem],
);

return {
excludedListItems,
const checkboxProps: CheckboxProps = {
checked:
mode === "inclusive"
? selectedListItems.length > 0 &&
listItems.length === selectedListItems.length
: excludedListItems.length === 0,
indeterminate:
mode === "inclusive"
? selectedListItems.length > 0 &&
listItems.length !== selectedListItems.length
: excludedListItems.length > 0,
isBulkSelect:
mode === "inclusive"
? selectedListItems.length > 0 &&
listItems.length === selectedListItems.length
: excludedListItems.length === 0,
onChange: (e) =>
updateListSelectMode(e.target.checked ? "exclusive" : "inclusive"),
};

return {
excludedListItems,
listSelectMode: mode,
resetListSelect,
selectedListItems,
updateListItems: setListItemsState,
updateListSelectMode,
updateSelectedListItem,
checkboxProps,
};
};
1 change: 1 addition & 0 deletions clients/fidesui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type {
export type {
AvatarProps as AntAvatarProps,
ButtonProps as AntButtonProps,
CheckboxProps as AntCheckboxProps,
CollapseProps as AntCollapseProps,
DatePickerProps as AntDatePickerProps,
DrawerProps as AntDrawerProps,
Expand Down
Loading