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-project.tsx
Views: 687
import { Button, 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 { SelectProject } from "@cocalc/frontend/projects/select-project";7import type { CloudFilesystem } from "@cocalc/util/db-schema/cloud-filesystems";8import { editCloudFilesystem } from "./api";9import { editModalStyle } from "./util";1011interface Props {12cloudFilesystem: CloudFilesystem;13open?: boolean;14setOpen;15refresh;16}1718// Edit the project_id of a cloud file system19export default function EditProjectId({20cloudFilesystem,21open,22setOpen,23refresh,24}: Props) {25const [changing, setChanging] = useState<boolean>(false);26const [error, setError] = useState<string>("");27const [project_id, setProjectId] = useState<string>(28cloudFilesystem.project_id,29);3031const doEdit = async () => {32if (cloudFilesystem.project_id == project_id) {33// no op34setOpen(false);35return;36}37try {38setChanging(true);39await editCloudFilesystem({40id: cloudFilesystem.id,41project_id,42});43refresh();44setOpen(false);45} catch (err) {46setError(`${err}`);47} finally {48setChanging(false);49}50};5152return (53<Modal54styles={{ body: editModalStyle(cloudFilesystem) }}55centered56title={57<>58<Icon name={"folder-open"} /> Move "{cloudFilesystem.title}" to59Another Project60</>61}62open={open}63onCancel={() => setOpen(false)}64footer={[65<Button key="cancel" onClick={() => setOpen(false)}>66<CancelText />67</Button>,68<Button69key="ok"70type="primary"71disabled={changing || cloudFilesystem.project_id == project_id}72onClick={doEdit}73>74Move Filesystem{" "}75{changing ? <Spin style={{ marginLeft: "15px" }} /> : undefined}76</Button>,77]}78>79<p>80You can instantly move this cloud file system to any other project that81you are a collaborator on.82</p>83<SelectProject84at_top={[cloudFilesystem.project_id]}85value={project_id}86onChange={setProjectId}87/>88<ShowError error={error} setError={setError} />89</Modal>90);91}929394