Skip to content

Commit

Permalink
upcomign: [DI-20929] - Updated types
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhagra-akamai committed Dec 6, 2024
1 parent 2bf49af commit 755ad00
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import type { Dashboard, TimeDuration } from '@linode/api-v4';

export type FilterValueType = number | number[] | string | string[] | undefined;

export interface FilterValue {
id: { [key: string]: FilterValueType };
label: { [key: string]: string[] };
export interface FilterData {
id: { [filterKey: string]: FilterValueType };
label: { [filterKey: string]: string[] };
}
export interface DashboardProp {
dashboard?: Dashboard;
Expand All @@ -23,7 +23,7 @@ export interface DashboardProp {
}

export const CloudPulseDashboardLanding = () => {
const [filterValue, setFilterValue] = React.useState<FilterValue>({
const [filterData, setFilterData] = React.useState<FilterData>({
id: {},
label: {},
});
Expand All @@ -42,7 +42,7 @@ export const CloudPulseDashboardLanding = () => {

const onFilterChange = React.useCallback(
(filterKey: string, filterValue: FilterValueType, labels: string[]) => {
setFilterValue((prev: FilterValue) => {
setFilterData((prev: FilterData) => {
return {
id: {
...prev.id,
Expand All @@ -60,7 +60,7 @@ export const CloudPulseDashboardLanding = () => {

const onDashboardChange = React.useCallback((dashboardObj: Dashboard) => {
setDashboard(dashboardObj);
setFilterValue({
setFilterData({
id: {},
label: {},
}); // clear the filter values on dashboard change
Expand All @@ -84,7 +84,7 @@ export const CloudPulseDashboardLanding = () => {
/>
{dashboard?.service_type && showAppliedFilters && (
<CloudPulseAppliedFilterRenderer
filters={filterValue.label}
filters={filterData.label}
serviceType={dashboard.service_type}
/>
)}
Expand All @@ -93,7 +93,7 @@ export const CloudPulseDashboardLanding = () => {
</Grid>
<CloudPulseDashboardRenderer
dashboard={dashboard}
filterValue={filterValue.id}
filterValue={filterData.id}
timeDuration={timeDuration}
/>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import {
} from '../Utils/ReusableDashboardFilterUtils';
import { CloudPulseDashboard } from './CloudPulseDashboard';

import type {
FilterValue,
FilterValueType,
} from './CloudPulseDashboardLanding';
import type { FilterData, FilterValueType } from './CloudPulseDashboardLanding';
import type { TimeDuration } from '@linode/api-v4';

export interface CloudPulseDashboardWithFiltersProp {
Expand All @@ -41,8 +38,8 @@ export const CloudPulseDashboardWithFilters = React.memo(
dashboardId
);

const [filterValue, setFilterValue] = React.useState<FilterValue>({
id: {},
const [filterValue, setFilterValue] = React.useState<FilterData>({
filterId: {},
label: {},
});

Expand All @@ -63,8 +60,8 @@ export const CloudPulseDashboardWithFilters = React.memo(
(filterKey: string, value: FilterValueType, labels: string[]) => {
setFilterValue((prev) => {
return {
id: {
...prev.id,
filterId: {
...prev.filterId,
[filterKey]: value,
},
label: {
Expand Down Expand Up @@ -115,7 +112,7 @@ export const CloudPulseDashboardWithFilters = React.memo(
const isFilterBuilderNeeded = checkIfFilterBuilderNeeded(dashboard);
const isMandatoryFiltersSelected = checkMandatoryFiltersSelected({
dashboardObj: dashboard,
filterValue: filterValue.id,
filterValue: filterValue.filterId,
resource,
timeDuration,
});
Expand Down Expand Up @@ -173,7 +170,7 @@ export const CloudPulseDashboardWithFilters = React.memo(
<CloudPulseDashboard
{...getDashboardProperties({
dashboardObj: dashboard,
filterValue: filterValue.id,
filterValue: filterValue.filterId,
resource,
timeDuration,
})}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Chip, Typography } from '@linode/ui';
import React from 'react';

interface CloudPulseAppliedFilterProps {
export interface CloudPulseAppliedFilterProps {
filters: {
[label: string]: string[];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import React from 'react';
import { FILTER_CONFIG } from '../Utils/FilterConfig';
import { CloudPulseAppliedFilter } from './CloudPulseAppliedFilter';

interface AppliedFilterRendererProps {
filters: {
[label: string]: string[];
};
import type { CloudPulseAppliedFilterProps } from './CloudPulseAppliedFilter';

interface AppliedFilterRendererProps extends CloudPulseAppliedFilterProps {
serviceType: string;
}

Expand Down

0 comments on commit 755ad00

Please sign in to comment.