stop pushing rowRef to user

This commit is contained in:
shamsmosowi
2022-03-24 14:17:50 +11:00
parent 7be80a8560
commit 4eaec3fe1b
2 changed files with 12 additions and 11 deletions

View File

@@ -38,13 +38,10 @@ export default function SideDrawer() {
const handleNavigate = (direction: "up" | "down") => () => {
if (!tableState?.rows) return;
let row = cell!.row;
if (direction === "up" && row > 0) row -= 1;
if (direction === "down" && row < tableState.rows.length - 1) row += 1;
setCell!((cell) => ({ column: cell!.column, row }));
const idx = tableState?.columns[cell!.column]?.index;
dataGridRef?.current?.selectCell({ rowIdx: row, idx }, false);
};
@@ -68,13 +65,6 @@ export default function SideDrawer() {
useEffect(() => {
if (cell && tableState?.rows[cell.row]) {
window.history.pushState(
"",
`${tableState?.config.id}`,
`${window.location.pathname}?rowRef=${encodeURIComponent(
tableState?.rows[cell.row].ref.path
)}`
);
if (urlDocState.doc) {
urlDocState.unsubscribe();
dispatchUrlDoc({ path: "", doc: null });

View File

@@ -4,6 +4,7 @@ import { getFieldProp } from "@src/components/fields";
import MenuContents from "./MenuContent";
import DuplicateIcon from "@src/assets/icons/CopyCells";
import DeleteIcon from "@mui/icons-material/DeleteOutlined";
import LinkIcon from "@mui/icons-material/Link";
import { useProjectContext } from "@src/contexts/ProjectContext";
import { useContextMenuAtom } from "@src/atoms/ContextMenu";
@@ -47,8 +48,18 @@ export default function ContextMenu() {
}
const row = tableState?.rows[selectedCell!.rowIndex];
if (userRoles.includes("ADMIN") && row) {
if (row) {
const rowActions = [
{
label: "Copy link to row",
icon: <LinkIcon />,
onClick: () => {
const rowRef = encodeURIComponent(row.ref.path);
navigator.clipboard.writeText(
window.location.href + `?rowRef=${rowRef}`
);
},
},
{
label: "Duplicate row",
icon: <DuplicateIcon />,