Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/ControlPlane/MCPHealthPopoverButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import ReactTimeAgo from 'react-time-ago';
import { AnimatedHoverTextButton } from '../Helper/AnimatedHoverTextButton.tsx';
import { useTranslation } from 'react-i18next';
import { useFrontendConfig } from '../../context/FrontendConfigContext.tsx';
import { useLink } from '../../lib/shared/useLink.ts';
export default function MCPHealthPopoverButton({
mcpStatus,
projectName,
Expand All @@ -31,7 +31,7 @@ export default function MCPHealthPopoverButton({
}) {
const popoverRef = useRef(null);
const [open, setOpen] = useState(false);
const { links } = useFrontendConfig();
const { githubIssuesSupportTicket } = useLink();

const { t } = useTranslation();

Expand Down Expand Up @@ -82,7 +82,7 @@ export default function MCPHealthPopoverButton({
'what-happened': statusDetails,
});

return `${links.COM_PAGE_SUPPORT_GITHUB_ISSUE}?${params}`;
return `${githubIssuesSupportTicket}?${params}`;
};

const statusTableColumns: AnalyticalTableColumnDefinition[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js';
import { ControlPlaneListWorkspaceGridTile } from './ControlPlaneListWorkspaceGridTile.tsx';
import { useApiResource } from '../../../lib/api/useApiResource.ts';
import { ListWorkspaces } from '../../../lib/api/types/crate/listWorkspaces.ts';
import { useFrontendConfig } from '../../../context/FrontendConfigContext.tsx';
import { useLink } from '../../../lib/shared/useLink.ts';
import { useTranslation } from 'react-i18next';

interface Props {
projectName: string;
}

export default function ControlPlaneListAllWorkspaces({ projectName }: Props) {
const { links } = useFrontendConfig();
const { workspaceCreationGuide } = useLink();
const { data: allWorkspaces, error } = useApiResource(
ListWorkspaces(projectName),
);
Expand Down Expand Up @@ -45,7 +45,7 @@ export default function ControlPlaneListAllWorkspaces({ projectName }: Props) {
design={ButtonDesign.Emphasized}
icon="sap-icon://question-mark"
onClick={() => {
window.open(links.COM_PAGE_GETTING_STARTED_WORKSPACE, '_blank');
window.open(workspaceCreationGuide, '_blank');
}}
>
Help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { APIError } from '../../../lib/api/error.ts';
import { useTranslation } from 'react-i18next';
import { YamlViewButton } from '../../Yaml/YamlViewButton.tsx';
import { IllustratedBanner } from '../../Ui/IllustratedBanner/IllustratedBanner.tsx';
import { useFrontendConfig } from '../../../context/FrontendConfigContext.tsx';
import { useLink } from '../../../lib/shared/useLink.ts';
import IllustrationMessageType from '@ui5/webcomponents-fiori/dist/types/IllustrationMessageType.js';

interface Props {
Expand Down Expand Up @@ -65,7 +65,7 @@ export function ControlPlaneListWorkspaceGridTile({
DeleteWorkspaceResource(projectNamespace, workspaceName),
);

const { links } = useFrontendConfig();
const { mcpCreationGuide } = useLink();
const errorView = createErrorView(cpsError);

function createErrorView(error: APIError) {
Expand Down Expand Up @@ -155,7 +155,7 @@ export function ControlPlaneListWorkspaceGridTile({
subtitle={t('IllustratedBanner.subtitleMessage')}
illustrationName={IllustrationMessageType.NoData}
help={{
link: links.COM_PAGE_GETTING_STARTED_MCP,
link: mcpCreationGuide,
buttonText: t('IllustratedBanner.helpButton'),
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { KubectlTerminal } from './KubectlTerminal';
import { useState, useEffect, ReactNode } from 'react';
import { useTranslation, Trans } from 'react-i18next';
import { useFrontendConfig } from '../../../context/FrontendConfigContext.tsx';
import { useLink } from '../../../lib/shared/useLink.ts';

export interface FormField {
id: string;
Expand Down Expand Up @@ -47,7 +47,7 @@ export const KubectlBaseDialog = ({
customCommands,
}: KubectlBaseDialogProps) => {
const { t } = useTranslation();
const { links } = useFrontendConfig();
const { gettingStartedGuide } = useLink();
const [formValues, setFormValues] = useState<Record<string, string>>({});

useEffect(() => {
Expand Down Expand Up @@ -165,9 +165,7 @@ export const KubectlBaseDialog = ({
<Trans
i18nKey="KubectlBaseDialog.onboardingGuide"
components={{
link1: (
<Link href={links.COM_PAGE_GETTING_STARTED} target="_blank" />
),
link1: <Link href={gettingStartedGuide} target="_blank" />,
}}
/>
</MessageStrip>
Expand Down
20 changes: 4 additions & 16 deletions src/context/FrontendConfigContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ReactNode, createContext, use } from 'react';
import { LinkCreator } from '../lib/shared/links';
import { z } from 'zod';

export enum Landscape {
Expand All @@ -10,12 +9,7 @@ export enum Landscape {
Local = 'LOCAL',
}

interface FrontendConfigContextType extends FrontendConfig {
links: LinkCreator;
}

export const FrontendConfigContext =
createContext<FrontendConfigContextType | null>(null);
export const FrontendConfigContext = createContext<FrontendConfig | null>(null);

const fetchPromise = fetch('/frontend-config.json')
.then((res) => res.json())
Expand All @@ -29,16 +23,10 @@ export function FrontendConfigProvider({
children,
}: FrontendConfigProviderProps) {
const config = use(fetchPromise);
const docLinks = new LinkCreator(
config.documentationBaseUrl,
config.githubBaseUrl,
);
const value: FrontendConfigContextType = {
links: docLinks,
...config,
};
return (
<FrontendConfigContext value={value}>{children}</FrontendConfigContext>
<FrontendConfigContext.Provider value={config}>
{children}
</FrontendConfigContext.Provider>
);
}

Expand Down
38 changes: 0 additions & 38 deletions src/lib/shared/links.ts

This file was deleted.

22 changes: 22 additions & 0 deletions src/lib/shared/useLink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useFrontendConfig } from '../../context/FrontendConfigContext';

export function useLink() {
const { documentationBaseUrl, githubBaseUrl } = useFrontendConfig();

const createLink = (path: string) => `${documentationBaseUrl}${path}`;
const createGithubLink = (path: string) => `${githubBaseUrl}${path}`;

return {
documentationHomepage: createLink('/'),
gettingStartedGuide: createLink(
'/docs/managed-control-planes/get-started/get-started-mcp',
),
workspaceCreationGuide: createLink(
'/docs/managed-control-planes/get-started/get-started-mcp#4-create-workspace',
),
mcpCreationGuide: createLink(
'/docs/managed-control-planes/get-started/get-started-mcp#5-create-managedcontrolplane',
),
githubIssuesSupportTicket: createGithubLink('/support/issues/new'),
};
}
7 changes: 4 additions & 3 deletions src/utils/testing.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { LinkCreator } from '../lib/shared/links.ts';
import { Landscape } from '../context/FrontendConfigContext.tsx';

export const isInTestingMode: boolean = !!window.Cypress;
const documentationBaseUrl = 'http://localhost:3000';
const githubBaseUrl = 'https://github.com/example/repo';

export const mockedFrontendConfig = {
backendUrl: 'http://localhost:3000',
landscape: Landscape.Local,
documentationBaseUrl: 'http://localhost:3000',
links: new LinkCreator(documentationBaseUrl),
documentationBaseUrl: documentationBaseUrl,
githubBaseUrl: githubBaseUrl,
};
6 changes: 3 additions & 3 deletions src/views/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Button, Card, FlexBox, Text } from '@ui5/webcomponents-react';
import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js';
import './login.css';
import { ThemingParameters } from '@ui5/webcomponents-react-base';
import { useFrontendConfig } from '../context/FrontendConfigContext';
import { useLink } from '../lib/shared/useLink.ts';
import { useTranslation } from 'react-i18next';

export default function LoginView() {
const auth = useAuth();
const { links } = useFrontendConfig();
const { documentationHomepage } = useLink();
const { t } = useTranslation();

return (
Expand All @@ -26,7 +26,7 @@ export default function LoginView() {
<Text>{t('Login.description')}</Text>
<Text>
<p>
<a href={links.COMMUNITY_PAGE} target="_blank" rel="noreferrer">
<a href={documentationHomepage} target="_blank" rel="noreferrer">
{t('Login.learnMore')}
</a>
</p>
Expand Down
Loading