From 16f0999bcc58ac7febe17ddd72f3f6d03d9bd2a3 Mon Sep 17 00:00:00 2001 From: lorinjameson Date: Tue, 24 Sep 2024 09:05:50 -0700 Subject: [PATCH] Updates --- .../CreateGroupDialog/CreateGroupDialog.tsx | 99 ++++++++----- src/components/Groups/Groups.tsx | 138 ++++++++++-------- src/providers/ConfigToolProvider.tsx | 1 + src/types/index.ts | 2 + 4 files changed, 146 insertions(+), 94 deletions(-) diff --git a/src/components/CreateGroupDialog/CreateGroupDialog.tsx b/src/components/CreateGroupDialog/CreateGroupDialog.tsx index 196c90d..2994c46 100644 --- a/src/components/CreateGroupDialog/CreateGroupDialog.tsx +++ b/src/components/CreateGroupDialog/CreateGroupDialog.tsx @@ -1,11 +1,11 @@ -import Button from "@mui/material/Button"; -import TextField from "@mui/material/TextField"; -import Dialog from "@mui/material/Dialog"; -import DialogActions from "@mui/material/DialogActions"; -import DialogContent from "@mui/material/DialogContent"; -import DialogTitle from "@mui/material/DialogTitle"; -import { GroupDefinition, RoleDefinition } from "../../types"; -import { useEffect, useState } from "react"; +import Button from '@mui/material/Button'; +import TextField from '@mui/material/TextField'; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogTitle from '@mui/material/DialogTitle'; +import { GroupDefinition, RoleDefinition } from '../../types'; +import { useEffect, useState } from 'react'; import { FormControl, MenuItem, @@ -14,7 +14,7 @@ import { FormControlLabel, Checkbox, FormGroup, -} from "@mui/material"; +} from '@mui/material'; export interface CreateGroupDialogProps { open: boolean; @@ -23,7 +23,14 @@ export interface CreateGroupDialogProps { onClose(): void; - onSave(_name: string, _description: string, _roleId: string, _isAdmin: boolean, _isDefault: boolean): void; + onSave( + _name: string, + _description: string, + _roleId: string, + _isAdmin: boolean, + _isDefault: boolean, + _isReadOnly: boolean + ): void; } const CreateGroupDialog = (props: CreateGroupDialogProps) => { @@ -34,6 +41,7 @@ const CreateGroupDialog = (props: CreateGroupDialogProps) => { const [roleId, setRoleId] = useState(); const [isAdmin, setIsAdmin] = useState(false); const [isDefault, setIsDefault] = useState(false); + const [isReadOnly, setIsReadOnly] = useState(false); useEffect(() => { if (group) { @@ -42,23 +50,26 @@ const CreateGroupDialog = (props: CreateGroupDialogProps) => { setRoleId(group.role_id); setIsAdmin(group.is_admin); setIsDefault(group.is_default); + setIsReadOnly(group.is_read_only); } else { setName(undefined); setDescription(undefined); setRoleId(undefined); setIsAdmin(false); setIsDefault(false); + setIsReadOnly(false); } }, [group]); const handleSave = () => { if (name && description && roleId) { - onSave(name, description, roleId, isAdmin, isDefault); + onSave(name, description, roleId, isAdmin, isDefault, isReadOnly); setName(undefined); setDescription(undefined); setRoleId(undefined); setIsAdmin(false); setIsDefault(false); + setIsReadOnly(false); } }; @@ -70,24 +81,33 @@ const CreateGroupDialog = (props: CreateGroupDialogProps) => { }; const handleChangeAdmin = (checked: boolean) => { - if(checked) { + if (checked) { setIsAdmin(true); setIsDefault(false); } else { setIsAdmin(false); } - } + }; + + const handleChangeReadOnly = (checked: boolean) => { + if (checked) { + setIsReadOnly(true); + setIsAdmin(false); + } else { + setIsReadOnly(false); + } + }; const handleChangeDefault = (checked: boolean) => { - if(checked) { + if (checked) { setIsDefault(true); setIsAdmin(false); } else { setIsDefault(false); } - } + }; - const mode = group ? "Edit" : "Create"; + const mode = group ? 'Edit' : 'Create'; const valid = name && description && roleId; return ( @@ -95,34 +115,34 @@ const CreateGroupDialog = (props: CreateGroupDialogProps) => { setName(e.target.value)} /> setDescription(e.target.value)} /> - Role + Role