mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
Add iconButton to open dot menu
This commit is contained in:
@ -19,16 +19,15 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Popper, InputAdornment} from "@mui/material";
|
import {Popper, InputAdornment, Box} from "@mui/material";
|
||||||
import AppBar from "@mui/material/AppBar";
|
import AppBar from "@mui/material/AppBar";
|
||||||
import Autocomplete from "@mui/material/Autocomplete";
|
import Autocomplete from "@mui/material/Autocomplete";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Icon from "@mui/material/Icon";
|
import Icon from "@mui/material/Icon";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import ListItemIcon from "@mui/material/ListItemIcon";
|
import ListItemIcon from "@mui/material/ListItemIcon";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import Toolbar from "@mui/material/Toolbar";
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
import React, {useContext, useEffect, useState} from "react";
|
import React, {useContext, useEffect, useRef, useState} from "react";
|
||||||
import {useLocation, useNavigate} from "react-router-dom";
|
import {useLocation, useNavigate} from "react-router-dom";
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
import QBreadcrumbs, {routeToLabel} from "qqq/components/horseshoe/Breadcrumbs";
|
import QBreadcrumbs, {routeToLabel} from "qqq/components/horseshoe/Breadcrumbs";
|
||||||
@ -45,7 +44,8 @@ interface Props
|
|||||||
isMini?: boolean;
|
isMini?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface HistoryEntry {
|
interface HistoryEntry
|
||||||
|
{
|
||||||
id: number;
|
id: number;
|
||||||
path: string;
|
path: string;
|
||||||
label: string;
|
label: string;
|
||||||
@ -64,7 +64,7 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
const route = useLocation().pathname.split("/").slice(1);
|
const route = useLocation().pathname.split("/").slice(1);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const {pageHeader} = useContext(QContext);
|
const {pageHeader, setDotMenuOpen} = useContext(QContext);
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
@ -99,7 +99,7 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
const options = [] as any;
|
const options = [] as any;
|
||||||
history.entries.reverse().forEach((entry, index) =>
|
history.entries.reverse().forEach((entry, index) =>
|
||||||
options.push({label: `${entry.label} index`, id: index, key: index, path: entry.path, iconName: entry.iconName})
|
options.push({label: `${entry.label} index`, id: index, key: index, path: entry.path, iconName: entry.iconName})
|
||||||
)
|
);
|
||||||
setHistory(options);
|
setHistory(options);
|
||||||
|
|
||||||
// Remove event listener on cleanup
|
// Remove event listener on cleanup
|
||||||
@ -111,7 +111,7 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
const goToHistory = (path: string) =>
|
const goToHistory = (path: string) =>
|
||||||
{
|
{
|
||||||
navigate(path);
|
navigate(path);
|
||||||
}
|
};
|
||||||
|
|
||||||
function buildHistoryEntries()
|
function buildHistoryEntries()
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
const options = [] as any;
|
const options = [] as any;
|
||||||
history.entries.reverse().forEach((entry, index) =>
|
history.entries.reverse().forEach((entry, index) =>
|
||||||
options.push({label: entry.label, id: index, key: index, path: entry.path, iconName: entry.iconName})
|
options.push({label: entry.label, id: index, key: index, path: entry.path, iconName: entry.iconName})
|
||||||
)
|
);
|
||||||
setHistory(options);
|
setHistory(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,12 +133,12 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
|
|
||||||
const handleAutocompleteOnChange = (event: any, value: any, reason: any, details: any) =>
|
const handleAutocompleteOnChange = (event: any, value: any, reason: any, details: any) =>
|
||||||
{
|
{
|
||||||
if(value)
|
if (value)
|
||||||
{
|
{
|
||||||
goToHistory(value.path);
|
goToHistory(value.path);
|
||||||
}
|
}
|
||||||
setAutocompleteValue(null);
|
setAutocompleteValue(null);
|
||||||
}
|
};
|
||||||
|
|
||||||
const CustomPopper = function (props: any)
|
const CustomPopper = function (props: any)
|
||||||
{
|
{
|
||||||
@ -146,8 +146,8 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
{...props}
|
{...props}
|
||||||
style={{whiteSpace: "nowrap", width: "auto"}}
|
style={{whiteSpace: "nowrap", width: "auto"}}
|
||||||
placement="bottom-end"
|
placement="bottom-end"
|
||||||
/>)
|
/>);
|
||||||
}
|
};
|
||||||
|
|
||||||
const renderHistory = () =>
|
const renderHistory = () =>
|
||||||
{
|
{
|
||||||
@ -184,7 +184,7 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Styles for the navbar icons
|
// Styles for the navbar icons
|
||||||
const iconsStyle = ({
|
const iconsStyle = ({
|
||||||
@ -210,18 +210,18 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
const {pathToLabelMap} = useContext(QContext);
|
const {pathToLabelMap} = useContext(QContext);
|
||||||
const fullPathToLabel = (fullPath: string, route: string): string =>
|
const fullPathToLabel = (fullPath: string, route: string): string =>
|
||||||
{
|
{
|
||||||
if(fullPath.endsWith("/"))
|
if (fullPath.endsWith("/"))
|
||||||
{
|
{
|
||||||
fullPath = fullPath.replace(/\/+$/, "");
|
fullPath = fullPath.replace(/\/+$/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pathToLabelMap && pathToLabelMap[fullPath])
|
if (pathToLabelMap && pathToLabelMap[fullPath])
|
||||||
{
|
{
|
||||||
return pathToLabelMap[fullPath];
|
return pathToLabelMap[fullPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (routeToLabel(route));
|
return (routeToLabel(route));
|
||||||
}
|
};
|
||||||
|
|
||||||
const breadcrumbTitle = fullPathToLabel(fullPath, route[route.length - 1]);
|
const breadcrumbTitle = fullPathToLabel(fullPath, route[route.length - 1]);
|
||||||
|
|
||||||
@ -242,9 +242,14 @@ function NavBar({absolute, light, isMini}: Props): JSX.Element
|
|||||||
</Box>
|
</Box>
|
||||||
{isMini ? null : (
|
{isMini ? null : (
|
||||||
<Box sx={(theme) => navbarRow(theme, {isMini})}>
|
<Box sx={(theme) => navbarRow(theme, {isMini})}>
|
||||||
<Box pr={0} mr={-2}>
|
<Box mt={"-0.25rem"} pb={"0.75rem"} pr={2} mr={-2} sx={{"& *": {cursor: "pointer !important"}}}>
|
||||||
{renderHistory()}
|
{renderHistory()}
|
||||||
</Box>
|
</Box>
|
||||||
|
<Box mt={"-1rem"}>
|
||||||
|
<IconButton size="small" disableRipple color="inherit" onClick={() => setDotMenuOpen(true)}>
|
||||||
|
<Icon sx={iconsStyle} fontSize="small">search</Icon>
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
|
Reference in New Issue
Block a user