move Action getActionName util fn to DisplayCell.tsx

This commit is contained in:
Sidney Alcantara
2022-11-14 16:11:34 +11:00
parent e9bc4a5a9b
commit 2822689897
3 changed files with 13 additions and 12 deletions

View File

@@ -1,5 +1,14 @@
import { IDisplayCellProps } from "@src/components/fields/types";
import { get } from "lodash-es";
export default function Action({ name, value }: IDisplayCellProps) {
return <>{value ? value.status : name}</>;
export const getActionName = (column: IDisplayCellProps["column"]) => {
const config = get(column, "config");
if (!get(config, "customName.enabled")) {
return get(column, "name");
}
return get(config, "customName.actionName") || get(column, "name");
};
export default function Action({ value, column }: IDisplayCellProps) {
return <>{value ? value.status : getActionName(column)}</>;
}

View File

@@ -4,15 +4,7 @@ import { Stack } from "@mui/material";
import ActionFab from "./ActionFab";
import { sanitiseCallableName, isUrl } from "./utils";
import { get } from "lodash-es";
export const getActionName = (column: any) => {
const config = get(column, "config");
if (!get(config, "customName.enabled")) {
return get(column, "name");
}
return get(config, "customName.actionName") || get(column, "name");
};
import { getActionName } from "./DisplayCell";
export default function Action({
column,

View File

@@ -10,7 +10,7 @@ import ActionFab from "./ActionFab";
import { tableScope, tableRowsAtom } from "@src/atoms/tableScope";
import { fieldSx, getFieldId } from "@src/components/SideDrawer/utils";
import { sanitiseCallableName, isUrl } from "./utils";
import { getActionName } from "./TableCell";
import { getActionName } from "./DisplayCell";
export default function Action({
column,