Skip to content

Commit

Permalink
Fix routing for ODF 4.9(OCS) Dashboard and link Ceph Block Pools
Browse files Browse the repository at this point in the history
  • Loading branch information
bipuladh committed Aug 4, 2021
1 parent 8c7a7e6 commit 3c1af99
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 19 deletions.
16 changes: 13 additions & 3 deletions frontend/packages/ceph-storage-plugin/console-extensions.json
Expand Up @@ -176,7 +176,7 @@
{
"type": "console.page/route",
"properties": {
"path": "/odf/resource/noobaa.io~v1alpha1~BackingStore/~new",
"path": "/odf/resource/noobaa.io~v1alpha1~BackingStore/create/~new",
"exact": true,
"component": {
"$codeRef": "bsCreate.default"
Expand All @@ -186,7 +186,7 @@
{
"type": "console.page/route",
"properties": {
"path": "/odf/resource/noobaa.io~v1alpha1~NamespaceStore/~new",
"path": "/odf/resource/noobaa.io~v1alpha1~NamespaceStore/create/~new",
"exact": true,
"component": {
"$codeRef": "nssCreate.default"
Expand All @@ -196,11 +196,21 @@
{
"type": "console.page/route",
"properties": {
"path": "/odf/resource/noobaa.io~v1alpha1~BucketClass/~new",
"path": "/odf/resource/noobaa.io~v1alpha1~BucketClass/create/~new",
"exact": true,
"component": {
"$codeRef": "bcCreate.default"
}
}
},
{
"type": "console.page/route",
"properties": {
"path": "/odf/system/ocs.openshift.io~v1~StorageCluster/:systemName",
"exact": false,
"component": {
"$codeRef": "odfSystemDashboard.default"
}
}
}
]
Expand Up @@ -379,6 +379,9 @@
"Storage Efficiency": "Storage Efficiency",
"OpenShift Container Storage Overview": "OpenShift Container Storage Overview",
"Block and File": "Block and File",
"Storage pools": "Storage pools",
"Storage systems": "Storage systems",
"Storage system details": "Storage system details",
"Storage Classes": "Storage Classes",
"Pods": "Pods",
"{{metricType}}": "{{metricType}}",
Expand Down
3 changes: 2 additions & 1 deletion frontend/packages/ceph-storage-plugin/package.json
Expand Up @@ -35,7 +35,8 @@
"resourceListPage": "./src/components/odf-resources/resource-list-page.tsx",
"bsCreate": "./src/components/create-backingstore-page/create-bs-page.tsx",
"bcCreate": "./src/components/bucket-class/create-bc.tsx",
"nssCreate": "./src/components/namespace-store/create-namespace-store.tsx"
"nssCreate": "./src/components/namespace-store/create-namespace-store.tsx",
"odfSystemDashboard": "./src/components/dashboards/odf-system-dashboard.tsx"
}
}
}
Expand Up @@ -50,8 +50,8 @@ const BLOCK_FILE = 'block-file';
const OBJECT = 'object';

const sortPages = (a: Page, b: Page): number => {
if (a.href === BLOCK_FILE) return -1;
if (b.href === OBJECT) return 1;
if (a.href === BLOCK_FILE || a.href === `overview/${BLOCK_FILE}`) return -1;
if (b.href === OBJECT || a.href === `overview/${OBJECT}`) return 1;
return 0;
};

Expand Down Expand Up @@ -144,19 +144,19 @@ const OCSSystemDashboard: React.FC<DashboardsPageProps> = ({
const showInternalDashboard = !isIndependent && isCephAvailable;

const internalPage = {
href: BLOCK_FILE,
href: !isOCS ? `overview/${BLOCK_FILE}` : BLOCK_FILE,
name: t('ceph-storage-plugin~Block and File'),
component: () => <PersistentInternalDashboard />,
component: PersistentInternalDashboard,
};
const externalPage = {
href: BLOCK_FILE,
href: !isOCS ? `overview/${BLOCK_FILE}` : BLOCK_FILE,
name: t('ceph-storage-plugin~Block and File'),
component: () => <PersistentExternalDashboard />,
component: PersistentExternalDashboard,
};
const objectPage = {
href: OBJECT,
href: !isOCS ? `overview/${OBJECT}` : OBJECT,
name: t('ceph-storage-plugin~Object'),
component: () => <ObjectServiceDashboard />,
component: ObjectServiceDashboard,
};

React.useEffect(() => {
Expand All @@ -183,12 +183,12 @@ const OCSSystemDashboard: React.FC<DashboardsPageProps> = ({
React.useEffect(() => {
if (!location.pathname.includes(BLOCK_FILE) && !location.pathname.includes(OBJECT)) {
if (isCephAvailable === true) {
history.push(`${match.path}/${BLOCK_FILE}`);
history.push(`${match.url}/${BLOCK_FILE}`);
} else if (isCephAvailable === false && isObjectServiceAvailable) {
history.push(`${match.path}/${OBJECT}`);
history.push(`${match.url}/${OBJECT}`);
}
}
}, [isCephAvailable, isObjectServiceAvailable, history, match.path, location.pathname]);
}, [isCephAvailable, isObjectServiceAvailable, history, match.url, location.pathname]);

return kindsInFlight && k8sModels.size === 0 ? (
<LoadingBox />
Expand Down
@@ -0,0 +1,66 @@
import * as React from 'react';
import { connect } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
import {
DashboardsPageProps,
mapStateToProps,
} from '@console/internal/components/dashboard/dashboards-page/dashboards';
import { Page, HorizontalNav, LoadingBox, PageHeading } from '@console/internal/components/utils';
// eslint-disable-next-line import/no-named-default
import { default as OCSOverview } from './ocs-system-dashboard';
import { BlockPoolListPage } from '../block-pool/block-pool-list-page';
import { CEPH_STORAGE_NAMESPACE } from '../../constants';

const ODFSystemDashboard: React.FC<DashboardsPageProps> = ({
kindsInFlight,
k8sModels,
...rest
}) => {
const { t } = useTranslation();
const pages: Page[] = [
{
path: 'overview/:dashboard',
href: 'overview/block-file',
name: t('ceph-storage-plugin~Overview'),
component: OCSOverview,
},
{
href: 'pools',
name: t('ceph-storage-plugin~Storage pools'),
component: () => <BlockPoolListPage namespace={CEPH_STORAGE_NAMESPACE} />,
},
];

const breadcrumbs = [
{
name: t('ceph-storage-plugin~Storage systems'),
path: '/odf/systems',
},
{
name: t('ceph-storage-plugin~Storage system details'),
path: '',
},
];

const title = (rest.match.params as any).systemName;

const location = useLocation();

React.useEffect(() => {
if (location.pathname.endsWith('overview')) {
rest.history.push(`${location.pathname}/block-file`);
}
}, [rest.history, location.pathname]);

return kindsInFlight && k8sModels.size === 0 ? (
<LoadingBox />
) : (
<>
<PageHeading title={title} breadcrumbs={breadcrumbs} detail />
<HorizontalNav match={rest.match} pages={pages} noStatusBox />
</>
);
};

export default connect(mapStateToProps)(ODFSystemDashboard);
Expand Up @@ -132,7 +132,7 @@ type GenericListPageProps = {
const GenericListPage: React.FC<GenericListPageProps> = (props) => {
const { resourceKind } = props;
const createProps = {
to: `/odf/resource/${resourceKind}/~new`,
to: `/odf/resource/${resourceKind}/create/~new`,
};
return (
<ListPage
Expand Down
6 changes: 3 additions & 3 deletions frontend/packages/ceph-storage-plugin/src/plugin.ts
Expand Up @@ -463,7 +463,7 @@ const plugin: Plugin<ConsumedExtensions> = [
page: {
// t('ceph-storage-plugin~Backing Store')
name: '%ceph-storage-plugin~Backing Store%',
href: 'resource/noobaa.io~v1alpha1~BucketClass',
href: 'resource/noobaa.io~v1alpha1~BackingStore',
},
loader: async () =>
(
Expand All @@ -489,7 +489,7 @@ const plugin: Plugin<ConsumedExtensions> = [
await import(
'./components/odf-resources/resource-list-page' /* webpackChunkName: "odf-system-list" */
)
).BackingStoreListPage,
).BucketClassListPage,
},
},
// Adding this Extension because dynamic endpoint is not avbl
Expand All @@ -508,7 +508,7 @@ const plugin: Plugin<ConsumedExtensions> = [
await import(
'./components/odf-resources/resource-list-page' /* webpackChunkName: "odf-system-list" */
)
).BackingStoreListPage,
).NamespaceStoreListPage,
},
},
];
Expand Down

0 comments on commit 3c1af99

Please sign in to comment.