Skip to content
Open
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 .changeset/clickable-log-components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openchoreo/backstage-plugin-openchoreo-observability': minor
---

Made component names in the project-level logging view clickable, allowing users to navigate directly to the component-scoped logging view while preserving the current time range and any relevant filters.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from 'react';
import { MemoryRouter } from 'react-router-dom';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { LogEntry } from './LogEntry';
Expand Down Expand Up @@ -48,7 +49,11 @@ function renderLogEntry(
expanded,
onToggleExpand: () => setExpanded(prev => !prev),
};
return <LogEntry {...defaultProps} {...overrides} />;
return (
<MemoryRouter>
<LogEntry {...defaultProps} {...overrides} />
</MemoryRouter>
);
};
return render(<Harness />);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add a new test to assert the navigation capability added by this PR

@kavix kavix Jun 19, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefinie123 Done! Added a new test navigates to component runtime logs and stops propagation on component name link click which renders the component inside a MemoryRouter wrapper to assert that:

  1. Clicking the link updates the browser location path to the derived runtime logs URL.
  2. onToggleExpand is not invoked (confirming that click propagation is successfully stopped so the row doesn't toggle).

Expand Down Expand Up @@ -97,6 +102,21 @@ describe('LogEntry', () => {
expect(screen.getByText('api-service')).toBeInTheDocument();
});

it('renders component name link with correct path', () => {
renderLogEntry({
selectedFields: [...allFields, LogEntryField.ComponentName],
entityNamespace: 'my-namespace',
entityKind: 'Component',
});

const link = screen.getByRole('link', { name: 'api-service' });
expect(link).toBeInTheDocument();
expect(link).toHaveAttribute(
'href',
'/catalog/my-namespace/component/api-service/runtime-logs',
);
});

it('expands to show metadata on row click', async () => {
const user = userEvent.setup();
renderLogEntry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import {
} from '@material-ui/core';
import FileCopyOutlined from '@material-ui/icons/FileCopyOutlined';
import { LogEntry as LogEntryType, LogEntryField } from './types';
import { Link } from '@backstage/core-components';
import { useLocation } from 'react-router-dom';
import { useLogEntryStyles } from './styles';
import { getColumnStyle } from './columns';
import { Entity } from '@backstage/catalog-model';
import { buildRuntimeLogsBasePath } from '@openchoreo/backstage-plugin-react';

/**
* Render-prop slot for a per-row action button (assistant integration,
Expand All @@ -29,6 +33,8 @@ interface LogEntryProps {
environmentName?: string;
projectName?: string;
componentName?: string;
entityNamespace?: string;
entityKind?: string;
/**
* Whether this row is currently expanded. Controlled by the parent so that
* expansion survives the virtualizer unmounting the row off-screen.
Expand All @@ -53,12 +59,15 @@ export const LogEntry: FC<LogEntryProps> = ({
environmentName,
projectName,
componentName,
entityNamespace,
entityKind,
expanded,
onToggleExpand,
getLogsSnapshot,
renderRowAction,
}) => {
const classes = useLogEntryStyles();
const location = useLocation();
const [copySuccess, setCopySuccess] = useState(false);

const handleCopyLog = async (event: MouseEvent<HTMLButtonElement>) => {
Expand Down Expand Up @@ -140,13 +149,32 @@ export const LogEntry: FC<LogEntryProps> = ({
}

if (field === LogEntryField.ComponentName) {
const compName = log.metadata?.componentName ?? componentName ?? '';
const entity: Entity = {
apiVersion: 'backstage.io/v1alpha1',
kind: entityKind || 'Component',
metadata: {
name: compName,
namespace: entityNamespace,
},
};
const basePath = buildRuntimeLogsBasePath(entity);
return (
<Box
key={field}
style={getColumnStyle(field)}
className={`${classes.cell} ${classes.monospaceCell}`}
>
{log.metadata?.componentName ?? componentName ?? ''}
{compName ? (
<Link
to={`${basePath}${location.search}`}
onClick={e => e.stopPropagation()}
>
{compName}
</Link>
) : (
''
)}
</Box>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface LogsTableProps {
environmentName?: string;
projectName?: string;
componentName?: string;
entityNamespace?: string;
entityKind?: string;
renderRowAction?: RenderLogRowAction;
}

Expand All @@ -37,6 +39,8 @@ export const LogsTable: FC<LogsTableProps> = ({
environmentName,
projectName,
componentName,
entityNamespace,
entityKind,
renderRowAction,
}) => {
const classes = useLogsTableStyles();
Expand Down Expand Up @@ -164,6 +168,8 @@ export const LogsTable: FC<LogsTableProps> = ({
environmentName={environmentName}
projectName={projectName}
componentName={componentName}
entityNamespace={entityNamespace}
entityKind={entityKind}
expanded={expanded.has(key)}
onToggleExpand={() => toggle(key)}
getLogsSnapshot={getLogsSnapshot}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ const ObservabilityProjectRuntimeLogsContent = ({
selectedEnvironment?.displayName || selectedEnvironment?.name
}
projectName={projectName}
entityNamespace={entity.metadata.namespace}
entityKind="component"
renderRowAction={renderRowAction}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ const ObservabilityRuntimeLogsContent = ({
}
projectName={project}
componentName={componentName}
entityNamespace={entity.metadata.namespace}
entityKind={entity.kind}
renderRowAction={renderRowAction}
/>
</>
Expand Down
Loading