Skip to content

Commit

Permalink
Add projects' descriptions to projects list view (#3174)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 authored Sep 11, 2024
1 parent 4fabe0c commit 39b023e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
4 changes: 4 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class NotebookRow extends TableRow {
}

class ProjectRow extends TableRow {
findDescription() {
return this.find().findByTestId('table-row-title-description');
}

findEnableSwitch() {
return this.find().pfSwitch('notebook-status-switch');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { asProjectAdminUser } from '~/__tests__/cypress/cypress/utils/mockUsers'
import { notebookConfirmModal } from '~/__tests__/cypress/cypress/pages/workbench';
import { testPagination } from '~/__tests__/cypress/cypress/utils/pagination';

const mockProject = mockProjectK8sResource({});
const mockProject = mockProjectK8sResource({ description: 'Mock description' });
const initIntercepts = () => {
cy.interceptK8sList(ProjectModel, mockK8sResourceList([mockProject]));
};
Expand Down Expand Up @@ -73,7 +73,9 @@ describe('Data science projects details', () => {
initIntercepts();
projectListPage.visit();
projectListPage.shouldHaveProjects();
projectListPage.getProjectRow('Test Project').find().should('exist');
const projectRow = projectListPage.getProjectRow('Test Project');
projectRow.find().should('exist');
projectRow.findDescription().should('contain.text', 'Mock description');
});

it('should delete project', () => {
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/pages/projects/screens/projects/ProjectLink.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link, LinkProps } from 'react-router-dom';
import { getDisplayNameFromK8sResource } from '~/concepts/k8s/utils';
import { ProjectKind } from '~/k8sTypes';

type ProjectLinkProps = {
project: ProjectKind;
};

const ProjectLink: React.FC<ProjectLinkProps> = ({ project }) => {
const ProjectLink: React.FC<Omit<LinkProps, 'to'> & ProjectLinkProps> = ({ project, ...props }) => {
const projectName = getDisplayNameFromK8sResource(project);

return <Link to={`/projects/${project.metadata.name}`}>{projectName}</Link>;
return (
<Link to={`/projects/${project.metadata.name}`} {...props}>
{projectName}
</Link>
);
};

export default ProjectLink;
33 changes: 26 additions & 7 deletions frontend/src/pages/projects/screens/projects/ProjectTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { ActionsColumn, Td, Tr } from '@patternfly/react-table';
import { useNavigate } from 'react-router-dom';
import { ProjectKind } from '~/k8sTypes';
import useProjectTableRowItems from '~/pages/projects/screens/projects/useProjectTableRowItems';
import ResourceNameTooltip from '~/components/ResourceNameTooltip';
import { getProjectOwner } from '~/concepts/projects/utils';
import useProjectNotebookStates from '~/pages/projects/notebook/useProjectNotebookStates';
import NotebookRouteLink from '~/pages/projects/notebook/NotebookRouteLink';
import CanEnableElyraPipelinesCheck from '~/concepts/pipelines/elyra/CanEnableElyraPipelinesCheck';
import NotebookStateStatus from '~/pages/projects/screens/projects/NotebookStateStatus';
import { getDisplayNameFromK8sResource } from '~/concepts/k8s/utils';
import ProjectLink from './ProjectLink';
import { getDescriptionFromK8sResource, getDisplayNameFromK8sResource } from '~/concepts/k8s/utils';
import { TableRowTitleDescription } from '~/components/table';
import ResourceNameTooltip from '~/components/ResourceNameTooltip';
import ProjectLink from '~/pages/projects/screens/projects/ProjectLink';

type ProjectTableRowProps = {
obj: ProjectKind;
Expand Down Expand Up @@ -47,10 +48,28 @@ const ProjectTableRow: React.FC<ProjectTableRowProps> = ({
>
{index === 0 ? (
<Td dataLabel="Name" rowSpan={notebookStates.length || 1}>
<ResourceNameTooltip resource={project}>
<ProjectLink project={project} />
</ResourceNameTooltip>
{owner && <Text component={TextVariants.small}>{owner}</Text>}
<TableRowTitleDescription
title={
<ResourceNameTooltip resource={project}>
<ProjectLink
project={project}
style={{
fontSize: 'var(--pf-v5-global--FontSize--md)',
fontWeight: 'var(--pf-v5-global--FontWeight--normal)',
}}
/>
</ResourceNameTooltip>
}
description={getDescriptionFromK8sResource(project)}
truncateDescriptionLines={2}
subtitle={
owner ? (
<div>
<Text component={TextVariants.small}>{owner}</Text>
</div>
) : undefined
}
/>
</Td>
) : null}
{index === 0 ? (
Expand Down

0 comments on commit 39b023e

Please sign in to comment.