Skip to content

Commit

Permalink
fix: propagate onClict to the tooltip row
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed Nov 20, 2024
1 parent 99caf1c commit 4a9994e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@ export const UpdateStatusActionBarIcon = ({
return null;
}

const suiteOnClick = () => mapSuiteUpdateToClick[updateStatusSuite]?.({ dispatch });
const deviceOnClick = () => mapDeviceUpdateToClick[updateStatusDevice]?.({ dispatch });
const suiteOnClick = mapSuiteUpdateToClick[updateStatusSuite];
const deviceOnClick = mapDeviceUpdateToClick[updateStatusDevice];

const suiteOnClickHandler = suiteOnClick ? () => suiteOnClick({ dispatch }) : undefined;
const deviceOnClickHandler = deviceOnClick ? () => deviceOnClick({ dispatch }) : undefined;

const handleClick = () => {
if (updateStatusSuite !== 'up-to-date') {
suiteOnClick();
suiteOnClickHandler?.();
} else if (updateStatusDevice !== 'up-to-date') {
deviceOnClick();
deviceOnClickHandler?.();
}
};

Expand All @@ -184,7 +187,9 @@ export const UpdateStatusActionBarIcon = ({
!showUpdateBannerNotification && (
<UpdateTooltip
updateStatusDevice={updateStatusDevice}
onClickSuite={suiteOnClickHandler}
updateStatusSuite={updateStatusSuite}
onClickDevice={deviceOnClickHandler}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
mapUpdateStatusToIcon,
mapUpdateStatusToVariant,
UpdateStatus,
UpdateStatusSuite,
UpdateStatusDevice,
UpdateStatusSuite,
} from './updateQuickActionTypes';
import { useDevice, useSelector } from '../../../../../../../hooks/suite';
import { TooltipRow } from '../TooltipRow';
Expand Down Expand Up @@ -113,16 +113,23 @@ const SuiteRow = ({ updateStatus, onClick }: SuiteRowProps) => {

type UpdateTooltipProps = {
updateStatusDevice: UpdateStatusDevice;
onClickDevice?: () => void;
updateStatusSuite: UpdateStatusSuite;
onClickSuite?: () => void;
};

export const UpdateTooltip = ({ updateStatusDevice, updateStatusSuite }: UpdateTooltipProps) => {
export const UpdateTooltip = ({
updateStatusDevice,
onClickDevice,
updateStatusSuite,
onClickSuite,
}: UpdateTooltipProps) => {
const isDesktopSuite = isDesktop();

return (
<Column gap={spacings.md} alignItems="start">
<DeviceRow updateStatus={updateStatusDevice} />
{isDesktopSuite && <SuiteRow updateStatus={updateStatusSuite} />}
<DeviceRow updateStatus={updateStatusDevice} onClick={onClickDevice} />
{isDesktopSuite && <SuiteRow updateStatus={updateStatusSuite} onClick={onClickSuite} />}
</Column>
);
};

0 comments on commit 4a9994e

Please sign in to comment.