Skip to content

Commit

Permalink
Merge pull request #1272 from GowthamShanmugam/fix_kebabmenu
Browse files Browse the repository at this point in the history
Kebab menu fix for DRPolicy
  • Loading branch information
openshift-merge-bot[bot] authored Apr 15, 2024
2 parents 0a02ff7 + 93219a8 commit 98d7f22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
23 changes: 11 additions & 12 deletions packages/mco/components/drpolicy-list-page/helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CustomKebabItem } from '@odf/shared/kebab';
import { ModalKeys } from '@odf/shared/modals/types';
import classNames from 'classnames';
import { TFunction } from 'i18next';
Expand Down Expand Up @@ -79,20 +80,18 @@ export const kebabActionItems = (
appsLoaded,
appsLoadedError,
t
) => [
): CustomKebabItem[] => [
{
key: ModalKeys.DELETE,
value: Actions.DELETE_DR_POLICY,
props: {
description: !!appsCount
? t('Cannot delete while connected to an application.')
: '',
isDisabled: !(
canDeleteDRPolicy &&
appsLoaded &&
!appsLoadedError &&
!appsCount
),
},
description: !!appsCount
? t('Cannot delete while connected to an application.')
: '',
isDisabled: !(
canDeleteDRPolicy &&
appsLoaded &&
!appsLoadedError &&
!appsCount
),
},
];
10 changes: 9 additions & 1 deletion packages/shared/src/kebab/kebab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { referenceForModel } from '../utils';
export type CustomKebabItem = {
key: string;
value: string;
isDisabled?: boolean;
description?: React.ReactNode;
component?: React.LazyExoticComponent<any>;
};

Expand Down Expand Up @@ -180,7 +182,13 @@ export const Kebab: React.FC<KebabProps> & KebabStaticProperties = ({
const { overrides, custom } = Object.entries(customResolved).reduce(
(acc, [k, obj]) => {
const dropdownItem = (
<DropdownItem key={k} id={k} data-test-action={obj?.value}>
<DropdownItem
key={k}
id={k}
data-test-action={obj?.value}
isDisabled={obj?.isDisabled}
description={obj?.description}
>
{obj?.value}
</DropdownItem>
);
Expand Down

0 comments on commit 98d7f22

Please sign in to comment.