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
42 changes: 42 additions & 0 deletions apps/ocp-plugin/console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
"section": "fctl"
}
},
{
"type": "console.navigation/href",
"properties": {
"id": "fctl-catalog",
"name": "%plugin__flightctl-plugin~Software Catalog%",
"href": "/edge/catalog",
"perspective": "acm",
"section": "fctl"
}
},
{
"type": "console.navigation/href",
"properties": {
Expand Down Expand Up @@ -87,6 +97,14 @@
"component": { "$codeRef": "FleetDetailsPage" }
}
},
{
"type": "console.page/route",
"properties": {
"exact": false,
"path": ["/edge/fleets/catalog/:fleetId/:catalogId/:itemId"],
"component": { "$codeRef": "CatalogEditFleetWizard" }
}
},
{
"type": "console.page/route",
"properties": {
Expand All @@ -111,6 +129,30 @@
"component": { "$codeRef": "EditDeviceWizardPage" }
}
},
{
"type": "console.page/route",
"properties": {
"exact": false,
"path": ["/edge/devices/catalog/:deviceId/:catalogId/:itemId"],
"component": { "$codeRef": "CatalogEditDeviceWizard" }
}
},
{
"type": "console.page/route",
"properties": {
"exact": true,
"path": ["/edge/catalog"],
"component": { "$codeRef": "CatalogPage" }
}
},
{
"type": "console.page/route",
"properties": {
"exact": false,
"path": ["/edge/catalog/install/:catalogId/:itemId"],
"component": { "$codeRef": "CatalogInstallWizard" }
}
},
{
"type": "console.page/route",
"properties": {
Expand Down
7 changes: 6 additions & 1 deletion apps/ocp-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"ResourceSyncToRepositoryPage": "./src/components/ResourceSyncs/ResourceSyncToRepositoryPage.tsx",
"EnrollmentRequestDetailsPage": "./src/components/EnrollmentRequests/EnrollmentRequestDetailsPage.tsx",
"appContext": "./src/components/AppContext/AppContext.tsx",
"OverviewTab": "./src/components/OverviewTab/OverviewTab.tsx"
"OverviewTab": "./src/components/OverviewTab/OverviewTab.tsx",
"CatalogPage": "./src/components/Catalog/CatalogPage.tsx",
"CatalogInstallWizard": "./src/components/Catalog/CatalogInstallWizard.tsx",
"CatalogEditDeviceWizard": "./src/components/Catalog/CatalogEditDeviceWizard.tsx",
"CatalogEditFleetWizard": "./src/components/Catalog/CatalogEditFleetWizard.tsx"
},
"dependencies": {
"@console/pluginAPI": "*"
Expand Down Expand Up @@ -74,6 +78,7 @@
"@patternfly/react-icons": "^6.4.0",
"@patternfly/react-styles": "^6.4.0",
"@patternfly/react-table": "^6.4.0",
"@patternfly/react-topology": "^6.4.0",
"@types/react-redux": "^7.1.33",
"formik": "^2.4.5",
"fuzzysearch": "^1.0.3",
Expand Down
4 changes: 4 additions & 0 deletions apps/ocp-plugin/src/components/AppContext/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const appRoutes = {
[ROUTE.AUTH_PROVIDER_CREATE]: '/',
[ROUTE.AUTH_PROVIDER_EDIT]: '/',
[ROUTE.AUTH_PROVIDER_DETAILS]: '/',
[ROUTE.CATALOG]: '/edge/catalog',
[ROUTE.CATALOG_INSTALL]: '/edge/catalog/install',
[ROUTE.CATALOG_FLEET_EDIT]: '/edge/fleets/catalog',
[ROUTE.CATALOG_DEVICE_EDIT]: '/edge/devices/catalog',
};

export const useValuesAppContext = (): AppContextProps => {
Expand Down
13 changes: 13 additions & 0 deletions apps/ocp-plugin/src/components/Catalog/CatalogEditDeviceWizard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import { EditDeviceWizard } from '@flightctl/ui-components/src/components/Catalog/EditWizard/EditWizard';
import WithPageLayout from '../common/WithPageLayout';

const CatalogEditDeviceWizard = () => {
return (
<WithPageLayout>
<EditDeviceWizard />
</WithPageLayout>
);
};

export default CatalogEditDeviceWizard;
13 changes: 13 additions & 0 deletions apps/ocp-plugin/src/components/Catalog/CatalogEditFleetWizard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import { EditFleetWizard } from '@flightctl/ui-components/src/components/Catalog/EditWizard/EditWizard';
import WithPageLayout from '../common/WithPageLayout';

const CatalogEditFleetWizard = () => {
return (
<WithPageLayout>
<EditFleetWizard />
</WithPageLayout>
);
};

export default CatalogEditFleetWizard;
13 changes: 13 additions & 0 deletions apps/ocp-plugin/src/components/Catalog/CatalogInstallWizard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import InstallWizard from '@flightctl/ui-components/src/components/Catalog/InstallWizard/InstallWizard';
import WithPageLayout from '../common/WithPageLayout';

const OcpInstallWizard = () => {
return (
<WithPageLayout>
<InstallWizard />
</WithPageLayout>
);
};

export default OcpInstallWizard;
13 changes: 13 additions & 0 deletions apps/ocp-plugin/src/components/Catalog/CatalogPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import CatalogPage from '@flightctl/ui-components/src/components/Catalog/CatalogPage';
import WithPageLayout from '../common/WithPageLayout';

const OcpCatalogPage = () => {
return (
<WithPageLayout>
<CatalogPage />
</WithPageLayout>
);
};

export default OcpCatalogPage;
15 changes: 15 additions & 0 deletions apps/ocp-plugin/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
declare module '*.png';
declare module '*.jpg';
declare module '*.jpeg';
declare module '*.gif';
declare module '*.svg' {
const content: string;
export default content;
}
declare module '*.css';
declare module '*.wav';
declare module '*.mp3';
declare module '*.m4a';
declare module '*.rdf';
declare module '*.ttl';
declare module '*.pdf';
10 changes: 9 additions & 1 deletion apps/ocp-plugin/src/utils/apiCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare global {
}
}

type Api = 'flightctl' | 'imagebuilder' | 'alerts';
type Api = 'flightctl' | 'imagebuilder' | 'alerts' | 'catalog';

const addRequiredHeaders = (options: RequestInit, api?: Api): RequestInit => {
const token = getCSRFToken();
Expand Down Expand Up @@ -47,6 +47,8 @@ export const uiProxy = `${window.location.protocol}//${apiServer}`;
const flightCtlAPI = `${uiProxy}/api/flightctl`;
const alertsAPI = `${uiProxy}/api/alerts`;
const imageBuilderPathRegex = /^image(builds|exports)/;
const catalogPathRegex = /^(catalogs|catalogitems)/;

export const wsEndpoint = `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${apiServer}`;

export const fetchUiProxy = async (endpoint: string, requestInit: RequestInit): Promise<Response> => {
Expand All @@ -62,6 +64,12 @@ const getFullApiUrl = (path: string): { api: Api; url: string } => {
if (imageBuilderPathRegex.test(path)) {
return { api: 'imagebuilder', url: `${uiProxy}/api/imagebuilder/api/v1/${path}` };
}
if (catalogPathRegex.test(path)) {
return {
api: 'catalog',
url: `${flightCtlAPI}/api/v1/${path}`,
};
}
return { api: 'flightctl', url: `${flightCtlAPI}/api/v1/${path}` };
};

Expand Down
1 change: 1 addition & 0 deletions apps/ocp-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@flightctl/ui-components/*": ["../../libs/ui-components/*"],
"@flightctl/types": ["../../libs/types"],
"@flightctl/types/imagebuilder": ["../../libs/types/imagebuilder"],
"@flightctl/types/alpha": ["../../libs/types/alpha"],
},
},
"include": ["**/*.ts", "**/*.tsx", "**/*.jsx", "**/*.js", "**/*.json"],
Expand Down
10 changes: 9 additions & 1 deletion apps/ocp-plugin/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ const config: Configuration & {
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|jpg|jpeg|gif|svg|woff2?|ttf|eot|otf)(\?.*$|$)/,
test: /\.(jpg|jpeg|png|gif|svg)$/i,
include: [path.resolve(__dirname, '../../libs/ui-components/assets')],
type: 'asset/resource',
generator: {
filename: 'assets/[name].[ext]',
},
},
{
test: /\.(woff2?|ttf|eot|otf)(\?.*$|$)/,
loader: 'file-loader',
options: {
name: 'assets/[name].[ext]',
Expand Down
1 change: 1 addition & 0 deletions apps/standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@patternfly/react-icons": "^6.4.0",
"@patternfly/react-styles": "^6.4.0",
"@patternfly/react-table": "^6.4.0",
"@patternfly/react-topology": "^6.4.0",
"formik": "^2.4.5",
"fuzzysearch": "^1.0.3",
"i18next": "^21.8.14",
Expand Down
59 changes: 59 additions & 0 deletions apps/standalone/src/app/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ const CreateImageBuildWizard = React.lazy(
() => import('@flightctl/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/CreateImageBuildWizard'),
);

const CatalogPage = React.lazy(() => import('@flightctl/ui-components/src/components/Catalog/CatalogPage'));
const CatalogInstallWizard = React.lazy(
() => import('@flightctl/ui-components/src/components/Catalog/InstallWizard/InstallWizard'),
);
const CatalogEditFleetWizard = React.lazy(() =>
import('@flightctl/ui-components/src/components/Catalog/EditWizard/EditWizard').then((module) => ({
default: module.EditFleetWizard,
})),
);

const CatalogEditDeviceWizard = React.lazy(() =>
import('@flightctl/ui-components/src/components/Catalog/EditWizard/EditWizard').then((module) => ({
default: module.EditDeviceWizard,
})),
);

export type ExtendedRouteObject = RouteObject & {
title?: string;
showInNav?: boolean;
Expand Down Expand Up @@ -215,6 +231,15 @@ const getAppRoutes = (t: TFunction): ExtendedRouteObject[] => [
</TitledRoute>
),
},
{
path: 'catalog/:fleetId/:catalogId/:itemId',
title: t('Edit Fleet'),
element: (
<TitledRoute title={t('Edit Fleet')}>
<CatalogEditFleetWizard />
</TitledRoute>
),
},
{
path: ':fleetId/*',
title: t('Fleet Details'),
Expand Down Expand Up @@ -264,6 +289,40 @@ const getAppRoutes = (t: TFunction): ExtendedRouteObject[] => [
</TitledRoute>
),
},
{
path: 'catalog/:deviceId/:catalogId/:itemId',
title: t('Edit device'),
element: (
<TitledRoute title={t('Edit device')}>
<CatalogEditDeviceWizard />
</TitledRoute>
),
},
],
},
{
path: '/catalog',
title: t('Software Catalog'),
showInNav: true,
children: [
{
index: true,
title: t('Software Catalog'),
element: (
<TitledRoute title={t('Catalog')}>
<CatalogPage />
</TitledRoute>
),
},
{
path: 'install/:catalogId/:itemId',
title: t('Install Catalog item'),
element: (
<TitledRoute title={t('Install Catalog item')}>
<CatalogInstallWizard />
</TitledRoute>
),
},
],
},
{
Expand Down
9 changes: 8 additions & 1 deletion apps/standalone/src/app/utils/apiCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const flightCtlAPI = `${window.location.protocol}//${apiServer}/api/flightctl`;
const uiProxyAPI = `${window.location.protocol}//${apiServer}/api`;

const imageBuilderPathRegex = /^image(builds|exports)/;
const catalogPathRegex = /^(catalogs|catalogitems)/;

export const loginAPI = `${window.location.protocol}//${apiServer}/api/login`;
export const wsEndpoint = `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${apiServer}`;
Expand Down Expand Up @@ -45,13 +46,19 @@ export const fetchUiProxy = async (endpoint: string, requestInit: RequestInit):
return await fetch(`${uiProxyAPI}/${endpoint}`, options);
};

const getFullApiUrl = (path: string): { api: 'flightctl' | 'imagebuilder' | 'alerts'; url: string } => {
const getFullApiUrl = (path: string): { api: 'flightctl' | 'imagebuilder' | 'alerts' | 'catalog'; url: string } => {
if (path.startsWith('alerts')) {
return { api: 'alerts', url: `${uiProxyAPI}/alerts/api/v2/${path}` };
}
if (imageBuilderPathRegex.test(path)) {
return { api: 'imagebuilder', url: `${uiProxyAPI}/imagebuilder/api/v1/${path}` };
}
if (catalogPathRegex.test(path)) {
return {
api: 'catalog',
url: `${flightCtlAPI}/api/v1/${path}`,
};
}
return { api: 'flightctl', url: `${flightCtlAPI}/api/v1/${path}` };
};

Expand Down
1 change: 1 addition & 0 deletions apps/standalone/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@flightctl/ui-components/*": ["../../libs/ui-components/*"],
"@flightctl/types": ["../../libs/types"],
"@flightctl/types/imagebuilder": ["../../libs/types/imagebuilder"],
"@flightctl/types/alpha": ["../../libs/types/alpha"],
},
},
"include": ["**/*.ts", "**/*.tsx", "**/*.jsx", "**/*.js", "**/*.json"],
Expand Down
10 changes: 1 addition & 9 deletions apps/standalone/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const config: Configuration & {
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'src/assets/images'),
path.resolve(__dirname, '../../libs/ui-components/assets'),
path.resolve(__dirname, 'node_modules/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/images'),
path.resolve(__dirname, 'node_modules/@patternfly/react-styles/css/assets/images'),
Expand All @@ -127,15 +128,6 @@ const config: Configuration & {
),
],
type: 'asset/inline',
use: [
{
options: {
limit: 5000,
outputPath: 'images',
name: '[name].[ext]',
},
},
],
},
],
},
Expand Down
Loading