FIX[WebApp]: Disable delete for sheet if it is the last one
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
6e8c47d4f6
commit
ebc31780ab
@@ -1,4 +1,4 @@
|
|||||||
import { Button, Menu, MenuItem, styled } from "@mui/material";
|
import { Button, Menu, MenuItem, MenuItemProps, styled } from "@mui/material";
|
||||||
import { ChevronDown } from "lucide-react";
|
import { ChevronDown } from "lucide-react";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { theme } from "../../theme";
|
import { theme } from "../../theme";
|
||||||
@@ -14,6 +14,7 @@ interface SheetTabProps {
|
|||||||
onSelected: () => void;
|
onSelected: () => void;
|
||||||
onColorChanged: (hex: string) => void;
|
onColorChanged: (hex: string) => void;
|
||||||
onRenamed: (name: string) => void;
|
onRenamed: (name: string) => void;
|
||||||
|
canDelete: () => boolean;
|
||||||
onDeleted: () => void;
|
onDeleted: () => void;
|
||||||
workbookState: WorkbookState;
|
workbookState: WorkbookState;
|
||||||
}
|
}
|
||||||
@@ -92,6 +93,7 @@ function SheetTab(props: SheetTabProps) {
|
|||||||
Change Color
|
Change Color
|
||||||
</StyledMenuItem>
|
</StyledMenuItem>
|
||||||
<StyledMenuItem
|
<StyledMenuItem
|
||||||
|
disabled={!props.canDelete()}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
props.onDeleted();
|
props.onDeleted();
|
||||||
handleClose();
|
handleClose();
|
||||||
@@ -137,16 +139,20 @@ const StyledMenu = styled(Menu)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledMenuItem = styled(MenuItem)`
|
const StyledMenuItem = styled(MenuItem)<MenuItemProps>(({}) => ({
|
||||||
display: flex;
|
display: "flex",
|
||||||
justify-content: space-between;
|
justifyContent: "space-between",
|
||||||
font-size: 12px;
|
fontSize: "12px",
|
||||||
width: calc(100% - 8px);
|
width: "calc(100% - 8px)",
|
||||||
margin: 0px 4px;
|
margin: "0px 4px",
|
||||||
border-radius: 4px;
|
borderRadius: "4px",
|
||||||
padding: 8px;
|
padding: "8px",
|
||||||
height: 32px;
|
height: "32px",
|
||||||
`;
|
'&:disabled': {
|
||||||
|
color: "#BDBDBD",
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
const TabWrapper = styled("div")<{ $color: string; $selected: boolean }>`
|
const TabWrapper = styled("div")<{ $color: string; $selected: boolean }>`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
onRenamed={(name: string): void => {
|
onRenamed={(name: string): void => {
|
||||||
props.onSheetRenamed(name);
|
props.onSheetRenamed(name);
|
||||||
}}
|
}}
|
||||||
|
canDelete={(): boolean => {
|
||||||
|
return sheets.length > 1;
|
||||||
|
}}
|
||||||
onDeleted={(): void => {
|
onDeleted={(): void => {
|
||||||
props.onSheetDeleted();
|
props.onSheetDeleted();
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user