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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const isPagePresent = (pages: Page[], page: Page): boolean =>
pages.some((p) => page.href === p.href);

export const BLOCK_FILE = 'block-file';
const OBJECT = 'object';
export const OBJECT = 'object';

const sortPages = (a: Page, b: Page): number => {
if (a.href === BLOCK_FILE || a.href === `overview/${BLOCK_FILE}`) return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import {
} from '@console/internal/components/dashboard/dashboards-page/dashboards';
import { Page, HorizontalNav, LoadingBox, PageHeading } from '@console/internal/components/utils';
import { referenceForModel } from '@console/internal/module/k8s';
import { useFlag } from '@console/shared/src/hooks/flag';
// eslint-disable-next-line import/no-named-default
import { default as OCSOverview, BLOCK_FILE } from './ocs-system-dashboard';
import { default as OCSOverview, BLOCK_FILE, OBJECT } from './ocs-system-dashboard';
import { BlockPoolListPage } from '../block-pool/block-pool-list-page';
import { CEPH_STORAGE_NAMESPACE } from '../../constants';
import { CephBlockPoolModel } from '../../models';
import { MCG_FLAG, CEPH_FLAG } from '../../features';

type ODFSystemDashboardPageProps = Omit<DashboardsPageProps, 'match'> & {
match: Match<{ systemName: string }>;
Expand All @@ -24,11 +26,16 @@ const ODFSystemDashboard: React.FC<ODFSystemDashboardPageProps> = ({
...rest
}) => {
const { t } = useTranslation();
const isObjectServiceAvailable = useFlag(MCG_FLAG);
const isCephAvailable = useFlag(CEPH_FLAG);
const { systemName } = rest.match.params;
const dashboardTab = isCephAvailable === false && isObjectServiceAvailable ? OBJECT : BLOCK_FILE;
const defaultDashboard = React.useRef(dashboardTab);

const pages: Page[] = [
{
path: 'overview/:dashboard',
href: 'overview/block-file',
href: `overview/${defaultDashboard.current}`,
name: t('ceph-storage-plugin~Overview'),
component: OCSOverview,
},
Expand Down Expand Up @@ -56,11 +63,15 @@ const ODFSystemDashboard: React.FC<ODFSystemDashboardPageProps> = ({

React.useEffect(() => {
if (location.pathname.endsWith(systemName)) {
rest.history.push(`${location.pathname}/overview/${BLOCK_FILE}`);
rest.history.push(`${location.pathname}/overview/${defaultDashboard.current}`);
} else if (location.pathname.endsWith('overview')) {
rest.history.push(`${location.pathname}/${BLOCK_FILE}`);
rest.history.push(`${location.pathname}/${defaultDashboard.current}`);
} else if (defaultDashboard.current !== dashboardTab) {
const pathname = location.pathname.substring(0, location.pathname.lastIndexOf('/overview'));
rest.history.push(`${pathname}/overview/${dashboardTab}`);
defaultDashboard.current = dashboardTab;
}
}, [rest.history, location.pathname, systemName]);
}, [rest.history, location.pathname, systemName, dashboardTab]);

return kindsInFlight && k8sModels.size === 0 ? (
<LoadingBox />
Expand Down
11 changes: 11 additions & 0 deletions frontend/packages/ceph-storage-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,17 @@ const plugin: Plugin<ConsumedExtensions> = [
disallowed: [ODF_MANAGED_FLAG, ODF_MODEL_FLAG],
},
},
{
type: 'Page/Route',
properties: {
path: `/ocs-dashboards`,
loader: () => import('./components/dashboards/ocs-system-dashboard').then((m) => m.default),
},
flags: {
required: [MCG_FLAG],
disallowed: [OCS_FLAG, ODF_MODEL_FLAG],
},
},
{
type: 'Project/Dashboard/Inventory/Item',
properties: {
Expand Down