mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-21 11:28:43 +00:00
feat: removed last bit of workspace in frontend. Fatality!
This commit is contained in:
+16
-19
@@ -21,7 +21,7 @@ import {
|
||||
ProjectPermissionActions,
|
||||
ProjectPermissionSub,
|
||||
useOrganization,
|
||||
useWorkspace
|
||||
useProject
|
||||
} from "@app/context";
|
||||
import { usePopUp, useToggle } from "@app/hooks";
|
||||
import {
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
} from "@app/hooks/api";
|
||||
import { fetchProjectKmsBackup } from "@app/hooks/api/kms/queries";
|
||||
import { INTERNAL_KMS_KEY_ID, KmsType } from "@app/hooks/api/kms/types";
|
||||
import { Organization, Workspace } from "@app/hooks/api/types";
|
||||
import { Organization, Project } from "@app/hooks/api/types";
|
||||
|
||||
const formSchema = z.object({
|
||||
kmsKeyId: z.string()
|
||||
@@ -44,32 +44,29 @@ const BackupConfirmationModal = ({
|
||||
isOpen,
|
||||
onOpenChange,
|
||||
org,
|
||||
workspace
|
||||
project
|
||||
}: {
|
||||
isOpen: boolean;
|
||||
onOpenChange: (state: boolean) => void;
|
||||
org?: Organization;
|
||||
workspace?: Workspace;
|
||||
project?: Project;
|
||||
}) => {
|
||||
const [isGeneratingBackup, setGeneratingBackup] = useToggle();
|
||||
const downloadKmsBackup = async () => {
|
||||
if (!workspace || !org) {
|
||||
if (!project || !org) {
|
||||
return;
|
||||
}
|
||||
|
||||
setGeneratingBackup.on();
|
||||
|
||||
try {
|
||||
const { secretManager } = await fetchProjectKmsBackup(workspace.id);
|
||||
const { secretManager } = await fetchProjectKmsBackup(project.id);
|
||||
|
||||
const [, , kmsFunction] = secretManager.split(".");
|
||||
const file = secretManager;
|
||||
|
||||
const blob = new Blob([file], { type: "text/plain;charset=utf-8" });
|
||||
FileSaver.saveAs(
|
||||
blob,
|
||||
`kms-backup-${org.slug}-${workspace.slug}-${kmsFunction}.infisical.txt`
|
||||
);
|
||||
FileSaver.saveAs(blob, `kms-backup-${org.slug}-${project.slug}-${kmsFunction}.infisical.txt`);
|
||||
|
||||
onOpenChange(false);
|
||||
} catch (err) {
|
||||
@@ -110,20 +107,20 @@ const LoadBackupModal = ({
|
||||
isOpen,
|
||||
onOpenChange,
|
||||
org,
|
||||
workspace
|
||||
workspace: project
|
||||
}: {
|
||||
isOpen: boolean;
|
||||
onOpenChange: (state: boolean) => void;
|
||||
org?: Organization;
|
||||
workspace: Workspace;
|
||||
workspace: Project;
|
||||
}) => {
|
||||
const fileUploadRef = useRef<HTMLInputElement>(null);
|
||||
const { mutateAsync: loadKmsBackup, isPending } = useLoadProjectKmsBackup(workspace.id);
|
||||
const { mutateAsync: loadKmsBackup, isPending } = useLoadProjectKmsBackup(project.id);
|
||||
const [backupContent, setBackupContent] = useState("");
|
||||
const [backupFileName, setBackupFileName] = useState("");
|
||||
|
||||
const uploadKmsBackup = async () => {
|
||||
if (!workspace || !org) {
|
||||
if (!project || !org) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -222,13 +219,13 @@ const LoadBackupModal = ({
|
||||
|
||||
export const EncryptionTab = () => {
|
||||
const { currentOrg } = useOrganization();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { currentProject } = useProject();
|
||||
|
||||
const { data: externalKmsList } = useGetExternalKmsList(currentOrg.id);
|
||||
const { data: activeKms } = useGetActiveProjectKms(currentWorkspace.id);
|
||||
const { data: activeKms } = useGetActiveProjectKms(currentProject.id);
|
||||
|
||||
const { mutateAsync: updateProjectKms, isPending: isUpdatingProjectKms } = useUpdateProjectKms(
|
||||
currentWorkspace.id
|
||||
currentProject.id
|
||||
);
|
||||
const { popUp, handlePopUpToggle, handlePopUpOpen } = usePopUp([
|
||||
"createBackupConfirmation",
|
||||
@@ -336,13 +333,13 @@ export const EncryptionTab = () => {
|
||||
isOpen={popUp.createBackupConfirmation.isOpen}
|
||||
onOpenChange={(state: boolean) => handlePopUpToggle("createBackupConfirmation", state)}
|
||||
org={currentOrg}
|
||||
workspace={currentWorkspace}
|
||||
project={currentProject}
|
||||
/>
|
||||
<LoadBackupModal
|
||||
isOpen={popUp.loadBackup.isOpen}
|
||||
onOpenChange={(state: boolean) => handlePopUpToggle("loadBackup", state)}
|
||||
org={currentOrg}
|
||||
workspace={currentWorkspace}
|
||||
workspace={currentProject}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user