Skip to content

Fix: unselect all nodes when richnode is focused & disable repo name editing by non-owner users #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions ui/src/components/RichNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import DeleteIcon from "@mui/icons-material/Delete";
import ViewComfyIcon from "@mui/icons-material/ViewComfy";
import RectangleIcon from "@mui/icons-material/Rectangle";
import DisabledByDefaultIcon from "@mui/icons-material/DisabledByDefault";
import { resetSelection } from "../lib/nodes";

import {
BoldExtension,
Expand Down Expand Up @@ -156,6 +157,7 @@ const MyEditor = ({
const setPodContent = useStore(store, (state) => state.setPodContent);
// initial content
const getPod = useStore(store, (state) => state.getPod);
const nodesMap = useStore(store, (state) => state.ydoc.getMap<Node>("pods"));
const pod = getPod(id);
const { manager, state, setState } = useRemirror({
extensions: () => [
Expand Down Expand Up @@ -192,9 +194,13 @@ const MyEditor = ({
return (
<Box
className="remirror-theme"
onFocus={() => {
if (resetSelection()) nodesMap.set(id, nodesMap.get(id) as Node);
}}
sx={{
cursor: "text",
}}
overflow="auto"
>
<AllStyledComponent>
<ThemeProvider>
Expand All @@ -203,6 +209,10 @@ const MyEditor = ({
manager={manager}
// initialContent={state}
state={state}
// FIXME: onFocus is not working
// onFocus={() => {
// console.log("onFocus");
// }}
onChange={(parameter) => {
let nextState = parameter.state;
setState(nextState);
Expand Down Expand Up @@ -463,19 +473,6 @@ export const RichNode = memo<Props>(function ({
}}
className="nodrag"
>
{role !== RoleType.GUEST && (
<Tooltip title="Run (shift-enter)">
<IconButton
size="small"
onClick={() => {
clearResults(id);
wsRun(id);
}}
>
<PlayCircleOutlineIcon fontSize="inherit" />
</IconButton>
</Tooltip>
)}
{role !== RoleType.GUEST && (
<Tooltip title="Delete">
<IconButton
Expand All @@ -488,16 +485,6 @@ export const RichNode = memo<Props>(function ({
</IconButton>
</Tooltip>
)}
<Tooltip title="Change layout">
<IconButton
size="small"
onClick={() => {
setLayout(layout === "bottom" ? "right" : "bottom");
}}
>
<ViewComfyIcon fontSize="inherit" />
</IconButton>
</Tooltip>
</Box>
</Box>
<Box>
Expand Down
4 changes: 3 additions & 1 deletion ui/src/pages/repo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useEffect, useState, useRef, useContext } from "react";

import { useStore } from "zustand";

import { createRepoStore, RepoContext } from "../lib/store";
import { createRepoStore, RepoContext, RoleType } from "../lib/store";

import useMe from "../lib/me";
import { Canvas } from "../components/Canvas";
Expand All @@ -35,6 +35,7 @@ function RepoWrapper({ children, id }) {
const repoName = useStore(store, (state) => state.repoName);
const setRepoName = useStore(store, (state) => state.setRepoName);
const setShareOpen = useStore(store, (state) => state.setShareOpen);
const role = useStore(store, (state) => state.role);

const [updateRepo, { error }] = useMutation(
gql`
Expand Down Expand Up @@ -83,6 +84,7 @@ function RepoWrapper({ children, id }) {
sx={{
maxWidth: "100%",
}}
disabled={role !== RoleType.OWNER}
onChange={(e) => {
const name = e.target.value;
setRepoName(name);
Expand Down