Skip to content

Commit

Permalink
Poll for classification updates (#1908)
Browse files Browse the repository at this point in the history
Co-authored-by: Sean Preston <[email protected]>
  • Loading branch information
allisonking and Sean Preston authored Nov 30, 2022
1 parent 754c93f commit 960f3fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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

0 comments on commit 960f3fb

Please sign in to comment.