Skip to content

Commit 396ce87

Browse files
committed
Remove kebab factory uses from default-resouce list and details pages
1 parent a9c7379 commit 396ce87

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

frontend/packages/metal3-plugin/src/components/modals/PowerOffHostModal.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,6 @@ const isPowerOffSafe = (status: string) => {
167167
return safeStates.includes(status);
168168
};
169169

170-
export type PowerOffHostModalProps1 = {
171-
host: BareMetalHostKind;
172-
nodeName: string;
173-
status: StatusProps;
174-
cancel?: () => void;
175-
close?: () => void;
176-
};
177-
178170
export type PowerOffHostModalProps = {
179171
host: BareMetalHostKind;
180172
nodeName: string;

frontend/public/components/default-resource.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
ExtensionK8sGroupModel,
2222
} from '../module/k8s';
2323
import { DetailsItem } from './utils/details-item';
24-
import { Kebab, ResourceKebab } from './utils/kebab';
2524
import { kindObj } from './utils/inject';
2625
import { navFactory } from './utils/horizontal-nav';
2726
import { ResourceLink } from './utils/resource-link';
@@ -51,8 +50,10 @@ import {
5150
ResolvedExtension,
5251
} from '@console/dynamic-plugin-sdk';
5352
import 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

5758
const 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+
8090
const 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

376385
export 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
};
382405
DefaultDetailsPage.displayName = 'DefaultDetailsPage';
383406

0 commit comments

Comments
 (0)