@messenger-box/platform-browser 0.0.1-alpha.42 → 0.0.1-alpha.420
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +540 -27
- package/jest.config.js +23 -7
- package/lib/components/InboxMessage/InboxDetails/index.d.ts +2 -0
- package/lib/components/InboxMessage/InboxDetails/style.d.ts +1 -0
- package/lib/components/InboxMessage/InboxSidebar/index.d.ts +11 -0
- package/lib/components/InboxMessage/InboxSidebar/styles.d.ts +1 -0
- package/lib/components/InboxMessage/Messages/index.d.ts +2 -0
- package/lib/components/InboxMessage/Messages/styles.d.ts +80 -0
- package/lib/components/InboxMessage/MessagesList/index.d.ts +2 -0
- package/lib/components/InboxMessage/Popover/index.d.ts +2 -0
- package/lib/components/InboxMessage/Popover/style.d.ts +27 -0
- package/lib/components/InboxMessage/UserModalContent/index.d.ts +2 -0
- package/lib/components/InboxMessage/UserModalContent/style.d.ts +1 -0
- package/lib/components/InboxMessage/index.d.ts +2 -0
- package/lib/components/InboxMessage/mock.d.ts +19 -0
- package/lib/components/InboxMessage/style.d.ts +1 -0
- package/lib/components/channel_view/DirectChannelView.d.ts +3 -0
- package/lib/components/channel_view/PublicChannelView.d.ts +3 -0
- package/lib/components/dashboard/menu_header.d.ts +5 -0
- package/lib/components/dashboard/modals/direct_modal.d.ts +9 -0
- package/lib/components/dashboard/modals.d.ts +8 -0
- package/lib/components/messenger/index.d.ts +6 -1
- package/lib/components/messenger/messagesList/index.d.ts +6 -4
- package/lib/components/messenger/messagesList/style.d.ts +1 -221
- package/lib/components/messenger/more_action/index.d.ts +11 -0
- package/lib/components/messenger/more_action/style.d.ts +1 -0
- package/lib/components/overlay_trigger.d.ts +3 -3
- package/lib/components/post/channel_intro_message/channel_intro_message.d.ts +2 -1
- package/lib/components/post/channel_layout/channel_identifier_router/channel_identifier_router.d.ts +2 -1
- package/lib/components/post/channel_view/channel_view.d.ts +2 -1
- package/lib/components/post/create_post/create_post.d.ts +2 -1
- package/lib/components/post/failed_post_options/failed_post_options.d.ts +2 -1
- package/lib/components/post/index.d.ts +5 -1
- package/lib/components/post/markdown/markdown.d.ts +2 -1
- package/lib/components/post/post/post.d.ts +2 -1
- package/lib/components/post/post_aria_label_div.d.ts +3 -2
- package/lib/components/post/post_body/post_body.d.ts +2 -1
- package/lib/components/post/post_header/post_header.d.ts +2 -1
- package/lib/components/post/post_header/post_header_custom_status.d.ts +2 -1
- package/lib/components/post/post_header/style.d.ts +1 -40
- package/lib/components/post/post_info/post_info.d.ts +2 -1
- package/lib/components/post/post_list/index.d.ts +2 -1
- package/lib/components/post/post_list/post_list.d.ts +2 -1
- package/lib/components/post/post_list_row/post_list_row.d.ts +2 -1
- package/lib/components/post/post_list_virtualized/latest_post_reader.d.ts +2 -1
- package/lib/components/post/post_list_virtualized/post_list_virtualized.d.ts +2 -1
- package/lib/components/post/post_markdown/post_markdown.d.ts +2 -1
- package/lib/components/post/post_message_view/post_message_view.d.ts +2 -1
- package/lib/components/post/post_pre_header/post_pre_header.d.ts +3 -2
- package/lib/components/post/post_profile_picture/post_profile_picture.d.ts +2 -1
- package/lib/components/post/post_view.d.ts +2 -1
- package/lib/components/post/profile_picture/profile_picture.d.ts +2 -1
- package/lib/components/post/show_more/show_more.d.ts +2 -1
- package/lib/components/post/style.d.ts +1 -93
- package/lib/components/post/threading/channel_threads/thread_footer/thread_footer.d.ts +2 -1
- package/lib/components/post/threading/common/button/button.d.ts +3 -3
- package/lib/components/post/threading/common/follow_button/follow_button.d.ts +2 -2
- package/lib/components/post/tutorial/tutorial_tip/tutorial_tip.d.ts +3 -3
- package/lib/components/post/user_profile/user_profile.d.ts +1 -1
- package/lib/components/status_icon.d.ts +2 -1
- package/lib/components/status_icon_new.d.ts +2 -2
- package/lib/compute.d.ts +8 -2
- package/lib/containers/Inbox.d.ts +3 -0
- package/lib/containers/Messenger.d.ts +5 -1
- package/lib/index.js +3864 -581
- package/lib/index.js.map +1 -1
- package/lib/packages/types/emojis.d.ts +5 -5
- package/lib/packages/types/files.d.ts +5 -5
- package/lib/packages/types/posts.d.ts +13 -13
- package/lib/packages/types/reactions.d.ts +1 -1
- package/lib/packages/types/utilities.d.ts +13 -13
- package/lib/style.d.ts +1 -37
- package/lib/utils/index.d.ts +2 -0
- package/lib/widgets/badges/badge.d.ts +3 -3
- package/lib/widgets/badges/bot_badge.d.ts +1 -1
- package/lib/widgets/badges/guest_badge.d.ts +1 -1
- package/lib/widgets/badges/style.d.ts +1 -23
- package/lib/widgets/icons/emoji_icon.d.ts +1 -1
- package/lib/widgets/icons/flag_icon_filled.d.ts +1 -1
- package/lib/widgets/icons/mattermost_logo.d.ts +1 -1
- package/lib/widgets/icons/status_away_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_away_icon.d.ts +1 -1
- package/lib/widgets/icons/status_dnd_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_dnd_icon.d.ts +1 -1
- package/lib/widgets/icons/status_offline_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_offline_icon.d.ts +1 -1
- package/lib/widgets/icons/status_online_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_online_icon.d.ts +1 -1
- package/lib/widgets/overlay_trigger.d.ts +3 -3
- package/lib/widgets/shared_user_indicator.d.ts +1 -1
- package/lib/widgets/simple_tooltip/simple_tooltip.d.ts +3 -3
- package/lib/widgets/users/avatar/avatar.d.ts +4 -4
- package/lib/widgets/users/avatar/style.d.ts +1 -75
- package/lib/widgets/users/avatars/avatars.d.ts +2 -2
- package/package.json +61 -67
- package/src/components/InboxMessage/InboxDetails/index.tsx +23 -0
- package/src/components/InboxMessage/InboxDetails/style.ts +27 -0
- package/src/components/InboxMessage/InboxSidebar/index.tsx +86 -0
- package/src/components/InboxMessage/InboxSidebar/styles.ts +57 -0
- package/src/components/InboxMessage/Messages/index.tsx +159 -0
- package/src/components/InboxMessage/Messages/styles.ts +85 -0
- package/src/components/InboxMessage/MessagesList/index.tsx +93 -0
- package/src/components/InboxMessage/Popover/index.tsx +57 -0
- package/src/components/InboxMessage/Popover/style.ts +27 -0
- package/src/components/InboxMessage/UserModalContent/index.tsx +60 -0
- package/src/components/InboxMessage/UserModalContent/style.ts +98 -0
- package/src/components/InboxMessage/index.tsx +286 -0
- package/src/components/InboxMessage/mock.ts +53 -0
- package/src/components/InboxMessage/style.ts +189 -0
- package/src/components/channel_view/DirectChannelView.tsx +25 -0
- package/src/components/channel_view/PublicChannelView.tsx +24 -0
- package/src/components/dashboard/menu_header.tsx +49 -0
- package/src/components/dashboard/modals/direct_modal.tsx +46 -0
- package/src/components/dashboard/modals.tsx +93 -0
- package/src/components/messenger/avatar/index.tsx +2 -4
- package/src/components/messenger/avatar/style.ts +3 -3
- package/src/components/messenger/index.tsx +258 -94
- package/src/components/messenger/messagesList/index.tsx +673 -249
- package/src/components/messenger/messagesList/messageBox.tsx +2 -1
- package/src/components/messenger/messagesList/style.ts +240 -14
- package/src/components/messenger/more_action/index.tsx +68 -0
- package/src/components/messenger/more_action/style.ts +45 -0
- package/src/components/messenger/postMessage/postMessage.tsx +2 -3
- package/src/components/messenger/postMessage/style.ts +3 -3
- package/src/components/messenger/sidebarThreadList/index.tsx +11 -10
- package/src/components/messenger/style.ts +16 -16
- package/src/components/messenger/threadSidebar/index.tsx +5 -5
- package/src/components/messenger/threadSidebar/style.ts +7 -7
- package/src/components/messenger/types/message.ts +1 -0
- package/src/components/post/channel_intro_message/channel_intro_message.tsx +0 -1
- package/src/components/post/index.tsx +102 -25
- package/src/components/post/post/post.tsx +8 -1
- package/src/components/post/post_header/post_header_custom_status.tsx +1 -2
- package/src/components/post/post_header/style.ts +3 -6
- package/src/components/post/style.ts +22 -8
- package/src/components/post/tutorial/tutorial_tip/tutorial_tip.tsx +1 -0
- package/src/components/post/user_profile/user_profile.tsx +1 -0
- package/src/compute.tsx +58 -37
- package/src/containers/Dashboard.tsx +488 -1
- package/src/containers/Inbox.tsx +13 -0
- package/src/containers/Loading.tsx +1 -1
- package/src/containers/Messenger.tsx +9 -4
- package/src/module.ts +10 -7
- package/src/style.ts +382 -19
- package/src/utils/index.ts +22 -0
- package/src/widgets/badges/badge.tsx +1 -2
- package/src/widgets/badges/style.ts +3 -3
- package/src/widgets/icons/accordion_toggle_icon.tsx +1 -1
- package/src/widgets/icons/add_reaction_icon.tsx +1 -1
- package/src/widgets/icons/admin_eye_icon.tsx +1 -1
- package/src/widgets/icons/alert_icon.tsx +1 -1
- package/src/widgets/icons/archive_icon.tsx +1 -1
- package/src/widgets/icons/arrow_right_icon.tsx +1 -1
- package/src/widgets/icons/at_icon.tsx +1 -1
- package/src/widgets/icons/attachment_icon.tsx +1 -1
- package/src/widgets/icons/back_icon.tsx +1 -1
- package/src/widgets/icons/bot_icon.tsx +1 -1
- package/src/widgets/icons/camera_icon.tsx +1 -1
- package/src/widgets/icons/checkbox_checked_icon.tsx +1 -1
- package/src/widgets/icons/checkbox_partial_icon.tsx +1 -1
- package/src/widgets/icons/close_circle_icon.tsx +1 -1
- package/src/widgets/icons/close_circle_solid_icon.tsx +1 -1
- package/src/widgets/icons/close_icon.tsx +1 -1
- package/src/widgets/icons/dots_horizontal.tsx +1 -1
- package/src/widgets/icons/download_icon.tsx +1 -1
- package/src/widgets/icons/draft_icon.tsx +1 -1
- package/src/widgets/icons/ellipsis_h_icon.tsx +1 -1
- package/src/widgets/icons/email_icon.tsx +1 -1
- package/src/widgets/icons/fa_add_icon.tsx +1 -1
- package/src/widgets/icons/fa_back_icon.tsx +1 -1
- package/src/widgets/icons/fa_dropdown_icon.tsx +1 -1
- package/src/widgets/icons/fa_edit_icon.tsx +1 -1
- package/src/widgets/icons/fa_logout_icon.tsx +1 -1
- package/src/widgets/icons/fa_next_icon.tsx +1 -1
- package/src/widgets/icons/fa_previous_icon.tsx +1 -1
- package/src/widgets/icons/fa_reload_icon.tsx +1 -1
- package/src/widgets/icons/fa_remove_icon.tsx +1 -1
- package/src/widgets/icons/fa_search_icon.tsx +1 -1
- package/src/widgets/icons/fa_select_icon.tsx +1 -1
- package/src/widgets/icons/fa_success_icon.tsx +1 -1
- package/src/widgets/icons/fa_warning_icon.tsx +1 -1
- package/src/widgets/icons/flag_icon.tsx +1 -1
- package/src/widgets/icons/gfycat_icon.tsx +1 -1
- package/src/widgets/icons/gif_reactions_icon.tsx +1 -1
- package/src/widgets/icons/gif_search_clear_icon.tsx +1 -1
- package/src/widgets/icons/gif_search_icon.tsx +1 -1
- package/src/widgets/icons/gif_trending_icon.tsx +1 -1
- package/src/widgets/icons/globe_icon.tsx +1 -1
- package/src/widgets/icons/icons.stories.js +1 -1
- package/src/widgets/icons/info_icon.tsx +1 -1
- package/src/widgets/icons/info_small_icon.tsx +1 -1
- package/src/widgets/icons/invite_icon.tsx +1 -1
- package/src/widgets/icons/invite_members_icon.tsx +1 -1
- package/src/widgets/icons/link_icon.tsx +1 -1
- package/src/widgets/icons/lock_icon.tsx +1 -1
- package/src/widgets/icons/mail_icon.tsx +1 -1
- package/src/widgets/icons/mail_plus_icon.tsx +1 -1
- package/src/widgets/icons/member_icon.tsx +1 -1
- package/src/widgets/icons/mentions_icon.tsx +1 -1
- package/src/widgets/icons/menu_icon.tsx +1 -1
- package/src/widgets/icons/message_icon.tsx +1 -1
- package/src/widgets/icons/pin_icon.tsx +1 -1
- package/src/widgets/icons/plugin_channel_header_icon.tsx +1 -1
- package/src/widgets/icons/plugin_icon.tsx +1 -1
- package/src/widgets/icons/reply_icon.tsx +1 -1
- package/src/widgets/icons/scroll_to_bottom_icon.tsx +1 -1
- package/src/widgets/icons/search_icon.tsx +1 -1
- package/src/widgets/icons/shield_outline_icon.tsx +1 -1
- package/src/widgets/icons/unarchive_icon.tsx +1 -1
- package/src/widgets/icons/unread_below_icon.tsx +1 -1
- package/src/widgets/icons/user_guide_icon.tsx +1 -1
- package/src/widgets/shared_user_indicator.tsx +1 -0
- package/src/widgets/simple_tooltip/simple_tooltip.tsx +1 -0
- package/src/widgets/users/avatar/avatar.tsx +1 -2
- package/src/widgets/users/avatar/style.ts +3 -3
- package/src/widgets/users/avatars/avatars.tsx +1 -0
- package/tsconfig.json +2 -1
- package/webpack.config.js +1 -1
- package/lib/components/messenger/mock.d.ts +0 -50
- package/lib/components/messenger/postMessage/postMessage.d.ts +0 -1
- package/lib/components/messenger/postMessage/style.d.ts +0 -22
- package/lib/components/messenger/sidebarThreadList/index.d.ts +0 -7
- package/lib/components/messenger/threadSidebar/index.d.ts +0 -1
- package/lib/components/messenger/threadSidebar/style.d.ts +0 -62
- package/lib/components/messenger/types/message.d.ts +0 -14
- package/src/api.ts +0 -35
- package/src/components/Counter.tsx +0 -52
- package/src/containers/Clock.tsx +0 -0
- package/src/containers/Counter.tsx +0 -42
- package/src/containers/PersonList.tsx +0 -20
- package/src/containers/ServerCounter.tsx +0 -140
- package/src/graphql/index.ts +0 -3
- package/src/graphql/mutations/addCount.graphql +0 -5
- package/src/graphql/mutations/addPerson.graphql +0 -6
- package/src/graphql/mutations/index.ts +0 -2
- package/src/graphql/queries/count.graphql +0 -5
- package/src/graphql/queries/index.ts +0 -3
- package/src/graphql/queries/person.graphql +0 -22
- package/src/graphql/queries/persons.graphql +0 -6
- package/src/graphql/subscriptions/count.graphql +0 -5
- package/src/graphql/subscriptions/index.ts +0 -1
- package/src/redux/__mocks__/api.ts +0 -4
- package/src/redux/actions/__tests__/sampleActions.test.ts +0 -159
- package/src/redux/actions/index.ts +0 -1
- package/src/redux/actions/sampleActions.ts +0 -91
- package/src/redux/index.ts +0 -2
- package/src/redux/reducers/Store.ts +0 -10
- package/src/redux/reducers/__tests__/sampleReducers.test.ts +0 -39
- package/src/redux/reducers/index.ts +0 -7
- package/src/redux/reducers/sampleReducers.ts +0 -71
- /package/src/components/post/channel_layout/{channel_controller.test.jsx → channel_controller.test.tsx} +0 -0
- /package/src/components/post/channel_layout/{channel_controller.jsx → channel_controller.tsx} +0 -0
|
@@ -1,7 +1,494 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { styleSheet } from "../style";
|
|
3
|
+
import { IntlProvider } from "react-intl";
|
|
4
|
+
import {
|
|
5
|
+
useAddChannelMutation,
|
|
6
|
+
useGetChannelsByUserQuery,
|
|
7
|
+
useGetAllChannelQuery,
|
|
8
|
+
useAddDirectChannelMutation,
|
|
9
|
+
useAddMemberToChannelMutation,
|
|
10
|
+
useSendMessagesMutation,
|
|
11
|
+
useUsersToChatQuery,
|
|
12
|
+
useCurrentUserQuery,
|
|
13
|
+
useGetAllUsersQuery,
|
|
14
|
+
} from '@messenger-box/platform-client';
|
|
15
|
+
import { PostViewPage } from "../components/post";
|
|
16
|
+
import { MenuHeader } from "../components/dashboard/menu_header";
|
|
17
|
+
import { Modals } from "../components/dashboard/modals";
|
|
18
|
+
import { DirectModal } from "../components/dashboard/modals/direct_modal";
|
|
19
|
+
import { css } from "@emotion/css";
|
|
20
|
+
import { BsGlobe2 } from "react-icons/bs";
|
|
21
|
+
import { FaRobot } from "react-icons/fa";
|
|
22
|
+
import { RiAdminFill } from "react-icons/ri";
|
|
23
|
+
import { Button, Modal } from "react-bootstrap";
|
|
24
|
+
import { useEffect, useState } from "react";
|
|
25
|
+
import { Popover, Avatar, Drawer } from 'antd';
|
|
26
|
+
import { Comment } from '@ant-design/compatible'
|
|
27
|
+
import Select from 'react-select';
|
|
28
|
+
import { indexOf } from "lodash-es";
|
|
29
|
+
import { useSelector } from "react-redux";
|
|
30
|
+
import {
|
|
31
|
+
BrowserRouter as Router,
|
|
32
|
+
Switch,
|
|
33
|
+
Route,
|
|
34
|
+
Link, useHistory
|
|
35
|
+
} from "react-router-dom";
|
|
36
|
+
import { dashboardRoutes } from "../compute";
|
|
37
|
+
|
|
38
|
+
const Messenger = React.lazy(() => import('./Messenger'));
|
|
2
39
|
|
|
3
40
|
const Dashboard: React.FC = () => {
|
|
4
|
-
|
|
41
|
+
const [channelInput, setChannelInput] = useState<any>({});
|
|
42
|
+
// const [channels, setChannels] = useState([]);
|
|
43
|
+
const [publicChannels, setPublicChannels] = useState([]);
|
|
44
|
+
const [directChannels, setDirectChannels] = useState([]);
|
|
45
|
+
const [clickedChannel, setClickedChannel] = useState<any>({});
|
|
46
|
+
const [currentUser, setCurrentUser] = useState<any>();
|
|
47
|
+
const [options, setOptions] = useState([]);
|
|
48
|
+
const [showDirectChl, setShowDirectChl] = useState(false);
|
|
49
|
+
const [selectedValues, setSelectedValues] = useState<any>([]);
|
|
50
|
+
const [directMoreModal, setDirectMoreModal] = useState<any>({ showDirectMore: false, modalPublicChannels: [] })
|
|
51
|
+
const [publicChlModal, setPublicChlModal] = useState<any>({ show: false })
|
|
52
|
+
const [classes, setClasses] = useState({
|
|
53
|
+
left_bar: 'left_bar',
|
|
54
|
+
root_div: 'root_div'
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const currentUserAuth0Id = useSelector((state: any) => state.user.auth0UserId)
|
|
58
|
+
|
|
59
|
+
const his = useHistory()
|
|
60
|
+
|
|
61
|
+
const allUsers = useGetAllUsersQuery()
|
|
62
|
+
const usersToChat = useUsersToChatQuery({ variables: { auth0Id: currentUserAuth0Id } })
|
|
63
|
+
const currentUserRes = useCurrentUserQuery({ variables: { auth0Id: currentUserAuth0Id } })
|
|
64
|
+
const { data, loading, error, refetch } = useGetChannelsByUserQuery()
|
|
65
|
+
const allChannels = useGetAllChannelQuery()
|
|
66
|
+
const [addMemberToChannelMutationInput, addMemberToChannelMutationResponse] = useAddMemberToChannelMutation({
|
|
67
|
+
update: (cache, mutationResult) => {
|
|
68
|
+
cache.modify({
|
|
69
|
+
fields: {
|
|
70
|
+
channels(existingChannels, { toReference }) {
|
|
71
|
+
return [...existingChannels, mutationResult]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const [sendMessagesMutationInput, sendMessagesMutationResponase] = useSendMessagesMutation({
|
|
79
|
+
update: (cache, mutationResult) => {
|
|
80
|
+
cache.modify({
|
|
81
|
+
fields: {
|
|
82
|
+
messages(existingMessages, { toReference }) {
|
|
83
|
+
return { ...existingMessages, data: toReference(mutationResult.data.sendMessage) }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const [createDirectChannel, addedDirectChannel] = useAddDirectChannelMutation({
|
|
91
|
+
update: (cache, mutationResult) => {
|
|
92
|
+
his.push(`/o/${his.location.pathname.split('/')[2]}/dashboard/message/${mutationResult.data.createDirectChannel.displayName.split('_').length === 2 ?
|
|
93
|
+
mutationResult.data.createDirectChannel.displayName.split('_')[0].split('-')[0] !== currentUser.id ?
|
|
94
|
+
mutationResult.data.createDirectChannel.displayName.split('_')[0].split('-')[1] :
|
|
95
|
+
mutationResult.data.createDirectChannel.displayName.split('_')[1].split('-')[1] : mutationResult.data.createDirectChannel.title}`,
|
|
96
|
+
{
|
|
97
|
+
channel: mutationResult.data.createDirectChannel,
|
|
98
|
+
currentUser: currentUserRes.data.currentUser
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
cache.modify({
|
|
102
|
+
fields: {
|
|
103
|
+
channels(existingChannels, { toReference }) {
|
|
104
|
+
return [...existingChannels, mutationResult]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const [createChannel, createdChannel] = useAddChannelMutation({
|
|
112
|
+
update: (cache, mutationResult) => {
|
|
113
|
+
his.push(`/o/${his.location.pathname.split('/')[2]}/dashboard/channel/${mutationResult.data.createChannel.title}`,
|
|
114
|
+
{
|
|
115
|
+
channel: mutationResult.data.createChannel,
|
|
116
|
+
currentUser: currentUserRes.data.currentUser
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (!currentUserRes.loading) {
|
|
124
|
+
setCurrentUser(currentUserRes.data.currentUser)
|
|
125
|
+
}
|
|
126
|
+
}, [currentUserRes.data, currentUserRes.loading])
|
|
127
|
+
|
|
128
|
+
const handleJoin = (channelId) => {
|
|
129
|
+
addMemberToChannelMutationInput({
|
|
130
|
+
variables: {
|
|
131
|
+
channelId: channelId,
|
|
132
|
+
memberId: currentUser.id
|
|
133
|
+
}
|
|
134
|
+
}).then(response => {
|
|
135
|
+
setClickedChannel(response.data.addMemberToChannel)
|
|
136
|
+
// setShowDirectMore(false)
|
|
137
|
+
setDirectMoreModal({ ...directMoreModal, showDirectMore: false })
|
|
138
|
+
sendMessagesMutationInput({
|
|
139
|
+
variables: {
|
|
140
|
+
channelId: channelId,
|
|
141
|
+
content: `@${currentUser.username} joined the channel`,
|
|
142
|
+
files: []
|
|
143
|
+
},
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
// refetch().then((value => {
|
|
147
|
+
// setChannels(value.data.channelsByUser)
|
|
148
|
+
// setChannelInput({})
|
|
149
|
+
// }))
|
|
150
|
+
// allChannels.refetch()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const handleGo = () => {
|
|
154
|
+
// console.log('------directModal------', directModal)
|
|
155
|
+
if (selectedValues) {
|
|
156
|
+
let uids = []
|
|
157
|
+
let dName = currentUser.username + ','
|
|
158
|
+
if (selectedValues.length > 1) {
|
|
159
|
+
selectedValues.forEach(i => {
|
|
160
|
+
uids.push(i.value.uid)
|
|
161
|
+
dName += i.value.username
|
|
162
|
+
if ((indexOf(selectedValues, i) + 1) !== selectedValues.length) {
|
|
163
|
+
dName += ','
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
} else {
|
|
167
|
+
uids.push(selectedValues[0].value.uid)
|
|
168
|
+
dName = `${selectedValues[0].value.uid}-${selectedValues[0].value.username}_${currentUser.id}-${currentUser.username}`
|
|
169
|
+
}
|
|
170
|
+
createDirectChannel({
|
|
171
|
+
variables: {
|
|
172
|
+
receiver: uids,
|
|
173
|
+
displayName: dName
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
handleClose('directChannel')
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (!addedDirectChannel.loading && addedDirectChannel.data) {
|
|
182
|
+
setClickedChannel(addedDirectChannel.data.createDirectChannel)
|
|
183
|
+
setSelectedValues([])
|
|
184
|
+
}
|
|
185
|
+
}, [addedDirectChannel.loading, addedDirectChannel.data])
|
|
186
|
+
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
if (!usersToChat.loading) {
|
|
189
|
+
let tempOpt = []
|
|
190
|
+
usersToChat.data.usersToChat.map(usr => {
|
|
191
|
+
tempOpt.push({
|
|
192
|
+
value: { username: `${usr.username}`, uid: `${usr.id}` },
|
|
193
|
+
label: <div style={{ cursor: 'pointer' }}>
|
|
194
|
+
<Comment
|
|
195
|
+
className="cmt_cls"
|
|
196
|
+
author={'@' + usr.username}
|
|
197
|
+
avatar={
|
|
198
|
+
<Avatar
|
|
199
|
+
style={{ backgroundColor: `#${Math.floor(Math.random() * 16777215).toString(16)}` }}>
|
|
200
|
+
{usr.username.match(/\b(\w)/g).join('').toUpperCase()}
|
|
201
|
+
</Avatar>
|
|
202
|
+
}
|
|
203
|
+
content={usr.email}
|
|
204
|
+
/>
|
|
205
|
+
</div>
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
setOptions(tempOpt)
|
|
209
|
+
}
|
|
210
|
+
}, [usersToChat.data, usersToChat.loading])
|
|
211
|
+
|
|
212
|
+
const refetchCall = () => {
|
|
213
|
+
// setClickedChannel({})
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (!loading) {
|
|
218
|
+
let diChal = []
|
|
219
|
+
let fChannel = []
|
|
220
|
+
let joinedChannel = []
|
|
221
|
+
let modelChannel = []
|
|
222
|
+
|
|
223
|
+
if (!currentUserRes.loading && !allChannels.loading) {
|
|
224
|
+
let uc = []
|
|
225
|
+
data.channelsByUser.forEach(u => uc.push(u.id))
|
|
226
|
+
let ac = []
|
|
227
|
+
allChannels.data.channels.forEach(a => ac.push(a.id))
|
|
228
|
+
diChal = ac.filter(t => !uc.includes(t))
|
|
229
|
+
allChannels.data.channels.filter(dc => {
|
|
230
|
+
if (diChal.includes(dc.id)) {
|
|
231
|
+
dc.members.forEach(m => {
|
|
232
|
+
if (m.user === currentUser.id) {
|
|
233
|
+
fChannel.push(dc)
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
allChannels.data.channels.filter(async chl => {
|
|
239
|
+
if (chl.type !== "DIRECT") {
|
|
240
|
+
let isMember = false
|
|
241
|
+
await chl.members.forEach(c => {
|
|
242
|
+
if (c.user === currentUser.id) {
|
|
243
|
+
joinedChannel.push(chl)
|
|
244
|
+
isMember = true
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
if (isMember === false) {
|
|
248
|
+
modelChannel.push(chl)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
// setChannels([...data.channelsByUser, ...fChannel])
|
|
254
|
+
setPublicChannels(joinedChannel)
|
|
255
|
+
// setModalPublicChannels(modelChannel)
|
|
256
|
+
setDirectMoreModal({ ...directMoreModal, modalPublicChannels: modelChannel })
|
|
257
|
+
setDirectChannels([
|
|
258
|
+
...data.channelsByUser.filter(chl => chl.type === "DIRECT"),
|
|
259
|
+
...fChannel.filter(chl => chl.type === "DIRECT")
|
|
260
|
+
])
|
|
261
|
+
}
|
|
262
|
+
}, [loading, data, allChannels.loading, allChannels.data, currentUser, currentUserRes.loading])
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
const handleCreate = () => {
|
|
266
|
+
createChannel({
|
|
267
|
+
variables: {
|
|
268
|
+
name: channelInput.name,
|
|
269
|
+
description: channelInput.description
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
setPublicChlModal({ ...publicChlModal, show: false })
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
useEffect(() => {
|
|
276
|
+
if (!createdChannel.loading && createdChannel.data) {
|
|
277
|
+
setClickedChannel(createdChannel.data.createChannel)
|
|
278
|
+
}
|
|
279
|
+
}, [createdChannel.loading, createdChannel.data])
|
|
280
|
+
|
|
281
|
+
const handleClose = (name) => {
|
|
282
|
+
if (name === "publicChannel") {
|
|
283
|
+
setPublicChlModal({ ...publicChlModal, show: false })
|
|
284
|
+
} else if (name === "directChannel") {
|
|
285
|
+
setShowDirectChl(false)
|
|
286
|
+
} else if (name === "publicMore") {
|
|
287
|
+
setDirectMoreModal({ ...directMoreModal, showDirectMore: false })
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const handleShow = (name, type?) => {
|
|
291
|
+
if (name === "publicChannel") {
|
|
292
|
+
setPublicChlModal({ ...publicChlModal, show: true })
|
|
293
|
+
handleClose('publicMore')
|
|
294
|
+
} else if (name === "directChannel") {
|
|
295
|
+
setShowDirectChl(true)
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const handleChange = (e) => {
|
|
300
|
+
setChannelInput({ ...channelInput, [e.target.name]: e.target.value })
|
|
301
|
+
}
|
|
302
|
+
const handleChannelClick = (channel) => {
|
|
303
|
+
setClickedChannel(channel)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
if (!addedDirectChannel.loading && addedDirectChannel.data) {
|
|
309
|
+
setClickedChannel(addedDirectChannel.data.createDirectChannel)
|
|
310
|
+
}
|
|
311
|
+
}, [addedDirectChannel.loading, addedDirectChannel.data])
|
|
312
|
+
|
|
313
|
+
const handleClass = () => {
|
|
314
|
+
const oldClasses = classes
|
|
315
|
+
if (!oldClasses.left_bar.split(' ').includes('drawer_style')) {
|
|
316
|
+
setClasses({
|
|
317
|
+
left_bar: `${oldClasses.left_bar} drawer_style`,
|
|
318
|
+
root_div: `${oldClasses.root_div} clicked_class`
|
|
319
|
+
})
|
|
320
|
+
} else {
|
|
321
|
+
setClasses({ left_bar: 'left_bar', root_div: 'root_div' })
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const handleSelect = (selectedOption) => {
|
|
326
|
+
setSelectedValues(selectedOption)
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
useEffect(() => {
|
|
330
|
+
setDirectMoreModal({ ...directMoreModal, ...{ handleJoin: handleJoin, handleShow: handleShow } })
|
|
331
|
+
}, []);
|
|
332
|
+
|
|
333
|
+
return (
|
|
334
|
+
<Router>
|
|
335
|
+
<div className={css(styleSheet.customStyle)}>
|
|
336
|
+
<div className={classes.root_div}>
|
|
337
|
+
<DirectModal
|
|
338
|
+
handleClose={handleClose}
|
|
339
|
+
handleGo={handleGo}
|
|
340
|
+
handleSelect={handleSelect}
|
|
341
|
+
selectedValues={selectedValues}
|
|
342
|
+
showDirectChl={showDirectChl}
|
|
343
|
+
options={options}
|
|
344
|
+
/>
|
|
345
|
+
<Modals
|
|
346
|
+
directMoreModal={directMoreModal}
|
|
347
|
+
publicChlModal={publicChlModal}
|
|
348
|
+
handleChange={handleChange}
|
|
349
|
+
handleClose={handleClose}
|
|
350
|
+
handleCreate={handleCreate}
|
|
351
|
+
/>
|
|
352
|
+
<MenuHeader clickedChannel={clickedChannel} handleClass={handleClass} />
|
|
353
|
+
<div className='dashboard_window' onClick={() => {
|
|
354
|
+
if (classes.root_div.split(' ').length > 1) {
|
|
355
|
+
handleClass()
|
|
356
|
+
}
|
|
357
|
+
}}>
|
|
358
|
+
<div className={classes.left_bar}>
|
|
359
|
+
<div className="nav-pills__container">
|
|
360
|
+
<ul>
|
|
361
|
+
<li id="li1" className="sidebar-section__header">
|
|
362
|
+
<h4><span>PUBLIC CHANNELS</span></h4>
|
|
363
|
+
<button className="add-channel-btn"
|
|
364
|
+
onClick={() => handleShow('publicChannel', 'Public Channel')}>
|
|
365
|
+
<span>+</span></button>
|
|
366
|
+
</li>
|
|
367
|
+
{/*{publicChannels.filter((item, index) => index < 3).map((chl, index) => {*/}
|
|
368
|
+
{publicChannels.map((chl, index) => {
|
|
369
|
+
return (
|
|
370
|
+
<Link
|
|
371
|
+
to={{
|
|
372
|
+
pathname: `/o/${his.location.pathname.split('/')[2]}/dashboard/channel/${chl.title}`,
|
|
373
|
+
state: { channel: chl, currentUser: currentUserRes.data.currentUser }
|
|
374
|
+
}}>
|
|
375
|
+
<li className="">
|
|
376
|
+
<a className="sidebar-item" onClick={() => handleChannelClick(chl)}>
|
|
377
|
+
<span className="icon icon__globe"><BsGlobe2 /></span>
|
|
378
|
+
<span
|
|
379
|
+
className="sidebar-item__name"><span>{chl.title}</span></span>
|
|
380
|
+
</a>
|
|
381
|
+
</li>
|
|
382
|
+
</Link>
|
|
383
|
+
)
|
|
384
|
+
})}
|
|
385
|
+
<li>
|
|
386
|
+
<button id="sidebarPublicChannelsMore"
|
|
387
|
+
className="nav-more"
|
|
388
|
+
onClick={() => setDirectMoreModal({
|
|
389
|
+
...directMoreModal,
|
|
390
|
+
showDirectMore: true
|
|
391
|
+
})}
|
|
392
|
+
>
|
|
393
|
+
<span>More...</span>
|
|
394
|
+
</button>
|
|
395
|
+
</li>
|
|
396
|
+
</ul>
|
|
397
|
+
<ul>
|
|
398
|
+
<li className="sidebar-section__header">
|
|
399
|
+
<h4><span>PRIVATE CHANNELS</span></h4>
|
|
400
|
+
<button className="add-channel-btn">
|
|
401
|
+
<span>+</span></button>
|
|
402
|
+
</li>
|
|
403
|
+
</ul>
|
|
404
|
+
<ul>
|
|
405
|
+
<li className="sidebar-section__header">
|
|
406
|
+
<h4><span>DIRECT MESSAGES</span></h4>
|
|
407
|
+
<button className="add-channel-btn" onClick={() => handleShow("directChannel")}>
|
|
408
|
+
<span>+</span></button>
|
|
409
|
+
</li>
|
|
410
|
+
{directChannels.map(cnl => {
|
|
411
|
+
return (
|
|
412
|
+
<Link
|
|
413
|
+
to={{
|
|
414
|
+
pathname: `/o/${his.location.pathname.split('/')[2]}/dashboard/message/${cnl.displayName.split('_').length === 2 ?
|
|
415
|
+
cnl.displayName.split('_')[0].split('-')[0] !== currentUser.id ?
|
|
416
|
+
cnl.displayName.split('_')[0].split('-')[1] :
|
|
417
|
+
cnl.displayName.split('_')[1].split('-')[1] : cnl.title}`,
|
|
418
|
+
state: {
|
|
419
|
+
channel: cnl,
|
|
420
|
+
currentUser: currentUserRes.data.currentUser
|
|
421
|
+
}
|
|
422
|
+
}}>
|
|
423
|
+
{/*{cnl.displayName === 'surveybot' ?*/}
|
|
424
|
+
{/* <li className="active">*/}
|
|
425
|
+
{/* <a className="sidebar-item has-close"*/}
|
|
426
|
+
{/* onClick={() => handleChannelClick(cnl)}>*/}
|
|
427
|
+
{/* <span className="icon icon__globe"><FaRobot/></span>*/}
|
|
428
|
+
{/* <span*/}
|
|
429
|
+
{/* className="sidebar-item__name"><span>surveybot</span></span>*/}
|
|
430
|
+
{/* </a>*/}
|
|
431
|
+
{/* </li> :*/}
|
|
432
|
+
<li className="active">
|
|
433
|
+
<a className="sidebar-item has-close"
|
|
434
|
+
onClick={() => handleChannelClick(cnl)}>
|
|
435
|
+
{cnl.displayName.split(',').length > 1 ?
|
|
436
|
+
<span
|
|
437
|
+
className="num_style">{cnl.displayName.split(',').length}</span> :
|
|
438
|
+
<span className="icon icon__globe"
|
|
439
|
+
color="white"><RiAdminFill /></span>}
|
|
440
|
+
<span className="sidebar-item__name">
|
|
441
|
+
{/*<span>*/}
|
|
442
|
+
{cnl.displayName.split('_').length === 2 ?
|
|
443
|
+
cnl.displayName.split('_')[0].split('-')[0] !== currentUser.id ?
|
|
444
|
+
cnl.displayName.split('_')[0].split('-')[1] :
|
|
445
|
+
cnl.displayName.split('_')[1].split('-')[1] : cnl.displayName
|
|
446
|
+
}
|
|
447
|
+
{/*</span>*/}
|
|
448
|
+
</span>
|
|
449
|
+
</a>
|
|
450
|
+
</li>
|
|
451
|
+
|
|
452
|
+
{/*}*/}
|
|
453
|
+
</Link>
|
|
454
|
+
)
|
|
455
|
+
})}
|
|
456
|
+
</ul>
|
|
457
|
+
</div>
|
|
458
|
+
</div>
|
|
459
|
+
<div className="route_view">
|
|
460
|
+
<Switch>
|
|
461
|
+
{dashboardRoutes.map((route, index) => (
|
|
462
|
+
<Route
|
|
463
|
+
key={index}
|
|
464
|
+
path={route.path}
|
|
465
|
+
exact={route.exact}
|
|
466
|
+
children={<route.component />}
|
|
467
|
+
/>
|
|
468
|
+
))}
|
|
469
|
+
</Switch>
|
|
470
|
+
</div>
|
|
471
|
+
{/*Add channel Modal*/}
|
|
472
|
+
|
|
473
|
+
{/*{clickedChannel.id ? <div className="main_wraper">*/}
|
|
474
|
+
{/* <IntlProvider locale="en">*/}
|
|
475
|
+
{/* <div className='chat_head_mid'>*/}
|
|
476
|
+
{/* <PostViewPage channel={clickedChannel}*/}
|
|
477
|
+
{/* currentUsrId={currentUser.id}/>*/}
|
|
478
|
+
{/* </div>*/}
|
|
479
|
+
{/* <Messenger channel={clickedChannel} isRefetch={isRefetch}*/}
|
|
480
|
+
{/* currentUsrId={currentUser.id}/>*/}
|
|
481
|
+
{/* </IntlProvider>*/}
|
|
482
|
+
{/* </div>*/}
|
|
483
|
+
{/* : <h2 style={{display: 'flex', alignItems: 'center', margin: '0 auto', color: 'gray'}}>*/}
|
|
484
|
+
{/* Please select any channel*/}
|
|
485
|
+
{/* </h2>*/}
|
|
486
|
+
{/*}*/}
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
</div>
|
|
490
|
+
</Router>
|
|
491
|
+
);
|
|
5
492
|
};
|
|
6
493
|
|
|
7
494
|
export default Dashboard;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PostViewPage } from './../components/post/index';
|
|
3
|
+
import InboxMessage from '../components/InboxMessage';
|
|
4
|
+
|
|
5
|
+
const Inbox= () => {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<InboxMessage />
|
|
9
|
+
</>
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default Inbox;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {PostViewPage} from './../components/post/index';
|
|
3
|
+
import {MessengerComponent} from './../components/messenger'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface ChannelProps {
|
|
6
|
+
channel: any
|
|
7
|
+
currentUsrId: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Messenger: React.FC<ChannelProps> = ({channel, currentUsrId}) => {
|
|
6
11
|
return (
|
|
7
12
|
<>
|
|
8
|
-
<MessengerComponent />
|
|
13
|
+
{channel ? <MessengerComponent channel={channel} currentUsrId={currentUsrId}/> : ''}
|
|
9
14
|
</>
|
|
10
15
|
);
|
|
11
16
|
};
|
package/src/module.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
2
|
import { Feature } from '@common-stack/client-react';
|
|
3
|
-
import { filteredRoutes,
|
|
3
|
+
import { filteredRoutes, filteredMenus } from './compute';
|
|
4
|
+
import { schema, typePolicies, dataIdFromObject } from '@messenger-box/platform-client';
|
|
4
5
|
|
|
5
6
|
export default new Feature({
|
|
6
7
|
routeConfig: filteredRoutes,
|
|
8
|
+
dataIdFromObject,
|
|
9
|
+
clientStateParams: { typeDefs: schema, typePolicies },
|
|
7
10
|
stylesInsert: [
|
|
8
11
|
'bootstrap/dist/css/bootstrap.css',
|
|
9
12
|
'jasny-bootstrap/dist/css/jasny-bootstrap.css',
|
|
10
13
|
'font-awesome/css/font-awesome.css',
|
|
11
14
|
],
|
|
12
|
-
componentFillPlugins: [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
],
|
|
15
|
+
// componentFillPlugins: [
|
|
16
|
+
// {
|
|
17
|
+
// name: 'report-fill-component',
|
|
18
|
+
// render: messengerPageStore,
|
|
19
|
+
// },
|
|
20
|
+
// ],
|
|
18
21
|
});
|