Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Menu,
MenuItem,
Skeleton,
Stack,
Typography,
} from "@wso2/oxygen-ui";
import {
Expand Down Expand Up @@ -158,6 +159,20 @@ function GetHelpDropdownContent(): JSX.Element {
: []),
];

if (isProjectsListBusy) {
return (
<Stack direction="row" alignItems="center" spacing={0.5}>
<Skeleton variant="rounded" width={96} height={36} />
<Skeleton variant="rounded" width={36} height={36} />
<Divider
orientation="vertical"
flexItem
sx={{ mx: 1, display: { xs: "none", sm: "block" } }}
/>
</Stack>
);
}

return (
<Box sx={{ display: "flex", alignItems: "center" }}>
<ButtonGroup variant="contained" color="primary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from "react";

import { ERROR_BANNER_TIMEOUT_MS } from "@constants/common";
import { consumePendingSuccessMessage } from "@features/settings/utils/settingsStorage";

interface SuccessBannerContextType {
/** Show the success banner with the given message. */
Expand Down Expand Up @@ -54,6 +55,14 @@ export function SuccessBannerProvider({
const [message, setMessage] = useState<string | null>(null);
const [key, setKey] = useState(0);

useEffect(() => {
const pending = consumePendingSuccessMessage();
if (pending) {
setMessage(pending);
setKey((prev) => prev + 1);
}
}, []);

const showSuccess = useCallback((msg: string) => {
setMessage(msg);
setKey((prev) => prev + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,7 @@ export default function DashboardItemsPage({
(s) => s.hasPermission && (s.isLoading || s.total > 0 || s.isError),
);

const visibleResolvedSections =
isPageLoading || isPageError
? []
: resolvedSections.filter(
(s) => s.hasPermission && (s.isLoading || s.total > 0 || s.isError),
);
void resolvedSections;

return (
<Stack spacing={3} sx={{ minWidth: 0 }}>
Expand Down Expand Up @@ -871,144 +866,6 @@ export default function DashboardItemsPage({
</Accordion>
))}

{isOutstandingMode && (
<>
<Typography
variant="subtitle2"
color="text.secondary"
fontWeight={600}
sx={{ px: 0.5, pt: visibleSections.length > 0 ? 1 : 0 }}
>
Resolved Items
</Typography>
{visibleResolvedSections.map((section) => (
<Accordion
key={section.id}
expanded={expandedSections.has(section.id)}
onChange={() => toggleSection(section.id)}
disableGutters
elevation={0}
sx={{
"&:before": { display: "none" },
border: "1px solid",
borderColor: "divider",
borderRadius: 2,
overflow: "hidden",
bgcolor: "background.paper",
}}
>
<AccordionSummary
expandIcon={<ChevronDown size={20} />}
sx={{ px: 2.5, py: 1.5, minHeight: 56 }}
>
<Box sx={{ display: "flex", alignItems: "center", gap: 1.5 }}>
<Typography variant="subtitle1" fontWeight={600}>
{section.label}
</Typography>
{section.isLoading ? (
<Skeleton variant="rounded" width={32} height={22} />
) : (
<Chip
label={section.total}
size="small"
color="default"
sx={{ fontWeight: 600 }}
/>
)}
</Box>
</AccordionSummary>
<AccordionDetails sx={{ px: 2.5, pb: 1, pt: 0 }}>
{section.isCr ? (
<>
<Box sx={{ pb: 2.5 }}>
<ChangeRequestsList
changeRequests={section.items}
isLoading={section.isLoading}
isError={section.isError}
onChangeRequestClick={section.onItemClick}
/>
</Box>
{section.total > 10 && (
<>
<Divider />
<Box
sx={{
display: "flex",
justifyContent: "flex-end",
pt: 0.5,
}}
>
<Button
variant="text"
color="warning"
endIcon={<ArrowRight size={16} />}
onClick={() =>
navigate(section.viewAllPath, {
relative: "path",
})
}
sx={{ textTransform: "none", fontWeight: 500 }}
>
{section.viewAllLabel}
</Button>
</Box>
</>
)}
</>
) : (
<>
<Box sx={{ pb: 2.5 }}>
<ListItems
cases={section.items}
isLoading={section.isLoading}
isError={section.isError}
onCaseClick={section.onItemClick}
entityName={section.entityName}
hideSeverity={section.hideSeverity}
/>
</Box>
{section.total > 10 && (
<>
<Divider />
<Box
sx={{
display: "flex",
justifyContent: "flex-end",
pt: 0.5,
}}
>
<Button
variant="text"
color="warning"
endIcon={<ArrowRight size={16} />}
onClick={() =>
navigate(section.viewAllPath, {
relative: "path",
})
}
sx={{ textTransform: "none", fontWeight: 500 }}
>
{section.viewAllLabel}
</Button>
</Box>
</>
)}
</>
)}
</AccordionDetails>
</Accordion>
))}
{!isPageLoading &&
!isPageError &&
visibleResolvedSections.length === 0 && (
<Box sx={{ textAlign: "center", py: 4 }}>
<Typography variant="body2" color="text.secondary">
No resolved items found.
</Typography>
</Box>
)}
</>
)}

{isPageError && (
<Box sx={{ py: 4 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ export default function ChangeRequestsListSkeleton(): JSX.Element {
flexWrap: "wrap",
}}
>
{/* CR number | state dot+label | pipe | case internalId | pipe | case number | pipe | product */}
<Skeleton variant="text" width={100} height={20} />
<Skeleton variant="rounded" width={88} height={22} />
<Box sx={{ display: "flex", alignItems: "center", gap: 0.75 }}>
<Skeleton variant="circular" width={8} height={8} />
<Skeleton variant="text" width={88} height={20} />
</Box>
<Skeleton variant="text" width={8} height={20} />
<Skeleton variant="text" width={80} height={20} />
<Skeleton variant="text" width={8} height={20} />
<Skeleton variant="text" width={90} height={20} />
<Skeleton variant="text" width={8} height={20} />
Expand All @@ -79,9 +85,11 @@ export default function ChangeRequestsListSkeleton(): JSX.Element {
flexWrap: "wrap",
}}
>
<Skeleton variant="text" width={150} height={20} />
<Skeleton variant="text" width={130} height={20} />
<Skeleton variant="text" width={8} height={20} />
<Skeleton variant="text" width={130} height={20} />
<Skeleton variant="text" width={8} height={20} />
<Skeleton variant="text" width={150} height={20} />
<Skeleton variant="text" width={130} height={20} />
<Skeleton variant="rounded" width={56} height={20} />
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function OperationsPage(): JSX.Element {
() =>
changeRequests.map((cr) => ({
id: cr.id,
internalId: cr.internalId ?? undefined,
internalId: cr.case?.internalId ?? cr.internalId ?? undefined,
number: cr.number,
title: cr.title,
description: cr.description ?? "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ export const SERVICENOW_REDIRECT_NO_CASE_ID =
"No case ID provided in the URL.";

export const SERVICENOW_REDIRECT_RESOLVE_ERROR =
"Unable to resolve the case. Please try again.";
"Something went wrong";
Comment thread
dileepapeiris marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ import {
Paper,
Switch,
Typography,
alpha,
colors,
} from "@wso2/oxygen-ui";
import { Bot, Sparkles } from "@wso2/oxygen-ui-icons-react";
import { useCallback, useState, useMemo, useEffect, type JSX } from "react";
import useGetProjectDetails from "@api/useGetProjectDetails";
import useInfiniteProjects from "@api/useGetProjects";
import { usePatchProject } from "@features/settings/api/usePatchProject";
import { useSuccessBanner } from "@context/success-banner/SuccessBannerContext";
import { useErrorBanner } from "@context/error-banner/ErrorBannerContext";
import { setNoveraChatEnabled } from "@features/settings/utils/settingsStorage";
import {
setNoveraChatEnabled,
setPendingSuccessMessage,
setPendingSettingsTab,
} from "@features/settings/utils/settingsStorage";
import {
SETTINGS_AI_ADMIN_ONLY_HINT,
SETTINGS_AI_CAPABILITIES_SECTION_TITLE,
Expand All @@ -56,12 +59,7 @@ export default function SettingsAiAssistant({
projectId,
canEdit = true,
}: SettingsAiAssistantProps): JSX.Element {
const { showSuccess } = useSuccessBanner();
const { showError } = useErrorBanner();
const { refetch: refetchProjects } = useInfiniteProjects({
pageSize: 20,
enabled: !!projectId,
});
const { data: projectDetails, isLoading: isProjectDetailsLoading } =
useGetProjectDetails(projectId);
const patchProject = usePatchProject(projectId);
Expand All @@ -84,20 +82,12 @@ export default function SettingsAiAssistant({
}, [projectHasAgent]);

const notifyPatchSuccess = useCallback(
async (kind: AiAssistantPatchSuccessKind) => {
const refreshed = await refetchProjects();
const refreshedProject = refreshed.data?.pages
?.flatMap((page) => page.projects ?? [])
?.find((p) => p.id === projectId);
setNoveraOverride(null);
if (refreshedProject?.hasAgent !== undefined) {
setNoveraChatEnabled(refreshedProject.hasAgent);
} else if (projectDetails?.hasAgent !== undefined) {
setNoveraChatEnabled(projectDetails.hasAgent);
}
showSuccess(getAiAssistantPatchSuccessMessage(kind));
(kind: AiAssistantPatchSuccessKind) => {
setPendingSettingsTab("ai");
setPendingSuccessMessage(getAiAssistantPatchSuccessMessage(kind));
window.location.reload();
},
[projectDetails, projectId, refetchProjects, showSuccess],
[],
);
Comment thread
dileepapeiris marked this conversation as resolved.
Resolved

const handlePatchError = useCallback(
Expand All @@ -118,7 +108,7 @@ export default function SettingsAiAssistant({
setNoveraChatEnabled(checked);
patchProject.mutate(checked ? { hasAgent: true } : { hasAgent: false }, {
onSuccess: () => {
void notifyPatchSuccess(AiAssistantPatchSuccessKind.NOVERA);
notifyPatchSuccess(AiAssistantPatchSuccessKind.NOVERA);
},
onError: (err) => {
handlePatchError(err);
Expand All @@ -138,25 +128,26 @@ export default function SettingsAiAssistant({
<Paper
sx={{
p: 2.5,
bgcolor: colors.grey[100],
bgcolor: alpha(colors.blue[500], 0.06),
border: "1px solid",
borderColor: colors.grey[300],
borderColor: alpha(colors.blue[500], 0.2),
}}
>
<Box sx={{ display: "flex", alignItems: "flex-start", gap: 2 }}>
<Paper
sx={{
width: 40,
height: 40,
bgcolor: colors.grey[200],
color: colors.grey[700],
bgcolor: alpha(colors.blue[500], 0.12),
color: colors.blue[700],
display: "flex",
alignItems: "center",
justifyContent: "center",
flexShrink: 0,
border: "none",
}}
>
<Sparkles size={20} color={colors.grey[700]} />
<Sparkles size={20} color={colors.blue[600]} />
</Paper>
<Box sx={{ flex: 1 }}>
<Typography variant="h6" color="text.primary" sx={{ mb: 0.5 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { Box, Typography } from "@wso2/oxygen-ui";
import { useParams } from "react-router";
import { useState, useMemo, type JSX } from "react";
import { useState, useMemo, useEffect, type JSX } from "react";
import useGetUserDetails from "@features/settings/api/useGetUserDetails";
import useGetProjectDetails from "@api/useGetProjectDetails";
import TabBar from "@components/tab-bar/TabBar";
Expand All @@ -30,6 +30,7 @@ import {
} from "@features/settings/constants/settingsConstants";
import { SettingsPageTabId } from "@features/settings/types/settings";
import { resolveSettingsPageTabId } from "@features/settings/utils/settingsPage";
import { consumePendingSettingsTab } from "@features/settings/utils/settingsStorage";
import { ProjectType } from "@/types/permission";
import { isProjectRestricted } from "@utils/permission";

Expand All @@ -42,6 +43,11 @@ export default function SettingsPage(): JSX.Element {
const { projectId } = useParams<{ projectId: string }>();
const [activeTab, setActiveTab] = useState<string>(SettingsPageTabId.USERS);
const { data: userDetails } = useGetUserDetails();

useEffect(() => {
const pending = consumePendingSettingsTab();
if (pending) setActiveTab(pending);
}, []);
Comment thread
dileepapeiris marked this conversation as resolved.
Resolved
const { data: projectDetails } = useGetProjectDetails(projectId || "");

const isCustomerAdmin = useMemo(
Expand Down Expand Up @@ -98,7 +104,7 @@ export default function SettingsPage(): JSX.Element {
}

return (
<Box sx={{ display: "flex", flexDirection: "column", gap: 1 }}>
<Box sx={{ display: "flex", flexDirection: "column", gap: 3 }}>
<TabBar
tabs={tabs.map((t) => ({
id: t.id,
Expand Down
Loading