Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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 @@ -26,6 +26,7 @@ import { ArrowLeft } from "@wso2/oxygen-ui-icons-react";
import { type JSX, type ReactNode } from "react";
import { useParams } from "react-router";
import { useGetAccount } from "@features/csm-accounts/api/useGetAccount";
import { resolveAccountTier } from "@features/csm-accounts/types/csmAccounts";
import { useNavTransition } from "@hooks/useNavTransition";

function formatDate(value?: string | null): string {
Expand Down Expand Up @@ -121,6 +122,7 @@ export default function CsmAccountDetailPage(): JSX.Element {
}

const a = data;
const tier = resolveAccountTier(a);

return (
<Box sx={{ display: "flex", flexDirection: "column", gap: 2.5 }}>
Expand All @@ -129,12 +131,14 @@ export default function CsmAccountDetailPage(): JSX.Element {
<Box sx={{ display: "flex", flexDirection: "column", gap: 1 }}>
<Box sx={{ display: "flex", alignItems: "center", gap: 1.5, flexWrap: "wrap" }}>
<Typography variant="h5">{a.name}</Typography>
<Chip
size="small"
label={a.tier}
color={a.tier === "enterprise" ? "primary" : "default"}
variant="outlined"
/>
{tier && (
<Chip
size="small"
label={tier}
color={tier === "enterprise" ? "primary" : "default"}
variant="outlined"
/>
)}
{a.deactivationDate && (
<Chip size="small" label="Deactivated" color="default" variant="outlined" />
)}
Expand All @@ -159,7 +163,7 @@ export default function CsmAccountDetailPage(): JSX.Element {
>
<MetaCell label="Tier">
<Typography variant="body2" sx={{ textTransform: "capitalize" }}>
{a.tier}
{tier ?? "—"}
</Typography>
</MetaCell>
<MetaCell label="Region">
Expand Down Expand Up @@ -197,10 +201,10 @@ export default function CsmAccountDetailPage(): JSX.Element {
<Mono>{a.technicalOwnerId || "—"}</Mono>
</MetaCell>
<MetaCell label="Created">
<Typography variant="body2">{formatDate(a.createdAt)}</Typography>
<Typography variant="body2">{formatDate(a.createdOn)}</Typography>
</MetaCell>
<MetaCell label="Last updated">
<Typography variant="body2">{formatDate(a.updatedAt)}</Typography>
<Typography variant="body2">{formatDate(a.updatedOn)}</Typography>
</MetaCell>
<MetaCell label="Account ID">
<Mono>{a.id}</Mono>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ import { Link as RouterLink } from "react-router";
import QueryErrorState from "@components/QueryErrorState";
import { useDebouncedValue } from "@hooks/useDebouncedValue";
import { useSearchAccounts } from "@features/csm-accounts/api/useSearchAccounts";
import type { SearchAccountsRequest } from "@features/csm-accounts/types/csmAccounts";
import {
resolveAccountTier,
type SearchAccountsRequest,
} from "@features/csm-accounts/types/csmAccounts";
import { BE_MAX_PAGE_LIMIT } from "@constants/apiConstants";

const DEFAULT_ROWS_PER_PAGE = 20;
Expand All @@ -59,13 +62,15 @@ export default function CsmAccountsPage(): JSX.Element {

const debouncedSearch = useDebouncedValue(searchInput, 300);

const request = useMemo<SearchAccountsRequest>(
() => ({
const request = useMemo<SearchAccountsRequest>(() => {
const searchQuery = debouncedSearch.trim() || undefined;
return {
pagination: { limit: rowsPerPage, offset: page * rowsPerPage },
searchQuery: debouncedSearch.trim() || undefined,
}),
[debouncedSearch, page, rowsPerPage],
);
// Filter fields are nested under `filters` (matches the `/cases/search`
// payload shape).
...(searchQuery && { filters: { searchQuery } }),
};
}, [debouncedSearch, page, rowsPerPage]);

const { data, isLoading, isFetching, isError, error } = useSearchAccounts(request);

Expand Down Expand Up @@ -141,37 +146,44 @@ export default function CsmAccountsPage(): JSX.Element {
</TableCell>
</TableRow>
) : (
accounts.map((a) => (
<TableRow key={a.id} hover>
<TableCell>
<Typography
component={RouterLink}
to={`/customers/accounts/${a.id}`}
variant="body2"
sx={(t) => ({
textDecoration: "none",
color: t.palette.primary.dark,
...t.applyStyles("dark", { color: t.palette.primary.main }),
"&:hover": { textDecoration: "underline" },
})}
>
{a.name}
</Typography>
</TableCell>
<TableCell>{a.sfId}</TableCell>
<TableCell>
<Chip
size="small"
label={a.tier}
color={a.tier === "enterprise" ? "primary" : "default"}
variant="outlined"
/>
</TableCell>
<TableCell>{a.region ?? "—"}</TableCell>
<TableCell>{formatDate(a.activationDate)}</TableCell>
<TableCell>{formatDate(a.deactivationDate)}</TableCell>
</TableRow>
))
accounts.map((a) => {
const tier = resolveAccountTier(a);
return (
<TableRow key={a.id} hover>
<TableCell>
<Typography
component={RouterLink}
to={`/customers/accounts/${a.id}`}
variant="body2"
sx={(t) => ({
textDecoration: "none",
color: t.palette.primary.dark,
...t.applyStyles("dark", { color: t.palette.primary.main }),
"&:hover": { textDecoration: "underline" },
})}
>
{a.name}
</Typography>
</TableCell>
<TableCell>{a.sfId || "—"}</TableCell>
<TableCell>
{tier ? (
<Chip
size="small"
label={tier}
color={tier === "enterprise" ? "primary" : "default"}
variant="outlined"
/>
) : (
"—"
)}
</TableCell>
<TableCell>{a.region ?? "—"}</TableCell>
<TableCell>{formatDate(a.activationDate)}</TableCell>
<TableCell>{formatDate(a.deactivationDate)}</TableCell>
</TableRow>
);
})
)}
</TableBody>
</Table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,57 @@

export type AccountTier = "basic" | "enterprise";

// A support-tier reference as returned on the account detail view for the
// backing-data-source-backed shape ({id, label}), vs. a plain label string on
// the list view. See `tier`/`supportTier` below.
export interface SupportTierRef {
id: string;
label: string;
}

export interface Account {
id: string;
sfId: string;
name: string;
tier: AccountTier;
// Postgres-backed accounts carry `tier`. Accounts sourced from the
// alternate (ServiceNow-shaped) response instead carry `supportTier`,
// either as a plain label string (list view) or an `{id, label}` ref
// (detail view) — there is only one FE `Account` type today, so both are
// modeled here as optional and resolved at the read site.
tier?: AccountTier;
supportTier?: string | SupportTierRef | null;
region?: string | null;
activationDate: string;
deactivationDate?: string | null;
ownerId: string;
technicalOwnerId?: string | null;
agentEnabled: boolean;
kbReferencesEnabled: boolean;
createdAt: string;
updatedAt: string;
createdOn: string;
updatedOn: string;
}

/**
* Resolves the Tier value regardless of which response shape the account
* came from: Postgres-backed `tier`, or the alternate-shape `supportTier`
* (plain string on the list view, `{id, label}` ref on the detail view).
*/
export function resolveAccountTier(
account: Pick<Account, "tier" | "supportTier">,
): string | undefined {
if (account.tier) return account.tier;
if (typeof account.supportTier === "string") return account.supportTier;
return account.supportTier?.label ?? undefined;
}

export interface SearchAccountsRequest {
pagination?: {
limit?: number;
offset?: number;
};
searchQuery?: string;
filters?: {
searchQuery?: string;
};
}

export interface SearchAccountsResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,10 @@ describe("CaseActionBar — Raise internal Git issue is blocked on a closed case
});
});

describe("CaseActionBar — Manage watchers / Hold auto-closure / Edit case details / Link to another case", () => {
describe("CaseActionBar — Hold auto-closure / Edit case details", () => {
const SECONDARY_ITEMS: Array<[RegExp, string]> = [
[/manage watchers/i, "manage_watchers"],
[/hold auto-closure/i, "hold_auto_close"],
[/edit case details/i, "edit_case_details"],
[/link to another case/i, "link_case"],
];

it.each(SECONDARY_ITEMS)(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ import {
ChevronDown,
Clock,
Copy,
Eye,
Gauge,
GitBranch,
Inbox,
Link as LinkIcon,
ListChecks,
PauseCircle,
Phone,
Pencil,
Play,
Send,
Expand Down Expand Up @@ -201,26 +199,36 @@ interface SecondaryItem {
* The "More" overflow lists state-independent actions on a case. Items here
* map to documented use cases — see `UseCases.md`:
* - Reassign engineer → ISSU-002 (self-assign generalised)
* - Manage watchers → ISSU-018 (PATCH /cases/{id} { watchList }); jumps to the case
* detail Related tab, which edits the watch list inline
* (see WatchersWidget in CaseDetailWidgets.tsx)
* - Hold auto-closure → ISSU-027 (PATCH /cases/{id} { autocloseHoldUntil }, see SetAutocloseHoldDialog.tsx)
* - Edit case details → subject/description/deployment/deployed product (see EditCaseDetailsDialog.tsx)
* - Link to another case → parent or related case (see LinkCaseDialog.tsx)
* - Create incident from case → ISSU-021 (POST /incidents { parentId }, see
* CreateIncidentPage.tsx's read of the nav state)
* - Link to incident → ISSU-021 (PATCH /cases/{id} { parentId }, see
* LinkIncidentDialog.tsx)
* - Raise Git issue → ISSU-020
* - Create task → ISSU-025 (POST /cases/{caseId}/tasks, see CreateTaskDialog.tsx)
* - Create task → ISSU-025 (POST /cases/{caseId}/tasks, see CreateTaskDialog.tsx).
* Kept here even though a Tasks tab exists: that tab is
* still `hidden` in CsmCaseDetailPage's TAB_DEFS, so this
* menu item is the only reachable entry point today.
* - Set fix ETA → PATCH /cases/{id} { fixEta }, see SetFixEtaDialog.tsx
* - Request a call → ISSU-008 (opens the Call requests tab's create dialog)
* - Log time → ISSU-017
* - Change severity → PATCH /cases/{id} { severity }, already fully
* backend-supported (see ChangeSeverityDialog.tsx)
* - Copy case link → ISSU-010 (per-comment + per-case permalinks)
*
* Intentionally NOT here:
* Intentionally NOT here (removed as duplicate entry points once their target
* tab already exposes the same action directly, so there's one way to do each
* thing rather than two):
* - Manage watchers → the Watchers tab does inline add/remove already; the
* menu item only ever jumped there with no dialog of
* its own (ISSU-018).
* - Link to another case → the Related tab's "Linked service requests" card
* has its own "Link to another case…" button wired to
* the same LinkCaseDialog.
* - Request a call → the Call requests tab has its own "Create call
* request" button (CallRequestsWidget.tsx); the menu
* item only jumped there and auto-opened that same
* dialog (ISSU-008).
* - Open in ServiceNow → this platform replaces ServiceNow; no back-link
* - Escalate to lead → withdrawn, no backend flow planned yet
*/
Expand Down Expand Up @@ -308,13 +316,6 @@ function buildSecondaryItems(caseDetail: CsmCaseDetail): SecondaryItem[] {
key: "edit_case_details",
label: "Edit case details…",
icon: <Pencil size={16} />,
disabled: caseClosed,
tooltip: caseClosed ? "This case is closed — it's read-only." : undefined,
},
{
key: "manage_watchers",
label: "Manage watchers…",
icon: <Eye size={16} />,
divider: true,
disabled: caseClosed,
tooltip: caseClosed ? "This case is closed — it's read-only." : undefined,
Expand All @@ -323,13 +324,6 @@ function buildSecondaryItems(caseDetail: CsmCaseDetail): SecondaryItem[] {
key: "hold_auto_close",
label: "Hold auto-closure…",
icon: <PauseCircle size={16} />,
disabled: caseClosed,
tooltip: caseClosed ? "This case is closed — it's read-only." : undefined,
},
{
key: "link_case",
label: "Link to another case…",
icon: <LinkIcon size={16} />,
divider: true,
disabled: caseClosed,
tooltip: caseClosed ? "This case is closed — it's read-only." : undefined,
Expand Down Expand Up @@ -364,13 +358,6 @@ function buildSecondaryItems(caseDetail: CsmCaseDetail): SecondaryItem[] {
disabled: caseClosed,
tooltip: caseClosed ? "This case is closed — it's read-only." : undefined,
},
{
key: "request_call",
label: "Request a call…",
icon: <Phone size={16} />,
disabled: caseClosed,
tooltip: caseClosed ? "This case is closed — it's read-only." : undefined,
},
{ key: "log_time", label: "Log time…", icon: <Clock size={16} />, divider: true },
{ key: "copy_link", label: "Copy case link", icon: <Copy size={16} /> },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import CasesList from "@features/csm-cases/components/CasesList";
import { useGetCsmCases } from "@features/csm-cases/api/useGetCsmCases";
import { useDirectoryUsers } from "@api/useDirectoryUsers";
import { BE_MAX_PAGE_LIMIT } from "@constants/apiConstants";
import { ALL_CASE_TYPES } from "@features/csm-cases/utils/caseType";
import {
DEFAULT_CASES_FILTERS,
readCasesFiltersFromUrl,
Expand Down Expand Up @@ -144,14 +145,31 @@ export default function CsmIssuesView({
// User filters (debounced search) with the locked overrides applied last so
// the fixed type/project can't be widened by a stale URL value.
const queryFilters = useMemo<CasesFilters>(
() => ({
...filters,
search: debouncedSearch,
// The severity control is hidden for non-case lists, so don't let a stale
// `severities` value from a shared URL silently filter those results.
...(showSeverityFilter ? {} : { severities: [] }),
...lockedFilters,
}),
() => {
const merged: CasesFilters = {
...filters,
search: debouncedSearch,
// The severity control is hidden for non-case lists, so don't let a
// stale `severities` value from a shared URL silently filter those
// results.
...(showSeverityFilter ? {} : { severities: [] }),
...lockedFilters,
};
// An unlocked, empty type selection means "no type filter applied" from
// the FE's perspective (every issue type shown — this is the only
// unlocked, multi-type view; every other CsmIssuesView caller locks
// `caseTypes` to a single value and hides the control). But
// `useGetCsmCases` omits an empty `caseTypes` from the search payload
// entirely, and the entity-service defaults an absent/empty `types`
// filter to support cases only (`default_case`) rather than "no
// restriction" — so an omitted filter silently narrows the result to
// one type instead of returning all of them. Send every known type
// explicitly in that case so the BE default can't kick in.
if (merged.caseTypes.length === 0) {
merged.caseTypes = ALL_CASE_TYPES;
}
return merged;
},
[filters, debouncedSearch, showSeverityFilter, lockedFilters],
);

Expand Down
Loading