-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1128 from The-Commit-Company/ability-to-pin-messa…
…ges-in-a-channel feat: pinned messages
- Loading branch information
Showing
23 changed files
with
335 additions
and
24 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
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
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
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
37 changes: 37 additions & 0 deletions
37
frontend/src/components/feature/pinned-messages/PinnedMessageModalContent.tsx
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,37 @@ | ||
import { Dialog, Flex, IconButton, Text } from '@radix-ui/themes' | ||
import { useFrappeGetCall } from 'frappe-react-sdk' | ||
import { useParams } from 'react-router-dom' | ||
import { Message } from '../../../../../types/Messaging/Message' | ||
import { ErrorBanner } from '@/components/layout/AlertBanner/ErrorBanner' | ||
import { MessageBox } from '../GlobalSearch/MessageBox' | ||
import { IoClose } from 'react-icons/io5' | ||
|
||
export const PinnedMessageModalContent = ({ onClose }: { onClose: () => void }) => { | ||
|
||
const { channelID } = useParams<{ channelID: string }>() | ||
|
||
const { data, error } = useFrappeGetCall<{ message: Message[] }>("raven.api.raven_message.get_pinned_messages", { 'channel_id': channelID }, undefined, { | ||
revalidateOnFocus: false | ||
}) | ||
|
||
return ( | ||
<> | ||
<Dialog.Title> | ||
<Flex justify={'between'} align={'center'}> | ||
<Text>Pinned Messages</Text> | ||
<IconButton variant='ghost' color='gray' aria-label='Close' onClick={onClose}> | ||
<IoClose size='20' /> | ||
</IconButton> | ||
</Flex> | ||
</Dialog.Title> | ||
<ErrorBanner error={error} /> | ||
<Flex direction='column' gap='3' justify='start'> | ||
{data?.message?.map((message) => { | ||
return ( | ||
<MessageBox key={message.name} message={message} /> | ||
) | ||
})} | ||
</Flex> | ||
</> | ||
) | ||
} |
38 changes: 38 additions & 0 deletions
38
frontend/src/components/feature/pinned-messages/ViewPinnedMessagesButton.tsx
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,38 @@ | ||
import { Button, Dialog } from '@radix-ui/themes' | ||
import { RiPushpinLine } from 'react-icons/ri' | ||
import { useState } from 'react' | ||
import { DIALOG_CONTENT_CLASS } from '@/utils/layout/dialog' | ||
import { PinnedMessageModalContent } from './PinnedMessageModalContent' | ||
|
||
interface ViewPinnedMessagesButtonProps { | ||
pinnedMessagesString: string | ||
} | ||
|
||
export const ViewPinnedMessagesButton = ({ pinnedMessagesString }: ViewPinnedMessagesButtonProps) => { | ||
|
||
const pinnedMessages = pinnedMessagesString ? pinnedMessagesString.split('\n').length : 0 | ||
|
||
const [open, setOpen] = useState(false) | ||
|
||
const onClose = () => { | ||
setOpen(false) | ||
} | ||
|
||
if (!pinnedMessages) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Dialog.Root open={open} onOpenChange={setOpen}> | ||
<Dialog.Trigger> | ||
<Button size='1' variant='soft' color='gray' aria-label="View pinned messages" | ||
title='View pinned messages'> | ||
<RiPushpinLine size='14' />{pinnedMessages} | ||
</Button> | ||
</Dialog.Trigger> | ||
<Dialog.Content className={DIALOG_CONTENT_CLASS}> | ||
<PinnedMessageModalContent onClose={onClose} /> | ||
</Dialog.Content> | ||
</Dialog.Root> | ||
) | ||
} |
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,15 @@ | ||
|
||
export interface RavenPinnedMessages{ | ||
name: string | ||
creation: string | ||
modified: string | ||
owner: string | ||
modified_by: string | ||
docstatus: 0 | 1 | 2 | ||
parent?: string | ||
parentfield?: string | ||
parenttype?: string | ||
idx?: number | ||
/** Message ID : Link - Raven Message */ | ||
message_id: string | ||
} |
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
Oops, something went wrong.