generated from openmcp-project/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
MCP: visualize members and MCP status in header area #386
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
Open
lucasgoral
wants to merge
17
commits into
main
Choose a base branch
from
mcp-Visualize-members-and-status-in-header-area
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+241
−39
Open
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6ce3e65
fix
lucasgoral ad5c4e1
refactor
lucasgoral deba1c0
refactor
lucasgoral 9054afc
Merge branch 'main' into mcp-Visualize-members-and-status-in-header-area
lucasgoral 79ff133
refactor
lucasgoral 36d2f3b
fix
lucasgoral d19f369
Update MCPHealthPopoverButton.tsx
lucasgoral c32b9ef
fix
lucasgoral b1cf458
fix
lucasgoral c9debe6
fix
lucasgoral eabdccd
fix
lucasgoral e5b2a01
Update AnimatedHoverTextButton.tsx
lucasgoral de79446
Update McpPage.tsx
lucasgoral b0cfb36
Merge branch 'main' into mcp-Visualize-members-and-status-in-header-area
lucasgoral f5cdd00
fix
lucasgoral 0f68884
fix
lucasgoral 9a9719a
Update McpStatusSection.module.css
lucasgoral 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
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,4 @@ | ||
| .statusLabel { | ||
| font-weight: bold; | ||
| margin-bottom: 1rem; | ||
| } |
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,29 @@ | ||
| import { FlexBox, Text } from '@ui5/webcomponents-react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import MCPHealthPopoverButton from './MCPHealthPopoverButton.tsx'; | ||
| import { ControlPlaneStatusType } from '../../lib/api/types/crate/controlPlanes.ts'; | ||
| import styles from './McpStatusSection.module.css'; | ||
|
|
||
| interface McpStatusSectionProps { | ||
| mcpStatus: ControlPlaneStatusType | undefined; | ||
| projectName: string; | ||
| workspaceName: string; | ||
| mcpName: string; | ||
| } | ||
|
|
||
| export function McpStatusSection({ mcpStatus, projectName, workspaceName, mcpName }: McpStatusSectionProps) { | ||
| const { t } = useTranslation(); | ||
|
|
||
| return ( | ||
| <FlexBox direction={'Column'}> | ||
| <Text className={styles.statusLabel}>{t('common.status')}:</Text> | ||
| <MCPHealthPopoverButton | ||
| mcpStatus={mcpStatus} | ||
| projectName={projectName} | ||
| workspaceName={workspaceName} | ||
| mcpName={mcpName} | ||
| large | ||
| /> | ||
| </FlexBox> | ||
| ); | ||
| } |
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
5 changes: 5 additions & 0 deletions
5
src/components/ControlPlanes/McpMembersAvatarView/McpMembersAvatarView.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,5 @@ | ||
| .membersTitle { | ||
| margin-left: 5px; | ||
| font-weight: bold; | ||
| margin-bottom: 0.5rem; | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/components/ControlPlanes/McpMembersAvatarView/McpMembersAvatarView.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,24 @@ | ||
| import { MembersAvatarView } from '../List/MembersAvatarView.tsx'; | ||
| import { useConvertRoleBindingsToMembers } from '../../../hooks/useConvertRoleBindingsToMembers.ts'; | ||
| import { FlexBox, Text } from '@ui5/webcomponents-react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import styles from './McpMembersAvatarView.module.css'; | ||
|
|
||
| interface Props { | ||
| project?: string; | ||
| workspace?: string; | ||
| roleBindings?: { role: string; subjects: { kind: string; name: string }[] }[]; | ||
| } | ||
|
|
||
| export function McpMembersAvatarView({ roleBindings, project, workspace }: Props) { | ||
| const members = useConvertRoleBindingsToMembers(roleBindings); | ||
| const { t } = useTranslation(); | ||
| return ( | ||
| <FlexBox direction="Column"> | ||
| <Text className={styles.membersTitle}> | ||
| {t('common.members')} ({members.length}): | ||
| </Text> | ||
| <MembersAvatarView members={members} project={project} workspace={workspace} hideNamespaceColumn /> | ||
| </FlexBox> | ||
| ); | ||
| } |
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,24 @@ | ||
| .text { | ||
| margin-right: 0.5rem; | ||
| } | ||
|
|
||
| .link:focus-within, | ||
| .link:focus-visible { | ||
| background-color: transparent; | ||
| } | ||
|
|
||
| .ready { | ||
| color: var(--sapPositiveColor); | ||
| } | ||
|
|
||
| .not-ready { | ||
| color: var(--sapNegativeColor); | ||
| } | ||
|
|
||
| .deleting { | ||
| color: var(--sapCriticalColor); | ||
| } | ||
|
|
||
| .large { | ||
| font-size: 1.25rem; | ||
| } |
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 |
|---|---|---|
| @@ -1,34 +1,66 @@ | ||
| import { Button, ButtonDomRef, FlexBox, FlexBoxAlignItems, Text } from '@ui5/webcomponents-react'; | ||
| import { Button, ButtonDomRef, Link, LinkDomRef, FlexBox, FlexBoxAlignItems, Text } from '@ui5/webcomponents-react'; | ||
| import '@ui5/webcomponents-icons/dist/copy'; | ||
| import { JSX, useId, useState } from 'react'; | ||
| import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js'; | ||
| import type { Ui5CustomEvent } from '@ui5/webcomponents-react-base'; | ||
| import type { ButtonClickEventDetail } from '@ui5/webcomponents/dist/Button.js'; | ||
|
|
||
| import type { LinkClickEventDetail } from '@ui5/webcomponents/dist/Link.js'; | ||
| import styles from './AnimatedHoverTextButton.module.css'; | ||
| import { getClassNameForOverallStatus } from '../ControlPlane/MCPHealthPopoverButton.tsx'; | ||
| import { ReadyStatus } from '../../lib/api/types/crate/controlPlanes.ts'; | ||
| import cx from 'clsx'; | ||
| type HoverTextButtonProps = { | ||
| id?: string; | ||
| text: string; | ||
| icon: JSX.Element; | ||
| onClick: (event: Ui5CustomEvent<ButtonDomRef, ButtonClickEventDetail>) => void; | ||
| onClick: ( | ||
| event: Ui5CustomEvent<ButtonDomRef, ButtonClickEventDetail> | Ui5CustomEvent<LinkDomRef, LinkClickEventDetail>, | ||
| ) => void; | ||
| large?: boolean; | ||
| }; | ||
| export const AnimatedHoverTextButton = ({ id, text, icon, onClick }: HoverTextButtonProps) => { | ||
| export const AnimatedHoverTextButton = ({ id, text, icon, onClick, large = false }: HoverTextButtonProps) => { | ||
| const [hover, setHover] = useState(false); | ||
|
|
||
| const generatedId = useId(); | ||
| id ??= generatedId; | ||
|
|
||
| const content = ( | ||
| <FlexBox alignItems={FlexBoxAlignItems.Center}> | ||
| {hover || large ? ( | ||
| <Text | ||
| className={cx(styles.text, styles[getClassNameForOverallStatus(text as ReadyStatus)], { | ||
| [styles.large]: large, | ||
| })} | ||
| > | ||
| {text} | ||
| </Text> | ||
| ) : null} | ||
| {icon} | ||
| </FlexBox> | ||
| ); | ||
|
|
||
| if (large) { | ||
| return ( | ||
| <Link | ||
| id={id} | ||
| className={cx(styles.link, styles[getClassNameForOverallStatus(text as ReadyStatus)])} | ||
lucasgoral marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| onClick={onClick} | ||
| onMouseLeave={() => setHover(false)} | ||
| onMouseOver={() => setHover(true)} | ||
| > | ||
| {content} | ||
| </Link> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Button | ||
| id={id} | ||
| design={ButtonDesign.Transparent} | ||
| design={'Transparent'} | ||
| onClick={onClick} | ||
| onMouseOver={() => setHover(true)} | ||
| onMouseLeave={() => setHover(false)} | ||
| onMouseOver={() => setHover(true)} | ||
| > | ||
| <FlexBox alignItems={FlexBoxAlignItems.Center}> | ||
| {hover ? <Text style={{ marginRight: '8px' }}> {text}</Text> : null} | ||
| {icon} | ||
| </FlexBox> | ||
| {content} | ||
| </Button> | ||
| ); | ||
| }; | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { Member } from '../lib/api/types/shared/members'; | ||
|
|
||
| export function useConvertRoleBindingsToMembers( | ||
lucasgoral marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| roleBindings?: { role: string; subjects: { kind: string; name: string }[] }[], | ||
| ): Member[] { | ||
| if (!roleBindings) return []; | ||
|
|
||
| const memberMap = new Map<string, Member>(); | ||
|
|
||
| for (const binding of roleBindings) { | ||
| for (const subject of binding.subjects) { | ||
| const key = `${subject.kind}-${subject.name}`; | ||
| if (memberMap.has(key)) { | ||
| // Add role to existing member | ||
| const member = memberMap.get(key)!; | ||
| if (!member.roles.includes(binding.role)) { | ||
| member.roles.push(binding.role); | ||
| } | ||
| } else { | ||
| // Create new member | ||
| memberMap.set(key, { | ||
| kind: subject.kind, | ||
| name: subject.name, | ||
| roles: [binding.role], | ||
| }); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return Array.from(memberMap.values()); | ||
| } | ||
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.