generated from openmcp-project/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add hint section to MCP overview page
#251
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
Merged
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
97d852d
feat: add hint object to guide users in quality management
Lasserich e5d5796
feat: populate crossplane and flux with data
Lasserich 319d67d
fix: make linitii happii
Lasserich 8263c6f
feat: use new types
Lasserich 81a95ec
fix: I love AI sometimes
Lasserich 5f5620d
feat: expand radar chart
Lasserich 0a15232
Merge branch 'main' into pr/251
lucasgoral ba9de76
Update listManagedResources.ts
lucasgoral 4ad9302
Update Hints.tsx
lucasgoral 1cc1189
fix: smaller stuff
Lasserich e0cb0ef
Merge branch 'ft/hints' of https://github.com/Lasserich/ui-frontend i…
Lasserich 26001d9
feat: fix darkmode
Lasserich 4939d67
Merge branch 'main' into ft/hints
Lasserich 82a4341
feat: nice bars!!
Lasserich 79b952c
feat: generify
Lasserich 7fbd8cd
fix: cleanup
Lasserich ccf9035
feat: cleanup
Lasserich ccc3686
test: added some
Lasserich fee5f26
fix: darkmode
Lasserich fadf3ac
fix: linting
Lasserich 5dace2d
fix: on activate
Lasserich 291c54e
feat: re-usable hover
Lasserich b2f9f93
feat: crossplane and flux component ready for review
Lasserich 8b89e31
fix: disable vault for now since it does not have stats yet
Lasserich 2b45192
Merge branch 'main' into ft/hints
lucasgoral bd550d9
feat: incorporate feedback
Lasserich 874a80b
Merge branch 'ft/hints' of https://github.com/Lasserich/ui-frontend i…
Lasserich aa745ad
fix: npm run lint:fix :)(:
Lasserich 530a862
fix: zIndex
Lasserich 9bdb8b2
fix: remove info, coming soon, downsize vault
Lasserich 4978b76
fix: build
Lasserich 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions
17
src/components/HintsCardsRow/CardHoverContent/CardHoverContent.module.css
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,17 @@ | ||
| /* Card Hover Content Styles */ | ||
| .hoverContent { | ||
| width: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| margin: 1rem 0; | ||
| overflow: visible; | ||
| } | ||
|
|
||
| .chartContainer { | ||
| width: 100%; | ||
| height: 300px; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } |
129 changes: 129 additions & 0 deletions
129
src/components/HintsCardsRow/CardHoverContent/CardHoverContent.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,129 @@ | ||
| import React, { useMemo } from 'react'; | ||
| import { RadarChart } from '@ui5/webcomponents-react-charts'; | ||
| import { LegendSection } from '../LegendSection/LegendSection'; | ||
| import { styles } from '../HintsCardsRow'; | ||
| import styles2 from './CardHoverContent.module.css'; | ||
| import cx from 'clsx'; | ||
|
|
||
| export interface LegendItem { | ||
| label: string; | ||
| count: number; | ||
| color: string; | ||
| } | ||
|
|
||
| export interface RadarDataPoint { | ||
| [key: string]: string | number; | ||
| } | ||
|
|
||
| export interface RadarMeasure { | ||
| accessor: string; | ||
| color: string; | ||
| hideDataLabel?: boolean; | ||
| label: string; | ||
| } | ||
|
|
||
| export interface RadarDimension { | ||
| accessor: string; | ||
| } | ||
|
|
||
| export interface HoverContentProps { | ||
| enabled: boolean; | ||
| totalCount: number; | ||
| totalLabel: string; | ||
| legendItems: LegendItem[]; | ||
| radarDataset: RadarDataPoint[]; | ||
| radarDimensions: RadarDimension[]; | ||
| radarMeasures: RadarMeasure[]; | ||
| isLoading?: boolean; | ||
| } | ||
|
|
||
| // Helper function to truncate labels to max 13 characters | ||
| const truncateLabel = (label: string, maxLength: number = 13): string => { | ||
| if (label.length <= maxLength) { | ||
| return label; | ||
| } | ||
| return label.substring(0, maxLength) + '...'; | ||
| }; | ||
|
|
||
| export const HoverContent: React.FC<HoverContentProps> = ({ | ||
| enabled, | ||
| totalCount, | ||
| totalLabel, | ||
| legendItems, | ||
| radarDataset, | ||
| radarDimensions, | ||
| radarMeasures, | ||
| isLoading = false, | ||
| }) => { | ||
| // Process the dataset to truncate labels | ||
| const processedDataset = useMemo(() => { | ||
| return radarDataset.map((dataPoint) => { | ||
| const processedDataPoint = { ...dataPoint }; | ||
|
|
||
| // Truncate labels for each dimension accessor | ||
| radarDimensions.forEach((dimension) => { | ||
| const value = dataPoint[dimension.accessor]; | ||
| if (typeof value === 'string') { | ||
| processedDataPoint[dimension.accessor] = truncateLabel(value); | ||
| } | ||
| }); | ||
|
|
||
| return processedDataPoint; | ||
| }); | ||
| }, [radarDataset, radarDimensions]); | ||
|
|
||
| if (!enabled) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div className={cx(styles.hoverContent, styles2.hoverContent)}> | ||
| <LegendSection title={`${totalCount} ${totalLabel}`} items={legendItems} /> | ||
| <div className={styles2.chartContainer}> | ||
| {isLoading || radarDataset.length === 0 ? ( | ||
| <div className={cx(styles.hoverContentLoading)}> | ||
| <RadarChart | ||
| dataset={[]} | ||
| dimensions={[ | ||
| { | ||
| accessor: 'name', | ||
| formatter: (value: string | number) => String(value || ''), | ||
| }, | ||
| ]} | ||
| measures={[ | ||
| { | ||
| accessor: 'users', | ||
| formatter: (value: string | number) => String(value || ''), | ||
| label: 'Users', | ||
| }, | ||
| { | ||
| accessor: 'sessions', | ||
| formatter: (value: string | number) => String(value || ''), | ||
| hideDataLabel: true, | ||
| label: 'Active Sessions', | ||
| }, | ||
| { | ||
| accessor: 'volume', | ||
| label: 'Vol.', | ||
| }, | ||
| ]} | ||
| style={{ width: '100%', height: '100%', minWidth: 280, minHeight: 280 }} | ||
| noLegend={true} | ||
| onClick={() => {}} | ||
| onDataPointClick={() => {}} | ||
| onLegendClick={() => {}} | ||
| /> | ||
| </div> | ||
| ) : ( | ||
| <RadarChart | ||
| dataset={processedDataset} | ||
| dimensions={radarDimensions} | ||
| measures={radarMeasures} | ||
| style={{ width: '100%', height: '100%', minWidth: 280, minHeight: 280 }} | ||
| noLegend={true} | ||
| /> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; |
85 changes: 85 additions & 0 deletions
85
src/components/HintsCardsRow/CardHoverContent/hoverCalculations.ts
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,85 @@ | ||
| import { ManagedResourceItem, Condition } from '../../../lib/shared/types'; | ||
|
|
||
| export interface ResourceTypeStats { | ||
| type: string; | ||
| total: number; | ||
| healthy: number; | ||
| creating: number; | ||
| unhealthy: number; | ||
| healthyPercentage: number; | ||
| creatingPercentage: number; | ||
| unhealthyPercentage: number; | ||
| } | ||
|
|
||
| export interface OverallStats { | ||
| total: number; | ||
| healthy: number; | ||
| creating: number; | ||
| unhealthy: number; | ||
| } | ||
|
|
||
| export interface CrossplaneHoverData { | ||
| resourceTypeStats: ResourceTypeStats[]; | ||
| overallStats: OverallStats; | ||
| } | ||
|
|
||
| /** | ||
| * Calculate comprehensive statistics for Crossplane hover content | ||
| */ | ||
| export const calculateCrossplaneHoverData = (allItems: ManagedResourceItem[]): CrossplaneHoverData => { | ||
| const typeStats: Record<string, { total: number; healthy: number; creating: number; unhealthy: number }> = {}; | ||
| let totalHealthy = 0; | ||
| let totalCreating = 0; | ||
| let totalUnhealthy = 0; | ||
|
|
||
| allItems.forEach((item: ManagedResourceItem) => { | ||
| const type = item.kind || 'Unknown'; | ||
|
|
||
| if (!typeStats[type]) { | ||
| typeStats[type] = { total: 0, healthy: 0, creating: 0, unhealthy: 0 }; | ||
| } | ||
|
|
||
| typeStats[type].total++; | ||
|
|
||
| const conditions = item.status?.conditions || []; | ||
| const ready = conditions.find((c: Condition) => c.type === 'Ready' && c.status === 'True'); | ||
| const synced = conditions.find((c: Condition) => c.type === 'Synced' && c.status === 'True'); | ||
|
|
||
| if (ready && synced) { | ||
| typeStats[type].healthy++; | ||
| totalHealthy++; | ||
| } else if (synced && !ready) { | ||
| // Resource is synced but not ready - it's creating | ||
| typeStats[type].creating++; | ||
| totalCreating++; | ||
| } else { | ||
| // Resource has issues or is not synced | ||
| typeStats[type].unhealthy++; | ||
| totalUnhealthy++; | ||
| } | ||
| }); | ||
|
|
||
| const resourceTypeStats: ResourceTypeStats[] = Object.keys(typeStats).map((type) => { | ||
| const stats = typeStats[type]; | ||
| return { | ||
| type, | ||
| total: stats.total, | ||
| healthy: stats.healthy, | ||
| creating: stats.creating, | ||
| unhealthy: stats.unhealthy, | ||
| healthyPercentage: Math.round((stats.healthy / stats.total) * 100), | ||
| creatingPercentage: Math.round((stats.creating / stats.total) * 100), | ||
| unhealthyPercentage: Math.round((stats.unhealthy / stats.total) * 100), | ||
| }; | ||
| }); | ||
|
|
||
| return { | ||
| resourceTypeStats, | ||
| overallStats: { | ||
| total: allItems.length, | ||
| healthy: totalHealthy, | ||
| creating: totalCreating, | ||
| unhealthy: totalUnhealthy, | ||
| }, | ||
| }; | ||
| }; |
47 changes: 47 additions & 0 deletions
47
src/components/HintsCardsRow/GenericHintCard/GenericHintCard.module.css
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,47 @@ | ||
| .container { | ||
| position: relative; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .avatar { | ||
| width: 50px; | ||
| height: 50px; | ||
| border-radius: 50%; | ||
| background: transparent; | ||
| object-fit: cover; | ||
| } | ||
|
|
||
| .contentContainer { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| padding: 0.5rem 0; | ||
| } | ||
|
|
||
| .progressBarContainer { | ||
| display: flex; | ||
| gap: 8px; | ||
| width: 100%; | ||
| max-width: 500px; | ||
| padding: 0 0.5rem; | ||
| } | ||
|
|
||
| .progressBar { | ||
| width: 100%; | ||
| } | ||
|
|
||
| .activateButton { | ||
| position: absolute; | ||
| top: 16px; | ||
| right: 16px; | ||
| z-index: 2; | ||
| pointer-events: auto; | ||
| } | ||
|
|
||
| .activateButtonClickable { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .activateButtonDefault { | ||
| cursor: default; | ||
| } |
Oops, something went wrong.
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.