diff --git a/packages/refine/src/components/DropdownMenuItems/EditAnnotationDropdownMenuItem.tsx b/packages/refine/src/components/DropdownMenuItems/EditAnnotationDropdownMenuItem.tsx index 3837eeb..a9f2cd7 100644 --- a/packages/refine/src/components/DropdownMenuItems/EditAnnotationDropdownMenuItem.tsx +++ b/packages/refine/src/components/DropdownMenuItems/EditAnnotationDropdownMenuItem.tsx @@ -1,5 +1,6 @@ import { Icon, Menu, usePushModal } from '@cloudtower/eagle'; import { EditPen16BlueIcon } from '@cloudtower/icons-react'; +import { MenuItemProps } from 'antd/lib/menu/MenuItem'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { ResourceModel } from '../../models'; @@ -11,7 +12,7 @@ type EditMenuItemProps = { submit: () => Promise | undefined; } | null>; resourceModel: Model; -}; +} & MenuItemProps; export function EditAnnotationDropdownMenuItem( props: EditMenuItemProps @@ -23,18 +24,13 @@ export function EditAnnotationDropdownMenuItem( { + onClick={(e) => { const modalProps = { formRef, title: t('dovetail.edit_annotation'), fullscreen: true, renderContent() { - return ( - - ); + return ; }, }; @@ -42,6 +38,8 @@ export function EditAnnotationDropdownMenuItem( component: EditFieldModal, props: modalProps, }); + + props.onClick?.(e); }} > {t('dovetail.edit_annotation')} diff --git a/packages/refine/src/components/DropdownMenuItems/EditLabelDropdownMenuItem.tsx b/packages/refine/src/components/DropdownMenuItems/EditLabelDropdownMenuItem.tsx index 31df546..131df30 100644 --- a/packages/refine/src/components/DropdownMenuItems/EditLabelDropdownMenuItem.tsx +++ b/packages/refine/src/components/DropdownMenuItems/EditLabelDropdownMenuItem.tsx @@ -1,5 +1,6 @@ import { Icon, Menu, usePushModal } from '@cloudtower/eagle'; import { EditPen16BlueIcon } from '@cloudtower/icons-react'; +import { MenuItemProps } from 'antd/lib/menu/MenuItem'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { ResourceModel } from '../../models'; @@ -11,7 +12,7 @@ type EditMenuItemProps = { submit: () => Promise | undefined; } | null>; resourceModel: Model; -}; +} & MenuItemProps; export function EditLabelDropdownMenuItem( props: EditMenuItemProps @@ -23,18 +24,13 @@ export function EditLabelDropdownMenuItem( { + onClick={(e) => { const modalProps = { formRef, title: t('dovetail.edit_label'), fullscreen: true, renderContent() { - return ( - - ); + return ; }, }; @@ -42,6 +38,8 @@ export function EditLabelDropdownMenuItem( component: EditFieldModal, props: modalProps, }); + + props.onClick?.(e); }} > {t('dovetail.edit_label')} diff --git a/packages/refine/src/components/DropdownMenuItems/EditNodeTaintDropdownMenuItem.tsx b/packages/refine/src/components/DropdownMenuItems/EditNodeTaintDropdownMenuItem.tsx index 39484f9..e83be37 100644 --- a/packages/refine/src/components/DropdownMenuItems/EditNodeTaintDropdownMenuItem.tsx +++ b/packages/refine/src/components/DropdownMenuItems/EditNodeTaintDropdownMenuItem.tsx @@ -1,5 +1,6 @@ import { Icon, Menu, usePushModal } from '@cloudtower/eagle'; import { EditPen16BlueIcon } from '@cloudtower/icons-react'; +import { MenuItemProps } from 'antd/lib/menu/MenuItem'; import { Unstructured } from 'k8s-api-provider'; import { Node } from 'kubernetes-types/core/v1'; import React from 'react'; @@ -13,11 +14,9 @@ type EditMenuItemProps = { submit: () => Promise | undefined; } | null>; resourceModel: ResourceModel; -}; +} & MenuItemProps; -export function EditNodeTaintDropdownMenuItem( - props: EditMenuItemProps -) { +export function EditNodeTaintDropdownMenuItem(props: EditMenuItemProps) { const { formRef, resourceModel } = props; const { t } = useTranslation(); const pushModal = usePushModal(); @@ -25,18 +24,13 @@ export function EditNodeTaintDropdownMenuItem( { + onClick={e => { const modalProps = { formRef, title: t('dovetail.edit_node_taint'), fullscreen: true, renderContent() { - return ( - - ); + return ; }, }; @@ -44,6 +38,8 @@ export function EditNodeTaintDropdownMenuItem( component: EditFieldModal, props: modalProps, }); + + props.onClick?.(e); }} > {t('dovetail.edit_node_taint')} diff --git a/packages/refine/src/components/EditMetadataForm/EditNodeTaintForm.tsx b/packages/refine/src/components/EditMetadataForm/EditNodeTaintForm.tsx index dffa855..7a8d580 100644 --- a/packages/refine/src/components/EditMetadataForm/EditNodeTaintForm.tsx +++ b/packages/refine/src/components/EditMetadataForm/EditNodeTaintForm.tsx @@ -26,7 +26,7 @@ interface EditNodeTaintFormHandler { submit: () => Promise | undefined; } -enum NodeTaintEffect { +export enum NodeTaintEffect { 'NoSchedule' = 'NoSchedule', 'PreferNoSchedule' = 'PreferNoSchedule', 'NoExecute' = 'NoExecute', @@ -80,36 +80,6 @@ export const EditNodeTaintForm = React.forwardRef< }, [nodeModel, mutateAsync, t] ); - - const noScheduleTooltip = ( -
- NoSchedule -
    -
  • {t('dovetail.taint_effect_NoSchedule_tooltip_1')}
  • -
  • {t('dovetail.taint_effect_NoSchedule_tooltip_2')}
  • -
-
- ); - - const preferNoScheduleTooltip = ( -
- PreferNoSchedule -
    -
  • {t('dovetail.taint_effect_PreferNoSchedule_tooltip_1')}
  • -
  • {t('dovetail.taint_effect_PreferNoSchedule_tooltip_2')}
  • -
  • {t('dovetail.taint_effect_PreferNoSchedule_tooltip_3')}
  • -
-
- ); - - const noExecuteTooltip = ( -
- NoExecute -
    -
  • {t('dovetail.taint_effect_NoExecute_tooltip_3')}
  • -
-
- ); return ( + } + > + + } + > + } + > ); }); + +export const TaintEffectTooltip: React.FC<{ + effect: NodeTaintEffect; +}> = ({ effect }) => { + const { t } = useTranslation(); + + const TaintEffectTooltipTextConfig = { + [NodeTaintEffect.NoSchedule]: { + title: 'NoSchedule', + tooltips: [ + t('dovetail.taint_effect_NoSchedule_tooltip_1'), + t('dovetail.taint_effect_NoSchedule_tooltip_2'), + ], + }, + [NodeTaintEffect.PreferNoSchedule]: { + title: 'PreferNoSchedule', + tooltips: [ + t('dovetail.taint_effect_PreferNoSchedule_tooltip_1'), + t('dovetail.taint_effect_PreferNoSchedule_tooltip_2'), + t('dovetail.taint_effect_PreferNoSchedule_tooltip_3'), + ], + }, + [NodeTaintEffect.NoExecute]: { + title: 'NoExecute', + tooltips: [t('dovetail.taint_effect_NoExecute_tooltip_3')], + }, + }; + + const config = TaintEffectTooltipTextConfig[effect]; + + return ( +
+ {config.title} +
    + {config.tooltips.map((tooltip, index) => ( +
  • {tooltip}
  • + ))} +
+
+ ); +}; diff --git a/packages/refine/src/components/NodeTaintsTable/NodeTaintsTable.tsx b/packages/refine/src/components/NodeTaintsTable/NodeTaintsTable.tsx index 232e2ac..74aea2f 100644 --- a/packages/refine/src/components/NodeTaintsTable/NodeTaintsTable.tsx +++ b/packages/refine/src/components/NodeTaintsTable/NodeTaintsTable.tsx @@ -1,3 +1,5 @@ +import { Tooltip } from '@cloudtower/eagle'; +import { css } from '@linaria/core'; import { Taint } from 'kubernetes-types/core/v1'; import React, { useContext } from 'react'; import { useTranslation } from 'react-i18next'; @@ -8,23 +10,31 @@ import { addDefaultRenderToColumns } from 'src/hooks/useEagleTable'; import useTableData from 'src/hooks/useTableData'; import { WithId } from 'src/types'; import { addId } from '../../utils/addId'; +import { + NodeTaintEffect, + TaintEffectTooltip, +} from '../EditMetadataForm/EditNodeTaintForm'; type Props = { taints: Taint[]; }; +const EffectStyle = css` + border-bottom: 1px dashed rgba(107, 128, 167, 0.6); +`; + export const NodeTaintsTable: React.FC = ({ taints = [] }) => { const { t } = useTranslation(); const component = useContext(ComponentContext); const Table = component.Table || InternalBaseTable; const taintsWithId = addId(taints, 'key'); + const columns = [ { key: 'key', display: true, dataIndex: 'key', title: t('dovetail.key'), - width: 120, sortable: true, }, { @@ -32,7 +42,6 @@ export const NodeTaintsTable: React.FC = ({ taints = [] }) => { display: true, dataIndex: 'value', title: t('dovetail.value'), - width: 120, sortable: true, }, { @@ -40,10 +49,13 @@ export const NodeTaintsTable: React.FC = ({ taints = [] }) => { display: true, dataIndex: 'effect', title: t('dovetail.effect'), - width: 120, sortable: true, - render: (value: string) => { - return t(`dovetail.node_taint_${value}`); + render: (value: NodeTaintEffect) => { + return ( + }> + {t(`dovetail.node_taint_${value}`)} + + ); }, }, ];