Skip to content

Commit 6dfb016

Browse files
committed
init
1 parent bff581d commit 6dfb016

File tree

2 files changed

+68
-7
lines changed

2 files changed

+68
-7
lines changed

src/components/Projects/ProjectsList.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
AnalyticalTable,
3-
AnalyticalTableColumnDefinition,
4-
} from '@ui5/webcomponents-react';
1+
import { AnalyticalTable, AnalyticalTableColumnDefinition } from '@ui5/webcomponents-react';
52
import { ThemingParameters } from '@ui5/webcomponents-react-base';
63
import { CopyButton } from '../Shared/CopyButton.tsx';
74
import useLuigiNavigate from '../Shared/useLuigiNavigate.tsx';
@@ -14,6 +11,7 @@ import { ListProjectNames } from '../../lib/api/types/crate/listProjectNames';
1411
import { t } from 'i18next';
1512
import { YamlViewButtonWithLoader } from '../Yaml/YamlViewButtonWithLoader.tsx';
1613
import { useMemo } from 'react';
14+
import { ProjectsListItemMenu } from './ProjectsListItemMenu.tsx';
1715

1816
export default function ProjectsList() {
1917
const navigate = useLuigiNavigate();
@@ -94,6 +92,26 @@ export default function ProjectsList() {
9492
</div>
9593
),
9694
},
95+
{
96+
Header: t('common.options'),
97+
accessor: 'options',
98+
width: 85,
99+
disableFilters: true,
100+
hAlign: 'Center',
101+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
102+
Cell: (instance: any) => (
103+
<div
104+
style={{
105+
width: '100%',
106+
display: 'flex',
107+
justifyContent: 'end',
108+
alignItems: 'center',
109+
}}
110+
>
111+
<ProjectsListItemMenu setDialogDeleteProjectIsOpen={() => {}} />
112+
</div>
113+
),
114+
},
97115
],
98116
[],
99117
);
@@ -109,9 +127,7 @@ export default function ProjectsList() {
109127
data={stabilizedData}
110128
// eslint-disable-next-line @typescript-eslint/no-explicit-any
111129
onRowClick={(e: any) => {
112-
navigate(
113-
`/mcp/projects/${data ? [e.detail.row.values.projectName] : ''}`,
114-
);
130+
navigate(`/mcp/projects/${data ? [e.detail.row.values.projectName] : ''}`);
115131
}}
116132
/>
117133
</>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Button, ButtonDomRef, Menu, MenuItem, Ui5CustomEvent, MenuDomRef } from '@ui5/webcomponents-react';
2+
import type { ButtonClickEventDetail } from '@ui5/webcomponents/dist/Button.js';
3+
import { Dispatch, FC, SetStateAction, useRef, useState } from 'react';
4+
import '@ui5/webcomponents-icons/dist/copy';
5+
import '@ui5/webcomponents-icons/dist/accept';
6+
7+
import { useTranslation } from 'react-i18next';
8+
9+
type ProjectsListItemMenuProps = {
10+
setDialogDeleteProjectIsOpen: Dispatch<SetStateAction<boolean>>;
11+
};
12+
13+
export const ProjectsListItemMenu: FC<ProjectsListItemMenuProps> = ({ setDialogDeleteProjectIsOpen }) => {
14+
const popoverRef = useRef<MenuDomRef>(null);
15+
const [open, setOpen] = useState(false);
16+
17+
const { t } = useTranslation();
18+
19+
const handleOpenerClick = (e: Ui5CustomEvent<ButtonDomRef, ButtonClickEventDetail>) => {
20+
if (popoverRef.current && e.currentTarget) {
21+
popoverRef.current.opener = e.currentTarget as HTMLElement;
22+
setOpen((prev) => !prev);
23+
}
24+
};
25+
26+
return (
27+
<div>
28+
<Button icon="overflow" icon-end onClick={handleOpenerClick} />
29+
<Menu
30+
ref={popoverRef}
31+
open={open}
32+
onItemClick={(event) => {
33+
const action = (event.detail.item as HTMLElement).dataset.action;
34+
if (action === 'deleteProject') {
35+
setDialogDeleteProjectIsOpen(true);
36+
}
37+
38+
setOpen(false);
39+
}}
40+
>
41+
<MenuItem key={'delete'} text={t('Project.deleteProject')} data-action="deleteProject" icon="delete" />
42+
</Menu>
43+
</div>
44+
);
45+
};

0 commit comments

Comments
 (0)