Skip to content

Commit 38de779

Browse files
committed
Added MCP delete, Added translation. + small refactor.
1 parent 24f0413 commit 38de779

17 files changed

+5124
-154
lines changed

public/locales/en.json

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
"messageHeader": "Message",
5050
"reasonHeader": "Reason",
5151
"transitionHeader": "Last transition time"
52-
},
52+
},
5353
"CopyKubeconfigButton": {
54-
"copiedMessage": "Copied to Clipboard",
54+
"copiedMessage": "Copied to Clipboard",
5555
"failedMessage": "Failed to copy, Error:",
5656
"menuDownload": "Download",
5757
"menuCopy": "Copy to clipboard"
@@ -106,7 +106,6 @@
106106
"errorMessage": "useCopyButton must be used within a CopyButtonProvider"
107107
},
108108
"CreateProjectWorkspaceDialog": {
109-
"learnButton": "Learn how to do this in code",
110109
"createButton": "Create",
111110
"cancelButton": "Cancel",
112111
"chargingTargetLabel": "Charging Target",
@@ -139,6 +138,79 @@
139138
"copiedMessage": "Copied To Clipboard",
140139
"failedMessage": "Failed to copy"
141140
},
141+
"DeleteWorkspaceDialog": {
142+
"title": "Delete a Workspace",
143+
"introSection1": "The below instructions will help you delete the workspace \"{{workspaceName}}\" from project namespace \"{{projectNamespace}}\" using kubectl.",
144+
"introSection2": "Remember that this action is <bold1>irreversible</bold1> and all resources within the workspace will be <bold2>permanently deleted</bold2>.",
145+
"mainCommandDescription": "Run this command to delete the workspace:",
146+
"verificationCommandDescription": "To verify the workspace has been deleted, run:"
147+
},
148+
"DeleteMcpDialog": {
149+
"title": "Delete a Managed Control Plane",
150+
"introSection1": "The below will help you delete the Managed Control Plane \"{{mcpName}}\" from workspace \"{{workspaceNamespace}}\" using kubectl.",
151+
"introSection2": "Remember that this action is <bold1>irreversible</bold1> and all resources managed by this control plane will be <bold2>permanently deleted</bold2>.",
152+
"annotateCommand": "First, annotate the ManagedControlPlane to confirm deletion:",
153+
"deleteCommand": "Run this command to delete the Managed Control Plane:",
154+
"verificationCommandDescription": "To verify the MCP has been deleted, run:"
155+
},
156+
"KubectlProjectDialog": {
157+
"title": "Create a Project",
158+
"introSection": "A Project is the starting point to our ManagedControlPlane offering. Projects are usually created for each Organization/Team or similar root setups.",
159+
"formFields": {
160+
"projectName": {
161+
"label": "Project Name",
162+
"placeholder": "Enter project name"
163+
},
164+
"chargingTargetId": {
165+
"label": "BTP Global Account ID",
166+
"placeholder": "Enter your Global Account ID",
167+
"defaultValue": "<your-ga-id>"
168+
},
169+
"userEmail": {
170+
"label": "User Email",
171+
"placeholder": "Enter your email address",
172+
"defaultValue": "<[email protected]>"
173+
}
174+
},
175+
"mainCommandDescription": "Run this command to create a new project:",
176+
"resultCommandDescription": "To see the result of the project creation, run the below command:",
177+
"namespaceCommandDescription": "A namespace is automatically generated for your project:"
178+
},
179+
"KubectlWorkspaceDialog": {
180+
"title": "Create a Workspace",
181+
"introSection": "Let's add a Workspace to our Project. We use workspaces to separate productive and non-productive ManagedControlPlanes.",
182+
"formFields": {
183+
"workspaceName": {
184+
"label": "Workspace Name",
185+
"placeholder": "Enter workspace name"
186+
},
187+
"chargingTargetId": {
188+
"label": "BTP Global Account ID",
189+
"placeholder": "Enter your Global Account ID",
190+
"defaultValue": "<your-ga-id>"
191+
},
192+
"userEmail": {
193+
"label": "User Email",
194+
"placeholder": "Enter your email address",
195+
"defaultValue": "<[email protected]>"
196+
}
197+
},
198+
"mainCommandDescription": "Run this command to create a new workspace in your project:",
199+
"resultCommandDescription": "To see the result of the workspace creation, run the below command:"
200+
},
201+
"KubectlBaseDialog": {
202+
"prerequisites": "Prerequisites",
203+
"prerequisitesText": "Make sure you have installed <bold1>kubectl</bold1> and the <bold2>kubelogin</bold2> plugin. We recommend using <bold3>krew</bold3> which is a plugin manager for kubectl.",
204+
"formFieldsNote": "<bold1>Important</bold1>: Before executing, modify the commands below:",
205+
"onboardingGuide": "You can also use our <link1>Onboarding Guide</link1> for more information."
206+
},
207+
"CommonKubectl": {
208+
"emphasis": {
209+
"irreversible": "irreversible",
210+
"permanentlyDeleted": "permanently deleted"
211+
},
212+
"learnButton": "Learn how to do this in code"
213+
},
142214
"App": {
143215
"loading": "Loading..."
144216
},
@@ -160,4 +232,4 @@
160232
"userExists": "User with this email already exists!",
161233
"atLeastOneUser": "You need to have at least one member assigned."
162234
}
163-
}
235+
}

src/components/ControlPlanes/ControlPlaneCard.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from '../../lib/api/types/crate/deleteMCP.ts';
2121
import { DeleteConfirmationDialog } from '../Dialogs/DeleteConfirmationDialog.tsx';
2222
import MCPHealthPopoverButton from '../ControlPlane/MCPHealthPopoverButton.tsx';
23+
import { KubectlDeleteMcp } from '../Dialogs/KubectlCommandInfo/Controllers/KubectlDeleteMcp.tsx';
2324

2425
interface Props {
2526
controlPlane: ListControlPlanesType;
@@ -98,6 +99,13 @@ export function ControlPlaneCard({
9899
</Card>
99100
<DeleteConfirmationDialog
100101
resourceName={controlPlane.metadata.name}
102+
resourceComponent={
103+
<KubectlDeleteMcp
104+
projectName={projectName}
105+
workspaceName={workspace.metadata.name}
106+
resourceName={controlPlane.metadata.name}
107+
/>
108+
}
101109
isOpen={dialogDeleteMcpIsOpen}
102110
setIsOpen={setDialogDeleteMcpIsOpen}
103111
onDeletionConfirmed={async () => {

src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import useApiResource, {
2727
} from '../../../lib/api/useApiResource.ts';
2828
import { DISPLAY_NAME_ANNOTATION } from '../../../lib/api/types/shared/keyNames.ts';
2929
import { DeleteConfirmationDialog } from '../../Dialogs/DeleteConfirmationDialog.tsx';
30+
import { KubectlDeleteWorkspace } from '../../Dialogs/KubectlCommandInfo/Controllers/KubectlDeleteWorkspace.tsx';
3031
import { useToast } from '../../../context/ToastContext.tsx';
3132
import { ListControlPlanes } from '../../../lib/api/types/crate/controlPlanes.ts';
3233
import IllustratedError from '../../Shared/IllustratedError.tsx';
@@ -155,6 +156,12 @@ export function ControlPlaneListWorkspaceGridTile({
155156
<DeleteConfirmationDialog
156157
resourceName={workspaceName}
157158
projectName={projectName}
159+
resourceComponent={
160+
<KubectlDeleteWorkspace
161+
projectName={projectName}
162+
resourceName={workspaceName}
163+
/>
164+
}
158165
isOpen={dialogDeleteWsIsOpen}
159166
setIsOpen={setDialogDeleteWsIsOpen}
160167
onDeletionConfirmed={async () => {

src/components/Dialogs/CreateProjectWorkspaceDialog.tsx

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import {
1212
import { Member } from '../../lib/api/types/shared/members';
1313
import { ErrorDialog, ErrorDialogHandle } from '../Shared/ErrorMessageBox.tsx';
1414

15-
import { useState, FormEvent } from 'react';
15+
import { FormEvent } from 'react';
1616
import { KubectlInfoButton } from './KubectlCommandInfo/KubectlInfoButton.tsx';
17-
import { KubectlWorkspaceDialog } from './KubectlCommandInfo/KubectlWorkspaceDialog.tsx';
18-
import { KubectlProjectDialog } from './KubectlCommandInfo/KubectlProjectDialog.tsx';
17+
import { KubectlWorkspaceDialog } from './KubectlCommandInfo/KubectlCreateWorkspaceDialog.tsx';
18+
import { KubectlProjectDialog } from './KubectlCommandInfo/KubectlCreateProjectDialog.tsx';
1919

2020
import { EditMembers } from '../Members/EditMembers.tsx';
2121
// import { useFrontendConfig } from '../../context/FrontendConfigContext.tsx';
2222
import { useTranslation } from 'react-i18next';
23+
import { useDialog } from './UseDialog.tsx';
2324

2425
import { CreateDialogProps } from './CreateWorkspaceDialogContainer.tsx';
2526
import { FieldErrors, UseFormRegister, UseFormSetValue } from 'react-hook-form';
@@ -58,14 +59,7 @@ export function CreateProjectWorkspaceDialog({
5859
}: CreateProjectWorkspaceDialogProps) {
5960
// const { links } = useFrontendConfig();
6061
const { t } = useTranslation();
61-
const [isKubectlDialogOpen, setIsKubectlDialogOpen] = useState(false);
62-
63-
const handleKubectlInfoClick = () => {
64-
setIsKubectlDialogOpen(true);
65-
};
66-
const handleKubectlDialogClose = () => {
67-
setIsKubectlDialogOpen(false);
68-
};
62+
const kubectlDialog = useDialog();
6963
return (
7064
<>
7165
<Dialog
@@ -80,7 +74,7 @@ export function CreateProjectWorkspaceDialog({
8074
<div
8175
style={{ display: 'flex', alignItems: 'center', gap: '8px' }}
8276
>
83-
<KubectlInfoButton onClick={handleKubectlInfoClick} />
77+
<KubectlInfoButton onClick={kubectlDialog.open} />
8478
<Button onClick={() => setIsOpen(false)}>
8579
{' '}
8680
{t('CreateProjectWorkspaceDialog.cancelButton')}
@@ -101,16 +95,15 @@ export function CreateProjectWorkspaceDialog({
10195
setValue={setValue}
10296
/>
10397
</Dialog>
104-
105-
{isKubectlDialogOpen &&
106-
(projectName ? (
107-
<KubectlWorkspaceDialog
108-
project={projectName}
109-
onClose={handleKubectlDialogClose}
110-
/>
111-
) : (
112-
<KubectlProjectDialog onClose={handleKubectlDialogClose} />
113-
))}
98+
<KubectlWorkspaceDialog
99+
project={projectName}
100+
isOpen={kubectlDialog.isOpen && !!projectName}
101+
onClose={kubectlDialog.close}
102+
/>
103+
<KubectlProjectDialog
104+
isOpen={kubectlDialog.isOpen && !projectName}
105+
onClose={kubectlDialog.close}
106+
/>
114107
<ErrorDialog ref={errorDialogRef} />
115108
</>
116109
);

src/components/Dialogs/DeleteConfirmationDialog.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useRef, useState } from 'react';
1+
import { ReactNode, useEffect, useRef, useState } from 'react';
22
import {
33
Bar,
44
Button,
@@ -12,13 +12,13 @@ import {
1212
} from '@ui5/webcomponents-react';
1313
import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js';
1414
import { useTranslation } from 'react-i18next';
15-
import { KubectlDeleteWorkspace } from './KubectlCommandInfo/Controllers/KubectlDeleteWorkspace';
1615

1716
interface DeleteConfirmationDialogProps {
1817
isOpen: boolean;
1918
setIsOpen: (isOpen: boolean) => void;
2019
resourceName: string;
2120
projectName?: string;
21+
resourceComponent: ReactNode;
2222
onDeletionConfirmed?: () => void;
2323
onCanceled?: () => void;
2424
}
@@ -27,9 +27,9 @@ export function DeleteConfirmationDialog({
2727
isOpen,
2828
setIsOpen,
2929
resourceName,
30-
projectName,
3130
onDeletionConfirmed,
3231
onCanceled,
32+
resourceComponent,
3333
}: DeleteConfirmationDialogProps) {
3434
const [confirmed, setConfirmed] = useState(false);
3535
const confirmationInput = useRef<InputDomRef>(null);
@@ -116,12 +116,7 @@ export function DeleteConfirmationDialog({
116116
onInput={onConfirmationInputChange}
117117
/>
118118
</FormItem>
119-
<FormItem>
120-
<KubectlDeleteWorkspace
121-
projectName={projectName}
122-
resourceName={resourceName}
123-
/>
124-
</FormItem>
119+
<FormItem>{resourceComponent}</FormItem>
125120
</FormGroup>
126121
</Form>
127122
</Dialog>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { DeleteMcpDialog } from '../KubectlDeleteMcpDialog';
2+
import { KubectlInfoButton } from '../KubectlInfoButton';
3+
import { useDialog } from '../../UseDialog';
4+
5+
interface KubectlDeleteMcpProps {
6+
projectName?: string;
7+
workspaceName: string;
8+
resourceName: string;
9+
}
10+
11+
export const KubectlDeleteMcp = ({
12+
projectName,
13+
workspaceName,
14+
resourceName,
15+
}: KubectlDeleteMcpProps) => {
16+
const infoDialog = useDialog();
17+
18+
return (
19+
<>
20+
<KubectlInfoButton onClick={infoDialog.open} />
21+
<DeleteMcpDialog
22+
projectName={projectName}
23+
workspaceName={workspaceName}
24+
resourceName={resourceName}
25+
isOpen={infoDialog.isOpen}
26+
onClose={infoDialog.close}
27+
/>
28+
</>
29+
);
30+
};
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DeleteWorkspaceDialog } from '../KubectlDeleteWorkspaceDialog';
22
import { KubectlInfoButton } from '../KubectlInfoButton';
3-
import { useState } from 'react';
3+
import { useDialog } from '../../UseDialog';
44

55
interface KubectlDeleteWorkspaceProps {
66
projectName?: string;
@@ -11,25 +11,17 @@ export const KubectlDeleteWorkspace = ({
1111
projectName,
1212
resourceName,
1313
}: KubectlDeleteWorkspaceProps) => {
14-
const [isDialogOpen, setIsDialogOpen] = useState(false);
15-
16-
const closeDialog = () => {
17-
setIsDialogOpen(false);
18-
};
14+
const infoDialog = useDialog();
1915

2016
return (
2117
<>
22-
<KubectlInfoButton
23-
onClick={() => setIsDialogOpen(true)}
24-
></KubectlInfoButton>
25-
26-
{isDialogOpen && (
27-
<DeleteWorkspaceDialog
28-
onClose={closeDialog}
29-
projectName={projectName}
30-
resourceName={resourceName}
31-
></DeleteWorkspaceDialog>
32-
)}
18+
<KubectlInfoButton onClick={infoDialog.open} />
19+
<DeleteWorkspaceDialog
20+
projectName={projectName}
21+
resourceName={resourceName}
22+
isOpen={infoDialog.isOpen}
23+
onClose={infoDialog.close}
24+
/>
3325
</>
3426
);
3527
};

0 commit comments

Comments
 (0)