Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chat): integrate sharing into stateful api #690

Merged
merged 248 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 247 commits
Commits
Show all changes
248 commits
Select commit Hold shift + click to select a range
64df08a
fix gradient
IlyaBondar Jan 25, 2024
f9c865e
move `api/files/bucket` -> `api/bucket`
IlyaBondar Jan 25, 2024
3b3d09e
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Jan 25, 2024
a21e9bf
API refactoring
IlyaBondar Jan 26, 2024
28c3bcf
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Jan 26, 2024
2d48586
refactoring
IlyaBondar Jan 26, 2024
a5ab094
url generating to getUrlFromSlugs method
Alexander-Kezik Jan 26, 2024
26626cc
remove "entities/" part
IlyaBondar Jan 26, 2024
3e969a4
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Jan 26, 2024
b53d3af
remove "/file/" part
IlyaBondar Jan 26, 2024
e6d0d80
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Jan 26, 2024
4c34bc4
util-methods for url/path
IlyaBondar Jan 26, 2024
c3400d1
if no filter
IlyaBondar Jan 26, 2024
858a2af
lint fix
IlyaBondar Jan 26, 2024
7baccda
errorDuringEntityRequest -> errorDuringEntityRequest
Alexander-Kezik Jan 26, 2024
2ba68a3
handle 404
IlyaBondar Jan 26, 2024
b3832ba
handle 404
IlyaBondar Jan 26, 2024
c839f57
StorageType
IlyaBondar Jan 26, 2024
474f7d6
add typing for backend conversations/prompts and refactor backend fil…
Alexander-Kezik Jan 26, 2024
1db926d
fix issue in data-service
Alexander-Kezik Jan 26, 2024
4ebeb50
add filterableEntityTypes for listing
Alexander-Kezik Jan 26, 2024
4763598
updateAt -> updatedAt
Alexander-Kezik Jan 26, 2024
4cfff00
generate/parse api keys
IlyaBondar Jan 26, 2024
26ac52c
setBucket
IlyaBondar Jan 26, 2024
af0f663
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Jan 26, 2024
0ba112f
refactoring
IlyaBondar Jan 26, 2024
c05a13c
Update data-service.ts
IlyaBondar Jan 26, 2024
59f00d8
move bucket receiving from file epic and reduser
Alexander-Kezik Jan 29, 2024
efc2bf6
draft changes for storage
IlyaBondar Jan 29, 2024
79653fe
generic storage and refactoring
IlyaBondar Jan 29, 2024
5d4c4f8
generic storage
IlyaBondar Jan 29, 2024
ac865c6
generic storage
IlyaBondar Jan 29, 2024
ea8663a
Update storage.ts
IlyaBondar Jan 29, 2024
7d7abc6
draft api
IlyaBondar Jan 29, 2024
7b8bb68
set entities draft
Alexander-Kezik Jan 29, 2024
85e3d1b
remove status from DialFile
Alexander-Kezik Jan 29, 2024
5762e38
refactor with ConversationsApiStorage and PromptApiStorage
Alexander-Kezik Jan 29, 2024
57cfb39
using stateful api
IlyaBondar Jan 29, 2024
43f4ecf
Merge branch 'feat/165-stateful-api-draft' of https://github.com/epam…
IlyaBondar Jan 29, 2024
232d878
Merge branch 'development' into feat/165-stateful-api-draft
IlyaBondar Jan 29, 2024
4d3557c
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Jan 29, 2024
85301da
Merge branch 'feat/165-stateful-api' into feat/165-stateful-api-draft
IlyaBondar Jan 29, 2024
2029fba
stateful API
IlyaBondar Jan 30, 2024
792d856
Update conversations.epics.ts
IlyaBondar Jan 30, 2024
fc62234
fix getData
IlyaBondar Jan 30, 2024
ecb9383
fix listing
IlyaBondar Jan 30, 2024
8bf751e
fix search
IlyaBondar Jan 30, 2024
99c516c
fix url
IlyaBondar Jan 30, 2024
c30d79f
fix key
IlyaBondar Jan 30, 2024
9d33bd0
temporary solution for saving
IlyaBondar Jan 30, 2024
7539bd5
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Jan 30, 2024
7de060b
loaders
IlyaBondar Jan 30, 2024
b813c07
Update Spinner.tsx
IlyaBondar Jan 30, 2024
3069337
refactoring loaders
IlyaBondar Jan 30, 2024
c680cc8
Update ChatLoader.tsx
IlyaBondar Jan 30, 2024
53967ef
upload folders, show loaders
IlyaBondar Jan 30, 2024
5b8501e
new loader with steps animation
IlyaBondar Jan 31, 2024
f145d2f
Update ChatLoader.tsx
IlyaBondar Jan 31, 2024
6896ef0
combineEntities + lint fixes
IlyaBondar Jan 31, 2024
a5fa45c
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Jan 31, 2024
c0e7ff1
fix file api request urls
IlyaBondar Jan 31, 2024
56b2225
upload chat
IlyaBondar Jan 31, 2024
6d075ae
Update Chat.tsx
IlyaBondar Jan 31, 2024
0542888
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Jan 31, 2024
4beabdf
fix displaying
IlyaBondar Jan 31, 2024
6184408
update keys
IlyaBondar Jan 31, 2024
ef3b603
id generation
IlyaBondar Jan 31, 2024
3ee8b0d
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Jan 31, 2024
0327964
update generation of api keys, fix selectedConversationIds
IlyaBondar Feb 1, 2024
b4df4f3
temp fix for dates
IlyaBondar Feb 1, 2024
4fef931
Update api-entity-storage.ts
IlyaBondar Feb 1, 2024
19084df
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Feb 1, 2024
850449a
fix chat
IlyaBondar Feb 1, 2024
0d4afab
fix new conversation
IlyaBondar Feb 1, 2024
7a38a7f
Update Chat.tsx
IlyaBondar Feb 1, 2024
7cfda58
Update conversations.epics.ts
IlyaBondar Feb 1, 2024
8aa5781
set API as default
IlyaBondar Feb 1, 2024
ce4a546
fix new
IlyaBondar Feb 1, 2024
0762edd
deleteConversations
IlyaBondar Feb 1, 2024
67b8f92
clearConversations
IlyaBondar Feb 1, 2024
fe44029
fix chat
IlyaBondar Feb 2, 2024
e928c2c
fix rate
IlyaBondar Feb 2, 2024
81936c4
fix file uploading
IlyaBondar Feb 2, 2024
b34b628
folder changes
IlyaBondar Feb 2, 2024
1c788a9
fix selectors
IlyaBondar Feb 2, 2024
18a6b44
small refactoring
IlyaBondar Feb 2, 2024
aced595
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 2, 2024
be1cc89
remove unused files
IlyaBondar Feb 2, 2024
4a31009
UploadStatus
IlyaBondar Feb 2, 2024
377c927
chat folders expand
IlyaBondar Feb 3, 2024
a62ca3e
safe parsing of conversation key
IlyaBondar Feb 3, 2024
b2827c4
safe generation of conversation key
IlyaBondar Feb 3, 2024
cb35cc5
EMPTY_MODEL_ID
IlyaBondar Feb 3, 2024
8084b2c
refactoring services and storages
IlyaBondar Feb 4, 2024
c52e811
fix drag & drop
IlyaBondar Feb 4, 2024
daef7f9
refactroing openFolderIds
IlyaBondar Feb 5, 2024
64b3e03
format:fix
IlyaBondar Feb 5, 2024
19d40e7
provide featureType
IlyaBondar Feb 5, 2024
ad948ca
don't save/read openedFoldersIds in/from localStorage
IlyaBondar Feb 5, 2024
e1351c8
lint fixes
IlyaBondar Feb 5, 2024
072f2a0
Merge branch 'development' into feat/165-stateful-api
Alexander-Kezik Feb 5, 2024
40f263b
upload selected conversations
IlyaBondar Feb 6, 2024
28e05e7
feat: remove BetweenFoldersLine and don't save open folder ids
IlyaBondar Feb 6, 2024
c6f13bd
Merge branch 'feat/165-rip-between-folders' into feat/165-stateful-api
IlyaBondar Feb 6, 2024
daa416d
fix: add additional folder to storages
mikitabut Feb 6, 2024
130c425
Merge branch 'feat/165-stateful-api' of github.com:epam/ai-dial-chat …
mikitabut Feb 6, 2024
1bbff51
fix: add todo for future refactoring
mikitabut Feb 6, 2024
e25ee87
fix uploading
IlyaBondar Feb 6, 2024
3be3d58
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Feb 6, 2024
bc12648
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Feb 6, 2024
8a75b3e
Merge branch 'development' into feat/165-rip-between-folders
IlyaBondar Feb 6, 2024
d34df82
draft changes
IlyaBondar Feb 6, 2024
43fd413
feat/165-rip-between-folders: updated e2e tests
irinakartun Feb 6, 2024
3356501
initFoldersEndConversations, fix folders
IlyaBondar Feb 6, 2024
2a09631
add update prompt and implement entity not found component
Alexander-Kezik Feb 6, 2024
d2d6b9c
fix not found for edit prompt
Alexander-Kezik Feb 6, 2024
e4d082a
add a selection prompt functionality
Alexander-Kezik Feb 6, 2024
a347767
feat/165-rip-between-folders: removed irrelevant e2e tests
irinakartun Feb 6, 2024
bc53e1b
handle errors
IlyaBondar Feb 6, 2024
0b63b16
fix not found message when open edit prompt
Alexander-Kezik Feb 6, 2024
7f0611f
className property
IlyaBondar Feb 6, 2024
65c095a
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Feb 6, 2024
b16584a
disable input while prompt is loading
Alexander-Kezik Feb 6, 2024
9ea533f
Update NotFoundEntity.tsx
IlyaBondar Feb 6, 2024
3d458bc
conversation not found
IlyaBondar Feb 6, 2024
8bff394
change icon and text of NotFoundEntity
IlyaBondar Feb 6, 2024
b7d844a
Update conversation not found
IlyaBondar Feb 6, 2024
0121416
Merge branch 'development' into feat/165-rip-between-folders
IlyaBondar Feb 6, 2024
ba576f9
manual merge and sorting folder items
IlyaBondar Feb 6, 2024
d788f1c
feat/165-rip-between-folders: reverted tests for drag&drop
irinakartun Feb 6, 2024
12d9b9f
Merge remote-tracking branch 'origin/feat/165-rip-between-folders' in…
irinakartun Feb 6, 2024
49b0fec
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Feb 6, 2024
d8ce089
manual merge
IlyaBondar Feb 6, 2024
c7a45d4
fixed moving folder to root level
IlyaBondar Feb 6, 2024
8ae31ee
Merge branch 'feat/165-rip-between-folders' into feat/165-stateful-api
IlyaBondar Feb 6, 2024
5441317
lint fix
IlyaBondar Feb 7, 2024
24934bd
fixed id generation
IlyaBondar Feb 7, 2024
0827770
don't save lastActivityDate
IlyaBondar Feb 7, 2024
a1e0f95
deleteFolder and init prompts
IlyaBondar Feb 7, 2024
52789a9
lint fix
IlyaBondar Feb 7, 2024
a874b69
fix recreatig and moving folders
IlyaBondar Feb 7, 2024
ebc7c5f
fix select chats
IlyaBondar Feb 7, 2024
83d7ce8
clean up entities
IlyaBondar Feb 7, 2024
88c9523
moveFolder
IlyaBondar Feb 7, 2024
a1cce8f
fixed updating
IlyaBondar Feb 7, 2024
b4262cb
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Feb 7, 2024
41d6239
revert some changes
IlyaBondar Feb 7, 2024
7232d68
fixed Replay and Playback menu options displaying
IlyaBondar Feb 7, 2024
79a51ca
fix replay and playback
IlyaBondar Feb 7, 2024
9397087
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Feb 7, 2024
9bc7aaa
mergeGetResult
IlyaBondar Feb 7, 2024
875c3a8
feat: add simple share flow
mikitabut Feb 7, 2024
ea42c8d
fixed upload conversation, fix incrementation of numerations
IlyaBondar Feb 7, 2024
b868e14
rename/move folder -> updateFolder
IlyaBondar Feb 8, 2024
a1c9470
Update conversations.epics.ts
IlyaBondar Feb 8, 2024
d1f1f71
add spinner to system prompt
Alexander-Kezik Feb 8, 2024
f39bdd0
merge conversations
IlyaBondar Feb 8, 2024
a167018
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Feb 8, 2024
2254c47
add prompt deletion
Alexander-Kezik Feb 8, 2024
d8f0bf9
fix prompt modal showing
Alexander-Kezik Feb 8, 2024
bf920b9
fixed openFolder
IlyaBondar Feb 8, 2024
4c30540
refactoring and clean up
IlyaBondar Feb 8, 2024
b7ac702
Update conversations.epics.ts
IlyaBondar Feb 8, 2024
3105929
add possibility to delete all propmts
Alexander-Kezik Feb 8, 2024
db7f07a
clean up prompt
IlyaBondar Feb 8, 2024
809b5bb
delete Array.from
Alexander-Kezik Feb 8, 2024
20e6c37
onChildMenuOpenChange in ContextMenu
IlyaBondar Feb 8, 2024
54c805d
MoveToFolderProps
IlyaBondar Feb 8, 2024
cd6de74
fix prompts renaming and add move to folder possibility for promts
Alexander-Kezik Feb 8, 2024
39bf011
fix promptbar handleDrop
Alexander-Kezik Feb 8, 2024
ed50b10
Merge branch 'feat/165-stateful-api' of github.com:epam/ai-dial-chat …
mikitabut Feb 8, 2024
54615f6
fixed replay
IlyaBondar Feb 8, 2024
fe42049
fixed replay
IlyaBondar Feb 8, 2024
73030c3
fix Playback
IlyaBondar Feb 8, 2024
a0ff30a
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Feb 8, 2024
5c87d66
fixed folder issues
IlyaBondar Feb 9, 2024
9622d92
fixed folder loader
IlyaBondar Feb 9, 2024
10b4edd
MoveTo
IlyaBondar Feb 9, 2024
0856e3d
sorting of folders
IlyaBondar Feb 9, 2024
51e6b3e
unique names for compare
IlyaBondar Feb 9, 2024
eac35dc
compare
IlyaBondar Feb 9, 2024
d21fdac
compare and generation of names with postfix
IlyaBondar Feb 9, 2024
8c69969
compare is working
IlyaBondar Feb 9, 2024
66b6ec9
fixed: upload all in background, open folder timeout, other issues
IlyaBondar Feb 9, 2024
d3b7ee3
remove timeout for open folder
IlyaBondar Feb 9, 2024
a928423
lint fix
IlyaBondar Feb 9, 2024
972a5e6
add possibility to move prompt folders
Alexander-Kezik Feb 9, 2024
ef5f772
refactor prompts epic
Alexander-Kezik Feb 9, 2024
ea3317e
remove unused imports
Alexander-Kezik Feb 9, 2024
083321c
Merge branch 'development' into feat/165-stateful-api
IlyaBondar Feb 9, 2024
070dff0
fixed loader and select
IlyaBondar Feb 9, 2024
0997846
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Feb 9, 2024
1ad8a8c
update compare text
IlyaBondar Feb 9, 2024
64367b0
add updateEntitiesFoldersAndIds method
Alexander-Kezik Feb 9, 2024
fe1b624
lint fix
Alexander-Kezik Feb 9, 2024
5b938d1
remove unused imports
Alexander-Kezik Feb 9, 2024
4e7e061
add possibility to remove prompt folder
Alexander-Kezik Feb 9, 2024
b2bd187
Show all conversations
IlyaBondar Feb 9, 2024
0074e9c
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Feb 9, 2024
cd19d25
fixed dates
IlyaBondar Feb 9, 2024
4f843e0
fix double new chats after clear
IlyaBondar Feb 9, 2024
99633e2
fixed sorting with the same dates(seconds)
IlyaBondar Feb 9, 2024
36b5aff
fix search and add possibility to use moveTo option in context menu
Alexander-Kezik Feb 9, 2024
a218ca3
test:watch
IlyaBondar Feb 9, 2024
8c1965c
fix: fix tests targets
mikitabut Feb 9, 2024
e204cde
fix issuse with id when update prompt
Alexander-Kezik Feb 9, 2024
508d7a3
added modelId encoding
IlyaBondar Feb 9, 2024
c23f358
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Feb 9, 2024
dacc2fd
fixed lastActivityDate
IlyaBondar Feb 9, 2024
725f0cf
fixed incrementation of postfix
IlyaBondar Feb 9, 2024
bf2c006
fixed filtering for comparison
IlyaBondar Feb 9, 2024
e6beeb6
temporary not allow type incorrect symbols
IlyaBondar Feb 9, 2024
073d65c
code review fixes
IlyaBondar Feb 9, 2024
0b67b6e
ChatLoader -> Loader
IlyaBondar Feb 9, 2024
9a20c58
feat: add shared by me section data
mikitabut Feb 11, 2024
4755356
resolve comments
Alexander-Kezik Feb 11, 2024
a0a3436
remove unnecessary code
Alexander-Kezik Feb 11, 2024
5d1fc84
Merge branch 'feat/165-stateful-api' of https://github.com/epam/ai-di…
IlyaBondar Feb 12, 2024
e91bdbd
Update README.md
IlyaBondar Feb 12, 2024
1c8ed8c
will handle error it in https://github.com/epam/ai-dial-chat/issues/663
IlyaBondar Feb 12, 2024
d822a04
will handle error it in https://github.com/epam/ai-dial-chat/issues/663
IlyaBondar Feb 12, 2024
388902d
will be fixed in https://github.com/epam/ai-dial-chat/issues/313
IlyaBondar Feb 12, 2024
e35c521
Update prompts.selectors.ts
IlyaBondar Feb 12, 2024
7637706
Merge branch 'feat/165-stateful-api' of github.com:epam/ai-dial-chat …
mikitabut Feb 12, 2024
6a9f202
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 12, 2024
de2c065
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 12, 2024
2dbdec9
fix: use full url for id
mikitabut Feb 12, 2024
47aa275
feat: implement share listing
mikitabut Feb 12, 2024
ee26628
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 12, 2024
5b61d3b
fix: fix path issues
mikitabut Feb 13, 2024
7f146c0
fix: skip tests
mikitabut Feb 13, 2024
59088a9
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 13, 2024
f40c3b6
feat: add ability to share folder with internal conversation resources
mikitabut Feb 13, 2024
89da1c7
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 13, 2024
004e7ca
fix: refactor getting root id
mikitabut Feb 13, 2024
646495b
fix: fix generating next name
mikitabut Feb 13, 2024
7c2dd6c
fix: refactor checking for rootId
mikitabut Feb 13, 2024
28ec9ac
fix: finish using root id utility
mikitabut Feb 13, 2024
2ce999e
fix: get rid of uuid generation
mikitabut Feb 13, 2024
3a0542c
fix: fix linting
mikitabut Feb 13, 2024
2e8a9f9
fix: fix duplication
mikitabut Feb 13, 2024
f313243
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 13, 2024
12fed01
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 13, 2024
d034a90
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 13, 2024
c66e1ba
fix: remove unused imports
mikitabut Feb 13, 2024
e4ed2cc
Merge branch 'development' of github.com:epam/ai-dial-chat into feat/…
mikitabut Feb 13, 2024
220aa0b
fix: return back arg
mikitabut Feb 13, 2024
13a3c3a
fix: fix linting
mikitabut Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
Message,
Replay,
} from '@/chat/types/chat';
import { constructPath } from '@/chat/utils/app/file';
import { getRootId } from '@/chat/utils/app/id';
import { ApiKeys } from '@/chat/utils/server/api';
import { ModelsUtil } from '@/src/utils';
import { v4 as uuidv4 } from 'uuid';

Expand All @@ -18,7 +21,10 @@ export class ConversationBuilder {

constructor() {
this.conversation = {
id: uuidv4(),
id: constructPath(
getRootId({ apiKey: ApiKeys.Conversations }),
DEFAULT_CONVERSATION_NAME,
),
name: DEFAULT_CONVERSATION_NAME,
messages: [],
model: { id: ModelsUtil.getDefaultModel()!.id },
Expand All @@ -28,6 +34,7 @@ export class ConversationBuilder {
selectedAddons: ModelsUtil.getDefaultModel()!.selectedAddons ?? [],
lastActivityDate: Date.now(),
isMessageStreaming: false,
folderId: getRootId({ apiKey: ApiKeys.Conversations }),
};
}

Expand Down Expand Up @@ -70,7 +77,7 @@ export class ConversationBuilder {
return this;
}

withFolderId(folderId: undefined | string): ConversationBuilder {
withFolderId(folderId: string): ConversationBuilder {
this.conversation.folderId = folderId;
return this;
}
Expand Down
9 changes: 0 additions & 9 deletions apps/chat/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,6 @@ const nextConfig = {
},
async headers() {
return [
{
source: '/overlay/script.js',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
],
},
{
source: '/:path*',
headers: [
Expand Down
6 changes: 1 addition & 5 deletions apps/chat/public/locales/en/sidebar.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"share.modal.link.description": "This link is temporary and will be active for 3 days.",
"share.modal.link_conversation": "This conversation and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.",
"share.modal.link_prompt": "This prompt and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.",
"share.modal.link_conversations_folder": "This conversation folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes.",
"share.modal.link_prompts_folder": "This prompt folder and future changes to it will be visible to users who follow the link. Only owner will be able to make changes."
"share.modal.link.description": "This link is temporary and will be active for 3 days."
}
5 changes: 3 additions & 2 deletions apps/chat/src/components/Chat/ChangePathDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getPathToFolderById,
validateFolderRenaming,
} from '@/src/utils/app/folders';
import { getRootId } from '@/src/utils/app/id';

import { FeatureType } from '@/src/types/common';
import { SharingType } from '@/src/types/share';
Expand Down Expand Up @@ -132,7 +133,7 @@ export const ChangePathDialog = ({
);

const handleAddFolder = useCallback(
(parentFolderId?: string) => {
(parentFolderId: string) => {
dispatch(
actions.createTemporaryFolder({
relativePath: parentFolderId,
Expand Down Expand Up @@ -206,7 +207,7 @@ export const ChangePathDialog = ({
/>
</SelectFolderHeader>
<SelectFolderFooter
handleNewFolder={() => handleAddFolder()}
handleNewFolder={() => handleAddFolder(getRootId())}
onSelectFolderClick={getPath}
/>
</SelectFolder>
Expand Down
6 changes: 5 additions & 1 deletion apps/chat/src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,11 @@ export const ChatView = memo(() => {
showReplayStart={!isNotEmptyConversations}
/>
)}
{isExternal && <ChatExternalControls />}
{isExternal && (
<ChatExternalControls
conversations={selectedConversations}
/>
)}
</ChatInput>
)}

Expand Down
13 changes: 10 additions & 3 deletions apps/chat/src/components/Chat/ChatExternalControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@ import { useCallback } from 'react';

import { useTranslation } from 'next-i18next';

import { ConversationInfo } from '@/src/types/chat';
import { Translation } from '@/src/types/translation';

import { ConversationsActions } from '@/src/store/conversations/conversations.reducers';
import { useAppDispatch } from '@/src/store/hooks';

export default function ChatExternalControls() {
interface Props {
conversations: ConversationInfo[];
}

export default function ChatExternalControls({ conversations }: Props) {
const { t } = useTranslation(Translation.Chat);
const dispatch = useAppDispatch();

const handleDuplicate = useCallback(() => {
dispatch(ConversationsActions.duplicateSelectedConversations());
}, [dispatch]);
conversations.forEach((conv) => {
dispatch(ConversationsActions.duplicateConversation(conv));
});
}, [conversations, dispatch]);

return (
<button
Expand Down
7 changes: 2 additions & 5 deletions apps/chat/src/components/Chat/Publish/PublishWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { onBlur } from '@/src/utils/app/style-helpers';

import { ShareEntity } from '@/src/types/common';
import { DialFile } from '@/src/types/files';
import { ModalState } from '@/src/types/modal';
import {
SharingType,
TargetAudienceFilter,
Expand All @@ -47,8 +48,6 @@ import { PublishAttachment } from './PublishAttachment';
import { TargetAudienceFilterComponent } from './TargetAudienceFilter';
import { UserGroupFilter } from './UserGroupFilter';

import { v4 as uuidv4 } from 'uuid';

interface Props {
entity: ShareEntity;
type: SharingType;
Expand Down Expand Up @@ -77,7 +76,6 @@ export default function PublishWizard({
const { t } = useTranslation(Translation.Chat);
const dispatch = useAppDispatch();
const publishAction = getPublishActionByType(type);
const shareId = useRef(uuidv4());
const nameInputRef = useRef<HTMLInputElement>(null);
const [submitted, setSubmitted] = useState(false);
const [name, setName] = useState<string>(entity.name);
Expand Down Expand Up @@ -181,7 +179,6 @@ export default function PublishWizard({
dispatch(
publishAction({
id: entity.id,
shareUniqueId: shareId.current,
name: trimmedName,
path: trimmedPath,
version: trimmedVersion,
Expand Down Expand Up @@ -226,7 +223,7 @@ export default function PublishWizard({
{ 'w-full': files.length },
)}
dataQa="publish-modal"
isOpen={isOpen}
state={isOpen ? ModalState.OPENED : ModalState.CLOSED}
onClose={onClose}
initialFocus={nameInputRef}
>
Expand Down
9 changes: 2 additions & 7 deletions apps/chat/src/components/Chat/ReportIssueDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import classNames from 'classnames';
import { checkValidity } from '@/src/utils/app/forms';
import { onBlur } from '@/src/utils/app/style-helpers';

import { ModalState } from '@/src/types/modal';
import { ReportIssueBody } from '@/src/types/report-issue';
import { Translation } from '@/src/types/translation';

Expand Down Expand Up @@ -115,22 +116,16 @@ export const ReportIssueDialog: FC<Props> = ({ isOpen, onClose }) => {
[description, dispatch, handleClose, t, title],
);

// Render nothing if the dialog is not open.
if (!isOpen) {
return <></>;
}

const inputClassName = classNames('input-form', 'peer', {
'input-invalid': submitted,
submitted: submitted,
});

// Render the dialog.
return (
<Modal
initialFocus={titleInputRef}
portalId="theme-main"
isOpen={isOpen}
state={isOpen ? ModalState.OPENED : ModalState.CLOSED}
onClose={handleClose}
dataQa="request-api-key-dialog"
overlayClassName="fixed inset-0"
Expand Down
8 changes: 2 additions & 6 deletions apps/chat/src/components/Chat/RequestApiKeyDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import classNames from 'classnames';
import { checkValidity } from '@/src/utils/app/forms';
import { onBlur } from '@/src/utils/app/style-helpers';

import { ModalState } from '@/src/types/modal';
import { RequestAPIKeyBody } from '@/src/types/request-api-key';
import { Translation } from '@/src/types/translation';

Expand Down Expand Up @@ -225,11 +226,6 @@ export const RequestAPIKeyDialog: FC<Props> = ({ isOpen, onClose }) => {
],
);

// Render nothing if the dialog is not open.
if (!isOpen) {
return <></>;
}

// Render the dialog.
const inputClassName = classNames('input-form', 'peer', {
'input-invalid': submitted,
Expand All @@ -244,7 +240,7 @@ export const RequestAPIKeyDialog: FC<Props> = ({ isOpen, onClose }) => {
<Modal
initialFocus={projectNameInputRef}
portalId="theme-main"
isOpen={isOpen}
state={isOpen ? ModalState.OPENED : ModalState.CLOSED}
onClose={handleClose}
dataQa="request-api-key-dialog"
overlayClassName="fixed inset-0"
Expand Down
61 changes: 24 additions & 37 deletions apps/chat/src/components/Chat/ShareModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,39 @@ import {

import { useTranslation } from 'next-i18next';

import { getShareActionByType } from '@/src/utils/app/share';

import { ShareEntity } from '@/src/types/common';
import { SharingType } from '@/src/types/share';
import { ModalState } from '@/src/types/modal';
import { Translation } from '@/src/types/translation';

import { useAppDispatch } from '@/src/store/hooks';
import { useAppDispatch, useAppSelector } from '@/src/store/hooks';
import { ShareActions, ShareSelectors } from '@/src/store/share/share.reducers';

import Modal from '../Common/Modal';
import Tooltip from '../Common/Tooltip';

import { v4 as uuidv4 } from 'uuid';

interface Props {
entity: ShareEntity;
type: SharingType;
isOpen: boolean;
onClose: () => void;
}

export default function ShareModal({ entity, isOpen, onClose, type }: Props) {
export default function ShareModal() {
const { t } = useTranslation(Translation.SideBar);
const dispatch = useAppDispatch();
const shareAction = getShareActionByType(type);

const copyButtonRef = useRef<HTMLButtonElement>(null);
const [urlCopied, setUrlCopied] = useState(false);
const [urlWasCopied, setUrlWasCopied] = useState(false);
const shareId = useRef(uuidv4());
const url = `${window?.location.origin}/share/${shareId.current}`;
const timeoutRef = useRef<ReturnType<typeof setTimeout>>();

const modalState = useAppSelector(ShareSelectors.selectShareModalState);
const invitationId = useAppSelector(ShareSelectors.selectInvitationId);
const shareResourceName = useAppSelector(
ShareSelectors.selectShareResourceName,
);
const [url, setUrl] = useState('');

useEffect(() => {
setUrl(`${window?.location.origin}/share/${invitationId || ''}`);
}, [invitationId]);

const handleClose = useCallback(() => {
dispatch(ShareActions.setModalState({ modalState: ModalState.CLOSED }));
}, [dispatch]);

const handleCopy = useCallback(
(e: MouseEvent<HTMLButtonElement> | ClipboardEvent<HTMLInputElement>) => {
e.preventDefault();
Expand All @@ -55,13 +57,10 @@ export default function ShareModal({ entity, isOpen, onClose, type }: Props) {
}, 2000);
if (!urlWasCopied) {
setUrlWasCopied(true);
dispatch(
shareAction({ id: entity.id, shareUniqueId: shareId.current }),
);
}
});
},
[dispatch, entity.id, shareAction, url, urlWasCopied],
[url, urlWasCopied],
);

useEffect(() => () => clearTimeout(timeoutRef.current), []);
Expand All @@ -71,26 +70,14 @@ export default function ShareModal({ entity, isOpen, onClose, type }: Props) {
portalId="theme-main"
containerClassName="inline-block w-full max-w-[424px] p-6"
dataQa="share-modal"
isOpen={isOpen}
onClose={onClose}
state={modalState}
onClose={handleClose}
heading={`${t('Share')}: ${shareResourceName?.trim()}`}
>
<div className="flex flex-col justify-between gap-2">
<h4 className="max-h-[50px] text-base font-semibold">
<Tooltip tooltip={entity.name.trim()}>
<span
className="line-clamp-2 break-words"
data-qa="share-chat-name"
>
{`${t('Share')}: ${entity.name.trim()}`}
</span>
</Tooltip>
</h4>
<p className="text-sm text-secondary">
{t('share.modal.link.description')}
</p>
<p className="text-sm text-secondary">
{t('share.modal.link', { context: type })}
</p>
<div className="relative mt-2">
<Tooltip tooltip={url}>
<input
Expand Down
13 changes: 4 additions & 9 deletions apps/chat/src/components/Chat/UnpublishModal.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { ClipboardEvent, MouseEvent, useCallback, useRef } from 'react';
import { ClipboardEvent, MouseEvent, useCallback } from 'react';

import { useTranslation } from 'next-i18next';

import { getUnpublishActionByType } from '@/src/utils/app/share';

import { Entity } from '@/src/types/common';
import { ModalState } from '@/src/types/modal';
import { SharingType } from '@/src/types/share';
import { Translation } from '@/src/types/translation';

import { useAppDispatch } from '@/src/store/hooks';

import Modal from '../Common/Modal';

import { v4 as uuidv4 } from 'uuid';

interface Props {
entity: Entity;
type: SharingType;
Expand All @@ -30,8 +29,6 @@ export default function UnpublishModal({
const { t } = useTranslation(Translation.SideBar);
const dispatch = useAppDispatch();
const unpublishAction = getUnpublishActionByType(type);
const shareId = useRef(uuidv4());

const handleClose = useCallback(
(e: MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
Expand All @@ -47,9 +44,7 @@ export default function UnpublishModal({
e.preventDefault();
e.stopPropagation();

dispatch(
unpublishAction({ id: entity.id, shareUniqueId: shareId.current }),
);
dispatch(unpublishAction({ id: entity.id }));
onClose();
},
[dispatch, entity.id, onClose, unpublishAction],
Expand All @@ -60,7 +55,7 @@ export default function UnpublishModal({
portalId="theme-main"
containerClassName="inline-block h-[434px] sm:w-[424px] p-6 w-full"
dataQa="unpublish-modal"
isOpen={isOpen}
state={isOpen ? ModalState.OPENED : ModalState.CLOSED}
onClose={onClose}
>
<div className="flex h-full flex-col justify-between gap-2">
Expand Down
Loading
Loading