Skip to content

Commit

Permalink
Merge pull request #71 from headlamp-k8s/fix_opencost_button
Browse files Browse the repository at this point in the history
opencost: Fix the Details View Header Action
  • Loading branch information
joaquimrocha authored Aug 7, 2024
2 parents fdf28ae + 3d5008f commit eb40521
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions opencost/src/__snapshots__/details.stories.storyshot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`Storyshots OpencostDetails Loading State 1`] = `
class="MuiBox-root css-j1fy4m"
>
<div
id="cost"
id="opencost-plugin-cost-section"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-2 makeStyles-sectionHeader makeStyles-sectionHeader css-6ejd34-MuiGrid-root"
Expand Down Expand Up @@ -125,7 +125,7 @@ exports[`Storyshots OpencostDetails No Data 1`] = `
class="MuiBox-root css-j1fy4m"
>
<div
id="cost"
id="opencost-plugin-cost-section"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-2 makeStyles-sectionHeader makeStyles-sectionHeader css-6ejd34-MuiGrid-root"
Expand Down Expand Up @@ -309,7 +309,7 @@ exports[`Storyshots OpencostDetails Not Installed 1`] = `
class="MuiBox-root css-j1fy4m"
>
<div
id="cost"
id="opencost-plugin-cost-section"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-2 makeStyles-sectionHeader makeStyles-sectionHeader css-6ejd34-MuiGrid-root"
Expand Down Expand Up @@ -388,7 +388,7 @@ exports[`Storyshots OpencostDetails Week Data 1`] = `
class="MuiBox-root css-j1fy4m"
>
<div
id="cost"
id="opencost-plugin-cost-section"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-2 makeStyles-sectionHeader makeStyles-sectionHeader css-6ejd34-MuiGrid-root"
Expand Down
2 changes: 1 addition & 1 deletion opencost/src/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export function OpencostDetailSectionPure(props: OpencostDetailSectionPureProps)
<Grid spacing={2}>
<SectionBox
title={
<div id="cost">
<div id="opencost-plugin-cost-section">
<SectionHeader
title="Cost"
actions={[
Expand Down
10 changes: 9 additions & 1 deletion opencost/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ import { Settings } from './settings';
import { getConfigStore, getDisplayCurrency, getDisplayTimespan, getServiceDetails } from './utils';

function IconAction() {
const handleClick = event => {
event.preventDefault();
const targetElement = document.getElementById('opencost-plugin-cost-section');
if (targetElement) {
targetElement.scrollIntoView({ behavior: 'auto' });
}
};

return (
<Tooltip title={'Cost'}>
<IconButton href="#cost" aria-label={'Cost'} aria-haspopup="true">
<IconButton onClick={handleClick} aria-label={'Cost'} aria-haspopup="true">
<Icon icon="mdi:cash-register" />
</IconButton>
</Tooltip>
Expand Down

0 comments on commit eb40521

Please sign in to comment.