quickblox-react-ui-kit 0.3.0-beta.3 → 0.3.0
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/dist/Data/Stubs.d.ts +1 -1
- package/dist/Data/dto/file/RemoteFileDTO.d.ts +1 -1
- package/dist/Data/dto/message/RemoteMessageDTO.d.ts +1 -1
- package/dist/Data/dto/user/LocalUserDTO.d.ts +1 -1
- package/dist/Data/dto/user/RemoteUserDTO.d.ts +2 -2
- package/dist/Domain/entity/FileEntity.d.ts +1 -1
- package/dist/Domain/entity/UserEntity.d.ts +1 -1
- package/dist/Presentation/Views/Dialog/AIComponents/AIAssist/AIAssist.d.ts +2 -1
- package/dist/Presentation/Views/Dialog/AIComponents/AITranslate/AITranslate.d.ts +2 -1
- package/dist/Presentation/Views/Dialog/AIWidgets/AIRephraseWidget/AIRephraseWidget.d.ts +1 -0
- package/dist/Presentation/Views/Dialog/ForwardMessageFlow/ForwardMessageFlow.d.ts +1 -0
- package/dist/Presentation/Views/Dialog/ForwardMessageFlow/InputForForwarding/InputForForwarding.d.ts +2 -2
- package/dist/Presentation/Views/Dialog/MessageContextMenu/MessageContextMenu.d.ts +2 -1
- package/dist/Presentation/Views/Dialog/MessageItem/MessageItem.d.ts +2 -1
- package/dist/Presentation/Views/DialogInfo/DialogInfo.d.ts +1 -0
- package/dist/Presentation/Views/DialogList/DialogList.d.ts +1 -0
- package/dist/Presentation/Views/EditDialog/EditDialog.d.ts +2 -1
- package/dist/Presentation/Views/Flow/CreateDialogFlow/CreateNewDialogFlow.d.ts +1 -0
- package/dist/Presentation/Views/PreviewDialog/PreviewDialog.d.ts +1 -0
- package/dist/Presentation/providers/QuickBloxUIKitProvider/useQBConnection.d.ts +1 -0
- package/dist/Presentation/ui-components/DialogWindow/DialogWindow.d.ts +3 -2
- package/dist/Presentation/ui-components/Dropdown/DropdownOption.d.ts +2 -1
- package/dist/Presentation/ui-components/MessageInput/AttachmentUploader/AttachmentUploader.d.ts +1 -0
- package/dist/Presentation/ui-components/MessageInput/MessageInput.d.ts +1 -0
- package/dist/index-ui.js +776 -710
- package/dist/index-ui.js.map +1 -1
- package/dist/qb-api-calls/index.d.ts +8 -7
- package/global.d.ts +2513 -546
- package/package.json +2 -2
- package/src/App.scss +3 -0
- package/src/Data/Creator.ts +1 -2
- package/src/Data/Stubs.ts +4 -5
- package/src/Data/dto/file/RemoteFileDTO.ts +2 -2
- package/src/Data/dto/message/RemoteMessageDTO.ts +1 -1
- package/src/Data/dto/user/LocalUserDTO.ts +2 -2
- package/src/Data/dto/user/RemoteUserDTO.ts +4 -4
- package/src/Data/mapper/FileRemoteDTOMapper.ts +8 -6
- package/src/Data/mapper/MessageRemoteDTOMapper.ts +1 -1
- package/src/Data/mapper/UserLocalDTOMapper.ts +2 -2
- package/src/Data/mapper/UserRemoteDTOMapper.ts +2 -2
- package/src/Data/repository/MessagesRepository.ts +2 -2
- package/src/Data/repository/UsersRepository.ts +1 -1
- package/src/Data/source/remote/Mapper/FileDTOMapper.ts +23 -23
- package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +2 -2
- package/src/Data/source/remote/Mapper/UserDTOMapper.ts +0 -2
- package/src/Data/source/remote/RemoteDataSource.ts +50 -8
- package/src/Domain/entity/FileEntity.ts +1 -1
- package/src/Domain/entity/UserEntity.ts +1 -11
- package/src/Domain/use_cases/UpdateDialogUseCase.ts +6 -1
- package/src/Domain/use_cases/base/Subscribable/SubscriptionPerformer.ts +1 -1
- package/src/Presentation/Views/Dialog/AIComponents/AIAssist/AIAssist.scss +5 -0
- package/src/Presentation/Views/Dialog/AIComponents/AIAssist/AIAssist.tsx +9 -2
- package/src/Presentation/Views/Dialog/AIComponents/AITranslate/AITranslate.scss +10 -0
- package/src/Presentation/Views/Dialog/AIComponents/AITranslate/AITranslate.tsx +16 -7
- package/src/Presentation/Views/Dialog/AIWidgets/AIRephraseWidget/AIRephraseWidget.scss +7 -2
- package/src/Presentation/Views/Dialog/AIWidgets/AIRephraseWidget/AIRephraseWidget.tsx +12 -3
- package/src/Presentation/Views/Dialog/ForwardMessageFlow/DialogsWithSearch/DialogListItem/DialogListItem.scss +1 -1
- package/src/Presentation/Views/Dialog/ForwardMessageFlow/ForwardMessageFlow.tsx +9 -5
- package/src/Presentation/Views/Dialog/ForwardMessageFlow/InputForForwarding/InputForForwarding.scss +31 -1
- package/src/Presentation/Views/Dialog/ForwardMessageFlow/InputForForwarding/InputForForwarding.tsx +7 -7
- package/src/Presentation/Views/Dialog/MessageContextMenu/MessageContextMenu.tsx +17 -6
- package/src/Presentation/Views/Dialog/MessageItem/MessageItem.tsx +6 -0
- package/src/Presentation/Views/Dialog/useDialogViewModel.ts +1 -0
- package/src/Presentation/Views/DialogInfo/DialogInfo.scss +11 -1
- package/src/Presentation/Views/DialogInfo/DialogInfo.tsx +36 -18
- package/src/Presentation/Views/DialogInfo/UsersList/useUsersListViewModel.ts +1 -0
- package/src/Presentation/Views/DialogList/DialogList.scss +5 -0
- package/src/Presentation/Views/DialogList/DialogList.tsx +12 -2
- package/src/Presentation/Views/DialogList/useDialogListViewModel.ts +33 -16
- package/src/Presentation/Views/EditDialog/EditDialog.scss +11 -0
- package/src/Presentation/Views/EditDialog/EditDialog.tsx +9 -1
- package/src/Presentation/Views/Flow/CreateDialogFlow/CreateNewDialogFlow.tsx +14 -0
- package/src/Presentation/Views/InviteMembers/useInviteMembersViewModel.ts +1 -11
- package/src/Presentation/Views/PreviewDialog/PreviewDialog.tsx +4 -0
- package/src/Presentation/icons/media/video-file.svg +2 -2
- package/src/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +426 -499
- package/src/Presentation/providers/QuickBloxUIKitProvider/useQBConnection.ts +16 -0
- package/src/Presentation/ui-components/DialogWindow/DialogWindow.scss +11 -0
- package/src/Presentation/ui-components/DialogWindow/DialogWindow.tsx +4 -1
- package/src/Presentation/ui-components/Dropdown/Dropdown.scss +4 -0
- package/src/Presentation/ui-components/Dropdown/Dropdown.tsx +1 -1
- package/src/Presentation/ui-components/Dropdown/DropdownOption.tsx +9 -1
- package/src/Presentation/ui-components/MessageInput/AttachmentUploader/AttachmentUploader.tsx +3 -0
- package/src/Presentation/ui-components/MessageInput/MessageInput.scss +18 -4
- package/src/Presentation/ui-components/MessageInput/MessageInput.tsx +8 -2
- package/src/Presentation/ui-components/PreviewFileMessage/PreviewFileMessage.tsx +2 -2
- package/src/Presentation/ui-components/SettingsItem/SettingsItem.stories.tsx +2 -0
- package/src/index.scss +5 -2
- package/src/qb-api-calls/index.ts +58 -49
- package/storybook-static/758.53b4954a.iframe.bundle.js +14 -0
- package/storybook-static/{758.e75a5a47.iframe.bundle.js.map → 758.53b4954a.iframe.bundle.js.map} +1 -1
- package/storybook-static/{Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.90aa44c5.iframe.bundle.js → Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.6665bbfb.iframe.bundle.js} +1 -1
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.cf340397.iframe.bundle.js +1 -0
- package/storybook-static/{Presentation-ui-components-Dropdown-Dropdown-stories.aacf2ec2.iframe.bundle.js → Presentation-ui-components-Dropdown-Dropdown-stories.b32a1e17.iframe.bundle.js} +1 -1
- package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.c2ead6a5.iframe.bundle.js +1 -0
- package/storybook-static/{Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.1661d95b.iframe.bundle.js → Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.527e000e.iframe.bundle.js} +1 -1
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.2ff75703.iframe.bundle.js +1 -0
- package/storybook-static/{docs-Introduction-mdx.ac401482.iframe.bundle.js → docs-Introduction-mdx.bcb06844.iframe.bundle.js} +2 -2
- package/storybook-static/{docs-Introduction-mdx.ac401482.iframe.bundle.js.map → docs-Introduction-mdx.bcb06844.iframe.bundle.js.map} +1 -1
- package/storybook-static/iframe.html +2 -2
- package/storybook-static/project.json +1 -1
- package/storybook-static/{runtime~main.e945879b.iframe.bundle.js → runtime~main.7ee2126e.iframe.bundle.js} +1 -1
- package/storybook-static/static/css/{Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.e720ff21.chunk.css → Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.bee082ca.chunk.css} +2 -2
- package/storybook-static/static/css/{Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.e720ff21.chunk.css.map → Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.bee082ca.chunk.css.map} +1 -1
- package/storybook-static/static/css/{Presentation-ui-components-DialogWindow-DialogWindow-stories.6fb3af8d.chunk.css → Presentation-ui-components-DialogWindow-DialogWindow-stories.4f813450.chunk.css} +2 -2
- package/storybook-static/static/css/Presentation-ui-components-DialogWindow-DialogWindow-stories.4f813450.chunk.css.map +1 -0
- package/storybook-static/static/css/{Presentation-ui-components-Dropdown-Dropdown-stories.66965d64.chunk.css → Presentation-ui-components-Dropdown-Dropdown-stories.e37f549d.chunk.css} +2 -2
- package/storybook-static/static/css/Presentation-ui-components-Dropdown-Dropdown-stories.e37f549d.chunk.css.map +1 -0
- package/storybook-static/static/css/{Presentation-ui-components-MessageInput-MessageInput-stories.0e99d80b.chunk.css → Presentation-ui-components-MessageInput-MessageInput-stories.7eb916fc.chunk.css} +2 -2
- package/storybook-static/static/css/Presentation-ui-components-MessageInput-MessageInput-stories.7eb916fc.chunk.css.map +1 -0
- package/storybook-static/static/css/{main.6fa55a2c.css → main.a921485c.css} +2 -2
- package/storybook-static/static/css/{main.6fa55a2c.css.map → main.a921485c.css.map} +1 -1
- package/storybook-static/static/media/video-file.dbd1f8c63a3769f9e9a027f0922d56b2.svg +3 -0
- package/storybook-static/758.e75a5a47.iframe.bundle.js +0 -14
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.3523a670.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.262a0cf2.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.8f6fca84.iframe.bundle.js +0 -1
- package/storybook-static/static/css/Presentation-ui-components-DialogWindow-DialogWindow-stories.6fb3af8d.chunk.css.map +0 -1
- package/storybook-static/static/css/Presentation-ui-components-Dropdown-Dropdown-stories.66965d64.chunk.css.map +0 -1
- package/storybook-static/static/css/Presentation-ui-components-MessageInput-MessageInput-stories.0e99d80b.chunk.css.map +0 -1
- package/storybook-static/static/media/video-file.dc2971be489b2af7b1c04dcc55bfe881.svg +0 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
1
2
|
import Dropdown from '../../../../ui-components/Dropdown/Dropdown';
|
|
2
3
|
import { ReactComponent as TranslateSvg } from '../../../../icons/actions/translate.svg';
|
|
3
4
|
import { MessageEntity } from '../../../../../Domain/entity/MessageEntity';
|
|
@@ -18,6 +19,7 @@ interface AITranslateComponentProps {
|
|
|
18
19
|
messageToTranslate?: MessageEntity;
|
|
19
20
|
messageHistory?: MessageEntity[];
|
|
20
21
|
currentUserId?: number;
|
|
22
|
+
disableAction?: boolean;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export default function AITranslate({
|
|
@@ -33,11 +35,12 @@ export default function AITranslate({
|
|
|
33
35
|
messageToTranslate,
|
|
34
36
|
messageHistory,
|
|
35
37
|
currentUserId,
|
|
38
|
+
disableAction = false,
|
|
36
39
|
}: AITranslateComponentProps) {
|
|
37
40
|
const options = languages.map((lang) => ({ value: lang, label: lang }));
|
|
38
41
|
|
|
39
42
|
async function translateHandler(translateLanguage: string) {
|
|
40
|
-
if (loading) {
|
|
43
|
+
if (loading || disableAction) {
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
46
|
|
|
@@ -79,12 +82,14 @@ export default function AITranslate({
|
|
|
79
82
|
return (
|
|
80
83
|
<div className="ai-translate">
|
|
81
84
|
<div
|
|
82
|
-
className={
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
+
className={cn('ai-translate__caption', {
|
|
86
|
+
'translate__caption--disable': loading,
|
|
87
|
+
})}
|
|
85
88
|
>
|
|
86
89
|
<div
|
|
87
|
-
className=
|
|
90
|
+
className={cn('ai-translate__caption__label', {
|
|
91
|
+
'ai-translate__caption__label--disable': disableAction,
|
|
92
|
+
})}
|
|
88
93
|
onClick={() => {
|
|
89
94
|
if (originalTextMessage) {
|
|
90
95
|
translateHandler(defaultLanguage);
|
|
@@ -102,13 +107,17 @@ export default function AITranslate({
|
|
|
102
107
|
<div>
|
|
103
108
|
<Dropdown
|
|
104
109
|
options={options}
|
|
105
|
-
disabled={loading}
|
|
110
|
+
disabled={loading || disableAction}
|
|
106
111
|
onSelect={(language) => {
|
|
107
112
|
translateHandler(language);
|
|
108
113
|
}}
|
|
109
114
|
>
|
|
110
115
|
<div className="ai-translate__icon">
|
|
111
|
-
<TranslateSvg
|
|
116
|
+
<TranslateSvg
|
|
117
|
+
className={cn('ai-translate__icon__media-translate', {
|
|
118
|
+
'ai-translate__icon__media-translate--disable': disableAction,
|
|
119
|
+
})}
|
|
120
|
+
/>
|
|
112
121
|
</div>
|
|
113
122
|
</Dropdown>
|
|
114
123
|
</div>
|
|
@@ -9,11 +9,16 @@
|
|
|
9
9
|
margin-bottom: 5px;
|
|
10
10
|
}
|
|
11
11
|
.rephrase-icon{
|
|
12
|
-
width:
|
|
13
|
-
height:
|
|
12
|
+
width: 24px;
|
|
13
|
+
height: 24px;
|
|
14
14
|
cursor: pointer;
|
|
15
15
|
fill: var(--color-icon);
|
|
16
16
|
|
|
17
|
+
&--disable {
|
|
18
|
+
cursor: default;
|
|
19
|
+
fill: var(--disabled-elements);
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
svg path{
|
|
18
23
|
fill: var(--color-icon);
|
|
19
24
|
}
|
|
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import './AIRephraseWidget.scss';
|
|
3
3
|
import { Tone } from 'qb-ai-rephrase/src/Tone';
|
|
4
4
|
import { QBAIRephrase } from 'qb-ai-rephrase';
|
|
5
|
+
import cn from 'classnames';
|
|
5
6
|
import {
|
|
6
7
|
FunctionTypeBooleanToVoid,
|
|
7
8
|
FunctionTypeStringToVoid,
|
|
@@ -36,6 +37,7 @@ type AIRephraseWidgetProps = {
|
|
|
36
37
|
rephraseTones: Tone[];
|
|
37
38
|
theme?: UiKitTheme;
|
|
38
39
|
setPrevValueText: FunctionTypeStringToVoid;
|
|
40
|
+
disableActions?: boolean;
|
|
39
41
|
};
|
|
40
42
|
// eslint-disable-next-line react/function-component-definition
|
|
41
43
|
const AIRephraseWidget: React.FC<AIRephraseWidgetProps> = ({
|
|
@@ -51,6 +53,7 @@ const AIRephraseWidget: React.FC<AIRephraseWidgetProps> = ({
|
|
|
51
53
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
54
|
theme = undefined,
|
|
53
55
|
setPrevValueText,
|
|
56
|
+
disableActions = false,
|
|
54
57
|
}: AIRephraseWidgetProps) => {
|
|
55
58
|
const [currentMessageText, setCurrentMessageText] =
|
|
56
59
|
useState<string>(messageText);
|
|
@@ -91,7 +94,8 @@ const AIRephraseWidget: React.FC<AIRephraseWidgetProps> = ({
|
|
|
91
94
|
if (
|
|
92
95
|
currentMessageText &&
|
|
93
96
|
currentMessageText.length > 0 &&
|
|
94
|
-
!waitAIWidget
|
|
97
|
+
!waitAIWidget &&
|
|
98
|
+
!disableActions
|
|
95
99
|
) {
|
|
96
100
|
setWaitAIWidget(true);
|
|
97
101
|
setPrevTextMessage(currentMessageText);
|
|
@@ -153,12 +157,17 @@ const AIRephraseWidget: React.FC<AIRephraseWidgetProps> = ({
|
|
|
153
157
|
<div
|
|
154
158
|
className="icon"
|
|
155
159
|
style={{
|
|
156
|
-
cursor: !waitAIWidget ? 'pointer' : '',
|
|
160
|
+
cursor: !waitAIWidget || !disableActions ? 'pointer' : '',
|
|
157
161
|
}}
|
|
158
162
|
>
|
|
159
163
|
<AIWidgetActions
|
|
164
|
+
disabled={!disableActions}
|
|
160
165
|
widgetToRender={
|
|
161
|
-
<RephraseSvg
|
|
166
|
+
<RephraseSvg
|
|
167
|
+
className={cn('rephrase-icon', {
|
|
168
|
+
'rephrase-icon--disable': disableActions,
|
|
169
|
+
})}
|
|
170
|
+
/>
|
|
162
171
|
// <ToneIcon
|
|
163
172
|
// width="24"
|
|
164
173
|
// height="24"
|
|
@@ -17,6 +17,7 @@ type ForwardMessageFlowProps = {
|
|
|
17
17
|
messages: MessageEntity[],
|
|
18
18
|
relatedText: string,
|
|
19
19
|
) => void;
|
|
20
|
+
disableActions: boolean;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
// eslint-disable-next-line react/function-component-definition
|
|
@@ -26,6 +27,7 @@ const ForwardMessageFlow: React.FC<ForwardMessageFlowProps> = ({
|
|
|
26
27
|
currentDialog,
|
|
27
28
|
currentUserName,
|
|
28
29
|
onSendData,
|
|
30
|
+
disableActions,
|
|
29
31
|
}: ForwardMessageFlowProps) => {
|
|
30
32
|
const [activeChatsTab, setActiveChatsTab] = useState(true);
|
|
31
33
|
const [selectedDialogs, setSelectedDialogs] = useState<string[]>([]);
|
|
@@ -33,11 +35,13 @@ const ForwardMessageFlow: React.FC<ForwardMessageFlowProps> = ({
|
|
|
33
35
|
|
|
34
36
|
const userName = currentUserName;
|
|
35
37
|
const sendMessageHandler = () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
if (!disableActions) {
|
|
39
|
+
const dialogsForSend: DialogEntity[] = dialogs.filter((item) =>
|
|
40
|
+
selectedDialogs.includes(item.id),
|
|
41
|
+
);
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
onSendData(dialogsForSend, messages, inputText);
|
|
44
|
+
}
|
|
41
45
|
};
|
|
42
46
|
|
|
43
47
|
return (
|
|
@@ -108,7 +112,7 @@ const ForwardMessageFlow: React.FC<ForwardMessageFlowProps> = ({
|
|
|
108
112
|
inputText={inputText}
|
|
109
113
|
onChange={(s) => setInputText(s)}
|
|
110
114
|
onSend={sendMessageHandler}
|
|
111
|
-
disabled={selectedDialogs.length === 0}
|
|
115
|
+
disabled={selectedDialogs.length === 0 || disableActions}
|
|
112
116
|
/>
|
|
113
117
|
</div>
|
|
114
118
|
</div>
|
package/src/Presentation/Views/Dialog/ForwardMessageFlow/InputForForwarding/InputForForwarding.scss
CHANGED
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
|
|
48
48
|
.forwarding-message-input-icon-send {
|
|
49
49
|
border-radius: 4px;
|
|
50
|
-
padding: 4px;
|
|
51
50
|
display: flex;
|
|
52
51
|
flex-direction: row;
|
|
53
52
|
gap: 0px;
|
|
@@ -57,6 +56,37 @@
|
|
|
57
56
|
width: 24px;
|
|
58
57
|
height: 44px;
|
|
59
58
|
position: relative;
|
|
59
|
+
|
|
60
|
+
&__icon{
|
|
61
|
+
width: 24px;
|
|
62
|
+
height: 24px;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
fill: var(--secondary-elements);
|
|
65
|
+
&__send {
|
|
66
|
+
width: 24px;
|
|
67
|
+
height: 24px;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
fill: var(--main-elements);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
svg path{
|
|
73
|
+
width: 24px;
|
|
74
|
+
height: 24px;
|
|
75
|
+
fill: var(--main-elements);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
&__icon--disable{
|
|
79
|
+
fill: var(--disabled-elements);
|
|
80
|
+
cursor: default;
|
|
81
|
+
width: 24px;
|
|
82
|
+
height: 24px;
|
|
83
|
+
svg path{
|
|
84
|
+
width: 24px;
|
|
85
|
+
height: 24px;
|
|
86
|
+
fill: var(--disabled-elements);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
60
90
|
}
|
|
61
91
|
.actions-send {
|
|
62
92
|
flex-shrink: 0;
|
package/src/Presentation/Views/Dialog/ForwardMessageFlow/InputForForwarding/InputForForwarding.tsx
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import './InputForForwarding.scss';
|
|
1
|
+
import cn from 'classnames';
|
|
3
2
|
import {
|
|
4
3
|
FunctionTypeStringToVoid,
|
|
5
4
|
FunctionTypeVoidToVoid,
|
|
6
5
|
} from '../../../../../CommonTypes/BaseViewModel';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import { SendSvg } from '../../../../icons';
|
|
7
|
+
import './InputForForwarding.scss';
|
|
9
8
|
|
|
10
9
|
type InputForForwardingProps = {
|
|
11
10
|
inputText: string;
|
|
@@ -34,10 +33,11 @@ const InputForForwarding: React.FC<InputForForwardingProps> = ({
|
|
|
34
33
|
/>
|
|
35
34
|
</div>
|
|
36
35
|
<div className="forwarding-message-input-icon-send">
|
|
37
|
-
<
|
|
38
|
-
|
|
36
|
+
<SendSvg
|
|
37
|
+
className={cn('forwarding-message-input-icon-send__icon__send', {
|
|
38
|
+
'forwarding-message-input-icon-send__icon--disable': disabled,
|
|
39
|
+
})}
|
|
39
40
|
onClick={onSend}
|
|
40
|
-
disabled={disabled}
|
|
41
41
|
/>
|
|
42
42
|
</div>
|
|
43
43
|
</div>
|
|
@@ -11,6 +11,7 @@ export type MessageContextMenuProps = {
|
|
|
11
11
|
enableReplying: boolean;
|
|
12
12
|
onReply: FunctionTypeMessageEntityToVoid;
|
|
13
13
|
onForward: FunctionTypeMessageEntityToVoid;
|
|
14
|
+
disableActions?: boolean;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export default function MessageContextMenu({
|
|
@@ -19,22 +20,32 @@ export default function MessageContextMenu({
|
|
|
19
20
|
enableForwarding,
|
|
20
21
|
onReply,
|
|
21
22
|
onForward,
|
|
23
|
+
disableActions = false,
|
|
22
24
|
}: MessageContextMenuProps) {
|
|
23
25
|
function selectHandler(value: string) {
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (!disableActions) {
|
|
27
|
+
if (value === 'Reply' && enableReplying) {
|
|
28
|
+
onReply(message);
|
|
29
|
+
}
|
|
30
|
+
if (value === 'Forward' && enableForwarding) {
|
|
31
|
+
onForward(message);
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
|
|
36
|
+
// const [disabled, setDisabled] = useState(disableActions);
|
|
37
|
+
|
|
38
|
+
// useEffect(() => {
|
|
39
|
+
// setDisabled(disableActions);
|
|
40
|
+
// }, [disableActions]);
|
|
41
|
+
|
|
32
42
|
const options: Option[] = [];
|
|
33
43
|
|
|
34
44
|
if (enableReplying) {
|
|
35
45
|
options.push({
|
|
36
46
|
value: 'Reply',
|
|
37
47
|
label: 'Reply',
|
|
48
|
+
disabled: disableActions,
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
51
|
|
|
@@ -50,7 +61,7 @@ export default function MessageContextMenu({
|
|
|
50
61
|
{enableForwarding || enableReplying ? (
|
|
51
62
|
<Dropdown
|
|
52
63
|
options={options}
|
|
53
|
-
disabled={
|
|
64
|
+
disabled={disableActions}
|
|
54
65
|
onSelect={(value) => selectHandler(value)}
|
|
55
66
|
>
|
|
56
67
|
<div className="message-context-menu-actions">
|
|
@@ -32,6 +32,7 @@ export type MessageItemProps = {
|
|
|
32
32
|
listRef?: RefObject<HTMLDivElement>;
|
|
33
33
|
messagesToView: MessageEntity[];
|
|
34
34
|
onError: (messageError: string) => void;
|
|
35
|
+
disableAction?: boolean;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
interface MessageStates {
|
|
@@ -79,6 +80,7 @@ export default function MessageItem({
|
|
|
79
80
|
defaultTranslationLanguage,
|
|
80
81
|
languagesForAITranslate,
|
|
81
82
|
onError,
|
|
83
|
+
disableAction = false,
|
|
82
84
|
}: MessageItemProps) {
|
|
83
85
|
const messageStates: Record<string, MessageStates> = {};
|
|
84
86
|
|
|
@@ -152,6 +154,7 @@ export default function MessageItem({
|
|
|
152
154
|
onForward={onForward}
|
|
153
155
|
enableReplying={enableReplying}
|
|
154
156
|
enableForwarding={enableForwarding}
|
|
157
|
+
disableActions={disableAction}
|
|
155
158
|
/>
|
|
156
159
|
{currentMessageType === 'incoming' && state[item.id]?.loading && (
|
|
157
160
|
<Loader size="sm" className="message-item-additional-part__loader" />
|
|
@@ -160,6 +163,7 @@ export default function MessageItem({
|
|
|
160
163
|
!(item.attachments && item.attachments.length > 0) &&
|
|
161
164
|
AIAssistWidget && (
|
|
162
165
|
<AIAssist
|
|
166
|
+
disableAction={disableAction}
|
|
163
167
|
AIAssistWidget={AIAssistWidget}
|
|
164
168
|
loading={
|
|
165
169
|
state[item.id] && state[item.id].loading
|
|
@@ -204,6 +208,7 @@ export default function MessageItem({
|
|
|
204
208
|
nestedMessage.attachments.length > 0
|
|
205
209
|
) && AITranslateWidget ? (
|
|
206
210
|
<AITranslate
|
|
211
|
+
disableAction={disableAction}
|
|
207
212
|
AITranslateWidget={AITranslateWidget}
|
|
208
213
|
defaultLanguage={defaultTranslationLanguage}
|
|
209
214
|
languages={languagesForAITranslate}
|
|
@@ -306,6 +311,7 @@ export default function MessageItem({
|
|
|
306
311
|
!(message.attachments && message.attachments.length > 0) &&
|
|
307
312
|
AITranslateWidget ? (
|
|
308
313
|
<AITranslate
|
|
314
|
+
disableAction={disableAction}
|
|
309
315
|
AITranslateWidget={AITranslateWidget}
|
|
310
316
|
defaultLanguage={defaultTranslationLanguage}
|
|
311
317
|
languages={languagesForAITranslate}
|
|
@@ -112,6 +112,11 @@ $dialog-information-container-dialog-information-height: 64px;
|
|
|
112
112
|
text-align: left;
|
|
113
113
|
font: var(--button-default);
|
|
114
114
|
position: relative;
|
|
115
|
+
|
|
116
|
+
&--disable {
|
|
117
|
+
color: var(--disabled-elements);
|
|
118
|
+
cursor: default;
|
|
119
|
+
}
|
|
115
120
|
}
|
|
116
121
|
|
|
117
122
|
.dialog-info-action-wrapper-settings,
|
|
@@ -202,8 +207,13 @@ $dialog-information-container-dialog-information-height: 64px;
|
|
|
202
207
|
|
|
203
208
|
.dialog-info-leave {
|
|
204
209
|
fill: var(--error);
|
|
205
|
-
|
|
206
210
|
border-bottom: 1px solid var(--divider);
|
|
211
|
+
cursor: pointer;
|
|
212
|
+
|
|
213
|
+
&--disable {
|
|
214
|
+
fill: var(--disabled-elements);
|
|
215
|
+
cursor: default;
|
|
216
|
+
}
|
|
207
217
|
}
|
|
208
218
|
|
|
209
219
|
.dialog-info-members {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import './DialogInfo.scss';
|
|
3
3
|
import { toast } from 'react-toastify';
|
|
4
|
+
import cn from 'classnames';
|
|
4
5
|
import ColumnContainer from '../../components/containers/ColumnContainer/ColumnContainer';
|
|
5
6
|
import { DialogEntity } from '../../../Domain/entity/DialogEntity';
|
|
6
7
|
import GroupChat from '../../components/UI/svgs/Icons/Contents/GroupChat';
|
|
@@ -40,6 +41,7 @@ type HeaderDialogsProps = {
|
|
|
40
41
|
subHeaderContent?: React.ReactNode;
|
|
41
42
|
upHeaderContent?: React.ReactNode;
|
|
42
43
|
rootStyles?: React.CSSProperties;
|
|
44
|
+
disableAction?: boolean;
|
|
43
45
|
};
|
|
44
46
|
// eslint-disable-next-line react/function-component-definition
|
|
45
47
|
const DialogInfo: React.FC<HeaderDialogsProps> = ({
|
|
@@ -53,6 +55,7 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
|
|
|
53
55
|
subHeaderContent = undefined,
|
|
54
56
|
upHeaderContent = undefined,
|
|
55
57
|
rootStyles = {},
|
|
58
|
+
disableAction = false,
|
|
56
59
|
}: HeaderDialogsProps) => {
|
|
57
60
|
const [dialogAvatarUrl, setDialogAvatarUrl] = useState('');
|
|
58
61
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -73,19 +76,21 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
|
|
|
73
76
|
const useUpContent = upHeaderContent || false;
|
|
74
77
|
|
|
75
78
|
const leaveDialogHandler = () => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
if (!disableAction) {
|
|
80
|
+
// onLeaveDialog((dialogViewModel?.entity || dialog) as GroupDialogEntity);
|
|
81
|
+
dialogViewModel
|
|
82
|
+
.deleteDialog((dialogViewModel?.entity || dialog) as GroupDialogEntity)
|
|
83
|
+
.then((result) => {
|
|
84
|
+
// eslint-disable-next-line promise/always-return
|
|
85
|
+
if (!result) {
|
|
86
|
+
toast('Dialog have not been left');
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
.catch((e) => {
|
|
90
|
+
console.log(e);
|
|
91
|
+
toast("Can't leave dialog");
|
|
92
|
+
});
|
|
93
|
+
}
|
|
89
94
|
};
|
|
90
95
|
|
|
91
96
|
const getUserAvatarByUid = async () => {
|
|
@@ -345,8 +350,17 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
|
|
|
345
350
|
<div className="dialog-information-profile-edit">
|
|
346
351
|
{dialog.type !== DialogType.private &&
|
|
347
352
|
dialog.ownerId === currentUserId ? (
|
|
348
|
-
<div
|
|
349
|
-
|
|
353
|
+
<div
|
|
354
|
+
className={cn('dialog-information-profile-edit-button', {
|
|
355
|
+
'dialog-information-profile-edit-button--disable':
|
|
356
|
+
disableAction,
|
|
357
|
+
})}
|
|
358
|
+
>
|
|
359
|
+
<Button
|
|
360
|
+
variant="text"
|
|
361
|
+
onClick={editModal.toggleModal}
|
|
362
|
+
disabled={disableAction}
|
|
363
|
+
>
|
|
350
364
|
Edit
|
|
351
365
|
</Button>
|
|
352
366
|
<DialogWindow
|
|
@@ -355,6 +369,7 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
|
|
|
355
369
|
open={editModal.isOpen}
|
|
356
370
|
>
|
|
357
371
|
<EditDialog
|
|
372
|
+
disableActions={disableAction}
|
|
358
373
|
nameDialog={dialogViewModel?.entity.name || dialog.name}
|
|
359
374
|
typeDialog={dialogViewModel?.entity.type || dialog.type}
|
|
360
375
|
ulrIcon={getUrlAvatar(dialogViewModel?.entity || dialog)}
|
|
@@ -387,6 +402,7 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
|
|
|
387
402
|
)}
|
|
388
403
|
<div className="dialog-info-action-wrapper-settings">
|
|
389
404
|
<DialogWindow
|
|
405
|
+
disableActions={disableAction}
|
|
390
406
|
title="Edit dialog"
|
|
391
407
|
open={inviteMembersModal.isOpen}
|
|
392
408
|
onClose={inviteMembersModal.toggleModal}
|
|
@@ -406,7 +422,7 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
|
|
|
406
422
|
className="dialog-info-action-wrapper-button"
|
|
407
423
|
onClick={inviteMembersModal.toggleModal}
|
|
408
424
|
variant="outlined"
|
|
409
|
-
disabled={dialog.ownerId !== currentUserId}
|
|
425
|
+
disabled={dialog.ownerId !== currentUserId || disableAction}
|
|
410
426
|
>
|
|
411
427
|
Invite members
|
|
412
428
|
</Button>
|
|
@@ -425,8 +441,10 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
|
|
|
425
441
|
<SettingsItem
|
|
426
442
|
icon={<LeaveSvg />}
|
|
427
443
|
title="Leave dialog"
|
|
428
|
-
onClick={leaveModal.toggleModal}
|
|
429
|
-
className=
|
|
444
|
+
onClick={!disableAction ? leaveModal.toggleModal : undefined}
|
|
445
|
+
className={cn('dialog-info-leave', {
|
|
446
|
+
'dialog-info-leave--disable': disableAction,
|
|
447
|
+
})}
|
|
430
448
|
/>
|
|
431
449
|
<DialogWindow
|
|
432
450
|
open={leaveModal.isOpen}
|
|
@@ -46,6 +46,7 @@ type DialogsProps = {
|
|
|
46
46
|
onCreateDialog?: FunctionTypeVoidToVoid;
|
|
47
47
|
dialogListViewModel: DialogListViewModel;
|
|
48
48
|
additionalSettings?: DialogsComponentSettings;
|
|
49
|
+
disableAction?: boolean;
|
|
49
50
|
scrollableHeight?: number;
|
|
50
51
|
};
|
|
51
52
|
|
|
@@ -60,6 +61,7 @@ const DialogList: React.FC<DialogsProps> = ({
|
|
|
60
61
|
onCreateDialog,
|
|
61
62
|
dialogListViewModel,
|
|
62
63
|
additionalSettings = undefined,
|
|
64
|
+
disableAction = false,
|
|
63
65
|
scrollableHeight = 736,
|
|
64
66
|
}: DialogsProps) => {
|
|
65
67
|
const dialogs: PreviewDialogViewModel[] = [];
|
|
@@ -146,6 +148,12 @@ const DialogList: React.FC<DialogsProps> = ({
|
|
|
146
148
|
}
|
|
147
149
|
};
|
|
148
150
|
|
|
151
|
+
const onClickHandler = () => {
|
|
152
|
+
if (!disableAction && onCreateDialog) {
|
|
153
|
+
onCreateDialog();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
149
157
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
150
158
|
const useHeader = !additionalSettings?.withoutHeader || header || false;
|
|
151
159
|
const useSubContent =
|
|
@@ -163,8 +171,10 @@ const DialogList: React.FC<DialogsProps> = ({
|
|
|
163
171
|
}}
|
|
164
172
|
/>
|
|
165
173
|
<NewChatSvg
|
|
166
|
-
className=
|
|
167
|
-
|
|
174
|
+
className={cn('dialog-list-header__icons', {
|
|
175
|
+
'dialog-list-header__icons--disable': disableAction,
|
|
176
|
+
})}
|
|
177
|
+
onClick={onClickHandler}
|
|
168
178
|
/>
|
|
169
179
|
</Header>
|
|
170
180
|
);
|
|
@@ -117,9 +117,10 @@ export default function useDialogListViewModel(
|
|
|
117
117
|
);
|
|
118
118
|
|
|
119
119
|
const sortedData = [...filteredDialogs].sort((a, b) => {
|
|
120
|
-
return
|
|
121
|
-
new Date(b.
|
|
122
|
-
|
|
120
|
+
return b.lastMessage.dateSent && a.lastMessage.dateSent
|
|
121
|
+
? new Date(b.lastMessage.dateSent).getTime() -
|
|
122
|
+
new Date(a.lastMessage.dateSent).getTime()
|
|
123
|
+
: new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime();
|
|
123
124
|
});
|
|
124
125
|
|
|
125
126
|
setDialogs([...sortedData]);
|
|
@@ -137,9 +138,10 @@ export default function useDialogListViewModel(
|
|
|
137
138
|
await useCaseSubscribeToDialogsUpdates?.execute((data) => {
|
|
138
139
|
try {
|
|
139
140
|
const sortedData = [...(data as PublicDialogEntity[])].sort((a, b) => {
|
|
140
|
-
return
|
|
141
|
-
new Date(b.
|
|
142
|
-
|
|
141
|
+
return b.lastMessage.dateSent && a.lastMessage.dateSent
|
|
142
|
+
? new Date(b.lastMessage.dateSent).getTime() -
|
|
143
|
+
new Date(a.lastMessage.dateSent).getTime()
|
|
144
|
+
: new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime();
|
|
143
145
|
});
|
|
144
146
|
|
|
145
147
|
setDialogs(sortedData);
|
|
@@ -174,9 +176,12 @@ export default function useDialogListViewModel(
|
|
|
174
176
|
dialogId,
|
|
175
177
|
);
|
|
176
178
|
|
|
177
|
-
// eslint-disable-next-line promise/catch-or-return
|
|
179
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
178
180
|
getDialogByIdUseCase.execute().then((updatedDialog) => {
|
|
179
|
-
|
|
181
|
+
// eslint-disable-next-line promise/always-return
|
|
182
|
+
if (newDialog && newDialog.id === updatedDialog.id) {
|
|
183
|
+
setNewDialog(updatedDialog);
|
|
184
|
+
}
|
|
180
185
|
});
|
|
181
186
|
}
|
|
182
187
|
} else if (
|
|
@@ -226,10 +231,11 @@ export default function useDialogListViewModel(
|
|
|
226
231
|
];
|
|
227
232
|
|
|
228
233
|
const sortedData = [...newDialogs].sort((a, b) => {
|
|
229
|
-
return
|
|
230
|
-
new Date(b.
|
|
231
|
-
|
|
232
|
-
|
|
234
|
+
return b.lastMessage.dateSent && a.lastMessage.dateSent
|
|
235
|
+
? new Date(b.lastMessage.dateSent).getTime() -
|
|
236
|
+
new Date(a.lastMessage.dateSent).getTime()
|
|
237
|
+
: new Date(b.updatedAt).getTime() -
|
|
238
|
+
new Date(a.updatedAt).getTime();
|
|
233
239
|
});
|
|
234
240
|
|
|
235
241
|
return sortedData;
|
|
@@ -237,7 +243,10 @@ export default function useDialogListViewModel(
|
|
|
237
243
|
//
|
|
238
244
|
})
|
|
239
245
|
.catch((e) => {
|
|
240
|
-
console.log(
|
|
246
|
+
console.log(
|
|
247
|
+
'Error getDialogByIdUseCase in useDialogListViewModel: ',
|
|
248
|
+
stringifyError(e),
|
|
249
|
+
);
|
|
241
250
|
});
|
|
242
251
|
}
|
|
243
252
|
// getDialogs(pagination).catch();
|
|
@@ -254,11 +263,19 @@ export default function useDialogListViewModel(
|
|
|
254
263
|
});
|
|
255
264
|
|
|
256
265
|
const sortedData = [...newDialogs].sort((a, b) => {
|
|
257
|
-
return
|
|
258
|
-
new Date(b.
|
|
259
|
-
|
|
266
|
+
return b.lastMessage.dateSent && a.lastMessage.dateSent
|
|
267
|
+
? new Date(b.lastMessage.dateSent).getTime() -
|
|
268
|
+
new Date(a.lastMessage.dateSent).getTime()
|
|
269
|
+
: new Date(b.updatedAt).getTime() -
|
|
270
|
+
new Date(a.updatedAt).getTime();
|
|
260
271
|
});
|
|
261
272
|
|
|
273
|
+
// const sortedData = [...newDialogs].sort((a, b) => {
|
|
274
|
+
// return (
|
|
275
|
+
// new Date(b.lastMessage.dateSent).getTime() - new Date(a.lastMessage.dateSent).getTime()
|
|
276
|
+
// );
|
|
277
|
+
// });
|
|
278
|
+
|
|
262
279
|
return sortedData;
|
|
263
280
|
});
|
|
264
281
|
}
|