Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/compute/cloud-filesystem/delete-filesystem.tsx
Views: 687
import { Alert, Button, Input, Modal, Popconfirm, Spin } from "antd";1import { useState } from "react";23import ShowError from "@cocalc/frontend/components/error";4import { Icon } from "@cocalc/frontend/components/icon";5import { CancelText } from "@cocalc/frontend/i18n/components";6import type { CloudFilesystem } from "@cocalc/util/db-schema/cloud-filesystems";7import { deleteCloudFilesystem } from "./api";8import { editModalStyle } from "./util";910interface Props {11cloudFilesystem: CloudFilesystem;12open?: boolean;13setOpen;14refresh;15}1617export default function DeleteCloudFilesystem({18cloudFilesystem,19open,20setOpen,21refresh,22}: Props) {23const lock = cloudFilesystem.lock ?? "DELETE";24const [unlock, setUnlock] = useState<string>("");25const [deleting, setDeleting] = useState<boolean>(false);26const [error, setError] = useState<string>("");2728const doDelete = async () => {29try {30setDeleting(true);31await deleteCloudFilesystem({ id: cloudFilesystem.id, lock: unlock });32refresh();33setOpen(false);34} catch (err) {35setError(`${err}`);36} finally {37setDeleting(false);38}39};4041return (42<Modal43styles={{ body: editModalStyle(cloudFilesystem) }}44centered45title={46<>47<Icon name="trash" /> Delete "{cloudFilesystem.title}"{" "}48</>49}50open={open}51onCancel={() => setOpen(false)}52footer={[53<Button key="cancel" onClick={() => setOpen(false)}>54<CancelText />55</Button>,56<Popconfirm57key="ok"58title={59<>60<b>Permanently delete</b> '{cloudFilesystem.title}' (Id:{" "}61{cloudFilesystem.project_specific_id})?62</>63}64onConfirm={doDelete}65okText="Delete"66cancelText="No"67>68<Button type="primary" danger disabled={unlock != lock || deleting}>69<Icon name="trash" /> Delete...{" "}70{deleting ? <Spin style={{ marginLeft: "15px" }} /> : undefined}71</Button>72</Popconfirm>,73]}74>75<Alert76type="warning"77showIcon78message={79<>80<p>81Are you sure you want to delete '{cloudFilesystem.title}' (Id:{" "}82{cloudFilesystem.project_specific_id}) with mountpoint{" "}83<code>~/{cloudFilesystem.mountpoint}</code>? This action will84permanently delete all data. <b>Data will not be recoverable.</b>85</p>86<p>Confirm deletion by typing "{lock}" below:</p>87<Input88status={unlock != lock ? "error" : "warning"}89value={unlock}90onChange={(e) => setUnlock(e.target.value)}91/>92</>93}94/>95<ShowError error={error} setError={setError} />96</Modal>97);98}99100101