Ignore:
Timestamp:
02/19/26 23:17:54 (5 months ago)
Author:
Mihail <mihail2.naumov@…>
Branches:
main
Children:
4f2900a
Parents:
6270fa4
Message:

Fixed clone auth errors and component names in the component dialogs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • components/BuildDetailsDialog.tsx

    r6270fa4 rd07d68c  
    22import {
    33    Dialog, DialogTitle, DialogContent, DialogActions, Button, Box, Typography,
    4     IconButton, Tab, Tabs, Table, TableBody, TableCell, TableRow, Rating, TextField, Avatar, Chip, Alert
     4    IconButton, Tab, Tabs, Table, TableBody, TableCell, TableRow, Rating, TextField, Avatar, Chip, Alert, Snackbar
    55} from '@mui/material';
    66import CloseIcon from '@mui/icons-material/Close';
     
    3434    const [ratingVal, setRatingVal] = useState(5);
    3535
     36    const [snackbar, setSnackbar] = useState<{
     37        open: boolean;
     38        message: string;
     39        severity: 'error' | 'warning' | 'info' | 'success';
     40    }>({
     41        open: false,
     42        message: '',
     43        severity: 'warning'
     44    });
     45
    3646    useEffect(() => {
    3747        if (open && buildId !== null) {
     
    95105        if (!cloningBuildId) return;
    96106
     107        if(!currentUser){
     108            window.location.href="/auth/login";
     109            return;
     110        }
     111
    97112        try {
    98113            const newBuildId = await onCloneBuild({buildId: cloningBuildId});
     
    101116            setCloningBuildId(null);
    102117        } catch (e) {
    103             alert("Failed to clone build. Please try again.");
     118            // alert("Failed to clone build. Please try again.");
     119            setCloneDialogOpen(false);
     120            setSnackbar({
     121                open: true,
     122                message: 'Failed to clone build. Please try again!',
     123                severity: 'error'
     124            })
    104125        }
    105126    };
     127
     128    const handleCloneClick = () => {
     129        if(!currentUser){
     130            window.location.href="/auth/login";
     131            return;
     132        }
     133
     134        setCloningBuildId(details.id);
     135        setCloneDialogOpen(true);
     136    }
    106137
    107138    if (!open) return null;
     
    242273                                                        size="large"
    243274                                                        startIcon={<AutoFixHighIcon/>}
    244                                                         onClick={() => {
    245                                                             setCloningBuildId(details.id);
    246                                                             setCloneDialogOpen(true);
    247                                                         }}
     275                                                        onClick={handleCloneClick}
    248276                                                    >
    249277                                                        Clone & Edit
     
    362390                </DialogActions>
    363391            </Dialog>
     392            <Snackbar
     393                open={snackbar.open}
     394                autoHideDuration={5000}
     395                onClose={() => setSnackbar(prev => ({...prev, open: false}))}
     396                anchorOrigin={{vertical: 'bottom', horizontal: 'center'}}
     397            >
     398                <Alert
     399                    onClose={() => setSnackbar(prev => ({...prev, open: false}))}
     400                    severity={snackbar.severity}
     401                    variant="filled"
     402                    sx={{width: '100%'}}
     403                >
     404                    {snackbar.message}
     405                </Alert>
     406            </Snackbar>
    364407        </>
    365408    );
Note: See TracChangeset for help on using the changeset viewer.