Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create topology side panel using dynamic plugin extensions
- Loading branch information
Showing
17 changed files
with
415 additions
and
8 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
5 changes: 3 additions & 2 deletions
5
frontend/packages/helm-plugin/src/components/details-page/overview/HelmReleaseOverview.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
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 @@ | ||
export * from './release-panel'; |
6 changes: 6 additions & 0 deletions
6
frontend/packages/helm-plugin/src/topology/sidebar/release-panel/index.ts
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,6 @@ | ||
export { default as getHelmReleasePanelResourceLink } from './resource-link'; | ||
export { | ||
useHelmReleasePanelDetailsTabSection as getHelmReleasePanelDetailsTabSection, | ||
useHelmReleasePanelReleaseNotesTabSection as getHelmReleasePanelReleaseNotesTabSection, | ||
useHelmReleasePanelResourceTabSection as getHelmReleasePanelResourceTabSection, | ||
} from './tab-sections'; |
27 changes: 27 additions & 0 deletions
27
frontend/packages/helm-plugin/src/topology/sidebar/release-panel/resource-link.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,27 @@ | ||
import * as React from 'react'; | ||
import { GraphElement, Node } from '@patternfly/react-topology'; | ||
import { Link } from 'react-router-dom'; | ||
import { ResourceIcon } from '@console/internal/components/utils/resource-icon'; | ||
import { getResource } from '@console/topology/src/utils'; | ||
import { TYPE_HELM_RELEASE } from '../../components/const'; | ||
|
||
const helmReleasePanelResourceLink = (element: GraphElement) => { | ||
if (element.getType() !== TYPE_HELM_RELEASE) return undefined; | ||
const name = element.getLabel(); | ||
const { namespace } = getResource(element as Node).metadata; | ||
return ( | ||
<> | ||
<ResourceIcon className="co-m-resource-icon--lg" kind="HelmRelease" /> | ||
{name && ( | ||
<Link | ||
to={`/helm-releases/ns/${namespace}/release/${name}`} | ||
className="co-resource-item__resource-name" | ||
> | ||
{name} | ||
</Link> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default helmReleasePanelResourceLink; |
51 changes: 51 additions & 0 deletions
51
frontend/packages/helm-plugin/src/topology/sidebar/release-panel/tab-sections.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,51 @@ | ||
import * as React from 'react'; | ||
import { GraphElement, Node } from '@patternfly/react-topology'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { StatusBox } from '@console/internal/components/utils/status-box'; | ||
import TopologyGroupResourcesPanel from '@console/topology/src/components/side-bar/TopologyGroupResourcesPanel'; | ||
import { getResource } from '@console/topology/src/utils'; | ||
import HelmReleaseOverview from '../../../components/details-page/overview/HelmReleaseOverview'; | ||
import { TYPE_HELM_RELEASE } from '../../components/const'; | ||
import TopologyHelmReleaseNotesPanel from '../../TopologyHelmReleaseNotesPanel'; | ||
|
||
export const useHelmReleasePanelDetailsTabSection = (element: GraphElement) => { | ||
const { t } = useTranslation(); | ||
if (element.getType() !== TYPE_HELM_RELEASE) return undefined; | ||
const secret = element.getData().resources.obj; | ||
return !secret ? ( | ||
<> | ||
<StatusBox | ||
loaded | ||
loadError={{ | ||
message: t('helm-plugin~Unable to find resource for {{helmLabel}}', { | ||
helmLabel: element.getLabel(), | ||
}), | ||
}} | ||
/> | ||
<p>Status Box</p> | ||
</> | ||
) : ( | ||
<HelmReleaseOverview obj={secret} customData={undefined} /> | ||
); | ||
}; | ||
|
||
export const useHelmReleasePanelResourceTabSection = (element: GraphElement) => { | ||
if (element.getType() !== TYPE_HELM_RELEASE) return undefined; | ||
const { manifestResources } = element.getData().data; | ||
const { namespace } = getResource(element as Node).metadata; | ||
|
||
return manifestResources ? ( | ||
<div className="overview__sidebar-pane-body"> | ||
<TopologyGroupResourcesPanel | ||
manifestResources={manifestResources} | ||
releaseNamespace={namespace} | ||
/> | ||
</div> | ||
) : null; | ||
}; | ||
|
||
export const useHelmReleasePanelReleaseNotesTabSection = (element: GraphElement) => { | ||
if (element.getType() !== TYPE_HELM_RELEASE) return undefined; | ||
const { releaseNotes } = element.getData().data; | ||
return <TopologyHelmReleaseNotesPanel releaseNotes={releaseNotes} />; | ||
}; |
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
15 changes: 15 additions & 0 deletions
15
frontend/packages/topology/src/components/side-bar/TopologySideBarContent.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,15 @@ | ||
import * as React from 'react'; | ||
import { GraphElement } from '@patternfly/react-topology'; | ||
import SideBarBody from './components/SideBarBody'; | ||
import SideBarHeading from './components/SideBarHeading'; | ||
|
||
const TopologySideBarContent: React.FC<{ element: GraphElement }> = ({ element }) => { | ||
return ( | ||
<div className="overview__sidebar-pane resource-overview"> | ||
<SideBarHeading element={element} /> | ||
<SideBarBody element={element} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TopologySideBarContent; |
60 changes: 60 additions & 0 deletions
60
frontend/packages/topology/src/components/side-bar/components/SideBarAlerts.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,60 @@ | ||
import * as React from 'react'; | ||
import { Alert, AlertActionCloseButton } from '@patternfly/react-core'; | ||
import { GraphElement } from '@patternfly/react-topology'; | ||
import { | ||
DetailsResourceAlert, | ||
DetailsResourceAlertContent, | ||
isDetailsResourceAlert, | ||
useResolvedExtensions, | ||
} from '@console/dynamic-plugin-sdk'; | ||
|
||
const ResolveResourceAlerts: React.FC<{ | ||
id?: string; | ||
dismissible?: boolean; | ||
title?: string; | ||
useResourceAlertsContent?: (element: GraphElement) => DetailsResourceAlertContent; | ||
element: GraphElement; | ||
}> = ({ title, dismissible = false, useResourceAlertsContent, element }) => { | ||
const [showAlert, setShowAlert] = React.useState<boolean>(true); | ||
const alertConfigs = useResourceAlertsContent(element); | ||
if (!alertConfigs) return null; | ||
const { variant, content, actionLinks, onClose } = alertConfigs; | ||
return showAlert ? ( | ||
<Alert | ||
isInline | ||
variant={variant} | ||
title={title} | ||
actionLinks={actionLinks} | ||
actionClose={ | ||
<AlertActionCloseButton | ||
onClose={() => { | ||
if (dismissible) setShowAlert(false); | ||
else onClose?.(); | ||
}} | ||
/> | ||
} | ||
> | ||
{content} | ||
</Alert> | ||
) : null; | ||
}; | ||
|
||
const SideBarAlerts: React.FC<{ element: GraphElement }> = ({ element }) => { | ||
const [resourceAlertsExtension, resolved] = useResolvedExtensions<DetailsResourceAlert>( | ||
isDetailsResourceAlert, | ||
); | ||
return resolved ? ( | ||
<> | ||
{resourceAlertsExtension.map(({ uid, properties: { contentProvider, ...props } }) => ( | ||
<ResolveResourceAlerts | ||
key={uid} | ||
{...props} | ||
useResourceAlertsContent={contentProvider} | ||
element={element} | ||
/> | ||
))} | ||
</> | ||
) : null; | ||
}; | ||
|
||
export default SideBarAlerts; |
22 changes: 22 additions & 0 deletions
22
frontend/packages/topology/src/components/side-bar/components/SideBarBody.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,22 @@ | ||
import * as React from 'react'; | ||
import { GraphElement } from '@patternfly/react-topology'; | ||
import { SimpleTabNav } from '@console/internal/components/utils'; | ||
import SideBarTabLoader from '../providers/SideBarTabLoader'; | ||
|
||
const SideBarBody: React.FC<{ element: GraphElement }> = ({ element }) => { | ||
return ( | ||
<SideBarTabLoader element={element}> | ||
{(tabs, loaded) => | ||
loaded ? ( | ||
<SimpleTabNav | ||
tabs={tabs} | ||
tabProps={null} | ||
additionalClassNames="co-m-horizontal-nav__menu--within-sidebar co-m-horizontal-nav__menu--within-overview-sidebar" | ||
/> | ||
) : null | ||
} | ||
</SideBarTabLoader> | ||
); | ||
}; | ||
|
||
export default SideBarBody; |
3 changes: 3 additions & 0 deletions
3
frontend/packages/topology/src/components/side-bar/components/SideBarHeading.scss
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,3 @@ | ||
.topology-sidebar-alert { | ||
margin: 0 20px var(--pf-global--spacer--md); | ||
} |
22 changes: 22 additions & 0 deletions
22
frontend/packages/topology/src/components/side-bar/components/SideBarHeading.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,22 @@ | ||
import * as React from 'react'; | ||
import { GraphElement } from '@patternfly/react-topology'; | ||
import { useDetailsResourceLink } from '../providers/useDetailsResourceLink'; | ||
import SideBarAlerts from './SideBarAlerts'; | ||
import './SideBarHeading.scss'; | ||
|
||
const SideBarHeading: React.FC<{ element: GraphElement }> = ({ element }) => { | ||
const resourceLink = useDetailsResourceLink(element); | ||
return ( | ||
<div className="overview__sidebar-pane-head resource-overview__heading"> | ||
<h1 className="co-m-pane__heading"> | ||
<div className="co-m-pane__name co-resource-item">{resourceLink}</div> | ||
<div className="co-actions">{/** actions */}</div> | ||
</h1> | ||
<div className="topology-sidebar-alert"> | ||
<SideBarAlerts element={element} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SideBarHeading; |
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
Oops, something went wrong.