actions menu
This commit is contained in:
1 parent
61651a0f4d
commit
56e0ac9640
2 files changed
+8
-7
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import Menu from "@mui/material/Menu";
|
import Menu from "@mui/material/Menu";
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
@@ -6,7 +6,7 @@ import Settings from "@/assets/icons/settings-bold.svg?react";
|
|||||||
|
|
||||||
export type ActionMenuItem = {
|
export type ActionMenuItem = {
|
||||||
id: number | string;
|
id: number | string;
|
||||||
label: string;
|
label: React.ReactNode;
|
||||||
action: Function;
|
action: Function;
|
||||||
closeMenu?: boolean;
|
closeMenu?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import { useMediaQuery } from "@mui/material";
|
|||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { ActionsMenu } from "@/Components/v2/ActionsMenu";
|
import { ActionsMenu } from "@/Components/v2/ActionsMenu";
|
||||||
import type { ActionMenuItem } from "@/Components/v2/ActionsMenu";
|
import type { ActionMenuItem } from "@/Components/v2/ActionsMenu";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
const getActions = (t: Function): ActionMenuItem[] => {
|
const getActions = (theme: any, t: Function): ActionMenuItem[] => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -57,7 +58,7 @@ const getActions = (t: Function): ActionMenuItem[] => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 7,
|
id: 7,
|
||||||
label: "Delete",
|
label: <Typography color={theme.palette.error.main}>Remove</Typography>,
|
||||||
action: () => {
|
action: () => {
|
||||||
console.log("Open delete");
|
console.log("Open delete");
|
||||||
},
|
},
|
||||||
@@ -66,7 +67,7 @@ const getActions = (t: Function): ActionMenuItem[] => {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getHeaders = (t: Function) => {
|
const getHeaders = (theme: any, t: Function) => {
|
||||||
const headers: Header<IMonitor>[] = [
|
const headers: Header<IMonitor>[] = [
|
||||||
{
|
{
|
||||||
id: "name",
|
id: "name",
|
||||||
@@ -104,7 +105,7 @@ const getHeaders = (t: Function) => {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
content: t("actions"),
|
content: t("actions"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
return <ActionsMenu items={getActions(t)} />;
|
return <ActionsMenu items={getActions(theme, t)} />;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -116,7 +117,7 @@ export const MonitorTable = ({ monitors }: { monitors: IMonitor[] }) => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
||||||
|
|
||||||
let headers = getHeaders(t);
|
let headers = getHeaders(theme, t);
|
||||||
|
|
||||||
if (isSmall) {
|
if (isSmall) {
|
||||||
headers = headers.filter((h) => h.id !== "histogram");
|
headers = headers.filter((h) => h.id !== "histogram");
|
||||||
|
|||||||
Reference in new issue
Block a user