Skip to content

Commit e32727e

Browse files
committed
init
1 parent 6dfb016 commit e32727e

File tree

6 files changed

+62
-42
lines changed

6 files changed

+62
-42
lines changed

public/locales/en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@
157157
},
158158
"ProjectsListView": {
159159
"pageTitle": "Let's get started",
160-
"title": "Projects"
160+
"title": "Projects",
161+
"deleteProject": "Delete project",
162+
"deleteConfirmationDialog": "Project deleted"
161163
},
162164
"ControlPlaneView": {
163165
"accessError": "Managed Control Plane does not have access information yet",
@@ -288,7 +290,8 @@
288290
"search": "Search",
289291
"components": "Components",
290292
"notSelected": "Not selected",
291-
"btp": "BTP"
293+
"btp": "BTP",
294+
"options": "Options"
292295
},
293296
"buttons": {
294297
"viewResource": "View resource",

src/components/Dialogs/DeleteConfirmationDialog.tsx

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import { ReactNode, useEffect, useRef, useState } from 'react';
2-
import {
3-
Bar,
4-
Button,
5-
Dialog,
6-
Form,
7-
FormGroup,
8-
FormItem,
9-
Input,
10-
InputDomRef,
11-
Label,
12-
} from '@ui5/webcomponents-react';
2+
import { Bar, Button, Dialog, Form, FormGroup, FormItem, Input, InputDomRef, Label } from '@ui5/webcomponents-react';
133
import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js';
144
import { useTranslation } from 'react-i18next';
155

@@ -74,7 +64,7 @@ export function DeleteConfirmationDialog({
7464
</Button>
7565
<Button
7666
design={ButtonDesign.Negative}
77-
disabled={confirmed === false}
67+
disabled={!confirmed}
7868
onClick={() => {
7969
setIsOpen(false);
8070
onDeletionConfirmed && onDeletionConfirmed();
@@ -94,27 +84,20 @@ export function DeleteConfirmationDialog({
9484
</Label>
9585
<Label>
9686
{' '}
97-
{t('DeleteConfirmationDialog.deleteMessageType')}{' '}
98-
<b>{resourceName}</b>{' '}
87+
{t('DeleteConfirmationDialog.deleteMessageType')} <b>{resourceName}</b>{' '}
9988
{t('DeleteConfirmationDialog.deleteMessageConfirm')}
10089
</Label>
10190
</FormGroup>
10291
<FormGroup>
10392
<FormItem
10493
labelContent={
10594
<Label>
106-
{t('DeleteConfirmationDialog.deleteMessageType')}{' '}
107-
{resourceName}{' '}
95+
{t('DeleteConfirmationDialog.deleteMessageType')} {resourceName}{' '}
10896
{t('DeleteConfirmationDialog.deleteMessageConfirm')}
10997
</Label>
11098
}
11199
>
112-
<Input
113-
ref={confirmationInput}
114-
id="mcp-name-input"
115-
placeholder=""
116-
onInput={onConfirmationInputChange}
117-
/>
100+
<Input ref={confirmationInput} id="mcp-name-input" placeholder="" onInput={onConfirmationInputChange} />
118101
</FormItem>
119102
<FormItem>{kubectl}</FormItem>
120103
</FormGroup>

src/components/Projects/ProjectsList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default function ProjectsList() {
108108
alignItems: 'center',
109109
}}
110110
>
111-
<ProjectsListItemMenu setDialogDeleteProjectIsOpen={() => {}} />
111+
<ProjectsListItemMenu projectName={instance.cell.row.original?.projectName ?? ''} />
112112
</div>
113113
),
114114
},
@@ -127,7 +127,7 @@ export default function ProjectsList() {
127127
data={stabilizedData}
128128
// eslint-disable-next-line @typescript-eslint/no-explicit-any
129129
onRowClick={(e: any) => {
130-
navigate(`/mcp/projects/${data ? [e.detail.row.values.projectName] : ''}`);
130+
// navigate(`/mcp/projects/${data ? [e.detail.row.values.projectName] : ''}`);
131131
}}
132132
/>
133133
</>

src/components/Projects/ProjectsListItemMenu.tsx

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
import { Button, ButtonDomRef, Menu, MenuItem, Ui5CustomEvent, MenuDomRef } from '@ui5/webcomponents-react';
22
import type { ButtonClickEventDetail } from '@ui5/webcomponents/dist/Button.js';
3-
import { Dispatch, FC, SetStateAction, useRef, useState } from 'react';
3+
import { FC, useRef, useState } from 'react';
44
import '@ui5/webcomponents-icons/dist/copy';
55
import '@ui5/webcomponents-icons/dist/accept';
66

77
import { useTranslation } from 'react-i18next';
8+
import { DeleteConfirmationDialog } from '../Dialogs/DeleteConfirmationDialog.tsx';
9+
10+
import { useToast } from '../../context/ToastContext.tsx';
11+
import { useApiResourceMutation } from '../../lib/api/useApiResource.ts';
12+
import { DeleteWorkspaceType } from '../../lib/api/types/crate/deleteWorkspace.ts';
13+
import { DeleteProjectResource } from '../../lib/api/types/crate/deleteProject.ts';
814

915
type ProjectsListItemMenuProps = {
10-
setDialogDeleteProjectIsOpen: Dispatch<SetStateAction<boolean>>;
16+
projectName: string;
1117
};
1218

13-
export const ProjectsListItemMenu: FC<ProjectsListItemMenuProps> = ({ setDialogDeleteProjectIsOpen }) => {
19+
export const ProjectsListItemMenu: FC<ProjectsListItemMenuProps> = ({ projectName }) => {
1420
const popoverRef = useRef<MenuDomRef>(null);
1521
const [open, setOpen] = useState(false);
16-
22+
const [dialogDeleteProjectIsOpen, setDialogDeleteProjectIsOpen] = useState(false);
1723
const { t } = useTranslation();
18-
24+
const toast = useToast();
25+
const { trigger } = useApiResourceMutation<DeleteWorkspaceType>(DeleteProjectResource(projectName));
1926
const handleOpenerClick = (e: Ui5CustomEvent<ButtonDomRef, ButtonClickEventDetail>) => {
27+
e.stopImmediatePropagation();
28+
e.stopPropagation();
2029
if (popoverRef.current && e.currentTarget) {
2130
popoverRef.current.opener = e.currentTarget as HTMLElement;
2231
setOpen((prev) => !prev);
@@ -30,6 +39,8 @@ export const ProjectsListItemMenu: FC<ProjectsListItemMenuProps> = ({ setDialogD
3039
ref={popoverRef}
3140
open={open}
3241
onItemClick={(event) => {
42+
event.stopImmediatePropagation();
43+
event.stopPropagation();
3344
const action = (event.detail.item as HTMLElement).dataset.action;
3445
if (action === 'deleteProject') {
3546
setDialogDeleteProjectIsOpen(true);
@@ -38,8 +49,24 @@ export const ProjectsListItemMenu: FC<ProjectsListItemMenuProps> = ({ setDialogD
3849
setOpen(false);
3950
}}
4051
>
41-
<MenuItem key={'delete'} text={t('Project.deleteProject')} data-action="deleteProject" icon="delete" />
52+
<MenuItem key={'delete'} text={t('ProjectsListView.deleteProject')} data-action="deleteProject" icon="delete" />
4253
</Menu>
54+
55+
{dialogDeleteProjectIsOpen && (
56+
<DeleteConfirmationDialog
57+
resourceName={projectName}
58+
kubectl={
59+
// <KubectlDeleteWorkspace projectName={projectName} resourceName={workspaceName} />
60+
<div />
61+
}
62+
isOpen={dialogDeleteProjectIsOpen}
63+
setIsOpen={setDialogDeleteProjectIsOpen}
64+
onDeletionConfirmed={async () => {
65+
await trigger();
66+
toast.show(t('ProjectsListView.deleteConfirmationDialog'));
67+
}}
68+
/>
69+
)}
4370
</div>
4471
);
4572
};

src/components/Yaml/YamlViewButtonWithLoader.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ export type YamlViewButtonProps = {
1212
resourceName: string;
1313
};
1414

15-
export const YamlViewButtonWithLoader: FC<YamlViewButtonProps> = ({
16-
workspaceName,
17-
resourceType,
18-
resourceName,
19-
}) => {
15+
export const YamlViewButtonWithLoader: FC<YamlViewButtonProps> = ({ workspaceName, resourceType, resourceName }) => {
2016
const [isOpen, setIsOpen] = useState(false);
2117
const { t } = useTranslation();
2218
return (
@@ -25,11 +21,7 @@ export const YamlViewButtonWithLoader: FC<YamlViewButtonProps> = ({
2521
isOpen={isOpen}
2622
setIsOpen={setIsOpen}
2723
dialogContent={
28-
<YamlLoader
29-
workspaceName={workspaceName}
30-
resourceName={resourceName}
31-
resourceType={resourceType}
32-
/>
24+
<YamlLoader workspaceName={workspaceName} resourceName={resourceName} resourceType={resourceType} />
3325
}
3426
/>
3527

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Resource } from '../resource';
2+
3+
export interface DeleteProjectType {
4+
name: string;
5+
namespace: string;
6+
}
7+
8+
export const DeleteProjectResource = (projectName: string): Resource<undefined> => {
9+
return {
10+
path: `/apis/core.openmcp.cloud/v1alpha1/projects/${projectName}`,
11+
method: 'DELETE',
12+
jq: undefined,
13+
body: undefined,
14+
};
15+
};

0 commit comments

Comments
 (0)