import { DialogTrigger, DialogSurface, DialogTitle, DialogBody, DialogActions, DialogContent, Button, Field, Input, makeStyles, tokens, Checkbox, } from "@fluentui/react-components"; import {useState} from "react"; import {useToast} from "../../message"; import {useStoreConnection} from "../../store/connection"; import {useStoreBucket} from "../../store/bucket"; const useStyle = makeStyles({ container: { backgroundColor: tokens.colorNeutralBackground1, display: "flex", flexDirection: "row", height: "100%", width: "100%", gridColumnStart: 0, }, content: {}, input: { margin: '1rem', }, checks: { margin: '1rem', display: "flex", }, }); export interface BucketCreateProps { openFn: (open: boolean) => void; } export function BucketCreate(props: BucketCreateProps) { const styles = useStyle(); const {dispatchMessage} = useToast(); const [name, set_name] = useState(); const [public_read, set_public_read] = useState(false); const [public_read_write, set_public_read_write] = useState(false); const {conn_active} = useStoreConnection(); const {bucket_create, bucket_get} = useStoreBucket() async function create() { if (!name) { dispatchMessage('桶名不能为空', "warning") return } bucket_create(conn_active!, name, public_read, public_read_write); bucket_get(conn_active!, true) props.openFn(false) } return <> 在 {conn_active?.name} 新建桶
{ set_name(e.target.value) }}>
{ if (public_read_write) { return } set_public_read(e.target.checked); }} label={"公共读"}> { set_public_read_write(e.target.checked) if (e.target.checked) { set_public_read(e.target.checked) } }} label={"公共读/写"}>
}