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
14 changes: 0 additions & 14 deletions apps/app-frontend/src/shell/AdminCatalogRoutes.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/app-frontend/src/shell/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { ClusterRoutes } from '@osac/ui-components/pages/tenant/ClusterRoutes';
import { VmCreatePage } from '@osac/ui-components/pages/tenant/VmCreatePage';
import { VmListPage } from '@osac/ui-components/pages/tenant/VmListPage';

import { AdminCatalogRoutes } from './AdminCatalogRoutes';
import { ShellMasthead } from './ShellMasthead';
import { defaultRouteForRole } from './shellRoutes';
import { ShellSidebar } from './ShellSidebar';
Expand Down Expand Up @@ -119,17 +118,6 @@ export const AppShell = ({ logout }: { logout: () => Promise<void> }) => {
}
/>

{(role === 'providerAdmin' || role === 'tenantAdmin') && (
<Route
path="/admin/catalog/*"
element={
<ShellRoute>
<AdminCatalogRoutes />
</ShellRoute>
}
/>
)}

<Route path="*" element={<Navigate to={defaultRoute} replace />} />
</Routes>
</Page>
Expand Down
17 changes: 3 additions & 14 deletions apps/app-frontend/src/shell/shellNav.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { tIdentity } from '@osac/ui-components/test-utils/i18n';
import { navRowsForRole } from './shellNav';

const roles: DemoShellRole[] = ['tenantUser', 'tenantAdmin', 'providerAdmin'];
const adminRoles: DemoShellRole[] = ['tenantAdmin', 'providerAdmin'];

const findSection = (role: DemoShellRole, sectionId: string) =>
navRowsForRole(role, tIdentity).find((row) => row.sectionId === sectionId);
Expand Down Expand Up @@ -37,19 +36,9 @@ describe('navRowsForRole', () => {
}
});

it('includes Administration section with Catalog management for admin roles', () => {
for (const role of adminRoles) {
const admin = findSection(role, 'nav-administration');
expect(admin).toBeDefined();
expect(admin?.label).toBe('Administration');
expect(admin?.children).toEqual([
{ id: 'catalog-management', label: 'Catalog management', path: '/admin/catalog' },
]);
it('does not include an Administration section for any role', () => {
for (const role of roles) {
expect(findSection(role, 'nav-administration')).toBeUndefined();
}
});

it('does not include Administration section for tenantUser', () => {
const admin = findSection('tenantUser', 'nav-administration');
expect(admin).toBeUndefined();
});
});
17 changes: 1 addition & 16 deletions apps/app-frontend/src/shell/shellNav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,4 @@ const getBaseNav = (t: TFunction): NavRow[] => [
},
];

export const navRowsForRole = (role: DemoShellRole, t: TFunction): NavRow[] => {
const rows = getBaseNav(t);

if (role === 'providerAdmin' || role === 'tenantAdmin') {
rows.push({
kind: 'section',
sectionId: 'nav-administration',
label: t('Administration'),
children: [
{ id: 'catalog-management', label: t('Catalog management'), path: '/admin/catalog' },
],
});
}

return rows;
};
export const navRowsForRole = (_role: DemoShellRole, t: TFunction): NavRow[] => getBaseNav(t);
11 changes: 0 additions & 11 deletions libs/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"Add": "Add",
"Add node set": "Add node set",
"Add rule": "Add rule",
"Administration": "Administration",
"All": "All",
"API URL": "API URL",
"At least one CIDR (IPv4 or IPv6) is required": "At least one CIDR (IPv4 or IPv6) is required",
Expand All @@ -22,8 +21,6 @@
"Catalog": "Catalog",
"Catalog configuration is unavailable for this virtual machine.": "Catalog configuration is unavailable for this virtual machine.",
"Catalog item": "Catalog item",
"Catalog management": "Catalog management",
"Catalog management resource type tabs": "Catalog management resource type tabs",
"catalogProvision.actions.back": "Back",
"catalogProvision.actions.cancel": "Cancel",
"catalogProvision.actions.create": "Create",
Expand Down Expand Up @@ -158,7 +155,6 @@
"Failed to load security groups": "Failed to load security groups",
"Failed to load subnets": "Failed to load subnets",
"Filter bare metal instances by name": "Filter bare metal instances by name",
"Filter by publication status": "Filter by publication status",
"Filter catalog by keyword": "Filter catalog by keyword",
"Filter catalog by resource type": "Filter catalog by resource type",
"Fixed": "Fixed",
Expand Down Expand Up @@ -201,8 +197,6 @@
"No bare metal instances match your search.": "No bare metal instances match your search.",
"No bare metal instances yet.": "No bare metal instances yet.",
"No catalog items found": "No catalog items found",
"No catalog items have been created yet.": "No catalog items have been created yet.",
"No catalog items match your search or filter.": "No catalog items match your search or filter.",
"No catalog items match your search.": "No catalog items match your search.",
"No inbound rules yet. Add one to allow incoming traffic.": "No inbound rules yet. Add one to allow incoming traffic.",
"No node sets added yet.": "No node sets added yet.",
Expand All @@ -221,8 +215,6 @@
"Nodes": "Nodes",
"Open catalog item details for {{title}}": "Open catalog item details for {{title}}",
"Optional cloud-init user data (max 64 KB).": "Optional cloud-init user data (max 64 KB).",
"Organization": "Organization",
"Organization: {{name}}": "Organization: {{name}}",
"Outbound Rules": "Outbound Rules",
"Overview": "Overview",
"Parent virtual network": "Parent virtual network",
Expand All @@ -240,7 +232,6 @@
"Port To": "Port To",
"Port To is required for TCP/UDP": "Port To is required for TCP/UDP",
"Port To must be >= Port From": "Port To must be >= Port From",
"Project: {{name}}": "Project: {{name}}",
"Protocol": "Protocol",
"Protocol is required": "Protocol is required",
"Provision a bare metal instance from a catalog item.": "Provision a bare metal instance from a catalog item.",
Expand All @@ -249,7 +240,6 @@
"Provisioning failed": "Provisioning failed",
"Public IP": "Public IP",
"Public SSH key is required": "Public SSH key is required",
"Published": "Published",
"Pull secret": "Pull secret",
"Pull secret is required": "Pull secret is required",
"Pull secrets download OpenShift components and connect clusters to your Red Hat account. Copy the full JSON from OpenShift Cluster Manager (console.redhat.com/openshift/install/pull-secret).": "Pull secrets download OpenShift components and connect clusters to your Red Hat account. Copy the full JSON from OpenShift Cluster Manager (console.redhat.com/openshift/install/pull-secret).",
Expand Down Expand Up @@ -299,7 +289,6 @@
"UDP": "UDP",
"Unauthorized": "Unauthorized",
"Unknown": "Unknown",
"Unpublished": "Unpublished",
"Use IPv4 CIDR notation (for example 10.128.0.0/14).": "Use IPv4 CIDR notation (for example 10.128.0.0/14).",
"Use IPv4 CIDR notation (for example 172.30.0.0/16).": "Use IPv4 CIDR notation (for example 172.30.0.0/16).",
"User data": "User data",
Expand Down
3 changes: 0 additions & 3 deletions libs/ui-components/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ export type ApiRoute =
| 'v1/baremetal_instances'
| 'v1/public_ips'
| 'v1/public_ip_attachments'
| 'v1/private/compute_instance_catalog_items'
| 'v1/private/cluster_catalog_items'
| 'v1/private/baremetal_instance_catalog_items'
| 'v1/console_sessions';

/**
Expand Down
40 changes: 2 additions & 38 deletions libs/ui-components/src/api/v1/baremetal-instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,11 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { act, renderHook, waitFor } from '@testing-library/react';
import { describe, expect, it } from 'vitest';

import type { BareMetalInstanceCatalogItem } from '@osac/types';
import {
BareMetalInstanceCatalogItems,
BareMetalInstanceRunStrategy,
BareMetalInstances,
} from '@osac/types';
import { BareMetalInstanceRunStrategy, BareMetalInstances } from '@osac/types';

import {
type PatchBareMetalInstanceInput,
useBareMetalInstanceCatalogItems,
usePatchBareMetalInstance,
} from './baremetal-instance';
import { createCatalogHookTests } from '../../test-utils/catalogHookTestHelpers';
import { type PatchBareMetalInstanceInput, usePatchBareMetalInstance } from './baremetal-instance';
import { ApiProvider } from '../api-context';

const item: BareMetalInstanceCatalogItem = {
$typeName: 'osac.public.v1.BareMetalInstanceCatalogItem',
id: 'public-1',
title: 'Public bare metal item',
description: '',
template: '',
published: true,
fieldDefinitions: [],
};

describe('useBareMetalInstanceCatalogItems', () => {
createCatalogHookTests({
endpointDescription: 'public BareMetalInstanceCatalogItems',
useHook: useBareMetalInstanceCatalogItems,
role: 'tenantAdmin',
item,
registerList: (router, onList) =>
router.service(BareMetalInstanceCatalogItems, {
list: () => {
onList?.();
return { items: [item] };
},
}),
});
});

const makeBmi = (id: string) => ({
id,
metadata: { name: `bmi-${id}` },
Expand Down
10 changes: 5 additions & 5 deletions libs/ui-components/src/api/v1/baremetal-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from '@osac/types';

import { useApiFetch } from '../api-context';
import { type ListParams, apiQueryKey } from '../types';
import { type ApiQueryClient, useApiQuery, useApiQueryClient } from '../use-api-query';
import { apiQueryKey } from '../types';
import { buildUpdateMaskPaths } from './update-mask';
import { type ApiQueryClient, useApiQuery, useApiQueryClient } from '../use-api-query';

export const useBareMetalInstances = () => {
const client = useApiFetch(BareMetalInstances);
Expand All @@ -32,11 +32,11 @@ export const useBareMetalInstance = (id: string) => {
});
};

export const useBareMetalInstanceCatalogItems = (params: ListParams = {}, enabled = true) => {
export const useBareMetalInstanceCatalogItems = (enabled = true) => {
const client = useApiFetch(BareMetalInstanceCatalogItems);
return useApiQuery({
queryKey: apiQueryKey('v1/baremetal_instance_catalog_items', undefined, params),
queryFn: () => client.list(params),
queryKey: apiQueryKey('v1/baremetal_instance_catalog_items'),
queryFn: () => client.list({}),
select: (data) => data.items,
enabled,
});
Expand Down
33 changes: 0 additions & 33 deletions libs/ui-components/src/api/v1/cluster-catalog-item.test.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading