Skip to content

Commit

Permalink
Remove button appearance settings and related code
Browse files Browse the repository at this point in the history
- Delete button appearance configuration from SettingsMenu
- Remove dynamic button display logic from AppHeader
- Clean up related code in AppHeaderActions and SettingsStore
- Simplify button rendering across components
  • Loading branch information
georgi committed Feb 3, 2025
1 parent eaf0556 commit fcf21bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 95 deletions.
26 changes: 0 additions & 26 deletions web/src/components/menus/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ function SettingsMenu() {
setSelectionMode,
setWorkflowLayout,
setTimeFormat,
setButtonAppearance,
setSelectNodesOnDrag,
setShowWelcomeOnStartup,
setEnableComfy,
Expand All @@ -272,7 +271,6 @@ function SettingsMenu() {
setSelectionMode: state.setSelectionMode,
setWorkflowLayout: state.setWorkflowLayout,
setTimeFormat: state.setTimeFormat,
setButtonAppearance: state.setButtonAppearance,
setSelectNodesOnDrag: state.setSelectNodesOnDrag,
setShowWelcomeOnStartup: state.setShowWelcomeOnStartup
}));
Expand Down Expand Up @@ -550,30 +548,6 @@ function SettingsMenu() {
</Typography>
</div>

<div className="settings-item">
<FormControl>
<InputLabel htmlFor={id}>Top Panel Button Display</InputLabel>
<Select
id={id}
labelId={id}
value={settings.buttonAppearance || "both"}
variant="standard"
onChange={(e) =>
setButtonAppearance(
e.target.value as "text" | "icon" | "both"
)
}
>
<MenuItem value={"text"}>Show Text only</MenuItem>
<MenuItem value={"icon"}>Show Icon only</MenuItem>
<MenuItem value={"both"}>Show Text and Icon</MenuItem>
</Select>
</FormControl>
<Typography className="description">
Change the display of the buttons in the top and center panel.
</Typography>
</div>

{user && user.auth_token && (
<>
<Typography variant="h3">Nodetool API</Typography>
Expand Down
77 changes: 22 additions & 55 deletions web/src/components/panels/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,35 +177,11 @@ const AppHeader: React.FC<AppHeaderProps> = React.memo(() => {
const navigate = useNavigate();
const path = useLocation().pathname;

const globalButtonAppearance = useSettingsStore(
(state) => state.settings.buttonAppearance
);

const [buttonAppearance, setButtonAppearance] = useState(
globalButtonAppearance
);

const { helpOpen, handleCloseHelp, handleOpenHelp } = useAppHeaderStore();

const { handlePanelToggle, collapsed: panelLeftCollapsed } =
useResizePanel("left");

const handleResize = useCallback(() => {
if (window.innerWidth <= 1200) {
setButtonAppearance("icon");
} else {
setButtonAppearance(globalButtonAppearance);
}
}, [globalButtonAppearance]);

useEffect(() => {
handleResize();
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
};
}, [handleResize]);

const NavigationButtons = useMemo(
() => (
<Box className="nav-buttons">
Expand All @@ -225,7 +201,7 @@ const AppHeader: React.FC<AppHeaderProps> = React.memo(() => {
: ThemeNodetool.palette.c_white
}}
>
{buttonAppearance !== "text" && <ExamplesIcon />}
<ExamplesIcon />
Examples
</Button>
</Tooltip>
Expand All @@ -249,27 +225,25 @@ const AppHeader: React.FC<AppHeaderProps> = React.memo(() => {
: ThemeNodetool.palette.c_white
}}
>
{buttonAppearance !== "text" && (
<IconForType
iconName="asset"
showTooltip={false}
svgProps={{
fill: path.startsWith("/assets")
? ThemeNodetool.palette.c_hl1
: ThemeNodetool.palette.c_white
}}
containerStyle={{
borderRadius: "0 0 3px 0",
marginLeft: "0.1em",
marginTop: "0"
}}
bgStyle={{
backgroundColor: "transparent",
width: "30px",
height: "20px"
}}
/>
)}
<IconForType
iconName="asset"
showTooltip={false}
svgProps={{
fill: path.startsWith("/assets")
? ThemeNodetool.palette.c_hl1
: ThemeNodetool.palette.c_white
}}
containerStyle={{
borderRadius: "0 0 3px 0",
marginLeft: "0.1em",
marginTop: "0"
}}
bgStyle={{
backgroundColor: "transparent",
width: "30px",
height: "20px"
}}
/>
Assets
</Button>
</Tooltip>
Expand Down Expand Up @@ -307,7 +281,7 @@ const AppHeader: React.FC<AppHeaderProps> = React.memo(() => {
)}
</Box>
),
[path, buttonAppearance, navigate, panelLeftCollapsed, handlePanelToggle]
[path, navigate, panelLeftCollapsed, handlePanelToggle]
);

const RightSideButtons = useMemo(
Expand Down Expand Up @@ -357,14 +331,7 @@ const AppHeader: React.FC<AppHeaderProps> = React.memo(() => {
<SettingsMenu />
</Box>
),
[
path,
buttonAppearance,
helpOpen,
handleCloseHelp,
navigate,
handleOpenHelp
]
[path, helpOpen, handleCloseHelp, navigate, handleOpenHelp]
);

return (
Expand Down
3 changes: 0 additions & 3 deletions web/src/components/panels/AppHeaderActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,6 @@ const RunAsAppButton = memo(() => {
const AppHeaderActions: React.FC = () => {
const openNodeMenu = useNodeMenuStore((state) => state.openNodeMenu);
const path = useLocation().pathname;
const buttonAppearance = useSettingsStore(
(state) => state.settings.buttonAppearance
);
const { autoLayout } = useNodes((state) => ({
autoLayout: state.autoLayout
}));
Expand Down
11 changes: 0 additions & 11 deletions web/src/stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface Settings {
assetsOrder: "name" | "date";
assetItemSize: number;
timeFormat: "12h" | "24h";
buttonAppearance: "text" | "icon" | "both";
alertBeforeTabClose: boolean;
selectNodesOnDrag: boolean;
showWelcomeOnStartup: boolean;
Expand All @@ -35,7 +34,6 @@ interface SettingsStore {
setAssetsOrder: (value: "name" | "date") => void;
setAssetItemSize: (value: number) => void;
setTimeFormat: (value: "12h" | "24h") => void;
setButtonAppearance: (value: "text" | "icon" | "both") => void;
setAlertBeforeTabClose: (value: boolean) => void;
setSelectNodesOnDrag: (value: boolean) => void;
setShowWelcomeOnStartup: (value: boolean) => void;
Expand All @@ -52,7 +50,6 @@ export const defaultSettings: Settings = {
assetsOrder: "name",
assetItemSize: 2,
timeFormat: "12h",
buttonAppearance: "both",
alertBeforeTabClose: true,
selectNodesOnDrag: false,
showWelcomeOnStartup: true
Expand Down Expand Up @@ -152,14 +149,6 @@ export const useSettingsStore = create<SettingsStore>()(

resetSettings: () => set({ settings: { ...defaultSettings } }),

setButtonAppearance: (value: "text" | "icon" | "both") =>
set((state) => ({
settings: {
...state.settings,
buttonAppearance: value || defaultSettings.buttonAppearance
}
})),

setAlertBeforeTabClose: (value: boolean) =>
set((state) => ({
settings: {
Expand Down

0 comments on commit fcf21bd

Please sign in to comment.