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-bucket-storage-class.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 type { CloudFilesystem } from "@cocalc/util/db-schema/cloud-filesystems";7import { editCloudFilesystem } from "./api";8import { BucketStorageClass } from "./bucket";910interface Props {11cloudFilesystem: CloudFilesystem;12open?: boolean;13setOpen;14refresh;15}1617export default function EditBucketStorageClass({18cloudFilesystem,19open,20setOpen,21refresh,22}: Props) {23const [changing, setChanging] = useState<boolean>(false);24const [error, setError] = useState<string>("");25const [configuration, setConfiguration] =26useState<CloudFilesystem>(cloudFilesystem);2728const doEdit = async () => {29if (30cloudFilesystem.bucket_storage_class == configuration.bucket_storage_class31) {32// no op33setOpen(false);34return;35}36try {37setChanging(true);38await editCloudFilesystem({39id: cloudFilesystem.id,40bucket_storage_class: configuration.bucket_storage_class,41});42refresh();43setOpen(false);44} catch (err) {45setError(`${err}`);46} finally {47setChanging(false);48}49};5051return (52<Modal53style={{ maxWidth: "100%" }}54width={750}55centered56title={57<>58<Icon name={"disk-snapshot"} /> Edit the Default Bucket Storage Class59for the cloud file system "{cloudFilesystem.title?.trim()}"60</>61}62open={open}63onCancel={() => setOpen(false)}64footer={[65<Button key="cancel" onClick={() => setOpen(false)}>66<CancelText />67</Button>,68<Button69key="ok"70type="primary"71disabled={72changing ||73cloudFilesystem.bucket_storage_class ==74configuration.bucket_storage_class75}76onClick={doEdit}77>78Change{" "}79{changing ? <Spin style={{ marginLeft: "15px" }} /> : undefined}80</Button>,81]}82>83<BucketStorageClass84configuration={configuration}85setConfiguration={setConfiguration}86/>8788<ShowError error={error} setError={setError} />89</Modal>90);91}929394