Skip to content

Commit

Permalink
HOSTSD-293 - fix for storage trends chart aspect ratio bug (#127)
Browse files Browse the repository at this point in the history
* fix for storage trends chart aspect ratio bug

* updating to use useCallback for Storage Trends chart

* fixing type for isLarge property on Storage Chart
  • Loading branch information
wkaspryk authored Mar 27, 2024
1 parent a8e5397 commit e24657b
Showing 1 changed file with 41 additions and 24 deletions.
65 changes: 41 additions & 24 deletions src/dashboard/src/components/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,34 @@ export const Dashboard = () => {
[download],
);

const renderStorageTrendsChart = React.useCallback(
(isLarge: boolean | undefined) => (
<StorageTrendsChart
large={isLarge}
serverItems={dashboardServerItem ? [dashboardServerItem] : dashboardServerItems}
showExport
onExport={(startDate, endDate) => {
handleExport({
tenantId: dashboardTenant?.id,
organizationId: dashboardOrganization?.id,
operatingSystemItemId: dashboardOperatingSystemItem?.id,
serviceNowKey: dashboardServerItem?.serviceNowKey,
startDate: startDate,
endDate: endDate,
});
}}
/>
),
[
dashboardServerItem,
dashboardServerItems,
dashboardTenant,
dashboardOrganization,
dashboardOperatingSystemItem,
handleExport,
]
);

return (
<>
<Breadcrumbs multipleOrganizations={organizations.length > 1} />
Expand Down Expand Up @@ -254,31 +282,20 @@ export const Dashboard = () => {
)}
{/* Multiple Organizations */}
{showAllOrganizations && (
<AllOrganizations
organizations={dashboardOrganizations}
serverItems={dashboardServerItems}
loading={!isReadyOrganizations || !isReadyServerItems}
showExport
onExport={() => {
handleExport({ tenantId: dashboardTenant?.id });
}}
/>
<>
<AllOrganizations
organizations={dashboardOrganizations}
serverItems={dashboardServerItems}
loading={!isReadyOrganizations || !isReadyServerItems}
showExport
onExport={() => {
handleExport({ tenantId: dashboardTenant?.id });
}}
/>
{renderStorageTrendsChart(false)}
</>
)}
<StorageTrendsChart
large={!!dashboardOrganization || !!dashboardOperatingSystemItem || !!dashboardServerItem}
serverItems={dashboardServerItem ? [dashboardServerItem] : dashboardServerItems}
showExport
onExport={(startDate, endDate) => {
handleExport({
tenantId: dashboardTenant?.id,
organizationId: dashboardOrganization?.id,
operatingSystemItemId: dashboardOperatingSystemItem?.id,
serviceNowKey: dashboardServerItem?.serviceNowKey,
startDate: startDate,
endDate: endDate,
});
}}
/>
{!showAllOrganizations && renderStorageTrendsChart(true)}
{showAllocationByStorageVolume && (
<AllocationByStorageVolume
organizations={dashboardOrganizations}
Expand Down

0 comments on commit e24657b

Please sign in to comment.