-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Group} from "@mantine/core" | ||
import ToggleSecondaryPanel from "@/components/DualPanel/ToggleSecondaryPanel" | ||
import EditTitleButton from "./EditTitleButton" | ||
|
||
export default function ActionButtons() { | ||
return ( | ||
<Group justify="space-between"> | ||
<Group> | ||
<EditTitleButton /> | ||
</Group> | ||
<Group> | ||
<ToggleSecondaryPanel /> | ||
</Group> | ||
</Group> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {useContext} from "react" | ||
import {Tooltip, ActionIcon} from "@mantine/core" | ||
import {IconEdit} from "@tabler/icons-react" | ||
|
||
import {useSelector, useDispatch} from "react-redux" | ||
import { | ||
selectSelectedNodes, | ||
nodeUpdated, | ||
clearNodesSelection | ||
} from "@/slices/dualPanel/dualPanel" | ||
import edit_node_title from "@/components/modals/EditNodeTitle" | ||
|
||
import type {RootState} from "@/app/types" | ||
|
||
import type {NodeType, PanelMode} from "@/types" | ||
|
||
import PanelContext from "@/contexts/PanelContext" | ||
|
||
export default function EditTitleButton() { | ||
const mode: PanelMode = useContext(PanelContext) | ||
const dispatch = useDispatch() | ||
const selectedNodes = useSelector((state: RootState) => | ||
selectSelectedNodes(state, mode) | ||
) | ||
const onEditNodeTitle = () => { | ||
if (selectedNodes.length < 1) { | ||
console.log("Error: no selected nodes") | ||
return | ||
} | ||
|
||
let node: NodeType = selectedNodes[0] | ||
|
||
edit_node_title(node) | ||
.then((node: NodeType) => { | ||
dispatch(nodeUpdated({node, mode})) | ||
}) | ||
.finally(() => dispatch(clearNodesSelection(mode))) | ||
} | ||
|
||
return ( | ||
<Tooltip label="Change title" withArrow> | ||
<ActionIcon size={"lg"} variant="default" onClick={onEditNodeTitle}> | ||
<IconEdit stroke={1.4} /> | ||
</ActionIcon> | ||
</Tooltip> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters