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-mountpoint.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 mountpoint of a cloud file system18export default function EditMountpoint({19cloudFilesystem,20open,21setOpen,22refresh,23}: Props) {24const [changing, setChanging] = useState<boolean>(false);25const [error, setError] = useState<string>("");26const [mountpoint, setMountpoint] = useState<string>(27cloudFilesystem.mountpoint,28);2930const doEditMountpoint = async () => {31if (cloudFilesystem.mountpoint == mountpoint) {32// no op33setOpen(false);34return;35}36try {37setChanging(true);38await editCloudFilesystem({39id: cloudFilesystem.id,40mountpoint,41});42refresh();43setOpen(false);44} catch (err) {45setError(`${err}`);46} finally {47setChanging(false);48}49};5051return (52<Modal53styles={{ body: editModalStyle(cloudFilesystem) }}54centered55title={56<>57<Icon name={"folder-open"} /> Edit Mountpoint of "58{cloudFilesystem.title}"59</>60}61open={open}62onCancel={() => setOpen(false)}63footer={[64<Button key="cancel" onClick={() => setOpen(false)}>65<CancelText />66</Button>,67<Button68key="ok"69type="primary"70disabled={changing || cloudFilesystem.mountpoint == mountpoint}71onClick={doEditMountpoint}72>73Change Mountpoint{" "}74{changing ? <Spin style={{ marginLeft: "15px" }} /> : undefined}75</Button>,76]}77>78Mount at <code>~/{mountpoint}</code> on all compute servers.79<Input80onPressEnter={doEditMountpoint}81style={{ width: "100%", marginTop: "10px" }}82value={mountpoint}83onChange={(e) => setMountpoint(e.target.value)}84/>85<ShowError error={error} setError={setError} />86</Modal>87);88}899091