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/edit-lock.tsx
Views: 687
import { Button, Input, Modal, 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 { editCloudFilesystem } from "./api";8import { editModalStyle } from "./util";910interface Props {11cloudFilesystem: CloudFilesystem;12open?: boolean;13setOpen;14refresh;15}1617// Edit the title and color of a cloud file system18export default function EditLock({19cloudFilesystem,20open,21setOpen,22refresh,23}: Props) {24const [changing, setChanging] = useState<boolean>(false);25const [error, setError] = useState<string>("");26const [lock, setLock] = useState<string>(cloudFilesystem.lock ?? "DELETE");2728const doEdit = async () => {29if (cloudFilesystem.lock == lock) {30// no op31setOpen(false);32return;33}34try {35setChanging(true);36await editCloudFilesystem({37id: cloudFilesystem.id,38lock,39});40refresh();41setOpen(false);42} catch (err) {43setError(`${err}`);44} finally {45setChanging(false);46}47};4849return (50<Modal51styles={{ body: editModalStyle(cloudFilesystem) }}52centered53title={54<>55<Icon name={"lock"} /> Edit Delete Confirmation for "56{cloudFilesystem.title}"57</>58}59open={open}60onCancel={() => setOpen(false)}61footer={[62<Button key="cancel" onClick={() => setOpen(false)}>63<CancelText />64</Button>,65<Button66key="ok"67type="primary"68disabled={changing || cloudFilesystem.lock == lock}69onClick={doEdit}70>71Change{" "}72{changing ? <Spin style={{ marginLeft: "15px" }} /> : undefined}73</Button>,74]}75>76If you delete this filesystem, you will first be asked to type this phrase77to avoid mistakes.78<Input79onPressEnter={doEdit}80style={{ width: "100%", margin: "10px 0", color: "red" }}81value={lock}82onChange={(e) => setLock(e.target.value)}83/>84<ShowError error={error} setError={setError} />85</Modal>86);87}888990