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 @@ -32,6 +32,7 @@ import type {
AllCasesFilterValues,
} from "@features/support/types/cases";
import type { ProjectDeploymentItem } from "@features/project-details/types/deployments";
import type { ProjectContact } from "@features/settings/types/users";
import {
SelectMenuLoadMoreRow,
SELECT_MENU_LOAD_MORE_ROW_VALUE,
Expand All @@ -49,13 +50,16 @@ export interface ListFiltersProps {
filters: AllCasesFilterValues;
filterMetadata: CaseMetadataResponse | undefined;
deployments?: ProjectDeploymentItem[];
contacts?: ProjectContact[];
isContactsLoading?: boolean;
onFilterChange: (field: string, value: string | string[]) => void;
excludeS0?: boolean;
restrictSeverityToLow?: boolean;
hideSeverityFilter?: boolean;
hideStatusFilter?: boolean;
hideDeploymentFilter?: boolean;
hideCategoryFilter?: boolean;
hideCreatedByFilter?: boolean;
onLoadMoreDeployments?: () => void;
hasMoreDeployments?: boolean;
isFetchingMoreDeployments?: boolean;
Expand All @@ -72,13 +76,16 @@ export default function ListFilters({
filters,
filterMetadata,
deployments,
contacts,
isContactsLoading = false,
onFilterChange,
excludeS0 = false,
restrictSeverityToLow = false,
hideSeverityFilter = false,
hideStatusFilter = false,
hideDeploymentFilter = false,
hideCategoryFilter = false,
hideCreatedByFilter = false,
onLoadMoreDeployments,
hasMoreDeployments = false,
isFetchingMoreDeployments = false,
Expand Down Expand Up @@ -112,12 +119,16 @@ export default function ListFilters({
if (hideCategoryFilter && def.id === "category") {
return null;
}
if (hideCreatedByFilter && def.id === "createdBy") {
return null;
}
if (def.metadataKey === "severities" && restrictSeverityToLow) {
return null;
}
const { label, allLabel } = deriveFilterLabels(def.id);

const isDeploymentFilter = def.id === "deployment";
const isCreatedByFilter = def.id === "createdBy";
const options = (() => {
if (isDeploymentFilter) {
return (
Expand All @@ -127,6 +138,15 @@ export default function ListFilters({
})) ?? []
);
}
if (isCreatedByFilter) {
return (
contacts?.map((contact) => ({
label: `${contact.firstName} ${contact.lastName}`.trim() || contact.email,
value: contact.email,
})) ?? []
);
}
if (!def.metadataKey) return [];
const metadataOptions = filterMetadata?.[def.metadataKey];
if (!Array.isArray(metadataOptions)) return [];
const filtered =
Expand Down Expand Up @@ -189,7 +209,11 @@ export default function ListFilters({
);
}}
>
{hasNoOptions ? (
{isCreatedByFilter && isContactsLoading ? (
<MenuItem disabled>
<Typography variant="body2">Loading...</Typography>
</MenuItem>
) : hasNoOptions ? (
<MenuItem disabled>
<Typography variant="body2">{EMPTY_DROPDOWN_PLACEHOLDER}</Typography>
</MenuItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import type { JSX, ReactNode } from "react";
import type { CaseMetadataResponse } from "@features/support/types/cases";
import type { ProjectDeploymentItem } from "@features/project-details/types/deployments";
import type { ProjectContact } from "@features/settings/types/users";
import ListSearchBar from "@components/list-view/ListSearchBar";
import ListFilters from "@components/list-view/ListFilters";
import { countListSearchAndFilters } from "@features/support/utils/support";
Expand All @@ -32,9 +33,12 @@ export interface ListSearchPanelProps {
severityIds?: string[];
issueTypes?: string[];
deploymentIds?: string[];
createdBy?: string[];
};
filterMetadata: CaseMetadataResponse | undefined;
deployments?: ProjectDeploymentItem[];
contacts?: ProjectContact[];
isContactsLoading?: boolean;
onFilterChange: (field: string, value: string | string[]) => void;
onClearFilters: () => void;
excludeS0?: boolean;
Expand All @@ -43,6 +47,7 @@ export interface ListSearchPanelProps {
hideStatusFilter?: boolean;
hideDeploymentFilter?: boolean;
hideCategoryFilter?: boolean;
hideCreatedByFilter?: boolean;
hideFiltersButton?: boolean;
isProjectContextLoading?: boolean;
onLoadMoreDeployments?: () => void;
Expand All @@ -67,6 +72,8 @@ export default function ListSearchPanel({
filters,
filterMetadata,
deployments,
contacts,
isContactsLoading = false,
onFilterChange,
onClearFilters,
excludeS0 = false,
Expand All @@ -75,6 +82,7 @@ export default function ListSearchPanel({
hideStatusFilter = false,
hideDeploymentFilter = false,
hideCategoryFilter = false,
hideCreatedByFilter = false,
hideFiltersButton = false,
isProjectContextLoading = false,
onLoadMoreDeployments,
Expand All @@ -90,6 +98,7 @@ export default function ListSearchPanel({
...(hideStatusFilter ? { statusIds: undefined } : {}),
...(hideDeploymentFilter ? { deploymentIds: undefined } : {}),
...(hideCategoryFilter ? { issueTypes: undefined } : {}),
...(hideCreatedByFilter ? { createdBy: undefined } : {}),
...excluded,
};
return (
Expand All @@ -112,13 +121,16 @@ export default function ListSearchPanel({
filters={filters}
filterMetadata={filterMetadata}
deployments={deployments}
contacts={contacts}
isContactsLoading={isContactsLoading}
onFilterChange={onFilterChange}
excludeS0={excludeS0}
restrictSeverityToLow={restrictSeverityToLow}
hideSeverityFilter={hideSeverityFilter}
hideStatusFilter={hideStatusFilter}
hideDeploymentFilter={hideDeploymentFilter}
hideCategoryFilter={hideCategoryFilter}
hideCreatedByFilter={hideCreatedByFilter}
onLoadMoreDeployments={onLoadMoreDeployments}
hasMoreDeployments={hasMoreDeployments}
isFetchingMoreDeployments={isFetchingMoreDeployments}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function buildDashboardCaseSearchFilters(params: {
deploymentIds?: string[];
searchQuery?: string;
createdByMe?: boolean;
createdBy?: string[];
caseStates?: MetadataItem[];
isDashboardSeverityNavigation?: boolean;
}): CaseSearchFilters {
Expand All @@ -97,6 +98,7 @@ export function buildDashboardCaseSearchFilters(params: {
deploymentIds,
searchQuery,
createdByMe,
createdBy,
caseStates,
isDashboardSeverityNavigation = false,
} = params;
Expand All @@ -107,6 +109,7 @@ export function buildDashboardCaseSearchFilters(params: {
? severityIds.map(Number)
: undefined;
const normalizedIssueIds = normalizeCaseSearchIssueIds(issueTypes);
const normalizedCreatedBy = createdBy?.length ? createdBy : undefined;

switch (true) {
case Boolean(explicitStatusIds?.length):
Expand All @@ -117,6 +120,7 @@ export function buildDashboardCaseSearchFilters(params: {
deploymentIds,
searchQuery: normalizedSearchQuery,
createdByMe,
createdBy: normalizedCreatedBy,
};
case isDashboardSeverityNavigation:
return {
Expand All @@ -126,6 +130,7 @@ export function buildDashboardCaseSearchFilters(params: {
deploymentIds,
searchQuery: normalizedSearchQuery,
createdByMe,
createdBy: normalizedCreatedBy,
};
default:
return {
Expand All @@ -134,6 +139,7 @@ export function buildDashboardCaseSearchFilters(params: {
deploymentIds,
searchQuery: normalizedSearchQuery,
createdByMe,
createdBy: normalizedCreatedBy,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ export default function useGetProjectContacts(
}
},
enabled: !!projectId && !!isSignedIn && !isAuthLoading,
staleTime: 0,
staleTime: 5 * 60 * 1000,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@ export const ALL_CASES_FILTER_DEFINITIONS: AllCasesFilterDefinition[] = [
metadataKey: "deploymentTypes",
multiSelect: true,
},
{
filterKey: "createdBy",
id: "createdBy",
multiSelect: true,
},
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import useGetProjectFeatures from "@api/useGetProjectFeatures";
import useGetProjectFilters from "@api/useGetProjectFilters";
import useGetProjectCases from "@api/useGetProjectCases";
import { usePostProjectDeploymentsSearchInfinite } from "@api/usePostProjectDeploymentsSearch";
import useGetProjectContacts from "@features/settings/api/useGetProjectContacts";
import {
hasListSearchOrFilters,
getLast30DaysUtcRange,
Expand Down Expand Up @@ -141,6 +142,9 @@ export default function AllCasesPage(): JSX.Element {
const deploymentsList =
deploymentsQuery.data?.pages.flatMap((p) => p.deployments ?? []) ?? [];

const { data: contactsData, isLoading: isContactsLoading } = useGetProjectContacts(projectId || "");
const contactsList = contactsData ?? [];

const caseSearchRequest = useMemo(
() => ({
filters: {
Expand All @@ -154,6 +158,7 @@ export default function AllCasesPage(): JSX.Element {
: undefined,
searchQuery: searchTerm,
createdByMe: createdByMe || undefined,
createdBy: filters.createdBy as string[] | undefined,
caseStates: filterMetadata?.caseStates,
isDashboardSeverityNavigation:
(isDashboardSeverityNavigation &&
Expand All @@ -178,6 +183,7 @@ export default function AllCasesPage(): JSX.Element {
filterMetadata?.caseStates,
isDashboardSeverityNavigation,
initialSeverityId,
contactsList,
],
);

Expand All @@ -204,7 +210,7 @@ export default function AllCasesPage(): JSX.Element {
(!!projectId && !hasCasesResponse) ||
isFetchingNextPage;

const isInitialPageLoading = isCasesAreaLoading;
const isInitialPageLoading = isCasesAreaLoading || isContactsLoading;

useEffect(() => {
if (isInitialPageLoading) {
Expand Down Expand Up @@ -356,6 +362,8 @@ export default function AllCasesPage(): JSX.Element {
onFiltersToggle={() => setIsFiltersOpen(!isFiltersOpen)}
filters={filters}
filterMetadata={filterMetadata}
contacts={contactsList}
isContactsLoading={isContactsLoading}
deployments={
projectDetailsReady && permissions.hasDeployments
? deploymentsList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export type AllCasesFilterValues = {
issueTypes?: string[];
deploymentIds?: string[];
engagementTypeKey?: string;
createdBy?: string[];
};

// Item type for a case attachment.
Expand Down Expand Up @@ -367,6 +368,7 @@ export type CaseSearchFilters = {
searchQuery?: string;
caseTypes?: string[];
createdByMe?: boolean;
createdBy?: string[];
closedStartDate?: string;
closedEndDate?: string;
engagementTypeKeys?: number[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type CaseStatusAction = {
/** All-cases list filter field mapping. */
export type AllCasesFilterDefinition = {
id: string;
metadataKey: keyof CaseMetadataResponse;
metadataKey?: keyof CaseMetadataResponse;
filterKey: string;
useLabelAsValue?: boolean;
multiSelect?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,9 @@ export function deriveFilterLabels(id: string): {
if (id === "caseType") {
return { label: "Case Type", allLabel: "All Case Types" };
}
if (id === "createdBy") {
return { label: "Created By", allLabel: "All Users" };
}
const label = id.charAt(0).toUpperCase() + id.slice(1);
const allLabel = `All ${
label.endsWith("s")
Expand Down