-
Notifications
You must be signed in to change notification settings - Fork 1
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
BA-2060: leave group chat #176
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { FC } from 'react' | ||
|
||
import { MenuItem, MenuList, Typography } from '@mui/material' | ||
|
||
import { ChatRoomOptionsProps } from './types' | ||
|
||
const ChatRoomOptions: FC<ChatRoomOptionsProps> = ({ | ||
onArchiveClicked, | ||
onDetailsClicked, | ||
onLeaveClicked, | ||
}) => ( | ||
<MenuList> | ||
{/* TODO: Implement archive room functionality */} | ||
<MenuItem onClick={onArchiveClicked}> | ||
<Typography variant="body2">Archive Chat</Typography> | ||
</MenuItem> | ||
<MenuItem onClick={onDetailsClicked}> | ||
<Typography variant="body2">Group Details</Typography> | ||
</MenuItem> | ||
<MenuItem onClick={onLeaveClicked}> | ||
<Typography variant="body2" color="error"> | ||
Leave Group | ||
</Typography> | ||
</MenuItem> | ||
</MenuList> | ||
) | ||
|
||
export default ChatRoomOptions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface ChatRoomOptionsProps { | ||
onArchiveClicked: () => void | ||
onDetailsClicked: () => void | ||
onLeaveClicked: () => void | ||
} | ||
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,7 +5,8 @@ import { TitleFragment$key } from '../../../../__generated__/TitleFragment.graph | |||||||||
export interface ChatRoomHeaderProps { | ||||||||||
participantsCount: number | ||||||||||
roomTitleRef: TitleFragment$key | ||||||||||
onDisplayGroupDetailsClicked: () => void | ||||||||||
onDisplayGroupDetailsClicked: VoidFunction | ||||||||||
roomId?: string | ||||||||||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make Since the room ID is essential for the leave group feature, this property should be required rather than optional. This ensures type safety and prevents potential runtime errors when implementing the leave group functionality. - roomId?: string
+ roomId: string 📝 Committable suggestion
Suggested change
|
||||||||||
} | ||||||||||
|
||||||||||
export interface ChatTitleContainerProps extends BoxProps { | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export interface GroupDetailsHeaderProps { | ||
onBackButtonClicked: () => void | ||
onEditButtonClicked?: () => void | ||
onBackButtonClicked: VoidFunction | ||
onEditButtonClicked?: VoidFunction | ||
shouldDisplayEditButton: boolean | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,18 @@ import { MenuItem, MenuList, Typography } from '@mui/material' | |
import { AdminOptionsProps } from './types' | ||
|
||
const AdminOptionsMenu: FC<AdminOptionsProps> = ({ | ||
isAdmin, | ||
isMe, | ||
onViewProfileClicked, | ||
onToggleAdminClicked, | ||
onRemoveClicked, | ||
}) => ( | ||
<MenuList> | ||
<MenuItem onClick={onToggleAdminClicked} disabled={isMe}> | ||
<Typography variant="body2">{isAdmin ? 'Make normal user' : 'Make Admin'}</Typography> | ||
<MenuItem onClick={onViewProfileClicked}> | ||
<Typography variant="body2">View Profile</Typography> | ||
</MenuItem> | ||
<MenuItem onClick={onRemoveClicked} disabled={isMe}> | ||
<MenuItem onClick={onToggleAdminClicked}> | ||
<Typography variant="body2">Make Admin</Typography> | ||
</MenuItem> | ||
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore permission checks for admin actions. The removal of - <MenuItem onClick={onToggleAdminClicked}>
+ {isAdmin && (
+ <MenuItem onClick={onToggleAdminClicked}>
<Typography variant="body2">Make Admin</Typography>
- </MenuItem>
+ </MenuItem>
+ )}
|
||
<MenuItem onClick={onRemoveClicked}> | ||
<Typography variant="body2" color="error"> | ||
Remove | ||
</Typography> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,5 @@ | ||||||||||||||||||||||||||||||||
export interface AdminOptionsProps { | ||||||||||||||||||||||||||||||||
isAdmin: boolean | ||||||||||||||||||||||||||||||||
isMe: boolean | ||||||||||||||||||||||||||||||||
onToggleAdminClicked: () => void | ||||||||||||||||||||||||||||||||
onRemoveClicked: () => void | ||||||||||||||||||||||||||||||||
onViewProfileClicked: VoidFunction | ||||||||||||||||||||||||||||||||
onToggleAdminClicked: VoidFunction | ||||||||||||||||||||||||||||||||
onRemoveClicked: VoidFunction | ||||||||||||||||||||||||||||||||
Comment on lines
1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reconsider removal of permission flags
export interface AdminOptionsProps {
+ isAdmin: boolean
+ isMe: boolean
onViewProfileClicked: VoidFunction
onToggleAdminClicked: VoidFunction
- onRemoveClicked: VoidFunction
+ onRemoveMemberClicked: VoidFunction
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { FC } from 'react' | ||
|
||
import { MenuItem, MenuList, Typography } from '@mui/material' | ||
|
||
import { MemberOptionsMenuProps } from './types' | ||
|
||
const MemberOptionsMenu: FC<MemberOptionsMenuProps> = ({ | ||
isMe, | ||
onViewProfileClicked, | ||
onRemoveClicked, | ||
}) => ( | ||
<MenuList> | ||
<MenuItem onClick={onViewProfileClicked}> | ||
<Typography variant="body2">View Profile</Typography> | ||
</MenuItem> | ||
{isMe && ( | ||
<MenuItem onClick={onRemoveClicked}> | ||
<Typography variant="body2" color="error"> | ||
Leave Group | ||
</Typography> | ||
</MenuItem> | ||
)} | ||
</MenuList> | ||
) | ||
|
||
export default MemberOptionsMenu |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,5 @@ | ||||||||||||||||||||||||
export interface MemberOptionsMenuProps { | ||||||||||||||||||||||||
isMe: boolean | ||||||||||||||||||||||||
onViewProfileClicked: VoidFunction | ||||||||||||||||||||||||
onRemoveClicked: VoidFunction | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding admin permission check The interface should include an export interface MemberOptionsMenuProps {
isMe: boolean
+ isAdmin: boolean
onViewProfileClicked: VoidFunction
onRemoveClicked: VoidFunction
} 📝 Committable suggestion
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add type safety for chat room types
The interface should include properties to distinguish between group and direct chats, as some options (like leaving) are only applicable to group chats. Also consider adding admin permission check.
📝 Committable suggestion