Skip to content

Commit 285248d

Browse files
committed
Events UI #3309 User events refactoring after review
1 parent ac446fa commit 285248d

8 files changed

Lines changed: 122 additions & 22 deletions

File tree

frontend/src/locale/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
"repositories": "Repositories",
183183
"runs": "Runs",
184184
"tags": "Tags",
185-
"events": "Project events",
185+
"events": "Events",
186186
"settings": "Settings",
187187
"join": "Join",
188188
"leave_confirm_title": "Leave project",
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import { useNavigate, useParams } from 'react-router-dom';
4+
5+
import { Button, Header, SpaceBetween } from 'components';
6+
7+
import { useBreadcrumbs } from 'hooks';
8+
import { ROUTES } from 'routes';
9+
10+
import { EventList } from 'pages/Events/List';
11+
12+
export const Events: React.FC = () => {
13+
const { t } = useTranslation();
14+
const params = useParams();
15+
const paramProjectName = params.projectName ?? '';
16+
const navigate = useNavigate();
17+
18+
useBreadcrumbs([
19+
{
20+
text: t('navigation.project_other'),
21+
href: ROUTES.PROJECT.LIST,
22+
},
23+
{
24+
text: paramProjectName,
25+
href: ROUTES.PROJECT.DETAILS.FORMAT(paramProjectName),
26+
},
27+
{
28+
text: t('projects.events'),
29+
href: ROUTES.PROJECT.DETAILS.EVENTS.FORMAT(paramProjectName),
30+
},
31+
]);
32+
33+
const goToEventsPage = () => {
34+
navigate(ROUTES.EVENTS.LIST + `?within_projects=${paramProjectName}`);
35+
};
36+
37+
return (
38+
<EventList
39+
renderHeader={() => {
40+
return (
41+
<Header
42+
variant="awsui-h1-sticky"
43+
actions={
44+
<SpaceBetween size="xs" direction="horizontal">
45+
<Button onClick={goToEventsPage}>{t('common.full_view')}</Button>
46+
</SpaceBetween>
47+
}
48+
/>
49+
);
50+
}}
51+
permanentFilters={{ within_projects: [paramProjectName] }}
52+
showFilters={false}
53+
/>
54+
);
55+
};
Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,49 @@
1-
import React from 'react';
1+
import React, { useMemo } from 'react';
22
import { useTranslation } from 'react-i18next';
3-
import { Outlet, useParams } from 'react-router-dom';
3+
import { Outlet, useMatch, useParams } from 'react-router-dom';
44

5-
import { ContentLayout, DetailsHeader, NavigateLink } from 'components';
5+
import { ContentLayout, DetailsHeader, Tabs } from 'components';
66

77
import { ROUTES } from 'routes';
88

9+
import styles from './styles.module.scss';
10+
911
export const ProjectDetails: React.FC = () => {
1012
const params = useParams();
1113
const paramProjectName = params.projectName ?? '';
1214
const { t } = useTranslation();
1315

16+
const matchSettings = useMatch(ROUTES.PROJECT.DETAILS.SETTINGS.FORMAT(paramProjectName));
17+
const matchEvents = useMatch(ROUTES.PROJECT.DETAILS.EVENTS.FORMAT(paramProjectName));
18+
19+
const tabs: {
20+
label: string;
21+
id: string;
22+
href: string;
23+
}[] = [
24+
{
25+
label: t('projects.settings'),
26+
id: 'settings',
27+
href: ROUTES.PROJECT.DETAILS.SETTINGS.FORMAT(paramProjectName),
28+
},
29+
{
30+
label: t('projects.events'),
31+
id: 'events',
32+
href: ROUTES.PROJECT.DETAILS.EVENTS.FORMAT(paramProjectName),
33+
},
34+
].filter(Boolean);
35+
36+
const showTabs = useMemo<boolean>(() => {
37+
return Boolean(matchSettings) || Boolean(matchEvents);
38+
}, [matchSettings, matchEvents]);
39+
1440
return (
15-
<ContentLayout
16-
header={
17-
<DetailsHeader
18-
title={paramProjectName}
19-
actionButtons={
20-
<NavigateLink href={ROUTES.EVENTS.LIST + `?within_projects=${paramProjectName}`}>
21-
{t('projects.events')}
22-
</NavigateLink>
23-
}
24-
/>
25-
}
26-
>
27-
<Outlet />
28-
</ContentLayout>
41+
<div className={styles.page}>
42+
<ContentLayout header={<DetailsHeader title={paramProjectName} />}>
43+
{showTabs && <Tabs withNavigation tabs={tabs} />}
44+
45+
<Outlet />
46+
</ContentLayout>
47+
</div>
2948
);
3049
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.page {
2+
height: 100%;
3+
4+
& [class^="awsui_tabs-content"] {
5+
display: none;
6+
}
7+
8+
& > [class^="awsui_layout"] {
9+
height: 100%;
10+
11+
& > [class^="awsui_content"] {
12+
display: flex;
13+
flex-direction: column;
14+
gap: 20px;
15+
height: 100%;
16+
}
17+
}
18+
}

frontend/src/pages/Project/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
export { ProjectList } from './List';
33
export { ProjectDetails } from './Details';
44
export { ProjectSettings } from './Details/Settings';
5+
export { Events as ProjectEvents } from './Details/Events';
56
export { ProjectAdd } from './Add';
67
export { CreateProjectWizard } from './CreateWizard';
78

frontend/src/pages/User/Details/Events/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ export const Events: React.FC = () => {
5454
<Button onClick={goToEventsPage}>{t('common.full_view')}</Button>
5555
</SpaceBetween>
5656
}
57-
>
58-
{/*{t('navigation.events')}*/}
59-
</Header>
57+
/>
6058
);
6159
}}
6260
permanentFilters={{ [filterParamName]: [paramUserName] }}

frontend/src/router.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { FleetInspect } from 'pages/Fleets/Details/Inspect';
1717
import { InstanceList } from 'pages/Instances';
1818
import { ModelsList } from 'pages/Models';
1919
import { ModelDetails } from 'pages/Models/Details';
20-
import { CreateProjectWizard, ProjectAdd, ProjectDetails, ProjectList, ProjectSettings } from 'pages/Project';
20+
import { CreateProjectWizard, ProjectAdd, ProjectDetails, ProjectEvents, ProjectList, ProjectSettings } from 'pages/Project';
2121
import { BackendAdd, BackendEdit } from 'pages/Project/Backends';
2222
import { AddGateway, EditGateway } from 'pages/Project/Gateways';
2323
import {
@@ -86,6 +86,10 @@ export const router = createBrowserRouter([
8686
index: true,
8787
element: <ProjectSettings />,
8888
},
89+
{
90+
path: ROUTES.PROJECT.DETAILS.EVENTS.TEMPLATE,
91+
element: <ProjectEvents />,
92+
},
8993
{
9094
path: ROUTES.PROJECT.BACKEND.ADD.TEMPLATE,
9195
element: <BackendAdd />,

frontend/src/routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export const ROUTES = {
2323
FORMAT: (projectName: string) => buildRoute(ROUTES.PROJECT.DETAILS.SETTINGS.TEMPLATE, { projectName }),
2424
},
2525

26+
EVENTS: {
27+
TEMPLATE: `/projects/:projectName/events`,
28+
FORMAT: (projectName: string) => buildRoute(ROUTES.PROJECT.DETAILS.EVENTS.TEMPLATE, { projectName }),
29+
},
30+
2631
RUNS: {
2732
DETAILS: {
2833
TEMPLATE: `/projects/:projectName/runs/:runId`,

0 commit comments

Comments
 (0)