Skip to content

Commit 4d0cd24

Browse files
committed
chore: linting and refinements
1 parent a6ba367 commit 4d0cd24

File tree

24 files changed

+295
-265
lines changed

24 files changed

+295
-265
lines changed

clients/admin-ui/src/features/common/api.slice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const baseApi = createApi({
114114
"Access Control",
115115
"Fides Dashboard",
116116
"Monitor Statistics",
117-
"Connection Type"
117+
"Connection Type",
118118
],
119119
endpoints: () => ({}),
120120
});

clients/admin-ui/src/features/data-discovery-and-detection/action-center/ActionCenterLayout.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import useActionCenterNavigation, {
1818
ActionCenterRoute,
1919
ActionCenterRouteConfig,
2020
} from "~/features/data-discovery-and-detection/action-center/hooks/useActionCenterNavigation";
21+
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
2122

2223
import MonitorStats from "./MonitorStats";
23-
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
2424

2525
export interface ActionCenterLayoutProps {
2626
monitorId?: string;
@@ -29,8 +29,8 @@ export interface ActionCenterLayoutProps {
2929
dropdownProps?: DropdownProps;
3030
badgeProps?: BadgeProps;
3131
};
32-
refresh?: () => void
33-
monitorType?: APIMonitorType
32+
refresh?: () => void;
33+
monitorType?: APIMonitorType;
3434
}
3535

3636
const ActionCenterLayout = ({
@@ -39,7 +39,7 @@ const ActionCenterLayout = ({
3939
monitorType,
4040
routeConfig,
4141
pageSettings,
42-
refresh
42+
refresh,
4343
}: PropsWithChildren<ActionCenterLayoutProps>) => {
4444
const {
4545
items: menuItems,
@@ -73,19 +73,20 @@ const ActionCenterLayout = ({
7373
</Dropdown>
7474
</Badge>
7575
</Flex>
76-
)
77-
}
78-
{refresh &&
76+
)}
77+
{refresh && (
7978
<Button
8079
aria-label="Page refresh"
8180
icon={<Icons.Renew />}
8281
onClick={refresh}
8382
/>
84-
}
83+
)}
8584
</Flex>
8685
}
8786
/>
88-
{monitorId && <MonitorStats monitorId={monitorId} monitorType={monitorType} />}
87+
{monitorId && monitorType && (
88+
<MonitorStats monitorId={monitorId} monitorType={monitorType} />
89+
)}
8990
<Menu
9091
aria-label="Action center tabs"
9192
mode="horizontal"

clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorDetailsWidget.tsx

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
1+
import { skipToken } from "@reduxjs/toolkit/query";
12
import { Descriptions, Flex, Text } from "fidesui";
23

34
import { useFlags } from "~/features/common/features";
4-
import { useGetConnectionQuery, useGetMonitorConfigQuery } from "./action-center.slice";
5-
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
6-
import { skipToken } from "@reduxjs/toolkit/query";
5+
6+
import {
7+
useGetConnectionQuery,
8+
useGetMonitorConfigQuery,
9+
} from "./action-center.slice";
710

811
export interface MonitorDetailsWidgetProps {
912
monitorId: string;
10-
monitorType: APIMonitorType
11-
disabled?: boolean
1213
}
1314

1415
const MonitorDetailsWidget = ({ monitorId }: MonitorDetailsWidgetProps) => {
1516
const {
1617
flags: { heliosInsights },
1718
} = useFlags();
18-
const { data: configData } = useGetMonitorConfigQuery({ monitor_config_id: monitorId })
19-
const connectionKey = configData?.connection_config_key
20-
const { data: connectionData } = useGetConnectionQuery(connectionKey ? { connection_key: connectionKey } : skipToken)
19+
const { data: configData } = useGetMonitorConfigQuery({
20+
monitor_config_id: monitorId,
21+
});
22+
const connectionKey = configData?.connection_config_key;
23+
const { data: connectionData } = useGetConnectionQuery(
24+
connectionKey ? { connection_key: connectionKey } : skipToken,
25+
);
2126

2227
return (
2328
heliosInsights && (
24-
<Flex
25-
className="w-full"
26-
gap="middle"
27-
vertical
28-
>
29+
<Flex className="w-full" gap="middle" vertical>
2930
<Text strong>Details</Text>
3031
<Descriptions
3132
size="small"
32-
items={[{
33-
label: "System",
34-
children: connectionData?.system_key,
35-
span: "filled"
36-
},
37-
{
38-
label: "Integration",
39-
children: connectionKey,
33+
items={[
34+
{
35+
label: "System",
36+
children: connectionData?.system_key,
37+
span: "filled",
38+
},
39+
{
40+
label: "Integration",
41+
children: connectionData?.key,
4042

41-
span: "filled"
42-
}
43-
]}>
44-
</Descriptions>
43+
span: "filled",
44+
},
45+
]}
46+
/>
4547
</Flex>
4648
)
4749
);

clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorList.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import { EmptyMonitorsResult } from "~/features/data-discovery-and-detection/act
1212
import useSearchForm from "~/features/data-discovery-and-detection/action-center/hooks/useSearchForm";
1313
import { MonitorResult } from "~/features/data-discovery-and-detection/action-center/MonitorResult";
1414
import { useGetUserMonitorsQuery } from "~/features/user-management";
15+
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
1516

1617
import MonitorListSearchForm from "./forms/MonitorListSearchForm";
1718
import {
1819
MonitorSearchForm,
1920
MonitorSearchFormQuerySchema,
2021
SearchFormQueryState,
2122
} from "./MonitorList.const";
22-
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
2323
import MonitorStats from "./MonitorStats";
2424

2525
const MonitorList = () => {
@@ -41,8 +41,8 @@ const MonitorList = () => {
4141
const { data: userMonitors } = useGetUserMonitorsQuery(
4242
currentUser?.id
4343
? {
44-
id: currentUser.id,
45-
}
44+
id: currentUser.id,
45+
}
4646
: skipToken,
4747
);
4848

@@ -68,7 +68,9 @@ const MonitorList = () => {
6868
search: search || undefined,
6969
monitor_type: monitor_type
7070
? [monitor_type]
71-
: [...availableMonitorTypes] /** this should be handled via ant binding ideally. * */,
71+
: [
72+
...availableMonitorTypes,
73+
] /** this should be handled via ant binding ideally. * */,
7274
steward_user_id:
7375
typeof steward_key === "undefined" || !steward_key
7476
? []

clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorProgressWidget.tsx

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,75 @@
1-
2-
import classNames from "classnames";
3-
import { Button, Card, Divider, Flex, Icons, Text } from "fidesui";
1+
import { Button, Flex, Icons, Text } from "fidesui";
42
import Link from "next/link";
3+
import { useQueryStates } from "nuqs";
54

65
import { useFlags } from "~/features/common/features";
76
import { INTEGRATION_MANAGEMENT_ROUTE } from "~/features/common/nav/routes";
7+
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
88

99
import { useGetAggregateStatisticsQuery } from "./action-center.slice";
10+
import { SearchFormQueryState } from "./MonitorList.const";
1011
import { ProgressCard } from "./ProgressCard/ProgressCard";
1112
import {
1213
buildWidgetProps,
1314
MONITOR_TYPE_TO_EMPTY_TEXT,
1415
MONITOR_TYPE_TO_ICON,
1516
MONITOR_TYPE_TO_LABEL,
16-
transformStatisticsResponseToCardProps,
1717
} from "./ProgressCard/utils";
18-
import { useQueryStates } from "nuqs";
19-
import { SearchFormQueryState } from "./MonitorList.const";
20-
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
2118

2219
export interface MonitorProgressWidgetProps {
2320
monitorId?: string;
24-
monitorType: APIMonitorType
25-
disabled?: boolean
21+
monitorType: APIMonitorType;
22+
disabled?: boolean;
2623
}
2724

2825
const renderIcon = (icon: Icons.CarbonIconType) => {
2926
const Icon = icon;
3027
return <Icon size={33} />;
3128
};
3229

33-
const MonitorProgressWidget = ({ monitorId, monitorType }: MonitorProgressWidgetProps) => {
30+
const MonitorProgressWidget = ({
31+
monitorId,
32+
monitorType,
33+
}: MonitorProgressWidgetProps) => {
3434
const {
3535
flags: { heliosInsights },
3636
} = useFlags();
37-
const [filters] = useQueryStates(SearchFormQueryState(Object.values(APIMonitorType
38-
)))
37+
const [filters] = useQueryStates(
38+
SearchFormQueryState(Object.values(APIMonitorType)),
39+
);
3940

4041
const { data } = useGetAggregateStatisticsQuery(
4142
{
4243
monitor_type: monitorType,
4344
monitor_config_id: monitorId,
44-
steward_user_id: filters.steward_key ? [filters.steward_key] : undefined
45+
steward_user_id: filters.steward_key ? [filters.steward_key] : undefined,
4546
},
4647
{
4748
refetchOnMountOrArgChange: true,
4849
},
4950
);
5051

51-
const { total_monitors = 0 } = data ?? { total_monitors: 0 }
52+
const totalMonitors = data?.total_monitors ?? 0;
5253

5354
return (
5455
heliosInsights && (
55-
<Flex
56-
className="w-full"
57-
gap="middle"
58-
>
59-
{data && total_monitors > 0 || !!filters.steward_key ? (
56+
<Flex className="w-full" gap="middle">
57+
{(data && totalMonitors > 0) || !!filters.steward_key ? (
6058
<ProgressCard
6159
{...buildWidgetProps({
6260
monitor_type: monitorType,
63-
total_monitors,
61+
total_monitors: totalMonitors,
6462
...data,
6563
})}
6664
compact={!!monitorId}
67-
disabled={(!!filters.monitor_type && monitorType !== filters.monitor_type) || (!!filters.steward_key && total_monitors <= 0)}
65+
disabled={
66+
(!!filters.monitor_type &&
67+
monitorType !== filters.monitor_type) ||
68+
(!!filters.steward_key && totalMonitors <= 0)
69+
}
6870
/>
6971
) : (
70-
<div
71-
>
72+
<div>
7273
<Flex vertical gap="middle" align="center" justify="center">
7374
<span>{MONITOR_TYPE_TO_LABEL[monitorType]}</span>
7475
<Text>{renderIcon(MONITOR_TYPE_TO_ICON[monitorType])}</Text>
@@ -80,8 +81,7 @@ const MonitorProgressWidget = ({ monitorId, monitorType }: MonitorProgressWidget
8081
</Link>
8182
</Flex>
8283
</div>
83-
)
84-
}
84+
)}
8585
</Flex>
8686
)
8787
);

clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorResult.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import {
2626
import ConnectionTypeLogo, {
2727
ConnectionLogoKind,
2828
} from "~/features/datastore-connections/ConnectionTypeLogo";
29+
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
2930
import { DatastoreMonitorUpdates } from "~/types/api/models/DatastoreMonitorUpdates";
3031

3132
import { ConfidenceRow } from "./ConfidenceRow";
3233
import { DiscoveryStatusIcon } from "./DiscoveryStatusIcon";
3334
import styles from "./MonitorResult.module.scss";
3435
import { MonitorResultDescription } from "./MonitorResultDescription";
3536
import { MonitorAggregatedResults } from "./types";
36-
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
3737

3838
const { Text } = Typography;
3939

clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorStats.tsx

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,61 @@
11
import classNames from "classnames";
2-
import { Divider, Flex, Text } from "fidesui";
2+
import { Divider, Flex } from "fidesui";
33

44
import { useFlags } from "~/features/common/features";
5-
6-
import { useQueryStates } from "nuqs";
7-
import { SearchFormQueryState } from "./MonitorList.const";
85
import { APIMonitorType } from "~/types/api/models/APIMonitorType";
6+
7+
import MonitorDetailsWidget from "./MonitorDetailsWidget";
98
import MonitorProgressWidget from "./MonitorProgressWidget";
109
import MonitorStatsWidget from "./MonitorStatsWidget";
11-
import MonitorDetailsWidget from "./MonitorDetailsWidget";
1210

1311
export interface MonitorStatsProps {
1412
monitorId?: string;
15-
monitorType: APIMonitorType
13+
monitorType?: APIMonitorType;
1614
}
1715

18-
1916
const MonitorStats = ({ monitorId, monitorType }: MonitorStatsProps) => {
2017
const {
2118
flags: { heliosInsights },
2219
} = useFlags();
23-
const [filters] = useQueryStates(SearchFormQueryState(Object.values(APIMonitorType
24-
)))
2520

2621
return (
2722
heliosInsights && (
28-
<Flex
29-
className={classNames(
30-
"w-full",
31-
)}
32-
gap="middle"
33-
>
34-
{Object.values(monitorType ? [monitorType] : APIMonitorType).map((mType) =>
35-
<MonitorProgressWidget
36-
monitorType={mType}
37-
monitorId={monitorId}
38-
key={mType}
39-
/>
40-
).reduce((prev, curr) => [prev, ...(prev[0] ? [<Divider vertical className="h-full" key={`${curr.key}--divider`} />] : []), curr], [] as React.ReactNode[])}
41-
{monitorId &&
23+
<Flex className={classNames("w-full")} gap="middle">
24+
{Object.values(monitorType ? [monitorType] : APIMonitorType)
25+
.map((mType) => (
26+
<MonitorProgressWidget
27+
monitorType={mType}
28+
monitorId={monitorId}
29+
key={mType}
30+
/>
31+
))
32+
.reduce(
33+
(prev, curr) => [
34+
prev,
35+
...(prev[0]
36+
? [
37+
<Divider
38+
vertical
39+
className="h-full"
40+
key={`${curr.key}--divider`}
41+
/>,
42+
]
43+
: []),
44+
curr,
45+
],
46+
[] as React.ReactNode[],
47+
)}
48+
{monitorId && monitorType && (
4249
<>
43-
<MonitorStatsWidget monitorType={monitorType} monitorId={monitorId} />
44-
<MonitorDetailsWidget monitorType={monitorType} monitorId={monitorId} />
50+
<Divider vertical className="h-full" />,
51+
<MonitorStatsWidget
52+
monitorType={monitorType}
53+
monitorId={monitorId}
54+
/>
55+
<Divider vertical className="h-full" />,
56+
<MonitorDetailsWidget monitorId={monitorId} />
4557
</>
46-
47-
}
58+
)}
4859
</Flex>
4960
)
5061
);

0 commit comments

Comments
 (0)