Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export const API = {
PORTAL_SESSION: (username: string) => `${API.USER_BILLING.BASE(username)}/portal_session`,
},

EVENTS: {
BASE: () => `${API.BASE()}/events`,
LIST: () => `${API.EVENTS.BASE()}/list`,
},

PROJECTS: {
BASE: () => `${API.BASE()}/projects`,
LIST: () => `${API.PROJECTS.BASE()}/list`,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/layouts/AppLayout/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const useSideNavigation = () => {
{ type: 'link', text: t('navigation.fleets'), href: ROUTES.FLEETS.LIST },
{ type: 'link', text: t('navigation.instances'), href: ROUTES.INSTANCES.LIST },
{ type: 'link', text: t('navigation.volumes'), href: ROUTES.VOLUMES.LIST },
{ type: 'link', text: t('navigation.events'), href: ROUTES.EVENTS.LIST },
{ type: 'link', text: t('navigation.project_other'), href: ROUTES.PROJECT.LIST },

isGlobalAdmin && {
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"resources": "Resources",
"volumes": "Volumes",
"instances": "Instances",
"offers": "Offers"
"offers": "Offers",
"events": "Events"
},

"backend": {
Expand Down Expand Up @@ -640,6 +641,13 @@
}
},

"events": {
"recorded_at": "Recorded At",
"actor": "Actor",
"targets": "Targets",
"message": "Message"
},

"users": {
"page_title": "Users",
"search_placeholder": "Find members",
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/pages/Events/List/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { PropertyFilterProps } from 'components';

export function filterLastElementByPrefix(
arr: PropertyFilterProps.Query['tokens'],
prefix: string,
): PropertyFilterProps.Query['tokens'] {
// Ищем индекс последнего элемента с префиксом "test_"
let lastTestIndex = -1;
for (let i = arr.length - 1; i >= 0; i--) {
if (arr[i].propertyKey?.startsWith(prefix)) {
lastTestIndex = i;
break;
}
}

// Фильтруем массив
return arr.filter((item, index) => {
// Оставляем элемент, если:
// 1. Это не строка с префиксом "test_"?
// 2. ИЛИ это строка с префиксом "test_" И она последняя в массиве
return !item.propertyKey?.startsWith(prefix) || index === lastTestIndex;
});
}
129 changes: 129 additions & 0 deletions frontend/src/pages/Events/List/hooks/useColumnDefinitions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { format } from 'date-fns';

import { NavigateLink, TableProps } from 'components';

import { DATE_TIME_FORMAT } from 'consts';
import { ROUTES } from 'routes';

export const useColumnsDefinitions = () => {
const { t } = useTranslation();

const columns: TableProps.ColumnDefinition<IEvent>[] = [
{
id: 'recorded_at',
header: t('events.recorded_at'),
cell: (item) => format(new Date(item.recorded_at), DATE_TIME_FORMAT),
},
{
id: 'actor',
header: t('events.actor'),
cell: (item) =>
item.actor_user ? (
<NavigateLink href={ROUTES.USER.DETAILS.FORMAT(item.actor_user)}>{item.actor_user}</NavigateLink>
) : (
'-'
),
},
{
id: 'target',
header: t('events.targets'),
cell: (item) => {
return item.targets.map((target) => {
switch (target.type) {
case 'project':
return (
<div>
Project{' '}
{target.project_name && (
<NavigateLink href={ROUTES.PROJECT.DETAILS.FORMAT(target.project_name)}>
{target.project_name}
</NavigateLink>
)}
</div>
);

case 'fleet':
return (
<div>
Fleet{' '}
{target.project_name && (
<NavigateLink href={ROUTES.PROJECT.DETAILS.FORMAT(target.project_name)}>
{target.project_name}
</NavigateLink>
)}
/
<NavigateLink href={ROUTES.FLEETS.DETAILS.FORMAT(target.project_name ?? '', target.id)}>
{target.name}
</NavigateLink>
</div>
);

case 'user':
return (
<div>
User{' '}
<NavigateLink href={ROUTES.USER.DETAILS.FORMAT(target.name)}>{target.name}</NavigateLink>
</div>
);

case 'instance':
return (
<div>
Instance{' '}
{target.project_name && (
<NavigateLink href={ROUTES.PROJECT.DETAILS.FORMAT(target.project_name)}>
{target.project_name}
</NavigateLink>
)}
/{target.name}
</div>
);

case 'run':
return (
<div>
Run{' '}
{target.project_name && (
<NavigateLink href={ROUTES.PROJECT.DETAILS.FORMAT(target.project_name)}>
{target.project_name}
</NavigateLink>
)}
/
<NavigateLink
href={ROUTES.PROJECT.DETAILS.RUNS.DETAILS.FORMAT(target.project_name ?? '', target.id)}
>
{target.name}
</NavigateLink>
</div>
);

case 'job':
return (
<div>
Job{' '}
{target.project_name && (
<NavigateLink href={ROUTES.PROJECT.DETAILS.FORMAT(target.project_name)}>
{target.project_name}
</NavigateLink>
)}
/{target.name}
</div>
);

default:
return '---';
}
});
},
},
{
id: 'message',
header: t('events.message'),
cell: ({ message }) => message,
},
];

return { columns } as const;
};
Loading