Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9722 from bipuladh/fix-dashboard
Bug 1989876: Fix routing for ODF 4.9(OCS) Dashboard and link Ceph Block Pools
- Loading branch information
Showing
7 changed files
with
109 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
frontend/packages/ceph-storage-plugin/src/components/dashboards/odf-system-dashboard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import * as React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useLocation, match as Match } 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'; | ||
import { referenceForModel } from '@console/internal/module/k8s'; | ||
// eslint-disable-next-line import/no-named-default | ||
import { default as OCSOverview, BLOCK_FILE } from './ocs-system-dashboard'; | ||
import { BlockPoolListPage } from '../block-pool/block-pool-list-page'; | ||
import { CEPH_STORAGE_NAMESPACE } from '../../constants'; | ||
import { CephBlockPoolModel } from '../../models'; | ||
|
||
type ODFSystemDashboardPageProps = Omit<DashboardsPageProps, 'match'> & { | ||
match: Match<{ systemName: string }>; | ||
}; | ||
|
||
const ODFSystemDashboard: React.FC<ODFSystemDashboardPageProps> = ({ | ||
kindsInFlight, | ||
k8sModels, | ||
...rest | ||
}) => { | ||
const { t } = useTranslation(); | ||
const { systemName } = rest.match.params; | ||
const pages: Page[] = [ | ||
{ | ||
path: 'overview/:dashboard', | ||
href: 'overview/block-file', | ||
name: t('ceph-storage-plugin~Overview'), | ||
component: OCSOverview, | ||
}, | ||
{ | ||
href: referenceForModel(CephBlockPoolModel), | ||
name: t('ceph-storage-plugin~BlockPools'), | ||
component: () => <BlockPoolListPage namespace={CEPH_STORAGE_NAMESPACE} />, | ||
}, | ||
]; | ||
|
||
const breadcrumbs = [ | ||
{ | ||
name: t('ceph-storage-plugin~StorageSystems'), | ||
path: '/odf/systems', | ||
}, | ||
{ | ||
name: t('ceph-storage-plugin~StorageSystem details'), | ||
path: '', | ||
}, | ||
]; | ||
|
||
const title = rest.match.params.systemName; | ||
|
||
const location = useLocation(); | ||
|
||
React.useEffect(() => { | ||
if (location.pathname.endsWith(systemName)) { | ||
rest.history.push(`${location.pathname}/overview/${BLOCK_FILE}`); | ||
} else if (location.pathname.endsWith('overview')) { | ||
rest.history.push(`${location.pathname}/${BLOCK_FILE}`); | ||
} | ||
}, [rest.history, location.pathname, systemName]); | ||
|
||
return kindsInFlight && k8sModels.size === 0 ? ( | ||
<LoadingBox /> | ||
) : ( | ||
<> | ||
<PageHeading title={title} breadcrumbs={breadcrumbs} detail /> | ||
<HorizontalNav match={rest.match} pages={pages} noStatusBox /> | ||
</> | ||
); | ||
}; | ||
|
||
export default connect(mapStateToProps)(ODFSystemDashboard); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters