Skip to content

Commit

Permalink
Kebab menu fix for DRPolicy
Browse files Browse the repository at this point in the history
Signed-off-by: Gowtham Shanmugasundaram <[email protected]>
  • Loading branch information
GowthamShanmugam committed Mar 29, 2024
1 parent a1825d6 commit 93219a8
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 93219a8

Please sign in to comment.