From 3d7917276998219d3bfeae0ad4827c835e93a60b Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Thu, 27 Jun 2024 19:29:47 +0100 Subject: [PATCH] Implemented Workspace Visibility Update & Added Fixes --- .../components/ManageMembersDialog.scss | 14 ++++++++++- ...rsDialog.tsx => ManageWorkspaceDialog.tsx} | 25 +++++++++++++------ .../src/ui/pages/workspaces/Workspaces.tsx | 1 + .../components/WorkspaceContextMenu.tsx | 14 +++++++++-- .../workspaces/components/WorkspaceView.tsx | 4 +++ .../http/handlers/workspacesHandlers.ts | 7 +++--- .../ws/events/document/onCursorChange.ts | 2 +- .../ws/events/document/onJoinDocument.ts | 4 +-- .../ws/events/document/onLeaveDocument.ts | 4 +-- .../ws/events/document/onOperation.ts | 2 +- .../ws/events/workspace/onJoinWorkspace.ts | 2 +- .../ws/events/workspace/onLeaveWorkspace.ts | 8 +++++- .../src/controllers/ws/initSocketEvents.ts | 24 ++++++++++++------ code/server/src/controllers/ws/rooms/rooms.ts | 4 +-- .../databases/memory/MemoryWorkspacesDB.ts | 6 ++--- .../src/databases/postgres/PostgresUsersDB.ts | 11 ++++++-- .../postgres/PostgresWorkspacesDB.ts | 6 +++-- code/server/src/databases/types.ts | 4 +-- code/server/src/services/WorkspacesService.ts | 9 ++++--- 19 files changed, 106 insertions(+), 45 deletions(-) rename code/client/src/ui/pages/workspace/components/{ManageMembersDialog.tsx => ManageWorkspaceDialog.tsx} (64%) diff --git a/code/client/src/ui/pages/workspace/components/ManageMembersDialog.scss b/code/client/src/ui/pages/workspace/components/ManageMembersDialog.scss index 2fc9168f..821b7b2b 100644 --- a/code/client/src/ui/pages/workspace/components/ManageMembersDialog.scss +++ b/code/client/src/ui/pages/workspace/components/ManageMembersDialog.scss @@ -1,7 +1,15 @@ -.manage-members-dialog { +.manage-workspace-dialog { ul { padding: 0; margin: 0; + + button { + background-color: transparent; + border: none; + cursor: pointer; + color: black; + font-size: larger; + } } li { @@ -11,4 +19,8 @@ align-items: center; list-style: none; } + + > button { + margin: auto; + } } diff --git a/code/client/src/ui/pages/workspace/components/ManageMembersDialog.tsx b/code/client/src/ui/pages/workspace/components/ManageWorkspaceDialog.tsx similarity index 64% rename from code/client/src/ui/pages/workspace/components/ManageMembersDialog.tsx rename to code/client/src/ui/pages/workspace/components/ManageWorkspaceDialog.tsx index fc123aaf..1bbcb63a 100644 --- a/code/client/src/ui/pages/workspace/components/ManageMembersDialog.tsx +++ b/code/client/src/ui/pages/workspace/components/ManageWorkspaceDialog.tsx @@ -1,25 +1,34 @@ import Dialog from '@ui/components/dialog/Dialog'; -import { FaUsers } from 'react-icons/fa6'; import { RxCross1 } from 'react-icons/rx'; +import { MdManageAccounts } from 'react-icons/md'; import './ManageMembersDialog.scss'; -type ManageMembersDialog = { +type ManageWorkspaceDialogProps = { members: string[]; onAddMember: (email: string) => void; onRemoveMember: (email: string) => void; + isPrivate: boolean; + toggleVisibility: () => void; }; -function ManageMembersDialog({ members, onAddMember, onRemoveMember }: ManageMembersDialog) { +function ManageWorkspaceDialog({ + members, + onAddMember, + onRemoveMember, + isPrivate, + toggleVisibility, +}: ManageWorkspaceDialogProps) { return ( { onAddMember(values['Add new member']); }} submitText="Add Member" extraContent={ -
+
+

Current Members

    {members?.map(member => ( @@ -38,11 +47,11 @@ function ManageMembersDialog({ members, onAddMember, onRemoveMember }: ManageMem } > <> - - Members + + Manage
); } -export default ManageMembersDialog; +export default ManageWorkspaceDialog; diff --git a/code/client/src/ui/pages/workspaces/Workspaces.tsx b/code/client/src/ui/pages/workspaces/Workspaces.tsx index 89d49081..81bfd85b 100644 --- a/code/client/src/ui/pages/workspaces/Workspaces.tsx +++ b/code/client/src/ui/pages/workspaces/Workspaces.tsx @@ -58,6 +58,7 @@ function Workspaces() { onGetMembers={() => operations.getWorkspaceMembers(workspace.id)} onAddMember={email => operations.addWorkspaceMember(workspace.id, email)} onRemoveMember={email => operations.removeWorkspaceMember(workspace.id, email)} + toggleVisibility={() => operations.updateWorkspace(workspace.id, { isPrivate: !workspace.isPrivate })} /> ))} diff --git a/code/client/src/ui/pages/workspaces/components/WorkspaceContextMenu.tsx b/code/client/src/ui/pages/workspaces/components/WorkspaceContextMenu.tsx index 53a44a24..1f07db67 100644 --- a/code/client/src/ui/pages/workspaces/components/WorkspaceContextMenu.tsx +++ b/code/client/src/ui/pages/workspaces/components/WorkspaceContextMenu.tsx @@ -1,8 +1,8 @@ import PopupMenu from '@ui/components/popup-menu/PopupMenu'; import { ReactNode, useEffect, useState } from 'react'; import { MdDelete, MdEdit } from 'react-icons/md'; -import ManageMembersDialog from '@ui/pages/workspace/components/ManageMembersDialog'; import { useAuth } from '@/contexts/auth/useAuth'; +import ManageWorkspaceDialog from '@ui/pages/workspace/components/ManageWorkspaceDialog'; type WorkspaceContextMenuProps = { children: ReactNode; @@ -11,6 +11,8 @@ type WorkspaceContextMenuProps = { onGetMembers: () => Promise; onAddMember: (email: string) => Promise; onRemoveMember: (email: string) => Promise; + isPrivate: boolean; + toggleVisibility: () => Promise; }; function WorkspaceContextMenu({ @@ -20,6 +22,8 @@ function WorkspaceContextMenu({ onGetMembers, onAddMember, onRemoveMember, + isPrivate, + toggleVisibility, }: WorkspaceContextMenuProps) { const [members, setMembers] = useState([]); const [isMember, setIsMember] = useState(false); @@ -41,7 +45,13 @@ function WorkspaceContextMenu({ Rename - +