Skip to content

Commit 51d96f7

Browse files
committed
LinkCreator Implementation(will change later) with requested changes
1 parent 41541a5 commit 51d96f7

File tree

7 files changed

+52
-34
lines changed

7 files changed

+52
-34
lines changed

public/locales/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@
6161
"reasonHeader": "Reason",
6262
"transitionHeader": "Last transition time",
6363
"createSupportTicketButton": "Create Support Ticket",
64-
"templateId": "1-mcp_issue.yml",
65-
"supportTicketTitle": "Control Plane Not Ready",
64+
"supportTicketTitleReady": "MCP Ready",
65+
"supportTicketTitleNotReady": "MCP Not Ready",
66+
"supportTicketTitleDeletion": "MCP in Deletion",
6667
"supportTicketTitleIssues": "Issues with Control Plane",
6768
"clusterIdentifierLabel": "cluster-link",
6869
"whatHappenedLabel": "what-happened",

src/components/ControlPlane/MCPHealthPopoverButton.tsx

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export default function MCPHealthPopoverButton({
2525
mcpName,
2626
}: {
2727
mcpStatus: ControlPlaneStatusType | undefined;
28-
projectName?: string;
29-
workspaceName?: string;
30-
mcpName?: string;
28+
projectName: string;
29+
workspaceName: string;
30+
mcpName: string;
3131
}) {
3232
const popoverRef = useRef(null);
3333
const [open, setOpen] = useState(false);
@@ -45,6 +45,19 @@ export default function MCPHealthPopoverButton({
4545
}
4646
};
4747

48+
const getTicketTitle = () => {
49+
switch (mcpStatus?.status) {
50+
case ReadyStatus.Ready:
51+
return t('MCPHealthPopoverButton.supportTicketTitleReady');
52+
case ReadyStatus.NotReady:
53+
return t('MCPHealthPopoverButton.supportTicketTitleNotReady');
54+
case ReadyStatus.InDeletion:
55+
return t('MCPHealthPopoverButton.supportTicketTitleDeletion');
56+
default:
57+
return t('MCPHealthPopoverButton.supportTicketTitleIssues');
58+
}
59+
};
60+
4861
const constructGithubIssuesLink = () => {
4962
const clusterDetails = `${projectName}/${workspaceName}/${mcpName}`;
5063

@@ -64,11 +77,7 @@ export default function MCPHealthPopoverButton({
6477

6578
const params = new URLSearchParams({
6679
template: '1-mcp_issue.yml',
67-
title: `[${clusterDetails}]: ${
68-
mcpStatus?.status === ReadyStatus.NotReady
69-
? t('MCPHealthPopoverButton.supportTicketTitle')
70-
: t('MCPHealthPopoverButton.supportTicketTitleIssues')
71-
}`,
80+
title: `[${clusterDetails}]: ${getTicketTitle()}`,
7281
'cluster-link': clusterDetails,
7382
'what-happened': statusDetails,
7483
});
@@ -143,10 +152,6 @@ function StatusTable({
143152
tableColumns: AnalyticalTableColumnDefinition[];
144153
githubIssuesLink: string;
145154
}) {
146-
const showSupportButton =
147-
status?.status === ReadyStatus.NotReady ||
148-
status?.status === ReadyStatus.InDeletion;
149-
150155
const { t } = useTranslation();
151156

152157
return (
@@ -160,18 +165,16 @@ function StatusTable({
160165
}) ?? []
161166
}
162167
/>
163-
{showSupportButton && (
164-
<FlexBox
165-
justifyContent={FlexBoxJustifyContent.End}
166-
style={{ marginTop: '0.5rem' }}
167-
>
168-
<a href={githubIssuesLink} target="_blank" rel="noreferrer">
169-
<Button>
170-
{t('MCPHealthPopoverButton.createSupportTicketButton')}
171-
</Button>
172-
</a>
173-
</FlexBox>
174-
)}
168+
<FlexBox
169+
justifyContent={FlexBoxJustifyContent.End}
170+
style={{ marginTop: '0.5rem' }}
171+
>
172+
<a href={githubIssuesLink} target="_blank" rel="noreferrer">
173+
<Button>
174+
{t('MCPHealthPopoverButton.createSupportTicketButton')}
175+
</Button>
176+
</a>
177+
</FlexBox>
175178
</div>
176179
);
177180
}

src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ export function ControlPlaneCard({
8282
alignItems="Center"
8383
className={styles.row}
8484
>
85-
<MCPHealthPopoverButton mcpStatus={controlPlane.status} />
85+
<MCPHealthPopoverButton
86+
mcpStatus={controlPlane.status}
87+
projectName={projectName}
88+
workspaceName={workspace.metadata.name ?? ''}
89+
mcpName={controlPlane.metadata.name}
90+
/>
8691
<FlexBox
8792
direction="Row"
8893
justifyContent="SpaceBetween"

src/context/FrontendConfigContext.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactNode, createContext, use } from 'react';
2-
import { DocLinkCreator } from '../lib/shared/links';
2+
import { LinkCreator } from '../lib/shared/links';
33
import { z } from 'zod';
44

55
export enum Landscape {
@@ -11,7 +11,7 @@ export enum Landscape {
1111
}
1212

1313
interface FrontendConfigContextType extends FrontendConfig {
14-
links: DocLinkCreator;
14+
links: LinkCreator;
1515
}
1616

1717
export const FrontendConfigContext =
@@ -29,7 +29,10 @@ export function FrontendConfigProvider({
2929
children,
3030
}: FrontendConfigProviderProps) {
3131
const config = use(fetchPromise);
32-
const docLinks = new DocLinkCreator(config.documentationBaseUrl);
32+
const docLinks = new LinkCreator(
33+
config.documentationBaseUrl,
34+
config.githubBaseUrl,
35+
);
3336
const value: FrontendConfigContextType = {
3437
links: docLinks,
3538
...config,
@@ -61,6 +64,7 @@ const FrontendConfigSchema = z.object({
6164
backendUrl: z.string(),
6265
gatewayUrl: z.string(),
6366
documentationBaseUrl: z.string(),
67+
githubBaseUrl: z.string(),
6468
oidcConfig: OidcConfigSchema,
6569
landscape: z.optional(z.nativeEnum(Landscape)),
6670
});

src/lib/shared/links.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ export class LinkCreator {
22
private baseUrl: string;
33
private githubBaseUrl: string;
44

5-
constructor(baseUrl: string, githubBaseUrl: string) {
5+
constructor(baseUrl: string, githubBaseUrl?: string) {
66
this.baseUrl = baseUrl;
7-
this.githubBaseUrl = githubBaseUrl;
7+
this.githubBaseUrl = githubBaseUrl || baseUrl;
88
}
99
private createLink(path: string) {
1010
return `${this.baseUrl}${path}`;

src/utils/testing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export const mockedFrontendConfig = {
77
backendUrl: 'http://localhost:3000',
88
landscape: Landscape.Local,
99
documentationBaseUrl: 'http://localhost:3000',
10-
links: new DocLinkCreator(documentationBaseUrl),
10+
links: new LinkCreator(documentationBaseUrl),
1111
};

src/views/ControlPlanes/ControlPlaneView.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ export default function ControlPlaneView() {
8181
justifyContent: 'space-between',
8282
}}
8383
>
84-
<MCPHealthPopoverButton mcpStatus={mcp?.status} />
84+
<MCPHealthPopoverButton
85+
mcpStatus={mcp?.status}
86+
projectName={projectName}
87+
workspaceName={workspaceName ?? ''}
88+
mcpName={controlPlaneName}
89+
/>
8590

8691
<CopyKubeconfigButton />
8792
</div>

0 commit comments

Comments
 (0)