@@ -21,7 +21,6 @@ import {
2121 ExtensionK8sGroupModel ,
2222} from '../module/k8s' ;
2323import { DetailsItem } from './utils/details-item' ;
24- import { Kebab , ResourceKebab } from './utils/kebab' ;
2524import { kindObj } from './utils/inject' ;
2625import { navFactory } from './utils/horizontal-nav' ;
2726import { ResourceLink } from './utils/resource-link' ;
@@ -51,8 +50,10 @@ import {
5150 ResolvedExtension ,
5251} from '@console/dynamic-plugin-sdk' ;
5352import LazyActionMenu from '@console/shared/src/components/actions/LazyActionMenu' ;
54-
55- const { common } = Kebab . factory ;
53+ import { useCommonResourceActions } from '@console/app/src/actions/hooks/useCommonResourceActions' ;
54+ import ActionMenu from '@console/shared/src/components/actions/menu/ActionMenu' ;
55+ import { ActionMenuVariant } from '@console/shared/src/components/actions/types' ;
56+ import { useK8sGet } from './utils/k8s-get-hook' ;
5657
5758const tableColumnInfo = [ { id : 'name' } , { id : 'namespace' } , { id : 'created' } , { id : 'actions' } ] ;
5859
@@ -77,6 +78,15 @@ const getAdditionaPrinterColumnID = (column: CRDAdditionalPrinterColumn) => {
7778 return `apc-${ column . name } ` ;
7879} ;
7980
81+ const ResourceActionsMenu : React . FC < { resource : K8sResourceKind ; variant : ActionMenuVariant } > = ( {
82+ resource,
83+ variant,
84+ } ) => {
85+ const common = useCommonResourceActions ( kindObj ( referenceFor ( resource ) ) , resource ) ;
86+ const menuActions = [ ...common ] ;
87+ return < ActionMenu actions = { menuActions } variant = { variant } /> ;
88+ } ;
89+
8090const NamespaceCell : React . FCC < NamespaceCellProps > = ( { namespace } ) => {
8191 const { t } = useTranslation ( ) ;
8292 return namespace ? < ResourceLink kind = "Namespace" name = { namespace } /> : < > { t ( 'public~None' ) } </ > ;
@@ -176,7 +186,6 @@ const getDataViewRows = (
176186 return data . map ( ( { obj } ) => {
177187 const { name, namespace, creationTimestamp } = obj . metadata ;
178188 const kind = referenceFor ( obj ) || kinds [ 0 ] ;
179- const menuActions = [ ...common ] ;
180189
181190 const hasExtensionActions =
182191 resourceProviderExtensionsResolved && resourceProviderExtensions ?. length > 0 ;
@@ -214,7 +223,7 @@ const getDataViewRows = (
214223 { hasExtensionActions ? (
215224 < LazyActionMenu context = { { [ kind ] : obj } } />
216225 ) : (
217- < ResourceKebab actions = { menuActions } kind = { kind } resource = { obj } />
226+ < ResourceActionsMenu resource = { obj } variant = { ActionMenuVariant . KEBAB } />
218227 ) }
219228 </ >
220229 ) ,
@@ -375,9 +384,23 @@ DefaultPage.displayName = 'DefaultPage';
375384
376385export const DefaultDetailsPage : React . FC < React . ComponentProps < typeof DetailsPage > > = ( props ) => {
377386 const pages = [ navFactory . details ( DetailsForKind ) , navFactory . editYaml ( ) ] ;
378- const menuActions = [ ...common ] ;
387+ const [ resource , resourceLoaded , resourceError ] = useK8sGet (
388+ kindObj ( props . kind ) ,
389+ props . name ,
390+ props . namespace ,
391+ ) ;
379392
380- return < DetailsPage { ...props } menuActions = { menuActions } pages = { pages } /> ;
393+ return (
394+ < DetailsPage
395+ { ...props }
396+ customActionMenu = {
397+ resourceLoaded && ! resourceError ? (
398+ < ResourceActionsMenu resource = { resource } variant = { ActionMenuVariant . DROPDOWN } />
399+ ) : null
400+ }
401+ pages = { pages }
402+ />
403+ ) ;
381404} ;
382405DefaultDetailsPage . displayName = 'DefaultDetailsPage' ;
383406
0 commit comments