Skip to content

Commit

Permalink
1128-Add Retry button back into the subject request detail view (ethy…
Browse files Browse the repository at this point in the history
…ca#1131)

* 1128-Add Retry button back into the subject request detail view

* Updated CHANGELOG.md file

* provide a way to give invited users the resume permission

Co-authored-by: Sean Preston <sean@ethyca.com>
  • Loading branch information
chriscalhoun1974 and Sean Preston authored Aug 23, 2022
1 parent 1ec332d commit 1b73fe0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The types of changes are:
* SaaS Connector Configuration - Testing a Connection [#985](https://github.com/ethyca/fidesops/pull/1099)
* Add an endpoint for verifying the user's identity before queuing the privacy request. [#1111](https://github.com/ethyca/fidesops/pull/1111)
* Adds tests for email endpoints and service [#1112](https://github.com/ethyca/fidesops/pull/1112)
* Add Retry button back into the subject request detail view [#1128](https://github.com/ethyca/fidesops/pull/1131)

### Developer Experience

Expand Down
4 changes: 4 additions & 0 deletions clients/ops/admin-ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const USER_PRIVILEGES: UserPrivileges[] = [
privilege: "Approve subject requests",
scope: "privacy-request:review",
},
{
privilege: "Resume subject requests",
scope: "privacy-request:resume",
},
{
privilege: "View datastore connections",
scope: "connection:read",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { Box, Divider, Flex, Heading, Text } from "@fidesui/react";
import React from "react";
import {
Button,
Divider,
Flex,
Heading,
HStack,
Text,
useToast,
} from "@fidesui/react";
import { isErrorWithDetail, isErrorWithDetailArray } from "common/helpers";
import { useRetryMutation } from "privacy-requests/privacy-requests.slice";
import { useState } from "react";

import ClipboardButton from "../common/ClipboardButton";
import RequestStatusBadge from "../common/RequestStatusBadge";
Expand All @@ -12,6 +22,30 @@ type RequestDetailsProps = {

const RequestDetails = ({ subjectRequest }: RequestDetailsProps) => {
const { id, status, policy } = subjectRequest;
const [retry] = useRetryMutation();
const toast = useToast();
const [isRetrying, setRetrying] = useState(false);

const handleRetry = async () => {
setRetrying(true);
retry(subjectRequest)
.unwrap()
.catch((error) => {
let errorMsg = "An unexpected error occurred. Please try again.";
if (isErrorWithDetail(error)) {
errorMsg = error.data.detail;
} else if (isErrorWithDetailArray(error)) {
errorMsg = error.data.detail[0].msg;
}
toast({
status: "error",
description: errorMsg,
});
})
.finally(() => {
setRetrying(false);
});
};

return (
<>
Expand Down Expand Up @@ -46,9 +80,21 @@ const RequestDetails = ({ subjectRequest }: RequestDetailsProps) => {
<Text mb={4} mr={2} fontSize="sm" color="gray.900" fontWeight="500">
Status:
</Text>
<Box>
<HStack spacing="16px">
<RequestStatusBadge status={status} />
</Box>
{status === "error" && (
<Button
isLoading={isRetrying}
loadingText="Retrying"
onClick={handleRetry}
size="xs"
spinnerPlacement="end"
variant="outline"
>
Retry
</Button>
)}
</HStack>
</Flex>
</>
);
Expand Down

0 comments on commit 1b73fe0

Please sign in to comment.