Skip to content

Commit 2009834

Browse files
committed
fix
1 parent 35bb5b3 commit 2009834

File tree

3 files changed

+14
-43
lines changed

3 files changed

+14
-43
lines changed
Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Button, Menu, MenuItem } from '@ui5/webcomponents-react';
2-
import { useToast } from '../../context/ToastContext.tsx';
2+
33
import { useRef, useState } from 'react';
44
import '@ui5/webcomponents-icons/dist/copy';
55
import '@ui5/webcomponents-icons/dist/accept';
6-
import { useMcp } from '../../lib/shared/McpContext.tsx';
6+
77
import { useTranslation } from 'react-i18next';
88

99
export const ControlPlanesListMenu = () => {
1010
const popoverRef = useRef(null);
1111
const [open, setOpen] = useState(false);
12-
const { show } = useToast();
12+
1313
const { t } = useTranslation();
1414

1515
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -21,7 +21,6 @@ export const ControlPlanesListMenu = () => {
2121
setOpen((prev) => !prev);
2222
}
2323
};
24-
const mcp = useMcp();
2524

2625
return (
2726
<>
@@ -30,19 +29,9 @@ export const ControlPlanesListMenu = () => {
3029
ref={popoverRef}
3130
open={open}
3231
onItemClick={(event) => {
33-
if (event.detail.item.dataset.action === 'download') {
34-
DownloadKubeconfig(mcp.kubeconfig, mcp.name);
35-
return;
32+
if (event.detail.item.dataset.action === 'newManagedControlPlane') {
3633
}
37-
if (event.detail.item.dataset.action === 'copy') {
38-
try {
39-
navigator.clipboard.writeText(mcp.kubeconfig ?? '');
40-
show(t('CopyKubeconfigButton.copiedMessage'));
41-
} catch (error) {
42-
//TODO: handle error, show error to user
43-
show(`${t('CopyKubeconfigButton.failedMessage')} ${error}`);
44-
console.error(error);
45-
}
34+
if (event.detail.item.dataset.action === 'deleteWorkspace') {
4635
}
4736

4837
setOpen(false);
@@ -64,28 +53,3 @@ export const ControlPlanesListMenu = () => {
6453
</>
6554
);
6655
};
67-
68-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
69-
export function DownloadKubeconfig(config: any, displayName: string) {
70-
const filename = 'kubeconfig-' + displayName + '.yaml';
71-
72-
try {
73-
const file = new File([config], filename, {
74-
type: 'application/yaml',
75-
});
76-
77-
const link = document.createElement('a');
78-
const url = URL.createObjectURL(file);
79-
80-
link.href = url;
81-
link.download = file.name;
82-
document.body.appendChild(link);
83-
link.click();
84-
85-
document.body.removeChild(link);
86-
window.URL.revokeObjectURL(url);
87-
} catch (error) {
88-
console.error(error);
89-
}
90-
// dynaLeaveAction(id);
91-
}

src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { YamlViewButtonWithLoader } from '../../Yaml/YamlViewButtonWithLoader.ts
3737
import { IllustratedBanner } from '../../Ui/IllustratedBanner/IllustratedBanner.tsx';
3838
import { useLink } from '../../../lib/shared/useLink.ts';
3939
import IllustrationMessageType from '@ui5/webcomponents-fiori/dist/types/IllustrationMessageType.js';
40-
import CopyKubeconfigButton from '../CopyKubeconfigButton.tsx';
40+
4141
import { ControlPlanesListMenu } from '../ControlPlanesListMenu.tsx';
4242

4343
interface Props {
@@ -105,7 +105,6 @@ export function ControlPlaneListWorkspaceGridTile({
105105
<Panel
106106
headerLevel="H2"
107107
style={{ margin: '12px 12px 12px 0' }}
108-
collapsed={controlplanes?.length === 0}
109108
header={
110109
<div
111110
style={{
@@ -162,6 +161,11 @@ export function ControlPlaneListWorkspaceGridTile({
162161
link: mcpCreationGuide,
163162
buttonText: t('IllustratedBanner.helpButton'),
164163
}}
164+
button={
165+
<Button icon={'add'} design={'Emphasized'}>
166+
{t('ControlPlaneListToolbar.createNewManagedControlPlane')}
167+
</Button>
168+
}
165169
/>
166170
) : (
167171
<Grid defaultSpan="XL4 L4 M7 S12">

src/components/Ui/IllustratedBanner/IllustratedBanner.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ type InfoBannerProps = {
1313
buttonText: string;
1414
buttonIcon?: string;
1515
};
16+
button?: React.ReactElement;
1617
};
1718

1819
export const IllustratedBanner = ({
1920
title,
2021
subtitle,
2122
illustrationName,
2223
help,
24+
button,
2325
}: InfoBannerProps) => {
2426
return (
2527
<FlexBox direction="Column" alignItems="Center">
@@ -41,6 +43,7 @@ export const IllustratedBanner = ({
4143
</Button>
4244
</a>
4345
)}
46+
{button}
4447
</FlexBox>
4548
);
4649
};

0 commit comments

Comments
 (0)