Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poll for classification updates #1908

Merged
merged 5 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The types of changes are:
* Add function to poll privacy request for completion [#1860](https://github.com/ethyca/fides/pull/1860)
* Added rescan flow for the data flow scanner [#1844](https://github.com/ethyca/fides/pull/1844)
* Add Fides connector to support parent-child Fides deployments [#1861](https://github.com/ethyca/fides/pull/1861)
* Classification UI now polls for updates to classifications [#1908](https://github.com/ethyca/fides/pull/1908)

### Changed

Expand Down
17 changes: 15 additions & 2 deletions clients/admin-ui/src/pages/classify-systems/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Heading, HStack, Spinner, Stack, Text } from "@fidesui/react";
import type { NextPage } from "next";
import NextLink from "next/link";
import { useRouter } from "next/router";
import { ReactNode, useEffect } from "react";
import { ReactNode, useEffect, useState } from "react";
import { useDispatch } from "react-redux";

import { useAppSelector } from "~/app/hooks";
Expand All @@ -20,6 +20,8 @@ import {
import ClassifySystemsTable from "~/features/system/ClassifySystemsTable";
import { ClassificationStatus, GenerateTypes } from "~/types/api";

const POLL_INTERVAL_SECONDS = 3;

const ClassifySystemsLayout = ({ children }: { children: ReactNode }) => (
<Layout title="Classify Systems">
<Stack spacing={4}>
Expand Down Expand Up @@ -56,13 +58,18 @@ const ClassifySystems: NextPage = () => {
}
}, [dispatch, allSystems]);

// Poll for updates to classification until all classifications are finished
const [shouldPoll, setShouldPoll] = useState(true);
const { isLoading: isLoadingClassifications, data: classifications } =
useGetAllClassifyInstancesQuery(
{
resource_type: GenerateTypes.SYSTEMS,
fides_keys: systems?.map((s) => s.fides_key),
},
{ skip: !hasPlus }
{
skip: !hasPlus,
pollingInterval: shouldPoll ? POLL_INTERVAL_SECONDS * 1000 : undefined,
}
);

useEffect(() => {
Expand All @@ -82,6 +89,12 @@ const ClassifySystems: NextPage = () => {
)
: false;

useEffect(() => {
if (isClassificationFinished) {
setShouldPoll(false);
}
}, [isClassificationFinished]);

if (isLoading) {
return (
<ClassifySystemsLayout>
Expand Down