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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom-v5-compat';
import { ResourceHealthHandler, WatchK8sResults } from '@console/dynamic-plugin-sdk';
import { ProjectModel } from '@console/internal/models';
import { referenceForModel } from '@console/internal/module/k8s';
import { HealthState } from '@console/shared/src/components/dashboard/status-card/states';
import { ExternalLink } from '@console/shared/src/components/links/ExternalLink';
Expand Down Expand Up @@ -74,7 +75,7 @@ export const SecurityBreakdownPopup: React.FC<SecurityBreakdownPopupProps> = ({
const imageNameClamped = (imageName: string): string =>
imageName.length > 25 ? `${imageName.slice(0, 25)}...` : imageName;
const baseVulnListUrl = namespace
? `/k8s/cluster/projects/${namespace}/vulnerabilities`
? `/k8s/cluster/${referenceForModel(ProjectModel)}/${namespace}/vulnerabilities`
: `/k8s/all-namespaces/${referenceForModel(ImageManifestVulnModel)}`;
const vulnDetailsUrl = `/k8s/ns/${namespace}/${referenceForModel(ImageManifestVulnModel)}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare global {
// ex: cy.createProject(name)
Cypress.Commands.add('createProject', (name: string, devConsole: boolean = false) => {
cy.log(`create project`);
cy.visit(`/k8s/cluster/projects`);
cy.visit(`/k8s/cluster/project.openshift.io~v1~Project`);
listPage.isCreateButtonVisible();
listPage.clickCreateYAMLbutton();
modal.shouldBeOpened();
Expand All @@ -38,7 +38,7 @@ Cypress.Commands.add('createProjectWithCLI', (name: string) => {

Cypress.Commands.add('deleteProject', (name: string) => {
cy.log(`delete project`);
cy.visit(`/k8s/cluster/projects/${name}`);
cy.visit(`/k8s/cluster/project.openshift.io~v1~Project/${name}`);
detailsPage.isLoaded();
detailsPage.clickPageActionFromDropdown('Delete Project');
modal.shouldBeOpened();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ describe('Visiting Overview page', () => {
});

it(`displays a ${kindModel.id} in the overview list page`, () => {
cy.visit(`/k8s/cluster/projects/${testName}/workloads?view=list`);
cy.visit(`/k8s/cluster/project.openshift.io~v1~Project/${testName}/workloads?view=list`);
overviewPage.projectOverviewShouldBeVisible();
overviewPage.itemsShouldBeVisible();
overviewPage.groupLabelItemContains(kindModel);
overviewPage.projectOverviewListItemContains(resourceName);
});

it(`shows ${kindModel.id} details sidebar when item is clicked`, () => {
cy.visit(`/k8s/cluster/projects/${testName}/workloads?view=list`);
cy.visit(`/k8s/cluster/project.openshift.io~v1~Project/${testName}/workloads?view=list`);
overviewPage.detailsSidebarShouldExist(false);
overviewPage.clickProjectOverviewListItem(resourceName);
overviewPage.detailsSidebarShouldExist(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Create key/value secrets', () => {

beforeEach(() => {
// ensure the test project is selected to avoid flakes
cy.visit(`/k8s/cluster/projects/${testName}`);
cy.visit(`/k8s/cluster/project.openshift.io~v1~Project/${testName}`);
nav.sidenav.clickNavLink(['Workloads', 'Secrets']);
listPage.titleShouldHaveText('Secrets');
secrets.clickCreateSecretDropdownButton('generic');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ describe('Cluster dashboard', () => {
it('has all items', () => {
cy.byLegacyTestID('inventory-card').should('be.visible');
const inventoryItems = [
{ title: 'Node', link: '/k8s/cluster/nodes' },
{ title: 'Pod', link: '/k8s/all-namespaces/pods' },
{ title: 'Node', link: '/k8s/cluster/core~v1~Node' },
{ title: 'Pod', link: '/k8s/all-namespaces/core~v1~Pod' },
{
title: 'StorageClass',
link: '/k8s/cluster/storageclasses',
link: '/k8s/cluster/storage.k8s.io~v1~StorageClass',
},
{
title: 'PersistentVolumeClaim',
link: '/k8s/all-namespaces/persistentvolumeclaims',
link: '/k8s/all-namespaces/core~v1~PersistentVolumeClaim',
},
];
inventoryItems.forEach((item, i) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Project dashboard', () => {
});

beforeEach(() => {
cy.visit(`/k8s/cluster/projects/${testName}`);
cy.visit(`/k8s/cluster/project.openshift.io~v1~Project/${testName}`);
});

describe('Details Card', () => {
Expand All @@ -36,7 +36,10 @@ describe('Project dashboard', () => {

it('has View all link', () => {
cy.byTestID('details-card-view-all').click();
cy.url().should('include', `/k8s/cluster/projects/${testName}/details`);
cy.url().should(
'include',
`/k8s/cluster/project.openshift.io~v1~Project/${testName}/details`,
);
});
});

Expand All @@ -50,7 +53,7 @@ describe('Project dashboard', () => {
describe('Inventory Card', () => {
it('has all items', () => {
const inventoryItems = [
{ kind: 'Deployment', path: `/k8s/ns/${testName}/deployments` },
{ kind: 'Deployment', path: `/k8s/ns/${testName}/apps~v1~Deployment` },
{ kind: 'DeploymentConfig', path: `/k8s/ns/${testName}/deploymentconfigs` },
{ kind: 'StatefulSets', path: `/k8s/ns/${testName}/statefulsets` },
{ kind: 'Pod', path: `/k8s/ns/${testName}/pods` },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('ExportViewLogButton', () => {
</Provider>,
);
const logButton = screen.getByTestId('export-view-log-btn');
expect(logButton).toHaveAttribute('href', '/k8s/ns/test/pods/test/logs');
expect(logButton).toHaveAttribute('href', '/k8s/ns/test/core~v1~Pod/test/logs');
});

it('should call onViewLog callback', async () => {
Expand Down
7 changes: 5 additions & 2 deletions frontend/public/components/app-contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
AlertmanagerModel,
CronJobModel,
HorizontalPodAutoscalerModel,
ProjectModel,
VolumeSnapshotModel,
} from '../models';
import { referenceForModel } from '../module/k8s';
Expand Down Expand Up @@ -131,12 +132,14 @@ const DefaultPage = connectToFlags(
// REDIRECT ROUTES FOR REACT-ROUTER-V6
const StatusProjectsRedirect = () => {
const { ns } = useParams();
return <Navigate to={`/k8s/cluster/projects/${ns}`} replace />;
return <Navigate to={`/k8s/cluster/${referenceForModel(ProjectModel)}/${ns}`} replace />;
};

const OverviewProjectsRedirect = () => {
const { ns } = useParams();
return <Navigate to={`/k8s/cluster/projects/${ns}/workloads`} replace />;
return (
<Navigate to={`/k8s/cluster/${referenceForModel(ProjectModel)}/${ns}/workloads`} replace />
);
};

const AlertManagerRedirect = () => {
Expand Down
18 changes: 14 additions & 4 deletions frontend/public/components/utils/__tests__/resource-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ describe('resourcePathFromModel', () => {
});
};

testResourcePath(ClusterRoleModel, 'my-role', null, '/k8s/cluster/clusterroles/my-role');
testResourcePath(ClusterRoleModel, null, null, '/k8s/cluster/clusterroles');
testResourcePath(PodModel, 'my-pod', 'my-project', '/k8s/ns/my-project/pods/my-pod');
testResourcePath(PodModel, null, null, '/k8s/all-namespaces/pods');
testResourcePath(
ClusterRoleModel,
'my-role',
null,
'/k8s/cluster/rbac.authorization.k8s.io~v1~ClusterRole/my-role',
);
testResourcePath(
ClusterRoleModel,
null,
null,
'/k8s/cluster/rbac.authorization.k8s.io~v1~ClusterRole',
);
testResourcePath(PodModel, 'my-pod', 'my-project', '/k8s/ns/my-project/core~v1~Pod/my-pod');
testResourcePath(PodModel, null, null, '/k8s/all-namespaces/core~v1~Pod');
testResourcePath(
MachineModel,
'my-machine',
Expand Down
8 changes: 2 additions & 6 deletions frontend/public/components/utils/resource-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getReference } from '@console/dynamic-plugin-sdk/src/utils/k8s/k8s-ref'
const unknownKinds = new Set();

export const resourcePathFromModel = (model: K8sModel, name?: string, namespace?: string) => {
const { plural, namespaced, crd } = model;
const { namespaced } = model;

let url = '/k8s/';

Expand All @@ -30,11 +30,7 @@ export const resourcePathFromModel = (model: K8sModel, name?: string, namespace?
url += namespace ? `ns/${namespace}/` : 'all-namespaces/';
}

if (crd) {
url += referenceForModel(model);
} else if (plural) {
url += plural;
}
url += referenceForModel(model);

if (name) {
// Some resources have a name that needs to be encoded. For instance,
Expand Down