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
5 changes: 1 addition & 4 deletions apps/csm-portal/webapp/src/AppWithConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import AppErrorBoundary from "@components/error/AppErrorBoundary";
import { AsgardeoProvider } from "@asgardeo/react";
import { loggerConfig } from "@config/loggerConfig";
import LoggerProvider from "@context/logger/LoggerProvider";
import { MockModeProvider } from "@context/mock-mode/MockModeContext";
import { ThemePreferenceProvider } from "@context/theme/ThemePreferenceContext";
import { authConfig } from "@config/authConfig";

Expand Down Expand Up @@ -90,9 +89,7 @@ export default function AppWithConfig(): JSX.Element {
<ThemePreferenceProvider>
<QueryClientProvider client={queryClient}>
<AppErrorBoundary>
<MockModeProvider>
<App />
</MockModeProvider>
<App />
</AppErrorBoundary>
{ReactQueryDevtools && (
<Suspense fallback={null}>
Expand Down
8 changes: 0 additions & 8 deletions apps/csm-portal/webapp/src/api/backend/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ import { useAuthApiClient } from "@hooks/useAuthApiClient";
import type { BeErrorPayload } from "@api/backend/types";
import { CORRELATION_ID_HEADER } from "@utils/correlationId";

/**
* `true` when the mock toggle is on. Hooks should branch on this and call
* the backend client only in LIVE mode.
*/
export function isMockMode(): boolean {
return !!window.config?.CSM_PORTAL_USE_MOCKS;
}

export function backendBaseUrl(): string {
const baseUrl = window.config?.CSM_PORTAL_BACKEND_BASE_URL;
if (!baseUrl) {
Expand Down
28 changes: 4 additions & 24 deletions apps/csm-portal/webapp/src/api/useDirectoryUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
// under the License.

import { useQuery, type UseQueryResult } from "@tanstack/react-query";
import { useLogger } from "@hooks/useLogger";
import { ApiQueryKeys } from "@constants/apiConstants";
import { isMockMode, useBackendApi } from "@api/backend/client";
import { useBackendApi } from "@api/backend/client";

/**
* Minimal user-directory entry: just what UI affordances like the cases
Expand All @@ -29,19 +28,6 @@ export interface DirectoryUser {
email: string;
}

const MOCK_LATENCY_MS = 150;

// A small mock directory so the assignee picker is populated in mock mode
// without coupling to the csm-admin mock data set.
const MOCK_DIRECTORY: DirectoryUser[] = [
{ name: "Sajith Ekanayaka", email: "sajithe@wso2.com" },
{ name: "Renee Park", email: "renee.park@example.com" },
{ name: "Marcus Webb", email: "marcus.webb@example.com" },
{ name: "Lena Fischer", email: "lena.fischer@example.com" },
{ name: "Arjun Nair", email: "arjun.nair@example.com" },
{ name: "Priya Sharma", email: "priya.sharma@example.com" },
];

/** Raw user shape the backend may return; mapped defensively to DirectoryUser. */
interface RawDirectoryUser {
name?: string;
Expand All @@ -58,22 +44,16 @@ function toDirectoryUser(u: RawDirectoryUser): DirectoryUser {
}

/**
* Shared user-directory lookup. Backed by `POST /users/search` in live mode
* (the canonical backend route — there is no `GET /users`), and a small mock
* set under the mock toggle. Returns a lightweight {@link DirectoryUser} list.
* Shared user-directory lookup. Backed by `POST /users/search`
* (the canonical backend route — there is no `GET /users`). Returns a
* lightweight {@link DirectoryUser} list.
*/
export function useDirectoryUsers(): UseQueryResult<DirectoryUser[], Error> {
const logger = useLogger();
const api = useBackendApi();

return useQuery<DirectoryUser[], Error>({
queryKey: [ApiQueryKeys.CSM_ADMIN_USERS, "directory"],
queryFn: async (): Promise<DirectoryUser[]> => {
if (isMockMode()) {
logger.debug("[useDirectoryUsers] returning mock directory");
await new Promise((r) => setTimeout(r, MOCK_LATENCY_MS));
return MOCK_DIRECTORY;
}
const res = await api.post<Record<string, never>, unknown>(
"/users/search",
{},
Expand Down
2 changes: 0 additions & 2 deletions apps/csm-portal/webapp/src/components/header/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
import type { JSX } from "react";
import { useAsgardeo } from "@asgardeo/react";
import UserProfile from "@components/header/UserProfile";
import MockModeToggle from "@components/header/MockModeToggle";
import ThemeSelect from "@components/header/ThemeSelect";
import RecentViewsButton from "@features/csm-recent/components/RecentViewsButton";
import PinThisPageButton from "@features/csm-recent/components/PinThisPageButton";
Expand All @@ -33,7 +32,6 @@ export default function Actions(): JSX.Element {

return (
<HeaderUI.Actions>
<MockModeToggle />
<ThemeSelect />
<ColorSchemeToggle />
{isSignedIn && <PinThisPageButton />}
Expand Down
76 changes: 0 additions & 76 deletions apps/csm-portal/webapp/src/components/header/MockModeToggle.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions apps/csm-portal/webapp/src/config/authConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ declare global {
CSM_PORTAL_ANNOUNCEMENT_BANNER_VISIBLE?: boolean;
CSM_PORTAL_ANNOUNCEMENT_BANNER_STORAGE_KEY?: string;
CSM_PORTAL_ANNOUNCEMENT_BANNER_HTML?: string;
CSM_PORTAL_USE_MOCKS?: boolean;
CSM_PORTAL_ALLOW_MOCK_TOGGLE?: boolean;
};
}
}
Expand Down
125 changes: 0 additions & 125 deletions apps/csm-portal/webapp/src/context/mock-mode/MockModeContext.tsx

This file was deleted.

Loading