Repository navigation
[CSM Portal Microapp] Add a Settings section / Add Home Page #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cloby99
merged 5 commits into
wso2-open-operations:dev-app-csm-portal
from
2003dinijay:feature/microapp-navigation
Jul 13, 2026
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
860f129
[CSM Portal Microapp] Add a Settings section under More (Users/Roles/…
2003dinijay efd7011
[CSM Portal Microapp] Add ARIA state to Settings role/status filter c…
2003dinijay b1bfa30
[CSM Portal Microapp] Add Home page, mirroring the webapp's Dashboard
2003dinijay 79cadd0
Update apps/csm-portal/microapp/src/components/home/AssignedToMeSecti…
2003dinijay cca49c5
Merge branch 'dev-app-csm-portal' into feature/microapp-navigation
2003dinijay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/csm-portal/microapp/src/components/home/AssignedToMeSection.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { Button, Stack, Typography } from "@wso2/oxygen-ui"; | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import { Link } from "react-router-dom"; | ||
| import { currentUser } from "@src/services/currentUser"; | ||
| import { dashboard } from "@src/services/dashboard"; | ||
| import { CaseCard, CaseCardSkeleton } from "@components/support/CaseCard"; | ||
| import { EmptyState } from "@components/support/EmptyState"; | ||
| import { ErrorState } from "@components/support/ErrorState"; | ||
|
|
||
| // The signed-in user's own non-closed cases — mirrors the webapp's "Assigned to me" widget | ||
| // (apps/csm-portal/webapp/src/features/csm-dashboard/components/MyAssignedCases.tsx), capped to a | ||
| // short 5-item preview with a "View all" link out to Support, rather than paginated in place. | ||
| export function AssignedToMeSection() { | ||
| const { data: currentUserId } = useQuery(currentUser.id()); | ||
| const { data, isLoading, isError, refetch } = useQuery(dashboard.assignedToMe(currentUserId ?? null)); | ||
|
|
||
| const items = data?.items ?? []; | ||
|
|
||
| return ( | ||
| <Stack gap={1.5}> | ||
| <Stack direction="row" alignItems="center" justifyContent="space-between"> | ||
| <Typography variant="subtitle1">Assigned to me</Typography> | ||
| <Button component={Link} to="/support" variant="text" size="small" disableRipple> | ||
| View all | ||
| </Button> | ||
| </Stack> | ||
|
|
||
| {isLoading ? ( | ||
| <Stack gap={1.5}> | ||
| {Array.from({ length: 3 }).map((_, index) => ( | ||
| <CaseCardSkeleton key={index} /> | ||
| ))} | ||
| </Stack> | ||
| ) : isError ? ( | ||
| <ErrorState onRetry={() => void refetch()} /> | ||
| ) : items.length === 0 ? ( | ||
| <EmptyState message="No cases assigned to you." /> | ||
| ) : ( | ||
| <Stack gap={1.5}> | ||
| {items.map((item) => ( | ||
| <CaseCard key={item.id} item={item} /> | ||
| ))} | ||
| </Stack> | ||
| )} | ||
| </Stack> | ||
| ); | ||
| } | ||
90 changes: 90 additions & 0 deletions
90
apps/csm-portal/microapp/src/components/home/CaseCompositionSection.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { useMemo } from "react"; | ||
| import { Stack, Typography } from "@wso2/oxygen-ui"; | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import { dashboard } from "@src/services/dashboard"; | ||
| import { ALL_SEVERITIES, SEVERITY_LABELS, STATE_LABELS } from "@components/support/config"; | ||
| import { COMPOSITION_STATES, SEVERITY_SLICE_COLOR, STATE_SLICE_COLOR } from "./config"; | ||
| import { CompositionDonut, type CompositionSlice } from "./CompositionDonut"; | ||
|
|
||
| // Two donuts — severity composition and state composition of active cases — mirrors the webapp's | ||
| // CaseCompositionCharts (apps/csm-portal/webapp/src/features/csm-dashboard/components/CaseCompositionCharts.tsx), | ||
| // stacked instead of side-by-side (the webapp's own grid already collapses to one column below its | ||
| // "md" breakpoint, which is every phone width anyway). Self-contained plain useQuery rather than | ||
| // Suspense, matching how TimeCardsPage.tsx already handles independent, non-blocking widgets in | ||
| // this app — one failed/slow widget shouldn't hold up the rest of the Home page. | ||
| export function CaseCompositionSection() { | ||
| const { data, isLoading, isError } = useQuery(dashboard.composition()); | ||
|
|
||
| const severitySlices = useMemo<CompositionSlice[]>( | ||
| () => | ||
| ALL_SEVERITIES.map((severity) => ({ | ||
| id: severity, | ||
| name: SEVERITY_LABELS[severity], | ||
| value: data?.bySeverity[severity] ?? 0, | ||
| color: SEVERITY_SLICE_COLOR[severity], | ||
| })), | ||
| [data], | ||
| ); | ||
|
|
||
| const stateSlices = useMemo<CompositionSlice[]>( | ||
| () => | ||
| COMPOSITION_STATES.map((state) => ({ | ||
| id: state, | ||
| name: STATE_LABELS[state], | ||
| value: data?.byState[state] ?? 0, | ||
| color: STATE_SLICE_COLOR[state], | ||
| })), | ||
| [data], | ||
| ); | ||
|
|
||
| const closedTotal = data?.closedTotal ?? 0; | ||
|
|
||
| return ( | ||
| <Stack gap={1.5}> | ||
| <Typography variant="subtitle1">Case composition</Typography> | ||
|
|
||
| <Stack gap={1.5}> | ||
| <CompositionDonut | ||
| title="Cases by severity" | ||
| description="Share of active cases at each severity level, excluding closed." | ||
| slices={severitySlices} | ||
| total={data?.severityTotal ?? 0} | ||
| isLoading={isLoading} | ||
| isError={isError} | ||
| /> | ||
| <CompositionDonut | ||
| title="Cases by state" | ||
| description="Share of active cases in each lifecycle state, excluding closed." | ||
| slices={stateSlices} | ||
| total={data?.stateTotal ?? 0} | ||
| isLoading={isLoading} | ||
| isError={isError} | ||
| /> | ||
| </Stack> | ||
|
|
||
| {/* Reconciles with the donuts: both show active cases only, so the closed count is called | ||
| out here rather than mixed into a slice — same as the webapp. */} | ||
| {!isLoading && !isError && closedTotal > 0 && ( | ||
| <Typography variant="caption" color="text.secondary"> | ||
| Excludes {closedTotal} closed {closedTotal === 1 ? "case" : "cases"}. | ||
| </Typography> | ||
| )} | ||
| </Stack> | ||
| ); | ||
| } |
153 changes: 153 additions & 0 deletions
153
apps/csm-portal/microapp/src/components/home/CompositionDonut.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you under the Apache License, | ||
| // Version 2.0 (the "License"); you may not use this file except | ||
| // in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| import { Box, Card, Skeleton, Typography } from "@wso2/oxygen-ui"; | ||
| import { PieChart } from "@wso2/oxygen-ui-charts-react"; | ||
|
|
||
| // Donut sits in a fixed square; the legend fills the rest of the card width. Smaller than the | ||
| // webapp's 200px version (CompositionDonut.tsx) to fit a phone-width card comfortably. | ||
| const DONUT_SIZE = 160; | ||
|
|
||
| export interface CompositionSlice { | ||
| id: string; | ||
| name: string; | ||
| value: number; | ||
| color: string; | ||
| } | ||
|
|
||
| interface CompositionDonutProps { | ||
| title: string; | ||
| description: string; | ||
| slices: CompositionSlice[]; | ||
| total: number; | ||
| isLoading: boolean; | ||
| isError: boolean; | ||
| /** Noun for the empty state, e.g. "cases". */ | ||
| emptyNoun?: string; | ||
| } | ||
|
|
||
| // A donut chart with a value/percentage legend and a centred total — mirrors the webapp's | ||
| // CompositionDonut (apps/csm-portal/webapp/src/features/csm-dashboard/components/CompositionDonut.tsx). | ||
| // Zero-value slices drop from the ring but stay in the legend so every category remains visible. | ||
| // No slice-click drill-down here (unlike the webapp): the microapp's Support page doesn't support | ||
| // seeding filters from the URL, so there's nowhere to deep-link a click into yet. | ||
| export function CompositionDonut({ | ||
| title, | ||
| description, | ||
| slices, | ||
| total, | ||
| isLoading, | ||
| isError, | ||
| emptyNoun = "cases", | ||
| }: CompositionDonutProps) { | ||
| const pieData = slices.filter((s) => s.value > 0); | ||
| const isEmpty = !isLoading && !isError && total === 0; | ||
|
|
||
| return ( | ||
| <Card sx={{ p: 2 }}> | ||
| <Typography variant="subtitle1" fontWeight={600}> | ||
| {title} | ||
| </Typography> | ||
| <Typography variant="caption" color="text.secondary"> | ||
| {description} | ||
| </Typography> | ||
|
|
||
| {isLoading ? ( | ||
| <Box sx={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 2, mt: 2 }}> | ||
| <Skeleton variant="circular" width={DONUT_SIZE} height={DONUT_SIZE} /> | ||
| <Box sx={{ width: "100%", display: "flex", flexDirection: "column", gap: 1 }}> | ||
| {slices.map((s) => ( | ||
| <Skeleton key={s.id} variant="rounded" height={18} /> | ||
| ))} | ||
| </Box> | ||
| </Box> | ||
| ) : isError ? ( | ||
| <Box sx={{ height: DONUT_SIZE, display: "flex", alignItems: "center", justifyContent: "center" }}> | ||
| <Typography variant="body2" color="text.secondary"> | ||
| Could not load {title.toLowerCase()}. | ||
| </Typography> | ||
| </Box> | ||
| ) : isEmpty ? ( | ||
| <Box sx={{ height: DONUT_SIZE, display: "flex", alignItems: "center", justifyContent: "center" }}> | ||
| <Typography variant="body2" color="text.disabled"> | ||
| No {emptyNoun} to show. | ||
| </Typography> | ||
| </Box> | ||
| ) : ( | ||
| <Box sx={{ mt: 2, display: "flex", flexDirection: "column", alignItems: "center", gap: 2 }}> | ||
| <Box sx={{ position: "relative", width: DONUT_SIZE, height: DONUT_SIZE, flexShrink: 0 }}> | ||
| <PieChart | ||
| data={pieData} | ||
| colors={pieData.map((s) => s.color)} | ||
| legend={{ show: false }} | ||
| tooltip={{ show: true }} | ||
| width="100%" | ||
| height={DONUT_SIZE} | ||
| pies={[ | ||
| { | ||
| dataKey: "value", | ||
| nameKey: "name", | ||
| innerRadius: "62%", | ||
| outerRadius: "100%", | ||
| paddingAngle: 1, | ||
| startAngle: 90, | ||
| endAngle: -270, | ||
| label: false, | ||
| labelLine: false, | ||
| }, | ||
| ]} | ||
| /> | ||
| <Box | ||
| sx={{ | ||
| position: "absolute", | ||
| top: "50%", | ||
| left: "50%", | ||
| transform: "translate(-50%, -50%)", | ||
| textAlign: "center", | ||
| pointerEvents: "none", | ||
| }} | ||
| > | ||
| <Typography variant="h5">{total}</Typography> | ||
| <Typography variant="caption" color="text.secondary"> | ||
| Total | ||
| </Typography> | ||
| </Box> | ||
| </Box> | ||
|
|
||
| {/* Legend: every category, with its count and share. */} | ||
| <Box sx={{ width: "100%", display: "flex", flexDirection: "column", gap: 1 }}> | ||
| {slices.map((s) => { | ||
| const pct = total > 0 ? Math.round((s.value / total) * 100) : 0; | ||
| return ( | ||
| <Box key={s.id} sx={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 1 }}> | ||
| <Box sx={{ display: "flex", alignItems: "center", gap: 1, minWidth: 0 }}> | ||
| <Box sx={{ width: 12, height: 12, borderRadius: "50%", bgcolor: s.color, flexShrink: 0 }} /> | ||
| <Typography variant="body2" color="text.secondary" noWrap> | ||
| {s.name} | ||
| </Typography> | ||
| </Box> | ||
| <Typography variant="body2" fontWeight={600} sx={{ whiteSpace: "nowrap" }}> | ||
| {s.value} ({pct}%) | ||
| </Typography> | ||
| </Box> | ||
| ); | ||
| })} | ||
| </Box> | ||
| </Box> | ||
| )} | ||
| </Card> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.