@@ -13,14 +13,6 @@ import type { FrameworkListViewQuery as FrameworkListViewQueryType } from "./__g
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Plus, Upload } from "lucide-react";
|
import { Plus, Upload } from "lucide-react";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
DialogTrigger,
|
|
||||||
} from "@/components/ui/dialog";
|
|
||||||
import { Label } from "@/components/ui/label";
|
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { FrameworkListViewImportFrameworkMutation as FrameworkListViewImportFrameworkMutationType } from "./__generated__/FrameworkListViewImportFrameworkMutation.graphql";
|
import { FrameworkListViewImportFrameworkMutation as FrameworkListViewImportFrameworkMutationType } from "./__generated__/FrameworkListViewImportFrameworkMutation.graphql";
|
||||||
import { PageTemplate } from "@/components/PageTemplate";
|
import { PageTemplate } from "@/components/PageTemplate";
|
||||||
@@ -77,11 +69,16 @@ function FrameworkListViewContent({
|
|||||||
useMutation<FrameworkListViewImportFrameworkMutationType>(
|
useMutation<FrameworkListViewImportFrameworkMutationType>(
|
||||||
FrameworkListViewImportFrameworkMutation
|
FrameworkListViewImportFrameworkMutation
|
||||||
);
|
);
|
||||||
const [isImportDialogOpen, setIsImportDialogOpen] = useState(false);
|
|
||||||
const [isUploading, setIsUploading] = useState(false);
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
|
const handleImportClick = () => {
|
||||||
|
if (fileInputRef.current) {
|
||||||
|
fileInputRef.current.click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const file = e.target.files?.[0];
|
const file = e.target.files?.[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
@@ -106,7 +103,6 @@ function FrameworkListViewContent({
|
|||||||
},
|
},
|
||||||
onCompleted: () => {
|
onCompleted: () => {
|
||||||
setIsUploading(false);
|
setIsUploading(false);
|
||||||
setIsImportDialogOpen(false);
|
|
||||||
toast({
|
toast({
|
||||||
title: "Framework imported",
|
title: "Framework imported",
|
||||||
description: "Framework has been imported successfully.",
|
description: "Framework has been imported successfully.",
|
||||||
@@ -133,38 +129,23 @@ function FrameworkListViewContent({
|
|||||||
description="Manage your compliance frameworks"
|
description="Manage your compliance frameworks"
|
||||||
actions={
|
actions={
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<Dialog
|
<Input
|
||||||
open={isImportDialogOpen}
|
id="framework-file"
|
||||||
onOpenChange={setIsImportDialogOpen}
|
type="file"
|
||||||
|
ref={fileInputRef}
|
||||||
|
onChange={handleFileChange}
|
||||||
|
disabled={isUploading}
|
||||||
|
accept=".json"
|
||||||
|
className="hidden"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={handleImportClick}
|
||||||
|
disabled={isUploading}
|
||||||
>
|
>
|
||||||
<DialogTrigger asChild>
|
<Upload className="mr-2 h-4 w-4" />
|
||||||
<Button variant="outline">
|
Import Framework
|
||||||
<Upload className="mr-2 h-4 w-4" />
|
</Button>
|
||||||
Import Framework
|
|
||||||
</Button>
|
|
||||||
</DialogTrigger>
|
|
||||||
<DialogContent>
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>Import Framework</DialogTitle>
|
|
||||||
</DialogHeader>
|
|
||||||
<div className="space-y-4 py-4">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="framework-file">Upload Framework File</Label>
|
|
||||||
<Input
|
|
||||||
id="framework-file"
|
|
||||||
type="file"
|
|
||||||
ref={fileInputRef}
|
|
||||||
onChange={handleFileChange}
|
|
||||||
disabled={isUploading}
|
|
||||||
accept=".json"
|
|
||||||
/>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
Upload a JSON file containing your framework definition.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
<Button asChild>
|
<Button asChild>
|
||||||
<Link to={`/organizations/${organizationId}/frameworks/create`}>
|
<Link to={`/organizations/${organizationId}/frameworks/create`}>
|
||||||
<Plus className="mr-2 h-4 w-4" />
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
|
|||||||
Reference in New Issue
Block a user