Skip to content

Commit

Permalink
Merge branch 'integration' into rav-39-raven-bot-doctype-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
TITANiumRox authored Feb 2, 2024
2 parents 4da8451 + 1bf1ac1 commit 0264a6c
Show file tree
Hide file tree
Showing 45 changed files with 705 additions and 483 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const ViewChannelMembers = ({ presentingElement, isOpen, onDismiss, chann
}

const removeMember = () => {
return call.post('raven.raven_channel_management.doctype.raven_channel_member.raven_channel_member.remove_channel_member', {
return call.post('raven.api.raven_channel_member.remove_channel_member', {
user_id: selectedMember?.name,
channel_id: channelID
}).then(() => {
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/components/features/chat-input/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {
}
export const ChatInput = ({ channelID, allChannels, allMembers, onMessageSend }: Props) => {

const { call, loading } = useFrappePostCall('raven.raven_messaging.doctype.raven_message.raven_message.send_message')
const { call, loading } = useFrappePostCall('raven.api.raven_message.send_message')

const [files, setFiles] = useState<File[]>([])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const ChatInterface = ({ channel }: { channel: ChannelListItem | DMChanne
*
* */
// Fetch all the messages in the channel
const { data: messages, error: messagesError, mutate: refreshMessages, isLoading: isMessageLoading } = useFrappeGetCall<{ message: MessagesWithDate }>("raven.raven_messaging.doctype.raven_message.raven_message.get_messages_with_dates", {
const { data: messages, error: messagesError, mutate: refreshMessages, isLoading: isMessageLoading } = useFrappeGetCall<{ message: MessagesWithDate }>("raven.api.raven_message.get_messages_with_dates", {
channel_id: channel.name
}, `get_messages_for_channel_${channel.name}`, {
keepPreviousData: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const PrivateMessages = ({ users, unread_count }: { users: DMUser[], unre

const { mutate } = useChannelList()

const { call } = useFrappePostCall<{ message: string }>("raven.raven_channel_management.doctype.raven_channel.raven_channel.create_direct_message_channel")
const { call } = useFrappePostCall<{ message: string }>("raven.api.raven_channel.create_direct_message_channel")

const history = useHistory();

Expand Down
2 changes: 1 addition & 1 deletion mobile/src/pages/channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Channels = () => {
return activeChannels.filter(channel => channel.channel_name.includes(searchTerm))
}, [searchInput, channels])

const { data: unread_count, mutate: update_count } = useFrappeGetCall<{ message: UnreadCountData }>("raven.raven_messaging.doctype.raven_message.raven_message.get_unread_count_for_channels",
const { data: unread_count, mutate: update_count } = useFrappeGetCall<{ message: UnreadCountData }>("raven.api.raven_message.get_unread_count_for_channels",
undefined,
'unread_channel_count', {
// revalidateOnFocus: false,
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/pages/direct-messages/DirectMessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const DirectMessageList = () => {
return users.filter(user => user.full_name.toLowerCase().includes(searchTerm))
}, [users, searchInput])

const { data: unread_count, mutate: update_count } = useFrappeGetCall<{ message: UnreadCountData }>("raven.raven_messaging.doctype.raven_message.raven_message.get_unread_count_for_channels",
const { data: unread_count, mutate: update_count } = useFrappeGetCall<{ message: UnreadCountData }>("raven.api.raven_message.get_unread_count_for_channels",
undefined,
'unread_channel_count', {
// revalidateOnFocus: false,
Expand Down
2 changes: 2 additions & 0 deletions mobile/src/types/RavenMessaging/RavenMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ export interface RavenMessage{
is_bot_message?: 0 | 1
/** Bot : Link - Raven User */
bot?: string
/** Content : Long Text */
content?: string
}
2 changes: 1 addition & 1 deletion mobile/src/utils/channel/ChannelListProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const useFetchChannelList = (): ChannelListContextType => {
position: 'bottom',
});
};
const { data, mutate, ...rest } = useFrappeGetCall<{ message: ChannelList }>("raven.raven_channel_management.doctype.raven_channel.raven_channel.get_all_channels", undefined, isLoggedIn ? undefined : null, {
const { data, mutate, ...rest } = useFrappeGetCall<{ message: ChannelList }>("raven.api.raven_channel.get_all_channels", undefined, isLoggedIn ? undefined : null, {
revalidateOnFocus: false,
revalidateIfStale: false,
onError: (error) => {
Expand Down
8 changes: 7 additions & 1 deletion raven-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { ProtectedRoute } from './utils/auth/ProtectedRoute'
import { UserProvider } from './utils/auth/UserProvider'
import { ChannelRedirect } from './utils/channel/ChannelRedirect'
import "cal-sans";
import { useState } from 'react'
import { ThemeProvider } from './ThemeProvider'
import { Toaster } from './components/common/Toast/Toaster'
import { FullPageLoader } from './components/layout/Loaders'
import { useStickyState } from './hooks/useStickyState'
import { Settings } from './pages/settings/Settings'


const router = createBrowserRouter(
Expand All @@ -23,6 +23,12 @@ const router = createBrowserRouter(
<Route path="saved-messages" lazy={() => import('./components/feature/saved-messages/SavedMessages')} />
<Route path=":channelID" lazy={() => import('@/pages/ChatSpace')} />
</Route>
<Route path='settings' element={<Settings />}>
<Route path='integrations'>
<Route path='webhooks' element={<p>Webhooks</p>} />
<Route path='server-scripts' element={<p>SS</p>} />
</Route>
</Route>
</Route>
</>
), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const MessageSearch = ({ onToggleMyChannels, isOpenMyChannels, onToggleSa
const { virtuosoRef } = useContext(VirtuosoRefContext)
const navigate = useNavigate()

const { call, reset } = useFrappePostCall<{ message: string }>("raven.raven_messaging.doctype.raven_message.raven_message.get_index_of_message")
const { call, reset } = useFrappePostCall<{ message: string }>("raven.api.raven_message.get_index_of_message")

const handleNavigateToChannel = (channelID: string) => {
onClose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface FilesSharedInChannelProps {
export const FilesSharedInChannel = ({ channelMembers }: FilesSharedInChannelProps) => {

const { channelID } = useParams()
const { data, error } = useFrappeGetCall<{ message: ChannelFile[] }>("raven.raven_messaging.doctype.raven_message.raven_message.fetch_recent_files", {
const { data, error } = useFrappeGetCall<{ message: ChannelFile[] }>("raven.api.raven_message.fetch_recent_files", {
channel_id: channelID
}, undefined, {
revalidateOnFocus: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Message } from '../../../../../../types/Messaging/Message'
export const useSendMessage = (channelID: string, noOfFiles: number, uploadFiles: () => Promise<void>, handleCancelReply: VoidFunction, selectedMessage?: Message | null) => {

const { mutate } = useSWRConfig()
const { call, loading } = useFrappePostCall('raven.raven_messaging.doctype.raven_message.raven_message.send_message')
const { call, loading } = useFrappePostCall('raven.api.raven_message.send_message')

const sendMessage = async (content: string, json?: any): Promise<void> => {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface QuickActionButtonProps extends IconButtonProps {
tooltip: string
}

export const QUICK_ACTION_BUTTON_CLASS = 'bg-gray-2 dark:bg-gray-3 hover:bg-gray-4 dark:hover:bg-gray-6 text-gray-12 hover:text-gray-12'
export const QUICK_ACTION_BUTTON_CLASS = 'bg-gray-2 dark:bg-gray-2 hover:bg-gray-4 dark:hover:bg-gray-5 text-gray-12 hover:text-gray-12'
export const QuickActionButton = forwardRef(({ className, tooltip, ...props }: QuickActionButtonProps, ref) => {
return (
<Tooltip content={tooltip}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const MessageLeftElement = ({ message, className, user, isActive, isScrolling, .
// If it's a continuation, then show the timestamp

// Else, show the avatar
return <Box className={clsx(message.is_continuation ? 'invisible group-hover:visible' : '', className)} {...props}>
return <Box className={clsx(message.is_continuation ? 'invisible group-hover:visible flex items-center max-w-[32px] w-[32px]' : '', className)} {...props}>
{message.is_continuation ?
<DateTooltipShort timestamp={message.creation} />
: <MessageSenderAvatar userID={message.owner} user={user} isActive={isActive} isScrolling={isScrolling} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const DateTooltipShort = ({ timestamp }: { timestamp: string }) => {
<Tooltip content={<DateMonthAtHourMinuteAmPm date={timestamp} />}>
<Link
asChild
size='1'
style={{ fontSize: '0.68rem' }}
color="gray"
>
<span><HourMinuteAmPm date={timestamp} amPm={false} /></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface ChatBoxBodyProps {
export const ChatBoxBody = ({ channelData }: ChatBoxBodyProps) => {

const { currentUser } = useContext(UserContext)
const { data, error, mutate, isLoading } = useFrappeGetCall<{ message: MessagesWithDate }>("raven.raven_messaging.doctype.raven_message.raven_message.get_messages_with_dates", {
const { data, error, mutate, isLoading } = useFrappeGetCall<{ message: MessagesWithDate }>("raven.api.raven_message.get_messages_with_dates", {
channel_id: channelData.name
}, `get_messages_for_channel_${channelData.name}`, {
revalidateOnFocus: false
Expand Down
10 changes: 7 additions & 3 deletions raven-app/src/components/feature/chat/ChatStream/ChatHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const ChatHistory = ({ parsedMessages, replyToMessage, channelData }: Cha

const onReplyMessageClick = (messageID: string) => {
if (virtuosoRef?.current) {
call.get('raven.raven_messaging.doctype.raven_message.raven_message.get_index_of_message', {
call.get('raven.api.raven_message.get_index_of_message', {
channel_id: channelData.name,
message_id: messageID
}).then((result) => {
Expand All @@ -102,8 +102,8 @@ export const ChatHistory = ({ parsedMessages, replyToMessage, channelData }: Cha
itemContent={(index, data, context) => <RenderItem block={parsedMessages[index]} index={index} {...data} {...context} isScrolling={isScrolling} />}
initialTopMostItemIndex={parsedMessages.length - 1}
components={{
Header: () => <ChannelHistoryFirstMessage channelID={channelData?.name} />,
Footer: () => <Box p='4' className="z-10 relative"></Box>
Header,
Footer,
}}
isScrolling={setIsScrolling}
context={{ channelData, replyToMessage, onReplyMessageClick, setDeleteMessage, updateMessages, setEditMessage }}
Expand All @@ -117,6 +117,9 @@ export const ChatHistory = ({ parsedMessages, replyToMessage, channelData }: Cha
</Box>
)
}
const Header = ({ context: { channelData } }: any) => <ChannelHistoryFirstMessage channelID={channelData?.name} />
const Footer = () => <Box p='4' className="z-10 relative"></Box>


const RenderItem = ({ index, replyToMessage, updateMessages, block, onReplyMessageClick, channelData, setEditMessage, setDeleteMessage, isScrolling, ...props }: {
index: number,
Expand All @@ -140,6 +143,7 @@ const RenderItem = ({ index, replyToMessage, updateMessages, block, onReplyMessa
message={block.data}
isScrolling={isScrolling}
updateMessages={updateMessages}
key={`${block.data.name}_${block.data.modified}`}
onReplyMessageClick={onReplyMessageClick}
setEditMessage={setEditMessage}
replyToMessage={replyToMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const DirectMessageItem = ({ channel, unreadCount }: { channel: DMChannelListIte
const ExtraUsersItemList = () => {

const { extra_users, mutate } = useContext(ChannelListContext) as ChannelListContextType
const { call } = useFrappePostCall<{ message: string }>("raven.raven_channel_management.doctype.raven_channel.raven_channel.create_direct_message_channel")
const { call } = useFrappePostCall<{ message: string }>("raven.api.raven_channel.create_direct_message_channel")

const { toast } = useToast()
const navigate = useNavigate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const AddRavenUsersContent = ({ onClose }: { onClose: VoidFunction }) => {
const [sortOrder, setSortOder] = useState<"asc" | "desc">("desc")

const { data, error } = useFrappeGetDocList<User>("User", {
fields: ["name", "full_name", "user_image", "creation", "enabled", "user_type"],
fields: ["name", "full_name", "user_image", "creation", "enabled", "user_type", "role_profile_name"],
filters,
orderBy: {
field: 'creation',
Expand Down
14 changes: 13 additions & 1 deletion raven-app/src/components/feature/raven-users/UsersTable.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { User } from "@/types/Core/User"
import { useMemo } from "react"
import { Checkbox, Flex, Table } from "@radix-ui/themes"
import { Badge, Box, Checkbox, Flex, Table, Tooltip } from "@radix-ui/themes"
import { UserAvatar } from "@/components/common/UserAvatar"
import { StandardDate } from "@/utils/dateConversions"
import { FiAlertTriangle } from "react-icons/fi"

interface UsersTableProps {
data: User[],
Expand Down Expand Up @@ -62,6 +63,7 @@ export const UsersTable = ({ data, selected, setSelected, defaultSelected }: Use
<Table.ColumnHeaderCell>Name</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell>User ID</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell>Created on</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell></Table.ColumnHeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
Expand All @@ -79,6 +81,16 @@ export const UsersTable = ({ data, selected, setSelected, defaultSelected }: Use

<Table.Cell>{user.name}</Table.Cell>
<Table.Cell><StandardDate date={user.creation} /></Table.Cell>
<Table.Cell>
{user.role_profile_name ?
<Box>
<Tooltip content={<span>A role profile has been assigned to this user.<br />If you want to add the user to Raven, please change their role profile.</span>}>
<Badge color='red' variant="solid">
<FiAlertTriangle size='12' />
Role Profile Added</Badge>
</Tooltip>
</Box> : null}
</Table.Cell>
</Table.Row>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const SavedMessages = () => {

const { virtuosoRef } = useContext(VirtuosoRefContext)

const { data, error } = useFrappeGetCall<{ message: Message[] }>("raven.raven_messaging.doctype.raven_message.raven_message.get_saved_messages", undefined, undefined, {
const { data, error } = useFrappeGetCall<{ message: Message[] }>("raven.api.raven_message.get_saved_messages", undefined, undefined, {
revalidateOnFocus: false
})

const { call, error: indexingError, reset } = useFrappePostCall<{ message: string }>("raven.raven_messaging.doctype.raven_message.raven_message.get_index_of_message")
const { call, error: indexingError, reset } = useFrappePostCall<{ message: string }>("raven.api.raven_message.get_index_of_message")

const handleNavigateToChannel = (channelID: string, _callback: VoidFunction) => {
navigate(`/channel/${channelID}`)
Expand Down
39 changes: 39 additions & 0 deletions raven-app/src/components/feature/settings/Integrations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { SidebarGroup, SidebarGroupItem, SidebarGroupLabel, SidebarGroupList, SidebarItem } from "@/components/layout/Sidebar"
import { Flex, Text } from "@radix-ui/themes"
import { BiPlug } from "react-icons/bi"

export interface Props { }

export const Integrations = (props: Props) => {
return (
<SidebarGroup>
<SidebarGroupItem gap='2' className={'pl-1.5'}>
{/* <SidebarViewMoreButton onClick={toggle} /> */}
<BiPlug />
<Flex width='100%' justify='between' align='center' gap='2'>
<Flex gap='3' align='center'>
<SidebarGroupLabel className='cal-sans'>Integrations</SidebarGroupLabel>
</Flex>
</Flex>
</SidebarGroupItem>
<SidebarGroup>
<SidebarGroupList>
<IntegrationsItem route='/settings/integrations/webhooks' label='Webhooks' />
<IntegrationsItem route='/settings/integrations/server-scripts' label='Server Scripts' />
</SidebarGroupList>
</SidebarGroup>
</SidebarGroup>
)
}


export const IntegrationsItem = ({ route, label }: { route: string, label: string }) => {

return (
<SidebarItem to={route ? route : "*"} className={'py-1.5'}>
<Flex justify='between' align={'center'} width='100%'>
<Text size='2' className="text-ellipsis line-clamp-1" as='span' weight={'regular'}>{label}</Text>
</Flex>
</SidebarItem>
)
}
24 changes: 24 additions & 0 deletions raven-app/src/components/layout/Settings/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Flex, Box, Separator } from "@radix-ui/themes"
import { SidebarBody } from "./SidebarBody"
import { SidebarFooter } from "../Sidebar/SidebarFooter"
import { SidebarHeader } from "./SidebarHeader"

export interface Props { }

/**
* Sidebar for Settings page
*/
export const Sidebar = (props: Props) => {
return (
<Flex justify='between' direction='row' gap='2'>
<Flex direction='column' gap='2' width='100%'>
<SidebarHeader />
<Box px='3'>
<Separator size='4' className={`bg-gray-4 dark:bg-gray-6`} />
</Box>
<SidebarBody />
</Flex>
<SidebarFooter isSettingsPage />
</Flex>
)
}
14 changes: 14 additions & 0 deletions raven-app/src/components/layout/Settings/SidebarBody.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Integrations } from "@/components/feature/settings/Integrations"
import { ScrollArea, Flex } from "@radix-ui/themes"

export interface Props { }

export const SidebarBody = (props: Props) => {
return (
<ScrollArea type="hover" scrollbars="vertical" className='h-[calc(100vh-7rem)]'>
<Flex direction='column' gap='2' className='overflow-x-hidden' px='2'>
<Integrations />
</Flex>
</ScrollArea>
)
}
27 changes: 27 additions & 0 deletions raven-app/src/components/layout/Settings/SidebarHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Flex, Text } from "@radix-ui/themes"
import { BiChevronLeft } from "react-icons/bi"
import { useNavigate } from "react-router-dom"

export interface Props { }

export const SidebarHeader = (props: Props) => {

const navigate = useNavigate()

return (
<header>
<Flex
px='3'
align='center'
gap={'3'}
pt='1'
height='8'
className="cursor-pointer"
onClick={() => navigate('/channel')}
>
<BiChevronLeft size={'24px'} color="gray" />
<Text as='span' size='4' weight={'medium'}>Settings</Text>
</Flex>
</header>
)
}
2 changes: 1 addition & 1 deletion raven-app/src/components/layout/Sidebar/SidebarBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BiBookmark } from 'react-icons/bi'

export const SidebarBody = () => {

const { data: unread_count, mutate: update_count } = useFrappeGetCall<{ message: UnreadCountData }>("raven.raven_messaging.doctype.raven_message.raven_message.get_unread_count_for_channels",
const { data: unread_count, mutate: update_count } = useFrappeGetCall<{ message: UnreadCountData }>("raven.api.raven_message.get_unread_count_for_channels",
undefined,
'unread_channel_count', {
// revalidateOnFocus: false,
Expand Down
Loading

0 comments on commit 0264a6c

Please sign in to comment.