-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into allow-no-content-response
- Loading branch information
Showing
44 changed files
with
1,237 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getFileNameFromContentDisposition } from "~/features/common/utils"; | ||
|
||
describe("common utils", () => { | ||
describe(getFileNameFromContentDisposition.name, () => { | ||
it('should return "export" when contentDisposition is null', () => { | ||
expect(getFileNameFromContentDisposition(null)).toEqual("export"); | ||
}); | ||
|
||
it("should return the filename from the contentDisposition header", () => { | ||
const contentDisposition = "attachment; filename=something-special.csv"; | ||
expect(getFileNameFromContentDisposition(contentDisposition)).toEqual( | ||
"something-special.csv" | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
export default undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
clients/admin-ui/src/features/common/modals/StandardDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { | ||
Button, | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalOverlay, | ||
ModalProps, | ||
ThemingProps, | ||
} from "@fidesui/react"; | ||
|
||
export interface StandardDialogProps extends ModalProps { | ||
heading?: string; | ||
cancelButtonText?: string; | ||
cancelButtonThemingProps?: ThemingProps<"Button">; | ||
continueButtonText?: string; | ||
continueButtonThemingProps?: ThemingProps<"Button">; | ||
onCancel?: () => void; | ||
onConfirm: () => void; | ||
isLoading?: boolean; | ||
"data-testid"?: string; | ||
} | ||
|
||
const StandardDialog = ({ | ||
children, | ||
heading, | ||
onCancel, | ||
onConfirm, | ||
isLoading, | ||
cancelButtonText, | ||
cancelButtonThemingProps, | ||
continueButtonText, | ||
continueButtonThemingProps, | ||
"data-testid": testId = "standard-dialog", | ||
...props | ||
}: StandardDialogProps): JSX.Element => { | ||
const { onClose } = props; | ||
return ( | ||
<Modal closeOnOverlayClick={isLoading} {...props}> | ||
<ModalOverlay /> | ||
<ModalContent data-testid={testId}> | ||
{heading && <ModalHeader>{heading}</ModalHeader>} | ||
<ModalCloseButton disabled={isLoading} /> | ||
{children && <ModalBody>{children}</ModalBody>} | ||
<ModalFooter | ||
gap={3} | ||
width="100%" | ||
sx={{ "& button": { width: "100%" } }} | ||
> | ||
<Button | ||
variant="outline" | ||
onClick={() => { | ||
if (onCancel) { | ||
onCancel(); | ||
} | ||
onClose(); | ||
}} | ||
data-testid={`${testId ? `${testId}-` : ""}cancel-btn`} | ||
isDisabled={isLoading} | ||
{...cancelButtonThemingProps} | ||
> | ||
{cancelButtonText || "Cancel"} | ||
</Button> | ||
<Button | ||
colorScheme="primary" | ||
onClick={onConfirm} | ||
data-testid={`${testId ? `${testId}-` : ""}continue-btn`} | ||
isLoading={isLoading} | ||
{...cancelButtonThemingProps} | ||
> | ||
{continueButtonText || "Continue"} | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default StandardDialog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
clients/admin-ui/src/features/datamap/modals/ReportExportModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Flex, FormControl, FormLabel, Select, Text } from "@fidesui/react"; | ||
import { useState } from "react"; | ||
|
||
import StandardDialog, { | ||
StandardDialogProps, | ||
} from "~/features/common/modals/StandardDialog"; | ||
import { ExportFormat } from "~/features/datamap/constants"; | ||
|
||
interface ReportExportModalProps | ||
extends Omit<StandardDialogProps, "children" | "onConfirm"> { | ||
onConfirm: (downloadType: ExportFormat) => void; | ||
} | ||
|
||
const ReportExportModal = (props: ReportExportModalProps): JSX.Element => { | ||
const [downloadType, setDownloadType] = useState<ExportFormat>( | ||
ExportFormat.csv | ||
); | ||
const { onConfirm } = props; | ||
|
||
return ( | ||
<StandardDialog | ||
heading="Export report" | ||
continueButtonText="Download" | ||
size="xl" | ||
{...props} | ||
onConfirm={() => onConfirm(downloadType)} | ||
data-testid="export-modal" | ||
> | ||
<Flex direction="column" gap={3} pb={3}> | ||
<Text textAlign="left"> | ||
Export your data map report using the options below. Depending on the | ||
number of rows, the file may take a few minutes to process. | ||
</Text> | ||
<FormControl> | ||
<FormLabel>Choose Format</FormLabel> | ||
<Select | ||
value={downloadType} | ||
onChange={(e) => setDownloadType(e.target.value as ExportFormat)} | ||
data-testid="export-format-select" | ||
> | ||
<option value={ExportFormat.csv}>CSV</option> | ||
<option value={ExportFormat.xlsx}>XLSX</option> | ||
</Select> | ||
</FormControl> | ||
</Flex> | ||
</StandardDialog> | ||
); | ||
}; | ||
|
||
export default ReportExportModal; |
Oops, something went wrong.