Skip to content

Commit ffff2c6

Browse files
Merge pull request #60 from microsoft/PSL-BUG-7026
fix: display confirmation of chat history saved popup
2 parents 123f9bc + 046d7ea commit ffff2c6

File tree

4 files changed

+90
-89
lines changed

4 files changed

+90
-89
lines changed

ClientAdvisor/App/frontend/src/pages/chat/Chat.module.css

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -379,56 +379,3 @@ a {
379379
}
380380

381381

382-
/* popup css*/
383-
.popupContainer {
384-
display: flex;
385-
align-items: center;
386-
justify-content: space-between;
387-
background: #fff;
388-
border: 1px solid #ccc;
389-
padding: 10px;
390-
border-radius: 5px;
391-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
392-
z-index: 1;
393-
position: fixed;
394-
right: 1rem;
395-
top: 6rem;
396-
}
397-
398-
399-
.popupContent {
400-
display: flex;
401-
align-items: center;
402-
}
403-
404-
.checkmark {
405-
color: white;
406-
font-size: 13px;
407-
vertical-align: middle;
408-
padding-right: 0.4rem;
409-
}
410-
411-
.popupText {
412-
margin-left: 10px;
413-
}
414-
415-
.headerText{
416-
font-weight: 600;
417-
color: #242424;
418-
}
419-
.popupSubtext {
420-
font-size: smaller;
421-
color: #242424;
422-
padding-left: 1.4rem;
423-
width: 75%;
424-
425-
}
426-
427-
.closeButton {
428-
background: none;
429-
border: none;
430-
font-size: 13px;
431-
cursor: pointer;
432-
position: absolute;
433-
right: 0.8rem;
434-
}

ClientAdvisor/App/frontend/src/pages/chat/Chat.tsx

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import DOMPurify from 'dompurify'
1111

1212
import styles from './Chat.module.css'
1313
import TeamAvatar from '../../assets/TeamAvatar.svg'
14-
import TickIcon from '../../assets/TickIcon.svg'
15-
import DismissIcon from '../../assets/Dismiss.svg'
1614
import { XSSAllowTags } from '../../constants/xssAllowTags'
1715

1816
import {
@@ -44,7 +42,7 @@ const enum messageStatus {
4442
Done = 'Done'
4543
}
4644

47-
const Chat = () => {
45+
const Chat = (props: any) => {
4846
const appStateContext = useContext(AppStateContext)
4947
const ui = appStateContext?.state.frontendSettings?.ui
5048
const AUTH_ENABLED = appStateContext?.state.frontendSettings?.auth_enabled
@@ -59,7 +57,6 @@ const Chat = () => {
5957
const [clearingChat, setClearingChat] = useState<boolean>(false)
6058
const [hideErrorDialog, { toggle: toggleErrorDialog }] = useBoolean(true)
6159
const [errorMsg, setErrorMsg] = useState<ErrorMessage | null>()
62-
const [isVisible, setIsVisible] = useState(false);
6360

6461
const errorDialogContentProps = {
6562
type: DialogType.close,
@@ -100,19 +97,6 @@ const Chat = () => {
10097
setErrorMsg(null)
10198
}, 500)
10299
}
103-
const closePopup = () => {
104-
setIsVisible(!isVisible);
105-
};
106-
107-
useEffect(() => {
108-
if (isVisible) {
109-
const timer = setTimeout(() => {
110-
setIsVisible(false);
111-
}, 4000); // Popup will disappear after 3 seconds
112-
113-
return () => clearTimeout(timer); // Cleanup the timer on component unmount
114-
}
115-
}, [isVisible]);
116100

117101
useEffect(() => {
118102
setIsLoading(appStateContext?.state.chatHistoryLoadingState === ChatHistoryLoadingState.Loading)
@@ -600,7 +584,7 @@ const Chat = () => {
600584
}
601585

602586
const newChat = () => {
603-
setIsVisible(true);
587+
props.setIsVisible(true);
604588
setProcessMessages(messageStatus.Processing)
605589
setMessages([])
606590
setIsCitationPanelOpen(false)
@@ -733,20 +717,6 @@ const Chat = () => {
733717

734718
return (
735719
<div className={styles.container} role="main">
736-
{isVisible && (
737-
<div className={styles.popupContainer}>
738-
<div className={styles.popupContent}>
739-
<div className={styles.popupText}>
740-
<div className={styles.headerText}><span className={styles.checkmark}>
741-
<img alt="check mark" src={TickIcon} /></span>Chat saved
742-
<img alt="close icon" src={DismissIcon} className={styles.closeButton} onClick={closePopup}/>
743-
</div>
744-
<div className={styles.popupSubtext}><span className={styles.popupMsg}>Your chat history has been saved successfully!</span></div>
745-
</div>
746-
747-
</div>
748-
</div>
749-
)}
750720
{showAuthMessage ? (
751721
<Stack className={styles.chatEmptyState}>
752722
<ShieldLockRegular

ClientAdvisor/App/frontend/src/pages/layout/Layout.module.css

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,58 @@
254254
padding: 10px 20px;
255255
cursor: pointer;
256256
font-size: 16px;
257-
}
257+
}
258+
259+
/* popup css*/
260+
.popupContainer {
261+
display: flex;
262+
align-items: center;
263+
justify-content: space-between;
264+
background: #fff;
265+
border: 1px solid #ccc;
266+
padding: 10px;
267+
border-radius: 5px;
268+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
269+
z-index: 1;
270+
position: fixed;
271+
right: 1.4rem;
272+
top: 4.4rem;
273+
}
274+
275+
276+
.popupContent {
277+
display: flex;
278+
align-items: center;
279+
}
280+
281+
.checkmark {
282+
color: white;
283+
font-size: 13px;
284+
vertical-align: middle;
285+
padding-right: 0.4rem;
286+
}
287+
288+
.popupText {
289+
margin-left: 10px;
290+
}
291+
292+
.headerText{
293+
font-weight: 600;
294+
color: #242424;
295+
}
296+
.popupSubtext {
297+
font-size: smaller;
298+
color: #242424;
299+
padding-left: 1.4rem;
300+
width: 75%;
301+
302+
}
303+
304+
.closeButton {
305+
background: none;
306+
border: none;
307+
font-size: 13px;
308+
cursor: pointer;
309+
position: absolute;
310+
right: 0.8rem;
311+
}

ClientAdvisor/App/frontend/src/pages/layout/Layout.tsx

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import Chat from '../chat/Chat' // Import the Chat component
1212
import { AppStateContext } from '../../state/AppProvider'
1313
import { getUserInfo, getpbi } from '../../api'
1414
import { User } from '../../types/User'
15-
15+
import TickIcon from '../../assets/TickIcon.svg'
16+
import DismissIcon from '../../assets/Dismiss.svg'
1617
import welcomeIcon from '../../assets/welcomeIcon.png'
1718
import styles from './Layout.module.css';
1819
import SpinnerComponent from '../../components/Spinner/Spinner';
@@ -37,7 +38,7 @@ const Layout = () => {
3738
const [name, setName] = useState<string>('')
3839

3940
const [pbiurl, setPbiUrl] = useState<string>('')
40-
41+
const [isVisible, setIsVisible] = useState(false);
4142
useEffect(() => {
4243
const fetchpbi = async () => {
4344
try {
@@ -51,6 +52,21 @@ const Layout = () => {
5152
fetchpbi()
5253
}, [])
5354

55+
56+
const closePopup = () => {
57+
setIsVisible(!isVisible);
58+
};
59+
60+
useEffect(() => {
61+
if (isVisible) {
62+
const timer = setTimeout(() => {
63+
setIsVisible(false);
64+
}, 4000); // Popup will disappear after 3 seconds
65+
66+
return () => clearTimeout(timer); // Cleanup the timer on component unmount
67+
}
68+
}, [isVisible]);
69+
5470
const handleCardClick = (user: User) => {
5571
setSelectedUser(user)
5672
setShowWelcomeCard(false)
@@ -121,6 +137,20 @@ const Layout = () => {
121137

122138
return (
123139
<div className={styles.layout}>
140+
{isVisible && (
141+
<div className={styles.popupContainer}>
142+
<div className={styles.popupContent}>
143+
<div className={styles.popupText}>
144+
<div className={styles.headerText}><span className={styles.checkmark}>
145+
<img alt="check mark" src={TickIcon} /></span>Chat saved
146+
<img alt="close icon" src={DismissIcon} className={styles.closeButton} onClick={closePopup}/>
147+
</div>
148+
<div className={styles.popupSubtext}><span className={styles.popupMsg}>Your chat history has been saved successfully!</span></div>
149+
</div>
150+
151+
</div>
152+
</div>
153+
)}
124154
<SpinnerComponent
125155
loading={appStateContext?.state.isLoader != undefined ? appStateContext?.state.isLoader : false}
126156
label="Please wait.....!"
@@ -184,7 +214,7 @@ const Layout = () => {
184214
)}
185215
<Pivot defaultSelectedKey="chat">
186216
<PivotItem headerText="Chat" itemKey="chat">
187-
<Chat />
217+
<Chat setIsVisible={setIsVisible}/>
188218
</PivotItem>
189219
<PivotItem headerText="Client 360 Profile" itemKey="profile">
190220
<PowerBIChart chartUrl={calculateChartUrl(selectedUser)} />

0 commit comments

Comments
 (0)